From 3caf8614f25d6b1962e20331fdf423c863bc02f3 Mon Sep 17 00:00:00 2001
From: lresende
Date: Wed, 11 Nov 2009 23:13:31 +0000
Subject: Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835144 13f79535-47bb-0310-9956-ffa450edef68
---
.../org/apache/tuscany/spi/AbstractLifecycle.java | 77 ++
.../apache/tuscany/spi/CoreRuntimeException.java | 55 ++
.../apache/tuscany/spi/InvalidNameException.java | 45 +
.../java/org/apache/tuscany/spi/Lifecycle.java | 69 ++
.../tuscany/spi/ObjectCreationException.java | 56 ++
.../java/org/apache/tuscany/spi/ObjectFactory.java | 35 +
.../java/org/apache/tuscany/spi/QualifiedName.java | 96 +++
.../apache/tuscany/spi/annotation/Autowire.java | 46 +
.../tuscany/spi/bootstrap/ComponentNames.java | 70 ++
.../tuscany/spi/bootstrap/RuntimeComponent.java | 55 ++
.../apache/tuscany/spi/builder/BindingBuilder.java | 57 ++
.../org/apache/tuscany/spi/builder/Builder.java | 86 ++
.../spi/builder/BuilderConfigException.java | 48 ++
.../tuscany/spi/builder/BuilderException.java | 55 ++
.../spi/builder/BuilderInstantiationException.java | 39 +
.../tuscany/spi/builder/BuilderRegistry.java | 85 ++
.../tuscany/spi/builder/ComponentBuilder.java | 36 +
.../org/apache/tuscany/spi/builder/Connector.java | 52 ++
.../apache/tuscany/spi/builder/GenericBuilder.java | 42 +
.../builder/InvalidServiceInterfaceException.java | 35 +
.../spi/builder/MissingWireTargetException.java | 36 +
.../spi/builder/ScopeNotFoundException.java | 29 +
.../tuscany/spi/builder/WiringException.java | 124 +++
.../tuscany/spi/component/AbstractSCAObject.java | 134 +++
.../tuscany/spi/component/AtomicComponent.java | 126 +++
.../apache/tuscany/spi/component/Component.java | 100 +++
.../tuscany/spi/component/ComponentException.java | 52 ++
.../component/ComponentRegistrationException.java | 45 +
.../spi/component/ComponentRuntimeException.java | 54 ++
.../tuscany/spi/component/CompositeComponent.java | 156 ++++
.../spi/component/DuplicateNameException.java | 36 +
.../spi/component/IllegalTargetException.java | 33 +
.../spi/component/InvalidAutowireInterface.java | 31 +
.../InvalidConversationSequenceException.java | 31 +
.../spi/component/PersistenceException.java | 41 +
.../tuscany/spi/component/PrepareException.java | 35 +
.../spi/component/ReactivationException.java | 45 +
.../apache/tuscany/spi/component/Reference.java | 34 +
.../tuscany/spi/component/ReferenceBinding.java | 88 ++
.../tuscany/spi/component/SCAExternalizable.java | 43 +
.../apache/tuscany/spi/component/SCAObject.java | 73 ++
.../spi/component/SCAObjectStartException.java | 33 +
.../spi/component/SCAObjectStopException.java | 33 +
.../tuscany/spi/component/ScopeContainer.java | 87 ++
.../spi/component/ScopeContainerMonitor.java | 36 +
.../tuscany/spi/component/ScopeRegistry.java | 43 +
.../org/apache/tuscany/spi/component/Service.java | 52 ++
.../tuscany/spi/component/ServiceBinding.java | 95 +++
.../spi/component/TargetDestructionException.java | 40 +
.../tuscany/spi/component/TargetException.java | 50 ++
.../component/TargetInitializationException.java | 39 +
.../spi/component/TargetInvocationException.java | 43 +
.../component/TargetInvokerCreationException.java | 50 ++
.../spi/component/TargetNotFoundException.java | 36 +
.../spi/component/TargetResolutionException.java | 43 +
.../apache/tuscany/spi/component/WorkContext.java | 116 +++
.../tuscany/spi/databinding/DataBinding.java | 99 +++
.../spi/databinding/DataBindingRegistry.java | 70 ++
.../apache/tuscany/spi/databinding/DataPipe.java | 44 +
.../tuscany/spi/databinding/ExceptionHandler.java | 57 ++
.../apache/tuscany/spi/databinding/Mediator.java | 67 ++
.../tuscany/spi/databinding/PullTransformer.java | 36 +
.../tuscany/spi/databinding/PushTransformer.java | 34 +
.../tuscany/spi/databinding/SimpleTypeMapper.java | 44 +
.../spi/databinding/TransformationContext.java | 72 ++
.../spi/databinding/TransformationException.java | 46 +
.../tuscany/spi/databinding/Transformer.java | 49 ++
.../spi/databinding/TransformerRegistry.java | 75 ++
.../tuscany/spi/databinding/WrapperHandler.java | 55 ++
.../spi/databinding/extension/DOMHelper.java | 69 ++
.../extension/DataBindingExtension.java | 166 ++++
.../extension/Java2SimpleTypeTransformer.java | 60 ++
.../extension/SimpleType2JavaTransformer.java | 63 ++
.../extension/SimpleTypeMapperExtension.java | 392 +++++++++
.../extension/TransformerExtension.java | 73 ++
.../extension/XSDDataTypeConverter.java | 940 +++++++++++++++++++++
.../tuscany/spi/deployer/ArtifactResolver.java | 84 ++
.../spi/deployer/ArtifactResolverRegistry.java | 45 +
.../tuscany/spi/deployer/ChangeSetHandler.java | 48 ++
.../spi/deployer/ChangeSetHandlerRegistry.java | 28 +
.../tuscany/spi/deployer/CompositeClassLoader.java | 52 ++
.../apache/tuscany/spi/deployer/ContentType.java | 37 +
.../tuscany/spi/deployer/ContentTypeDescriber.java | 36 +
.../spi/deployer/ContributionProcessor.java | 66 ++
.../deployer/ContributionProcessorRegistry.java | 36 +
.../spi/deployer/ContributionRepository.java | 78 ++
.../org/apache/tuscany/spi/deployer/Deployer.java | 62 ++
.../tuscany/spi/deployer/DeploymentContext.java | 84 ++
.../tuscany/spi/deployer/DeploymentMonitor.java | 20 +
.../tuscany/spi/event/AbstractEventPublisher.java | 83 ++
.../java/org/apache/tuscany/spi/event/Event.java | 33 +
.../org/apache/tuscany/spi/event/EventFilter.java | 33 +
.../apache/tuscany/spi/event/EventPublisher.java | 50 ++
.../tuscany/spi/event/RuntimeEventListener.java | 31 +
.../org/apache/tuscany/spi/event/TrueFilter.java | 31 +
.../spi/extension/AbstractComponentExtension.java | 65 ++
.../spi/extension/ArtifactResolverExtension.java | 75 ++
.../spi/extension/AtomicComponentExtension.java | 225 +++++
.../spi/extension/BindingBuilderExtension.java | 79 ++
.../spi/extension/ComponentBuilderExtension.java | 100 +++
.../extension/ComponentTypeLoaderExtension.java | 63 ++
.../spi/extension/CompositeComponentExtension.java | 564 +++++++++++++
.../extension/ContributionProcessorExtension.java | 75 ++
.../tuscany/spi/extension/ExecutionMonitor.java | 33 +
.../spi/extension/GenericBuilderExtension.java | 52 ++
.../tuscany/spi/extension/LoaderExtension.java | 79 ++
.../spi/extension/ReferenceBindingExtension.java | 78 ++
.../spi/extension/ServiceBindingExtension.java | 90 ++
.../extension/SystemAtomicComponentExtension.java | 45 +
.../spi/extension/TargetInvokerExtension.java | 96 +++
.../org/apache/tuscany/spi/host/ResourceHost.java | 46 +
.../tuscany/spi/host/ResourceHostRegistry.java | 72 ++
.../spi/host/ResourceResolutionException.java | 32 +
.../org/apache/tuscany/spi/host/ServletHost.java | 58 ++
.../org/apache/tuscany/spi/idl/ElementInfo.java | 54 ++
.../InvalidConversationalOperationException.java | 40 +
.../spi/idl/InvalidServiceContractException.java | 50 ++
.../spi/idl/OverloadedOperationException.java | 41 +
.../tuscany/spi/idl/ServiceFaultException.java | 82 ++
.../java/org/apache/tuscany/spi/idl/TypeInfo.java | 66 ++
.../java/org/apache/tuscany/spi/idl/XMLType.java | 124 +++
.../spi/idl/java/InterfaceJavaIntrospector.java | 57 ++
.../apache/tuscany/spi/idl/java/JavaIDLUtils.java | 104 +++
.../spi/idl/java/JavaInterfaceProcessor.java | 34 +
.../idl/java/JavaInterfaceProcessorExtension.java | 47 ++
.../idl/java/JavaInterfaceProcessorRegistry.java | 39 +
.../tuscany/spi/idl/java/JavaServiceContract.java | 39 +
.../java/AbstractPropertyProcessor.java | 205 +++++
.../implementation/java/ConstructorDefinition.java | 51 ++
.../java/DuplicatePropertyException.java | 35 +
.../java/IllegalPropertyException.java | 36 +
.../java/ImplementationProcessor.java | 128 +++
.../java/ImplementationProcessorExtension.java | 118 +++
.../java/ImplementationProcessorService.java | 91 ++
.../implementation/java/IntrospectionRegistry.java | 38 +
.../spi/implementation/java/Introspector.java | 47 ++
.../java/JavaMappedComponentType.java | 61 ++
.../implementation/java/JavaMappedProperty.java | 64 ++
.../implementation/java/JavaMappedReference.java | 60 ++
.../spi/implementation/java/JavaMappedService.java | 91 ++
.../spi/implementation/java/PojoComponentType.java | 121 +++
.../implementation/java/ProcessingException.java | 65 ++
.../tuscany/spi/implementation/java/Resource.java | 138 +++
.../tuscany/spi/loader/ComponentTypeLoader.java | 45 +
.../loader/DuplicateReferenceNameException.java | 81 ++
...mpatibleOverridingServiceContractException.java | 74 ++
.../spi/loader/InvalidConfigurationException.java | 36 +
.../loader/InvalidPromotedReferenceException.java | 39 +
.../spi/loader/InvalidReferenceException.java | 38 +
.../spi/loader/InvalidServiceException.java | 30 +
.../tuscany/spi/loader/InvalidValueException.java | 40 +
.../tuscany/spi/loader/InvalidWireException.java | 45 +
.../java/org/apache/tuscany/spi/loader/Loader.java | 92 ++
.../apache/tuscany/spi/loader/LoaderException.java | 92 ++
.../apache/tuscany/spi/loader/LoaderRegistry.java | 69 ++
.../org/apache/tuscany/spi/loader/LoaderUtil.java | 78 ++
.../spi/loader/MissingImplementationException.java | 35 +
.../spi/loader/MissingIncludeException.java | 32 +
.../MissingMustOverridePropertyException.java | 30 +
.../spi/loader/MissingPropertyValueException.java | 30 +
.../spi/loader/MissingReferenceException.java | 32 +
.../spi/loader/MissingResourceException.java | 67 ++
.../spi/loader/MissingSideFileException.java | 31 +
.../loader/NotOverridablePropertyException.java | 30 +
.../tuscany/spi/loader/PropertyObjectFactory.java | 49 ++
.../ReferenceMultiplicityOverridingException.java | 78 ++
.../ReferenceMultiplicityViolationException.java | 75 ++
.../tuscany/spi/loader/StAXElementLoader.java | 48 ++
.../spi/loader/UndefinedPropertyException.java | 28 +
.../spi/loader/UndefinedReferenceException.java | 30 +
.../loader/UnrecognizedComponentTypeException.java | 42 +
.../spi/loader/UnrecognizedElementException.java | 46 +
.../tuscany/spi/marshaller/MarshalException.java | 48 ++
.../tuscany/spi/marshaller/ModelMarshaller.java | 54 ++
.../spi/model/AbstractReferenceDefinition.java | 137 +++
.../tuscany/spi/model/AtomicImplementation.java | 33 +
.../tuscany/spi/model/BindingDefinition.java | 47 ++
.../tuscany/spi/model/ComponentDefinition.java | 152 ++++
.../spi/model/ComponentReferenceDefinition.java | 95 +++
.../apache/tuscany/spi/model/ComponentType.java | 188 +++++
.../model/ComponentTypeReferenceDefinition.java | 40 +
.../tuscany/spi/model/CompositeComponentType.java | 197 +++++
.../tuscany/spi/model/CompositeImplementation.java | 56 ++
.../spi/model/CompositeReferenceDefinition.java | 55 ++
.../org/apache/tuscany/spi/model/Contribution.java | 113 +++
.../tuscany/spi/model/ContributionImport.java | 50 ++
.../org/apache/tuscany/spi/model/DataType.java | 249 ++++++
.../apache/tuscany/spi/model/DeployedArtifact.java | 114 +++
.../apache/tuscany/spi/model/Implementation.java | 43 +
.../java/org/apache/tuscany/spi/model/Include.java | 80 ++
.../java/org/apache/tuscany/spi/model/Intent.java | 92 ++
.../org/apache/tuscany/spi/model/IntentMap.java | 64 ++
.../org/apache/tuscany/spi/model/IntentName.java | 140 +++
.../apache/tuscany/spi/model/InteractionScope.java | 29 +
.../org/apache/tuscany/spi/model/ModelObject.java | 38 +
.../org/apache/tuscany/spi/model/Multiplicity.java | 47 ++
.../org/apache/tuscany/spi/model/Operation.java | 413 +++++++++
.../apache/tuscany/spi/model/OverrideOptions.java | 34 +
.../apache/tuscany/spi/model/PolicyAttachable.java | 21 +
.../tuscany/spi/model/PolicyAttachableModel.java | 49 ++
.../tuscany/spi/model/PolicyContentModel.java | 45 +
.../org/apache/tuscany/spi/model/PolicyModel.java | 29 +
.../org/apache/tuscany/spi/model/PolicySet.java | 99 +++
.../tuscany/spi/model/PolicySetReference.java | 38 +
.../org/apache/tuscany/spi/model/Property.java | 132 +++
.../apache/tuscany/spi/model/PropertyValue.java | 134 +++
.../org/apache/tuscany/spi/model/Qualifier.java | 51 ++
.../apache/tuscany/spi/model/ReferenceTarget.java | 50 ++
.../java/org/apache/tuscany/spi/model/Scope.java | 61 ++
.../apache/tuscany/spi/model/ServiceContract.java | 279 ++++++
.../tuscany/spi/model/ServiceDefinition.java | 163 ++++
.../tuscany/spi/model/WSPolicyAttachment.java | 35 +
.../apache/tuscany/spi/model/WireDefinition.java | 47 ++
.../org/apache/tuscany/spi/model/WrapperInfo.java | 141 ++++
.../apache/tuscany/spi/policy/IntentRegistry.java | 83 ++
.../tuscany/spi/policy/PolicyBuilderRegistry.java | 70 ++
.../apache/tuscany/spi/policy/PolicyEngine.java | 42 +
.../tuscany/spi/policy/PolicySetContainer.java | 46 +
.../apache/tuscany/spi/policy/SCATypeManager.java | 29 +
.../tuscany/spi/policy/SourcePolicyBuilder.java | 41 +
.../spi/policy/SourcePolicyBuilderExtension.java | 53 ++
.../tuscany/spi/policy/TargetPolicyBuilder.java | 41 +
.../spi/policy/TargetPolicyBuilderExtension.java | 53 ++
.../tuscany/spi/resolver/ResolutionException.java | 52 ++
.../org/apache/tuscany/spi/resolver/Resolver.java | 37 +
.../tuscany/spi/resolver/ResolverRegistry.java | 46 +
.../apache/tuscany/spi/services/VoidService.java | 33 +
.../tuscany/spi/services/artifact/Artifact.java | 197 +++++
.../spi/services/artifact/ArtifactRepository.java | 45 +
.../discovery/AbstractDiscoveryService.java | 149 ++++
.../spi/services/discovery/DiscoveryException.java | 48 ++
.../spi/services/discovery/DiscoveryService.java | 75 ++
.../spi/services/discovery/RequestListener.java | 39 +
.../spi/services/discovery/ResponseListener.java | 40 +
.../management/TuscanyManagementService.java | 40 +
.../services/store/DuplicateRecordException.java | 31 +
.../spi/services/store/RecoveryListener.java | 46 +
.../apache/tuscany/spi/services/store/Store.java | 96 +++
.../tuscany/spi/services/store/StoreException.java | 54 ++
.../spi/services/store/StoreExpirationEvent.java | 71 ++
.../tuscany/spi/services/store/StoreMonitor.java | 74 ++
.../spi/services/store/StoreReadException.java | 41 +
.../spi/services/store/StoreWriteException.java | 43 +
.../spi/services/work/NotificationListener.java | 66 ++
.../tuscany/spi/services/work/WorkScheduler.java | 52 ++
.../spi/services/work/WorkSchedulerException.java | 41 +
.../tuscany/spi/util/SCAObjectInputStream.java | 60 ++
.../org/apache/tuscany/spi/util/stax/StaxUtil.java | 401 +++++++++
.../spi/wire/AbstractInboundInvocationHandler.java | 54 ++
.../wire/AbstractOutboundInvocationHandler.java | 104 +++
.../tuscany/spi/wire/InboundInvocationChain.java | 29 +
.../org/apache/tuscany/spi/wire/InboundWire.java | 89 ++
.../wire/IncompatibleServiceContractException.java | 74 ++
.../org/apache/tuscany/spi/wire/Interceptor.java | 50 ++
.../apache/tuscany/spi/wire/InvocationChain.java | 95 +++
.../spi/wire/InvocationRuntimeException.java | 46 +
.../java/org/apache/tuscany/spi/wire/Message.java | 120 +++
.../org/apache/tuscany/spi/wire/MessageId.java | 56 ++
.../org/apache/tuscany/spi/wire/MessageImpl.java | 116 +++
.../tuscany/spi/wire/OutboundChainHolder.java | 38 +
.../tuscany/spi/wire/OutboundInvocationChain.java | 28 +
.../org/apache/tuscany/spi/wire/OutboundWire.java | 106 +++
.../tuscany/spi/wire/ProxyCreationException.java | 51 ++
.../org/apache/tuscany/spi/wire/TargetInvoker.java | 79 ++
.../java/org/apache/tuscany/spi/wire/Wire.java | 82 ++
.../tuscany/spi/wire/WireInvocationHandler.java | 32 +
.../apache/tuscany/spi/wire/WireObjectFactory.java | 48 ++
.../apache/tuscany/spi/wire/WirePostProcessor.java | 40 +
.../spi/wire/WirePostProcessorExtension.java | 44 +
.../spi/wire/WirePostProcessorRegistry.java | 44 +
.../org/apache/tuscany/spi/wire/WireService.java | 157 ++++
271 files changed, 20123 insertions(+)
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderInstantiationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/GenericBuilder.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/MissingWireTargetException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ScopeNotFoundException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WiringException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRegistrationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidAutowireInterface.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidConversationSequenceException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PersistenceException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PrepareException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReactivationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceBinding.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAExternalizable.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStartException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStopException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainerMonitor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ServiceBinding.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetDestructionException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInitializationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvocationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvokerCreationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetResolutionException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java
create mode 100755 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java
create mode 100755 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java
create mode 100755 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java
create mode 100755 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java
create mode 100755 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java
create mode 100755 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolver.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolverRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandler.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandlerRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContentType.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContentTypeDescriber.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessorRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionRepository.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentMonitor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/AbstractEventPublisher.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AbstractComponentExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ArtifactResolverExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ExecutionMonitor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/GenericBuilderExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceBindingExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceBindingExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHost.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHostRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceResolutionException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidConversationalOperationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ServiceFaultException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/XMLType.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Resource.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/DuplicateReferenceNameException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/IncompatibleOverridingServiceContractException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidConfigurationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidPromotedReferenceException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidServiceException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidWireException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingPropertyValueException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingReferenceException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingSideFileException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ReferenceMultiplicityOverridingException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ReferenceMultiplicityViolationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedReferenceException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedComponentTypeException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/marshaller/MarshalException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/marshaller/ModelMarshaller.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AbstractReferenceDefinition.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindingDefinition.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentReferenceDefinition.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentTypeReferenceDefinition.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeImplementation.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeReferenceDefinition.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ContributionImport.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DataType.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Implementation.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Include.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Intent.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentMap.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/IntentName.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/InteractionScope.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ModelObject.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Multiplicity.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/OverrideOptions.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachable.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyAttachableModel.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyContentModel.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicyModel.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySet.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PolicySetReference.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Property.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/PropertyValue.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Qualifier.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ReferenceTarget.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceDefinition.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WSPolicyAttachment.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WireDefinition.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/WrapperInfo.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/IntentRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyBuilderRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicyEngine.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/PolicySetContainer.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SCATypeManager.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilder.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/SourcePolicyBuilderExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilder.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/policy/TargetPolicyBuilderExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/resolver/ResolutionException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/resolver/Resolver.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/resolver/ResolverRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/VoidService.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/Artifact.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/artifact/ArtifactRepository.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/AbstractDiscoveryService.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/DiscoveryService.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/RequestListener.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/discovery/ResponseListener.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/management/TuscanyManagementService.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/DuplicateRecordException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/RecoveryListener.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/Store.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreExpirationEvent.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreMonitor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreReadException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/store/StoreWriteException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/NotificationListener.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkScheduler.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/services/work/WorkSchedulerException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/SCAObjectInputStream.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/util/stax/StaxUtil.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandler.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandler.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundWire.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/IncompatibleServiceContractException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Interceptor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationChain.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InvocationRuntimeException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Message.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageId.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/MessageImpl.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundChainHolder.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundInvocationChain.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/OutboundWire.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/ProxyCreationException.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/TargetInvoker.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/Wire.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireInvocationHandler.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireObjectFactory.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessor.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorExtension.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WirePostProcessorRegistry.java
create mode 100644 sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/WireService.java
(limited to 'sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java')
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.java
new file mode 100644
index 0000000000..e8597a55fc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/AbstractLifecycle.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.spi;
+
+/**
+ * Base class providing a simple implementation of Lifecycle.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractLifecycle implements Lifecycle {
+ protected volatile int lifecycleState = UNINITIALIZED;
+
+ public int getLifecycleState() {
+ return lifecycleState;
+ }
+
+ /**
+ * Set the current state of the Lifecycle.
+ *
+ * @param lifecycleState the new state
+ */
+ protected void setLifecycleState(int lifecycleState) {
+ this.lifecycleState = lifecycleState;
+ }
+
+ public void start() {
+ setLifecycleState(RUNNING);
+ }
+
+ public void stop() {
+ setLifecycleState(STOPPED);
+ }
+
+ /**
+ * Returns the current lifecycle as a String (for example, "RUNNING").
+ *
+ * @return the current lifecycle as a String
+ */
+ public String toString() {
+ switch (lifecycleState) {
+ case Lifecycle.CONFIG_ERROR:
+ return "CONFIG_ERROR";
+ case Lifecycle.ERROR:
+ return "ERROR";
+ case Lifecycle.INITIALIZING:
+ return "INITIALIZING";
+ case Lifecycle.INITIALIZED:
+ return "INITIALIZED";
+ case Lifecycle.RUNNING:
+ return "RUNNING";
+ case Lifecycle.STOPPING:
+ return "STOPPING";
+ case Lifecycle.STOPPED:
+ return "STOPPED";
+ case Lifecycle.UNINITIALIZED:
+ return "UNINITIALIZED";
+ default:
+ return "UNKNOWN";
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.java
new file mode 100644
index 0000000000..641a4e5d21
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/CoreRuntimeException.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.spi;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * The root exception for the runtime package. Exceptions occurring in the runtime are generally non-recoverable
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class CoreRuntimeException extends TuscanyRuntimeException {
+
+ public CoreRuntimeException() {
+ super();
+ }
+
+ public CoreRuntimeException(String message) {
+ super(message);
+ }
+
+
+ protected CoreRuntimeException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public CoreRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+
+ protected CoreRuntimeException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public CoreRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.java
new file mode 100644
index 0000000000..28bc8652b2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/InvalidNameException.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.spi;
+
+/**
+ * Denotes an invalid name
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidNameException extends CoreRuntimeException {
+
+ public InvalidNameException() {
+ super();
+ }
+
+ public InvalidNameException(String message) {
+ super(message);
+ }
+
+ public InvalidNameException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidNameException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.java
new file mode 100644
index 0000000000..e8a0448e44
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/Lifecycle.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.spi;
+
+/**
+ * Implementations adhere to runtime lifecycle semantics
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Lifecycle {
+ /* A configuration error state */
+ int CONFIG_ERROR = -1;
+ /* Has not been initialized */
+ int UNINITIALIZED = 0;
+ /* In the process of being configured and initialized */
+ int INITIALIZING = 1;
+ /* Instantiated and configured */
+ int INITIALIZED = 2;
+ /* Configured and initialized */
+ int RUNNING = 4;
+ /* In the process of being shutdown */
+ int STOPPING = 5;
+ /* Has been shutdown and removed from the composite */
+ int STOPPED = 6;
+ /* In an error state */
+ int ERROR = 7;
+
+ /**
+ * Returns the lifecycle state
+ *
+ * @see #UNINITIALIZED
+ * @see #INITIALIZING
+ * @see #INITIALIZED
+ * @see #RUNNING
+ * @see #STOPPING
+ * @see #STOPPED
+ */
+ int getLifecycleState();
+
+ /**
+ * Starts the Lifecycle.
+ *
+ * @throws CoreRuntimeException
+ */
+ void start() throws CoreRuntimeException;
+
+ /**
+ * Stops the Lifecycle.
+ *
+ * @throws CoreRuntimeException
+ */
+ void stop() throws CoreRuntimeException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.java
new file mode 100644
index 0000000000..580e928000
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectCreationException.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.spi;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Denotes an error creating a new object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ObjectCreationException extends TuscanyRuntimeException {
+ private static final long serialVersionUID = -6423113430265944499L;
+
+ public ObjectCreationException() {
+ super();
+ }
+
+ public ObjectCreationException(String message) {
+ super(message);
+ }
+
+ public ObjectCreationException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public ObjectCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ObjectCreationException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public ObjectCreationException(Throwable cause) {
+ super(cause);
+ }
+
+}
+
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.java
new file mode 100644
index 0000000000..d505e14f61
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/ObjectFactory.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.spi;
+
+/**
+ * Implementations create new instances of a particular type
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ObjectFactory {
+
+ /**
+ * Return a instance of the type that this factory creates.
+ *
+ * @return a instance from this factory
+ */
+ T getInstance() throws ObjectCreationException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java
new file mode 100644
index 0000000000..575f69db18
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/QualifiedName.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi;
+
+/**
+ * An evaluated name consisting of a part/port pair. In the runtime, a part generally 'contains' or 'provides' ports
+ * such as a component/service point or a component/reference pair.
+ *
+ * @version $Rev$ $Date$
+ */
+public class QualifiedName {
+ public static final String NAME_SEPARATOR = "/";
+
+ private String qName;
+ private String partName;
+ private String portName;
+
+ /**
+ * Constructs a new qualified name in the form of part/port where part is the parent context and port represents a
+ * child, which is either a service in the case of an atomic context or a contained context in the case of a
+ * composite.
+ *
+ * @throws InvalidNameException if the name is in an invalid format
+ */
+ public QualifiedName(String qualifiedName) throws InvalidNameException {
+ if (qualifiedName == null) {
+ return;
+ }
+ int pos = qualifiedName.indexOf(QualifiedName.NAME_SEPARATOR);
+ switch (pos) {
+ case-1:
+ partName = qualifiedName;
+ break;
+ case 0:
+ throw new InvalidNameException(qualifiedName);
+ default:
+ partName = qualifiedName.substring(0, pos);
+ portName = qualifiedName.substring(pos + 1);
+ break;
+ }
+ qName = qualifiedName;
+ }
+
+ /**
+ * Constructs a qualified name using the given part/port combination
+ *
+ * @param partName the part name
+ * @param portName the port name
+ */
+ public QualifiedName(String partName, String portName) {
+ this.partName = partName;
+ this.portName = portName;
+ this.qName = partName + '/' + portName;
+ }
+
+ /**
+ * Returns the parsed part name
+ */
+ public String getPartName() {
+ return partName;
+ }
+
+ /**
+ * Returns the parsed port name if the original is of the compound for part/port
+ */
+ public String getPortName() {
+ return portName;
+ }
+
+ /**
+ * Returns the full part/port name pair
+ */
+ public String getQualifiedName() {
+ return qName;
+ }
+
+ public String toString() {
+ return qName;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.java
new file mode 100644
index 0000000000..0e48f1bc1b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/annotation/Autowire.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.spi.annotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * A system annotation to inject an autowired instance
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD, FIELD, PARAMETER})
+@Retention(RUNTIME)
+public @interface Autowire {
+ /**
+ * The name of the autowire. If not specified then the name will be derived from the annotated field.
+ */
+ String name() default "";
+
+ /**
+ * Indicates if a reference must be specified.
+ */
+ boolean required() default true;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java
new file mode 100644
index 0000000000..fed2898102
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ComponentNames.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.bootstrap;
+
+/**
+ * Class that defines the names of well known component
+ *
+ * @version $Rev$ $Date$
+ */
+public final class ComponentNames {
+ /**
+ * The name of the component that forms the root of the runtime tree.
+ */
+ public static final String TUSCANY_RUNTIME = "tuscany.runtime";
+
+ /**
+ * The name of the component that is the root of the application composite tree.
+ */
+ public static final String TUSCANY_APPLICATION_ROOT = "tuscany.root.application";
+
+ /**
+ * The name of the component that is the root of the system composite tree.
+ */
+ public static final String TUSCANY_SYSTEM_ROOT = "tuscany.root.system";
+
+ /**
+ * The name of the top-level component in the system composite tree.
+ */
+ public static final String TUSCANY_SYSTEM = "tuscany.system";
+
+ /**
+ * The name of the component that contains the deployer.
+ */
+ public static final String TUSCANY_DEPLOYER = "deployer";
+
+ /**
+ * The name of the component that contains the deployer.
+ */
+ public static final String TUSCANY_WIRE_SERVICE = "wireService";
+
+ /**
+ * The name of the component that contains the contribution service.
+ */
+ public static final String TUSCANY_CONTRIBUTION_SERVICE = "contributionService";
+
+ /**
+ * The name of the component that contains the assmebly service.
+ */
+ public static final String TUSCANY_ASSEMBLY_SERVICE = "assemblyService";
+
+ private ComponentNames() {
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.java
new file mode 100644
index 0000000000..6e0184fbd6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeComponent.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.spi.bootstrap;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.deployer.Deployer;
+
+/**
+ * Interface that represents the Tuscany runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeComponent extends CompositeComponent {
+ /**
+ * Returns the component that forms the root of the user component tree. All user components will be managed by
+ * composites that are children of this root.
+ *
+ * @return the root of the user component tree
+ */
+ CompositeComponent getRootComponent();
+
+ /**
+ * Returns the component that forms the root of the system component tree. All system components, components that
+ * provide system services needed by the Tuscany runtime itself, will be managed by composites that are children of
+ * this root.
+ *
+ * @return the root of the system component tree
+ */
+ CompositeComponent getSystemComponent();
+
+ /**
+ * Returns the deployer for this runtime. This interface can be used to deploy new SCA bundles to the runtime.
+ *
+ * @return the deployer for this runtime
+ * @throws TargetException if there is an error returning the deployer
+ */
+ Deployer getDeployer() throws TargetException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.java
new file mode 100644
index 0000000000..3e2ee38d35
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BindingBuilder.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.spi.builder;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ReferenceBinding;
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.BindingDefinition;
+import org.apache.tuscany.spi.model.AbstractReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Responsible for processing a service or reference in an assembly configured with a particular binding. The builder
+ * will create and return corresponding {@link org.apache.tuscany.spi.component.ServiceBinding} or {@link
+ * org.apache.tuscany.spi.component.ReferenceBinding}
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindingBuilder {
+
+ /**
+ * Creates a service binding
+ *
+ * @param parent the containing composite component
+ * @param serviceDefinition the service the binding is configured for
+ * @param bindingDefinition the binding definition
+ * @param deploymentContext the current deployment context
+ * @return a service binding
+ * @throws BuilderException
+ */
+ ServiceBinding build(CompositeComponent parent,
+ ServiceDefinition serviceDefinition,
+ B bindingDefinition,
+ DeploymentContext deploymentContext) throws BuilderException;
+
+ ReferenceBinding build(CompositeComponent parent,
+ AbstractReferenceDefinition boundReferenceDefinition,
+ B bindingDefinition,
+ DeploymentContext deploymentContext) throws BuilderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.java
new file mode 100644
index 0000000000..0e11c93d8d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Builder.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.spi.builder;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.apache.tuscany.spi.model.AbstractReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * Implementations build SCAObject
types from model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Builder {
+ /**
+ * Builds a Component
from a ComponentDefinition
+ *
+ * @param parent the composite that will be the parent of the newly built component
+ * @param definition the component definition as parsed from an SCA assembly
+ * @param context the current deployment context
+ * @return the newly created component
+ * @throws BuilderException
+ */
+ > Component build(CompositeComponent parent,
+ ComponentDefinition definition,
+ DeploymentContext context) throws BuilderException;
+
+ /**
+ * Builds a Service
and its bindings from a ServiceDefinition
+ *
+ * @param parent the composite that will be the parent of the newly built service
+ * @param definition the service definition as parsed from an SCA assembly
+ * @param context the current deployment context
+ * @return the newly created service
+ * @throws BuilderException
+ */
+ Service build(CompositeComponent parent, ServiceDefinition definition, DeploymentContext context)
+ throws BuilderException;
+
+ /**
+ * Builds a Reference
and its bindings from a ReferenceDefinition
+ *
+ * @param parent the composite that will be the parent of the newly built reference
+ * @param definition the reference definition as parsed from an SCA assembly
+ * @param context the current deployment context
+ * @return the newly created reference
+ * @throws BuilderException
+ */
+ Reference build(CompositeComponent parent, AbstractReferenceDefinition definition, DeploymentContext context)
+ throws BuilderException;
+
+ /**
+ * Builds a SCAObject
+ * @param parent
+ * @param modelObject
+ * @param context
+ * @return
+ * @throws BuilderException
+ */
+ SCAObject build(SCAObject parent, ModelObject modelObject, DeploymentContext context)
+ throws BuilderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.java
new file mode 100644
index 0000000000..6e9f2ef95d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderConfigException.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.spi.builder;
+
+/**
+ * Represents an error processing an assembly model
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuilderConfigException extends BuilderException {
+
+ public BuilderConfigException() {
+ super();
+ }
+
+ public BuilderConfigException(String message) {
+ super(message);
+ }
+
+ public BuilderConfigException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public BuilderConfigException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderConfigException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.java
new file mode 100644
index 0000000000..846d52492c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderException.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.spi.builder;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * The root exception for the builder package. Builder exceptions denote a non-recoverable failure.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BuilderException extends TuscanyException {
+
+ public BuilderException() {
+ super();
+ }
+
+ public BuilderException(String message) {
+ super(message);
+ }
+
+
+ protected BuilderException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public BuilderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ protected BuilderException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public BuilderException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderInstantiationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderInstantiationException.java
new file mode 100644
index 0000000000..30957635db
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderInstantiationException.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.spi.builder;
+
+/**
+ * Denotes an error instantiating an SCAObject
+ *
+ * @version $Rev$ $Date$
+ */
+public class BuilderInstantiationException extends BuilderException {
+
+ public BuilderInstantiationException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public BuilderInstantiationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BuilderInstantiationException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java
new file mode 100644
index 0000000000..8d94ed1ebd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/BuilderRegistry.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.model.BindingDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * Maintains a registry of builders in the runtime, dispatching to the
+ * appropriate one as an assembly model is processed into runtime artifacts
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BuilderRegistry extends Builder {
+
+ /**
+ * Register a builder for an implementation type.
+ *
+ * @param implClass the type of implementation that this builder can handle
+ * @param builder the builder to be registered
+ */
+ > void register(Class implClass, ComponentBuilder builder);
+
+ /**
+ * Unregister a builder for an implementation type.
+ *
+ * @param implClass the implementation whose builder should be unregistered
+ */
+ > void unregisterComponentBuilder(Class implClass);
+
+ // FIXME: We need to provide unregister() for other builders
+
+ /**
+ * Register a binding builder for a binding type
+ *
+ * @param implClass the binding type
+ * @param builder the buinder to be registered
+ */
+ void register(Class implClass, BindingBuilder builder);
+
+ /**
+ * Unregister a binding builder
+ *
+ * @param
+ * @param implClass the binding type
+ */
+ void unregisterBindingBuilder(Class implClass);
+
+ /**
+ * Register a generic builder for a model type
+ *
+ * @param
+ * @param
+ * @param modelClass
+ * @param builder
+ */
+ void register(Class modelClass, GenericBuilder builder);
+
+ /**
+ * Unregister a generic builder
+ *
+ * @param
+ * @param modelClass The model type
+ */
+ void unregisterGenericBuilder(Class modelClass);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.java
new file mode 100644
index 0000000000..668cee77e6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ComponentBuilder.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.spi.builder;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * Responsible for building a {@link Component} from an atomic or composite component configured in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ComponentBuilder> {
+ Component build(CompositeComponent parent,
+ ComponentDefinition componentDefinition,
+ DeploymentContext deploymentContext) throws BuilderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.java
new file mode 100644
index 0000000000..b11aacc47e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/Connector.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.spi.builder;
+
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * Implementations are responsible for bridging invocation chains as an assembly is converted to runtime artifacts
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface Connector {
+
+ /**
+ * Connects the given source's wires to corresponding wires to a target. Wires are connected by bridging invocation
+ * chains.
+ *
+ * @param source the source, i.e. a ServiceBinding
, Component
, or Reference
+ * @throws WiringException
+ */
+ void connect(SCAObject source) throws WiringException;
+
+ /**
+ * Bridges the invocation chains associated with an inbound and outbound wire.
+ *
+ * @param inbound the wire to bridge from
+ * @param outbound the target wire
+ * @param optimizable if the bridge may be optimized
+ * @throws WiringException
+ */
+ void connect(InboundWire inbound, OutboundWire outbound, boolean optimizable)
+ throws WiringException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/GenericBuilder.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/GenericBuilder.java
new file mode 100644
index 0000000000..3cb3940729
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/GenericBuilder.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.spi.builder;
+
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * Responsible for building a {@link SCAObject} from an extensibility element in
+ * the SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public interface GenericBuilder {
+ /**
+ * Build a SCAObject from an extensibility element in the SCDL
+ *
+ * @param parent The parent SCAObject
+ * @param modelObject The model object
+ * @param deploymentContext The deployment context
+ * @return A SCAObject representing the runtime metdata for the extension
+ * @throws BuilderException
+ */
+ S build(SCAObject parent, M modelObject, DeploymentContext deploymentContext) throws BuilderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.java
new file mode 100644
index 0000000000..78bb5a5cc8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/InvalidServiceInterfaceException.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.spi.builder;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidServiceInterfaceException extends BuilderConfigException {
+ private final Class> interfaceClass;
+
+ public InvalidServiceInterfaceException(String message, Class> interfaceClass) {
+ super(message);
+ this.interfaceClass = interfaceClass;
+ }
+
+ public Class> getInterfaceClass() {
+ return interfaceClass;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/MissingWireTargetException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/MissingWireTargetException.java
new file mode 100644
index 0000000000..5a0b046430
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/MissingWireTargetException.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.spi.builder;
+
+/**
+ * Denotes a missing wire target in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingWireTargetException extends WiringException {
+
+ public MissingWireTargetException(String message) {
+ super(message);
+ }
+
+ public MissingWireTargetException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ScopeNotFoundException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ScopeNotFoundException.java
new file mode 100644
index 0000000000..acf8dadda6
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/ScopeNotFoundException.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.spi.builder;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ScopeNotFoundException extends BuilderConfigException {
+
+ public ScopeNotFoundException(String scope) {
+ super("Scope not found", scope);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WiringException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WiringException.java
new file mode 100644
index 0000000000..d5e17919fd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/builder/WiringException.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.builder;
+
+/**
+ * Denotes a general error raised during wiring
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class WiringException extends BuilderException {
+ private String sourceName;
+ private String referenceName;
+ private String targetName;
+ private String targetServiceName;
+
+ protected WiringException(String message) {
+ super(message);
+ }
+
+ protected WiringException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ protected WiringException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ protected WiringException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ protected WiringException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns the source name for the wire
+ *
+ * @return the source name the source name for the wire
+ */
+ public String getSourceName() {
+ return sourceName;
+ }
+
+ /**
+ * Sets the source name for the wire
+ *
+ * @param sourceName the source name for the wire
+ */
+ public void setSourceName(String sourceName) {
+ this.sourceName = sourceName;
+ }
+
+ /**
+ * Returns the target name for the wire
+ *
+ * @return the target name the source name for the wire
+ */
+ public String getTargetName() {
+ return targetName;
+ }
+
+ /**
+ * Sets the target name for the wire
+ *
+ * @param targetName the source name for the wire
+ */
+ public void setTargetName(String targetName) {
+ this.targetName = targetName;
+ }
+
+
+ /**
+ * Returns the source reference name for the wire
+ *
+ * @return the source reference name for the wire
+ */
+ public String getReferenceName() {
+ return referenceName;
+ }
+
+ /**
+ * Sets the source reference name for the wire
+ *
+ * @param referenceName the source reference name for the wire
+ */
+ public void setReferenceName(String referenceName) {
+ this.referenceName = referenceName;
+ }
+
+ /**
+ * Returns the target service name for the wire
+ *
+ * @return the target service name for the wire
+ */
+ public String getTargetServiceName() {
+ return targetServiceName;
+ }
+
+ /**
+ * Sets the target service name for the wire
+ *
+ * @param targetServiceName the target service name for the wire
+ */
+ public void setTargetServiceName(String targetServiceName) {
+ this.targetServiceName = targetServiceName;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java
new file mode 100644
index 0000000000..de98aa4437
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AbstractSCAObject.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.spi.AbstractLifecycle;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.event.TrueFilter;
+
+/**
+ * Functionality common to all SCAObject implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractSCAObject extends AbstractLifecycle implements SCAObject {
+ protected static final EventFilter TRUE_FILTER = new TrueFilter();
+
+ protected Map> listeners;
+ protected final CompositeComponent parent;
+ private final String name;
+ private final Map extensions = new HashMap();
+ private String canonicalName;
+
+ public AbstractSCAObject(String name, CompositeComponent parent) {
+ this.name = name;
+ this.parent = parent;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getCanonicalName() {
+ if (canonicalName == null) {
+ StringBuffer b = new StringBuffer(name);
+ if (parent != null) {
+ b.insert(0, parent.getCanonicalName() + "/");
+ }
+ canonicalName = b.toString();
+ }
+ return canonicalName;
+ }
+
+ public CompositeComponent getParent() {
+ return parent;
+ }
+
+ public void addListener(RuntimeEventListener listener) {
+ addListener(TRUE_FILTER, listener);
+ }
+
+ public void removeListener(RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ for (List currentList : getListeners().values()) {
+ for (RuntimeEventListener current : currentList) {
+ if (current == listener) {
+ currentList.remove(current);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ public void addListener(EventFilter filter, RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ List list = getListeners().get(filter);
+ if (list == null) {
+ list = new CopyOnWriteArrayList();
+ listeners.put(filter, list);
+ }
+ list.add(listener);
+ }
+ }
+
+ public void publish(Event event) {
+ assert event != null : "Event object was null";
+ for (Map.Entry> entry : getListeners().entrySet()) {
+ if (entry.getKey().match(event)) {
+ for (RuntimeEventListener listener : entry.getValue()) {
+ listener.onEvent(event);
+ }
+ }
+ }
+ }
+
+ protected Map> getListeners() {
+ if (listeners == null) {
+ listeners = new ConcurrentHashMap>();
+ }
+ return listeners;
+ }
+
+ public void prepare() throws PrepareException {
+
+ }
+
+ public String toString() {
+ return "[" + name + "] in state [" + super.toString() + ']';
+ }
+
+ public Map getExtensions() {
+ return extensions;
+ }
+
+ public boolean isSystem() {
+ return false;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java
new file mode 100644
index 0000000000..aa4c41889b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * The runtime instantiation of an SCA atomic, or leaf-type, component
+ *
+ * @version $Rev$ $Date$
+ */
+public interface AtomicComponent extends Component {
+
+ /**
+ * Returns true if component instances should be eagerly initialized.
+ *
+ * @return true if component instances should be eagerly initialized
+ */
+ boolean isEagerInit();
+
+ /**
+ * Returns true if component instances receive destroy events.
+ *
+ * @return true if component instances receive destroy events
+ */
+ boolean isDestroyable();
+
+ /**
+ * Returns the initialization level for this component.
+ *
+ * @return the initialization level for this component
+ */
+ int getInitLevel();
+
+ /**
+ * Returns the idle time allowed between operations in milliseconds if the implementation is conversational.
+ *
+ * @return the idle time allowed between operations in milliseconds if the implementation is conversational
+ */
+ long getMaxIdleTime();
+
+ /**
+ * Returns the maximum age a conversation may remain active in milliseconds if the implementation is
+ * conversational.
+ *
+ * @return the maximum age a conversation may remain active in milliseconds if the implementation is conversational
+ */
+ long getMaxAge();
+
+ /**
+ * Adds a target-side wire. Target-side wire factories contain the invocation chains associated with the destination
+ * service of a wire
+ */
+ void addInboundWire(InboundWire wire);
+
+ /**
+ * Adds a source-side wire for the given reference. Source-side wires contain the invocation chains for a reference
+ * in the implementation associated with the instance wrapper created by this configuration.
+ */
+ void addOutboundWire(OutboundWire wire);
+
+ /**
+ * Adds a set of source-side multiplicity wires for the given reference. Source-side wires contain the invocation
+ * chains for a reference in the implementation associated with the instance wrapper created by this configuration.
+ */
+ void addOutboundWires(List wires);
+
+ /**
+ * Notifies the given instance of an initialization event.
+ *
+ * @throws TargetInitializationException
+ */
+ void init(Object instance) throws TargetInitializationException;
+
+ /**
+ * Notifies the given instance of a destroy event.
+ *
+ * @throws TargetDestructionException
+ */
+ void destroy(Object instance) throws TargetDestructionException;
+
+ /**
+ * Creates a new implementation instance, generally used as a callback by a {@link
+ * org.apache.tuscany.spi.component.ScopeContainer}.
+ *
+ * @return the instance
+ * @throws ObjectCreationException
+ */
+ Object createInstance() throws ObjectCreationException;
+
+ /**
+ * Removes an implementation instance associated with the current invocation context.
+ *
+ * @throws ComponentException
+ */
+ void removeInstance() throws ComponentException;
+
+ /**
+ * Returns the target instance associated with the component. A target instance is the actual object a request is
+ * dispatched to sans wire chain.
+ *
+ * @throws TargetResolutionException
+ */
+ Object getTargetInstance() throws TargetResolutionException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java
new file mode 100644
index 0000000000..ec4eedfe90
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Component.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.PropertyValue;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * The runtime instantiation of an SCA component
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface Component extends SCAObject {
+
+ /**
+ * Sets the scope container associated with the component
+ *
+ * @param scopeContainer the scope container associated with the component
+ */
+ void setScopeContainer(ScopeContainer scopeContainer);
+
+ /**
+ * Returns the default property values associated with the component.
+ *
+ * @return default property values associated with the component.
+ */
+ Map> getDefaultPropertyValues();
+
+ /**
+ * Sets the default property values associated with the component.
+ *
+ * @param defaultPropertyValues Default property values associated with the component.
+ */
+ void setDefaultPropertyValues(Map> defaultPropertyValues);
+
+ /**
+ * Returns true if invocation dispatching can be optimized, i.e. invocation chains are not required
+ *
+ * @return true if invocation dispatching can be optimized, i.e. invocation chains are not required
+ */
+ boolean isOptimizable();
+
+ /**
+ * Returns the wire associated with the given service name or null if not found.
+ *
+ * @return the wire associated with the given service name or null if not found.
+ */
+ InboundWire getInboundWire(String serviceName);
+
+ /**
+ * Returns a map of inbound wires.
+ *
+ * @return a map of inbound wires.
+ */
+ Collection getInboundWires();
+
+ /**
+ * Returns a map of source-side wires for references. There may be 1..n wires per reference.
+ *
+ * @return a map of source-side wires for references.
+ */
+ Map> getOutboundWires();
+
+ /**
+ * Callback to create a {@link org.apache.tuscany.spi.wire.TargetInvoker} which dispatches to a service offered by
+ * the component
+ *
+ * @param targetName the service name
+ * @param operation the operation to invoke
+ * @param callbackWire the callback wire or null if the associated wire is unidirectional
+ * @return the target invoker
+ * @throws TargetInvokerCreationException
+ */
+ TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire)
+ throws TargetInvokerCreationException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentException.java
new file mode 100644
index 0000000000..2007cbb6bc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentException.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.spi.component;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * An checked exception encountered by an {@link org.apache.tuscany.spi.component.Component}
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ComponentException extends TuscanyException {
+
+ protected ComponentException() {
+ }
+
+ protected ComponentException(String message) {
+ super(message);
+ }
+
+ protected ComponentException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ protected ComponentException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ protected ComponentException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ protected ComponentException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRegistrationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRegistrationException.java
new file mode 100644
index 0000000000..f34fda47a2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRegistrationException.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.spi.component;
+
+/**
+ * Thrown when an error is encountered registering a component
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public abstract class ComponentRegistrationException extends ComponentException {
+ public ComponentRegistrationException() {
+ }
+
+ public ComponentRegistrationException(String message) {
+ super(message);
+ }
+
+ public ComponentRegistrationException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public ComponentRegistrationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ComponentRegistrationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.java
new file mode 100644
index 0000000000..8479681c75
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ComponentRuntimeException.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.spi.component;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * An unchecked exception encountered by an {@link org.apache.tuscany.spi.component.Component}
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ComponentRuntimeException extends CoreRuntimeException {
+
+ public ComponentRuntimeException() {
+ super();
+ }
+
+ public ComponentRuntimeException(String message) {
+ super(message);
+ }
+
+ public ComponentRuntimeException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public ComponentRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ComponentRuntimeException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public ComponentRuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java
new file mode 100644
index 0000000000..0f73fbfac5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/CompositeComponent.java
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.List;
+import java.util.Collection;
+
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.services.management.TuscanyManagementService;
+import org.apache.tuscany.spi.wire.InboundWire;
+
+/**
+ * The runtime instantiation of an SCA composite component. Composites may contain child components, offer services, and
+ * have references. Children are contained in two namespaces, an application namespace for end-user components deployed
+ * to a runtime, and a system namespace for components that provide system services.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface CompositeComponent extends Component, RuntimeEventListener {
+
+ /**
+ * Sets the management service associated with the composite
+ *
+ * @param managementService the management service associated with the composite
+ */
+ void setManagementService(TuscanyManagementService managementService);
+
+ /**
+ * Returns the value of a Property of this composite.
+ *
+ * @param name the name of the Property
+ * @return its value, or null if there is not such property or if it has no defined value
+ */
+ Document getPropertyValue(String name);
+
+ /**
+ * Registers a child of this composite.
+ *
+ * @param object the object to add as a child
+ * @throws ComponentRegistrationException
+ */
+ void register(SCAObject object) throws ComponentRegistrationException;
+
+ /**
+ * Returns the internal system wire associated with the given service name or null if not found
+ *
+ * @param serviceName the service name
+ * @return the system wire or null if not found
+ */
+ InboundWire getInboundSystemWire(String serviceName);
+
+ /**
+ * Returns a map of inbound system wires.
+ *
+ * @return a map of inbound system wires.
+ */
+ Collection getInboundSystemWires();
+
+
+ /**
+ * Register a simple Java Object as a system component. This is primarily intended for use by bootstrap code to
+ * create the initial configuration components.
+ *
+ * @param name the name of the resulting component
+ * @param service the service interface the component should expose
+ * @param instance the Object that will become the component's implementation
+ * @throws ComponentRegistrationException
+ */
+ void registerJavaObject(String name, Class service, I instance)
+ throws ComponentRegistrationException;
+
+ /**
+ * Register a simple Java Object as a system component. This is primarily intended for use by bootstrap code to
+ * create the initial configuration components.
+ *
+ * @param name the name of the resulting component
+ * @param services the service interfaces the component should expose
+ * @param instance the Object that will become the component's implementation
+ * @throws ComponentRegistrationException
+ */
+ void registerJavaObject(String name, List> services, I instance)
+ throws ComponentRegistrationException;
+
+ /**
+ * Returns the child associated with a given name
+ */
+ SCAObject getChild(String name);
+
+ /**
+ * Returns the system child associated with a given name
+ */
+ SCAObject getSystemChild(String name);
+
+ /**
+ * Invoked by child components to return an wire to a target based on matching type. Resolved targets may be
+ * serviceBindings or components in the parent or its ancestors, or references in a sibling component
+ *
+ * @param instanceInterface the type of service being requested
+ * @return a reference to the requested service or null if one is not be found
+ * @throws TargetResolutionException
+ */
+ InboundWire resolveAutowire(Class> instanceInterface) throws TargetResolutionException;
+
+ /**
+ * Invoked by system child components to return a wire to a system target based on matching type. Resolved targets
+ * may be system serviceBindings or components in the parent or its ancestors, or references in a sibling component
+ *
+ * @param instanceInterface the type of service being requested
+ * @return a reference to the requested service or null if one is not be found
+ * @throws TargetResolutionException
+ */
+ InboundWire resolveSystemAutowire(Class> instanceInterface) throws TargetResolutionException;
+
+ /**
+ * Invoked by a parent component to return an wire to a target in a child based on matching type. Resolved targets
+ * must be serviceBindings. For example, given a parent P and two siblings, A and B, A would request an autowire by
+ * invoking {@link #resolveAutowire(Class>)} on P, which in turn could invoke the present method on B in order to
+ * resolve a target.
+ *
+ * @param instanceInterface the type of service being requested
+ * @return a reference to the requested service or null if one is not be found
+ * @throws TargetResolutionException
+ */
+ InboundWire resolveExternalAutowire(Class> instanceInterface) throws TargetResolutionException;
+
+ /**
+ * Invoked by a parent component to return a wire to a system target in a child based on matching type. Resolved
+ * targets must be system serviceBindings. For example, given a parent P and two siblings, A and B, A would request
+ * an autowire by invoking {@link #resolveAutowire(Class>)} on P, which in turn could invoke the present method on
+ * B in order to resolve a target.
+ *
+ * @param instanceInterface the type of service being requested
+ * @return a reference to the requested service or null if one is not be found
+ * @throws TargetResolutionException
+ */
+ InboundWire resolveSystemExternalAutowire(Class> instanceInterface) throws TargetResolutionException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.java
new file mode 100644
index 0000000000..128f301256
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/DuplicateNameException.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.spi.component;
+
+/**
+ * Denotes an attempt to add an child to a composite component with a name equal to an existing child
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicateNameException extends ComponentRegistrationException {
+
+ public DuplicateNameException(String message) {
+ super(message);
+ }
+
+ public DuplicateNameException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.java
new file mode 100644
index 0000000000..7eb37c3639
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/IllegalTargetException.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.spi.component;
+
+/**
+ * Thrown when a target for an operation is not of the required type
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class IllegalTargetException extends TargetResolutionException {
+
+ public IllegalTargetException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidAutowireInterface.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidAutowireInterface.java
new file mode 100644
index 0000000000..ffda730a27
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidAutowireInterface.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.spi.component;
+
+/**
+ * Thrown when an invalid interface is specified during autowire registration
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidAutowireInterface extends ComponentRegistrationException {
+
+ public InvalidAutowireInterface(String message, String identifier) {
+ super(message, identifier);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidConversationSequenceException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidConversationSequenceException.java
new file mode 100644
index 0000000000..21a1712e1a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/InvalidConversationSequenceException.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.spi.component;
+
+/**
+ * Denotes an unknown operation sequence in a conversation
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidConversationSequenceException extends TargetInvocationException {
+
+ public InvalidConversationSequenceException(String message, String identifier) {
+ super(message, identifier);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PersistenceException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PersistenceException.java
new file mode 100644
index 0000000000..06940aaff7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PersistenceException.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.spi.component;
+
+/**
+ * Raised when an error persisting a component implementation instance is encountered
+ *
+ * @version $Rev$ $Date$
+ */
+public class PersistenceException extends ComponentException {
+ public PersistenceException() {
+ }
+
+ public PersistenceException(String message) {
+ super(message);
+ }
+
+ public PersistenceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public PersistenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PrepareException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PrepareException.java
new file mode 100644
index 0000000000..d2be6daadf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/PrepareException.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.spi.component;
+
+/**
+ * Denotes an exception preparing a component
+ *
+ * @version $Rev$ $Date$
+ */
+public class PrepareException extends ComponentException {
+
+ public PrepareException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public PrepareException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReactivationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReactivationException.java
new file mode 100644
index 0000000000..4ef0929422
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReactivationException.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.spi.component;
+
+/**
+ * Raised when an error is encountered reactivating a serialized instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReactivationException extends ComponentRuntimeException {
+ private String owner;
+
+ public ReactivationException(String message) {
+ super(message);
+ }
+
+ public ReactivationException(String message, String identifier, String ower) {
+ super(message, identifier);
+ this.owner = ower;
+ }
+
+ public ReactivationException(Throwable cause) {
+ super(cause);
+ }
+
+ public String getOwner() {
+ return owner;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java
new file mode 100644
index 0000000000..2b3ef4be30
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Reference.java
@@ -0,0 +1,34 @@
+package org.apache.tuscany.spi.component;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * The runtime instantiation of an SCA reference
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Reference extends SCAObject {
+
+ /**
+ * Returns the contract for the reference.
+ *
+ * @return the contract for the reference.
+ */
+ ServiceContract> getServiceContract();
+
+ /**
+ * Returns the collection of bindings configured for the reference.
+ *
+ * @return the collection of bindings configured for the reference.
+ */
+ List getReferenceBindings();
+
+ /**
+ * Adds a binding the reference is configured with.
+ *
+ * @param binding the binding the reference is configured with.
+ */
+ void addReferenceBinding(ReferenceBinding binding);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceBinding.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceBinding.java
new file mode 100644
index 0000000000..82a2105a36
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ReferenceBinding.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * Manages an SCA reference configured with a binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ReferenceBinding extends SCAObject {
+
+ /**
+ * Returns the binding qualified name
+ *
+ * @return the binding qualified name
+ */
+ QName getBindingType();
+
+ /**
+ * Sets the parent reference for the binding
+ *
+ * @param reference the parent reference for the binding
+ */
+ void setReference(Reference reference);
+
+ /**
+ * Returns the inbound wire for flowing a request through the reference
+ */
+ InboundWire getInboundWire();
+
+ /**
+ * Sets the inbound wire for flowing a request through the reference
+ */
+ void setInboundWire(InboundWire wire);
+
+ /**
+ * Returns the outbound wire used by the reference to connect to a target
+ */
+ OutboundWire getOutboundWire();
+
+ /**
+ * Sets the outbound wire used by the reference to connect to a target
+ */
+ void setOutboundWire(OutboundWire wire);
+
+ /**
+ * Callback to create a {@link org.apache.tuscany.spi.wire.TargetInvoker} which dispatches to the target service of
+ * the reference
+ *
+ * @param contract the service contract to invoke on
+ * @param operation the operation to invoke
+ * @throws TargetInvokerCreationException
+ */
+ TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation)
+ throws TargetInvokerCreationException;
+
+ /**
+ * Returns the service contract for the binding
+ *
+ * @return the service contract for the binding
+ */
+ ServiceContract> getBindingServiceContract();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAExternalizable.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAExternalizable.java
new file mode 100644
index 0000000000..6454e66369
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAExternalizable.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.spi.component;
+
+/**
+ * A serialization contract for runtime SCA artifacts. When an instance is deserialized, runtime services defined in
+ * this contract must be set before reactivating the instance
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SCAExternalizable {
+
+ /**
+ * Sets the current work context
+ *
+ * @param context the current work context
+ */
+ void setWorkContext(WorkContext context);
+
+ /**
+ * Callback after all values have been set prior to making the instance available in the runtime
+ *
+ * @throws org.apache.tuscany.spi.component.ReactivationException
+ *
+ */
+ void reactivate() throws ReactivationException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java
new file mode 100644
index 0000000000..668eb1f90a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObject.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.Lifecycle;
+import org.apache.tuscany.spi.event.EventPublisher;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * Represents the base SCA artifact type in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SCAObject extends EventPublisher, Lifecycle {
+
+ /**
+ * Returns the artifact name
+ */
+ String getName();
+
+ /**
+ * Returns the canonical artifact name
+ */
+ String getCanonicalName();
+
+ /**
+ * Returns the parent composite, or null if the artifact does not have one
+ */
+ CompositeComponent getParent();
+
+ /**
+ * Returns the artifact scope
+ */
+ Scope getScope();
+
+ /**
+ * Returns true if the artifact is a system artifact
+ *
+ * @return true if the artifact is a system artifact
+ */
+ boolean isSystem();
+
+ /**
+ * The extensions map contains other runtime context such as type systems for various databindings
+ *
+ * @return A live map of extended context
+ */
+ Map getExtensions();
+
+ /**
+ * Called to signal that the composite should perform any initizalization
+ */
+ void prepare() throws PrepareException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStartException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStartException.java
new file mode 100644
index 0000000000..a712b1b0eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStartException.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.spi.component;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * Denotes an error starting an SCAObject
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAObjectStartException extends CoreRuntimeException {
+
+ public SCAObjectStartException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStopException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStopException.java
new file mode 100644
index 0000000000..9f430bc414
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/SCAObjectStopException.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.spi.component;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+
+/**
+ * Denotes an error stopping an SCAObject
+ *
+ * @version $Rev$ $Date$
+ */
+public class SCAObjectStopException extends CoreRuntimeException {
+
+ public SCAObjectStopException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.java
new file mode 100644
index 0000000000..8b67dfa696
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainer.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.spi.component;
+
+import org.apache.tuscany.spi.Lifecycle;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.model.Scope;
+
+
+/**
+ * Manages the lifecycle and visibility of instances associated with a an {@link AtomicComponent}.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ScopeContainer extends Lifecycle, RuntimeEventListener {
+
+ /**
+ * Returns the scope value representing the scope context
+ */
+ Scope getScope();
+
+ /**
+ * Registers a component with the scope component
+ */
+ void register(AtomicComponent component);
+
+ /**
+ * Returns an implementation instance associated with the current request context, creating one if necessary
+ *
+ * @throws TargetResolutionException
+ */
+ Object getInstance(AtomicComponent component) throws TargetResolutionException;
+
+ /**
+ * Returns an implementation instance associated with the current context. If no instance is found, a {@link
+ * TargetNotFoundException} is thrown
+ *
+ * @throws TargetResolutionException
+ */
+ Object getAssociatedInstance(AtomicComponent component) throws TargetResolutionException;
+
+ /**
+ * Persists a new component implementation instance, equivalent to an insert or append operation
+ *
+ * @param component the owning component
+ * @param id the id associated with the instance
+ * @param instance the instance to persist
+ * @param expiration the expiration in milliseconds
+ * @throws PersistenceException
+ */
+ void persistNew(AtomicComponent component, String id, Object instance, long expiration) throws PersistenceException;
+
+ /**
+ * Persists a component implementation instance, equivalent to an update operation
+ *
+ * @param component the owning component
+ * @param id the id associated with the instance
+ * @param instance the instance to persist
+ * @param expiration the expiration in milliseconds
+ * @throws PersistenceException
+ */
+ void persist(AtomicComponent component, String id, Object instance, long expiration) throws PersistenceException;
+
+ /**
+ * Removes a component implementation instance associated with the current context from persistent storage
+ *
+ * @param component the owning component
+ * @throws PersistenceException
+ */
+ void remove(AtomicComponent component) throws PersistenceException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainerMonitor.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainerMonitor.java
new file mode 100644
index 0000000000..3e7649d59e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeContainerMonitor.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.spi.component;
+
+import org.apache.tuscany.api.annotation.LogLevel;
+
+/**
+ * Defines monitor events for scope containers
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ScopeContainerMonitor {
+
+ @LogLevel("SEVERE")
+ void eagerInitializationError(Exception e);
+
+ @LogLevel("SEVERE")
+ void destructionError(TargetDestructionException e);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.java
new file mode 100644
index 0000000000..181b094403
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ScopeRegistry.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.spi.component;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * Manages {@link ScopeContainer}s in the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface ScopeRegistry {
+
+ /**
+ * Returns the scope container for the given scope or null if one not found
+ *
+ * @param scope the scope
+ * @return the scope container for the given scope or null if one not found
+ */
+ ScopeContainer getScopeContainer(Scope scope);
+
+ void registerFactory(Scope scope, ObjectFactory factory);
+
+ void deregisterFactory(Scope scope);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.java
new file mode 100644
index 0000000000..714a0a4313
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/Service.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.spi.component;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * The runtime instantiation of an SCA service
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Service extends SCAObject {
+
+ /**
+ * Returns the contract for the service.
+ *
+ * @return the contract for the service.
+ */
+ ServiceContract> getServiceContract();
+
+ /**
+ * Returns the collection of bindings configured for the service.
+ *
+ * @return the collection of bindings configured for the service.
+ */
+ List getServiceBindings();
+
+ /**
+ * Adds a binding the service is exposed over.
+ *
+ * @param binding the binding the service is exposed over.
+ */
+ void addServiceBinding(ServiceBinding binding);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ServiceBinding.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ServiceBinding.java
new file mode 100644
index 0000000000..3912c3bb60
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/ServiceBinding.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * The runtime instantiation of an SCA service binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ServiceBinding extends SCAObject {
+
+ /**
+ * Returns the binding qualified name
+ *
+ * @return the binding qualified name
+ */
+ QName getBindingType();
+
+ /**
+ * Sets the parent service for the binding
+ *
+ * @param service the parent service for the binding
+ */
+ void setService(Service service);
+
+ /**
+ * Get the ServiceContract for the binding
+ *
+ * @return the ServiceContract for the binding
+ */
+ ServiceContract> getBindingServiceContract();
+
+ /**
+ * Returns the inbound wire for flowing a request through the service
+ *
+ * @return the inbound wire for flowing a request through the service
+ */
+ InboundWire getInboundWire();
+
+ /**
+ * Sets the inbound wire for flowing a request through the service
+ *
+ * @param wire the inbound wire for flowing a request through the service
+ */
+ void setInboundWire(InboundWire wire);
+
+ /**
+ * Returns the outbound wire for flowing a request out of the service
+ *
+ * @return the outbound wire for flowing a request out of the service
+ */
+ OutboundWire getOutboundWire();
+
+ /**
+ * Sets the outbound wire for flowing a request out of the service
+ *
+ * @param wire the outbound wire for flowing a request out of the service
+ */
+ void setOutboundWire(OutboundWire wire);
+
+ /**
+ * Returns the target invoker for dispatching callback invocations
+ *
+ * @param contract the callback contract
+ * @param operation the callback operation the target invoker dispatches to
+ * @throws TargetInvokerCreationException
+ */
+ TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation)
+ throws TargetInvokerCreationException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetDestructionException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetDestructionException.java
new file mode 100644
index 0000000000..5f521f9b0a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetDestructionException.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.spi.component;
+
+/**
+ * Denotes an error destroying a target
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetDestructionException extends TargetResolutionException {
+
+ public TargetDestructionException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public TargetDestructionException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+
+ public TargetDestructionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.java
new file mode 100644
index 0000000000..6b8278cf8b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetException.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.spi.component;
+
+/**
+ * Denotes an error while performing an operation on a target component implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class TargetException extends ComponentException {
+
+ public TargetException(String message) {
+ super(message);
+ }
+
+
+ public TargetException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public TargetException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+
+ public TargetException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public TargetException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInitializationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInitializationException.java
new file mode 100644
index 0000000000..eaea4c3bc9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInitializationException.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.spi.component;
+
+/**
+ * Denotes an error initializing a target
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetInitializationException extends TargetResolutionException {
+
+ public TargetInitializationException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public TargetInitializationException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public TargetInitializationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvocationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvocationException.java
new file mode 100644
index 0000000000..1fc2b24f5b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvocationException.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.spi.component;
+
+/**
+ * Raised when an error is encountered during a target invocation
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetInvocationException extends TargetException {
+
+ public TargetInvocationException(String message) {
+ super(message);
+ }
+
+ public TargetInvocationException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public TargetInvocationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetInvocationException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvokerCreationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvokerCreationException.java
new file mode 100644
index 0000000000..ac914401cf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetInvokerCreationException.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.spi.component;
+
+/**
+ * Denotes an error creating a {@link org.apache.tuscany.spi.wire.TargetInvoker}
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class TargetInvokerCreationException extends ComponentException {
+
+ public TargetInvokerCreationException() {
+ }
+
+ public TargetInvokerCreationException(String message) {
+ super(message);
+ }
+
+ public TargetInvokerCreationException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public TargetInvokerCreationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetInvokerCreationException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public TargetInvokerCreationException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.java
new file mode 100644
index 0000000000..cd6996789c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetNotFoundException.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.spi.component;
+
+/**
+ * Thrown when a target of an operation cannot be found
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class TargetNotFoundException extends TargetResolutionException {
+
+ public TargetNotFoundException(String message) {
+ super(message);
+ }
+
+ public TargetNotFoundException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetResolutionException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetResolutionException.java
new file mode 100644
index 0000000000..858fa9415d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/TargetResolutionException.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.spi.component;
+
+/**
+ * Denotes an error retrieving a target instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class TargetResolutionException extends TargetException {
+
+ public TargetResolutionException(String message) {
+ super(message);
+ }
+
+ public TargetResolutionException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public TargetResolutionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TargetResolutionException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java
new file mode 100644
index 0000000000..3e244873c8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/WorkContext.java
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.component;
+
+import java.util.LinkedList;
+
+/**
+ * Implementations track information associated with a request as it is processed by the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WorkContext {
+
+ Object getCurrentCorrelationId();
+
+ void setCurrentCorrelationId(Object correlationId);
+
+ /**
+ * Returns the current atomic component as a request is processed or null if it is not being tracked. Note that the
+ * current atomic component is typically only tracked during persistence operations involving implementation
+ * instances
+ *
+ * @return the current atomic component as a request is processed or null
+ */
+ AtomicComponent getCurrentAtomicComponent();
+
+ /**
+ * Sets the current atomic component that is handling processing of a request. Note that in most cases it will not
+ * be necessary to track this in the rumtime
+ *
+ * @param component the current atomic component
+ */
+ void setCurrentAtomicComponent(AtomicComponent component);
+
+ /**
+ * Returns the current chain of SCAObject addresses
+ */
+ LinkedList getCurrentCallbackRoutingChain();
+
+ /**
+ * Sets the current stack of SCAObject addresses
+ */
+ void setCurrentCallbackRoutingChain(LinkedList callbackRoutingChain);
+
+ /**
+ * Returns the composite where a remote request came in
+ */
+ CompositeComponent getRemoteComponent();
+
+ /**
+ * Sets the composite where a remote request came in
+ */
+ void setRemoteComponent(CompositeComponent component);
+
+ /**
+ * Returns the unique key for the given identifier associated with the current request
+ */
+ Object getIdentifier(Object type);
+
+ /**
+ * Sets the unique key for the given identifier associated with the current request
+ */
+ void setIdentifier(Object type, Object identifier);
+
+ /**
+ * Clears the unique key for the given identifier associated with the current request
+ */
+ void clearIdentifier(Object type);
+
+ /**
+ * Clears all identifiers associated with the current request
+ */
+ void clearIdentifiers();
+
+ /**
+ * Removes and returns the name of the last remotable service to handle the current request
+ *
+ * @return the name of the last remotable service to handle the current request or null
+ */
+ String popServiceName();
+
+ /**
+ * Returns the name of the last remotable service to handle the current request
+ *
+ * @return the name of the last remotable service to handle the current request or null
+ */
+ String getCurrentServiceName();
+
+ /**
+ * Adds the name of the last remotable service to handle the current request
+ *
+ * @param name the name of the last remotable service to handle the current request or null
+ */
+ void pushServiceName(String name);
+
+ /**
+ * Clears the stack of current service names
+ */
+ void clearServiceNames();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.java
new file mode 100644
index 0000000000..6916c62f51
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBinding.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.spi.databinding;
+
+import java.lang.annotation.Annotation;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * DataBinding represents a data representation, for example, SDO, JAXB and AXIOM
+ */
+public interface DataBinding {
+ /**
+ * A special databinding for input message of an operation
+ */
+ String IDL_INPUT = "idl:input";
+ /**
+ * A special databinding for output message of an operation
+ */
+ String IDL_OUTPUT = "idl:output";
+ /**
+ * A special databinding for fault message of an operation
+ */
+ String IDL_FAULT = "idl:fault";
+ /**
+ * The name of a databinding should be case-insensitive and unique
+ *
+ * @return The name of the databinding
+ */
+ String getName();
+
+ /**
+ * Get the aliases for the databinding
+ *
+ * @return An array of aliases
+ */
+ String[] getAliases();
+
+ /**
+ * Introspect and populate information to a DataType model
+ *
+ * @param javaType The java class or interface to be introspected
+ * @param annotations The java annotations
+ * @return true if the databinding has recognized the given data type
+ */
+ boolean introspect(DataType dataType, Annotation[] annotations);
+
+ /**
+ * Introspect the data to figure out the corresponding data type
+ *
+ * @param value The object to be checked
+ * @return The DataType or null if the java type is not supported by this databinding
+ */
+ DataType introspect(Object value);
+
+ /**
+ * Provide a WrapperHandler for this databinding
+ * @return A wrapper handler which can handle wrapping/wrapping for this databinding
+ */
+ WrapperHandler getWrapperHandler();
+
+ /**
+ * Make a copy of the object for "pass-by-value" semantics
+ * @param source object to copy
+ * @return copy of the object passed in as argument
+ */
+ Object copy(Object object);
+
+ /**
+ * Get the type mapper for simple types
+ * @return The databinding-specific simple type mapper
+ */
+ SimpleTypeMapper getSimpleTypeMapper();
+
+ /**
+ * Get the handler that can handle exceptions/faults in the
+ * databinding-specific way
+ *
+ * @return An instance of the exception handler
+ */
+ ExceptionHandler getExceptionHandler();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java
new file mode 100644
index 0000000000..09f0347777
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataBindingRegistry.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+import java.lang.annotation.Annotation;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * The registry for data bindings
+ */
+public interface DataBindingRegistry {
+ /**
+ * Register a data binding
+ *
+ * @param dataBinding
+ */
+ void register(DataBinding dataBinding);
+
+ /**
+ * Look up a data binding by id
+ *
+ * @param id The name of the databinding
+ * @return The databinding
+ */
+ DataBinding getDataBinding(String id);
+
+ /**
+ * Unregister a data binding
+ *
+ * @param id
+ * @return The unregistered databinding
+ */
+ DataBinding unregister(String id);
+
+ /**
+ * Introspect the java class to figure out what DataType supports it
+ *
+ * @param DataType The initial data type
+ * @param annotations The java annotations
+ * @return A DataType representing the java type or null if no databinding
+ * recognizes the java type
+ */
+ boolean introspectType(DataType dataType, Annotation[] annotations);
+
+ /**
+ * Introspect the value to figure out the corresponding DataType
+ *
+ * @param value The object value
+ * @return A DataType representing the value or null if no databinding
+ * recognizes the value
+ */
+ DataType introspectType(Object value);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.java
new file mode 100755
index 0000000000..a0eb7ac10d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/DataPipe.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.spi.databinding;
+
+/**
+ * Data pipe allows a data source pushes data into its sink and pipe the data into its result
+ *
+ * @param The data binding type of the sink
+ * @param The data binding type of the result
+ */
+public interface DataPipe extends Transformer {
+
+ /**
+ * Returns a sink (for example, java.io.OutputStream, java.io.Writer or org.xml.sax.ContentHandler) to receive data
+ * pushed by the source
+ *
+ * @return The sink to consume data
+ */
+ S getSink();
+
+ /**
+ * Returns the data populated by the sink
+ *
+ * @return
+ */
+ R getResult();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.java
new file mode 100644
index 0000000000..5599ae00de
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/ExceptionHandler.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.spi.databinding;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * ExceptionHandler provides databinding-specific logic for exception handling
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ExceptionHandler {
+ /**
+ * Create an exception to wrap the fault data
+ *
+ * @param exceptionType The DataType for the exception
+ * @param message The error message
+ * @param faultInfo The databinding-specific fault data
+ * @param cause The protocol-specific error
+ * @return An instance of java exception to represent the fault
+ */
+ Exception createException(DataType exceptionType, String message, Object faultInfo, Throwable cause);
+
+ /**
+ * Retrieve the fault info from a java exception
+ *
+ * @param exception The databinding-specific java exception that represents
+ * the fault data
+ * @return The databinding-specific fault data
+ */
+ Object getFaultInfo(Exception exception);
+
+ /**
+ * Introspect an exception class to figure out the fault data type
+ *
+ * @param exceptionDataType The exception class
+ * @return The data type for the fault
+ */
+ DataType> getFaultType(DataType exceptionDataType);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java
new file mode 100755
index 0000000000..53b8e8d95f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Mediator.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * This interface will be used as a Tuscany system service to perform data mediations
+ *
+ * Mediate the data from one type to the other one
+ *
+ */
+public interface Mediator {
+
+ /**
+ * Mediate the data from the source type to the target type
+ * @param source The data to be mediated
+ * @param sourceDataType Data type for the source data
+ * @param targetDataType Data type for the target data
+ * @param context
+ * @return
+ */
+ Object mediate(Object source, DataType sourceDataType, DataType targetDataType, Map, Object> context);
+ /**
+ * Mediate the source data into the target which is a sink to receive the data
+ * @param source The data to be mediated
+ * @param target The sink to receive data
+ * @param sourceDataType Data type for the source data
+ * @param targetDataType Data type for the target data
+ */
+ void mediate(
+ Object source,
+ Object target,
+ DataType sourceDataType,
+ DataType targetDataType,
+ Map, Object> context);
+
+ /**
+ * Get the DataBinding registry
+ * @return
+ */
+ DataBindingRegistry getDataBindingRegistry();
+
+ /**
+ * Get the Transformer registry
+ * @return
+ */
+ TransformerRegistry getTransformerRegistry();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.java
new file mode 100644
index 0000000000..21e8cc2750
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PullTransformer.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.spi.databinding;
+
+/**
+ * PullTransformer transforms data from one binding format to the other one which can be directly consumed
+ *
+ * @param The source data type
+ * @param the target data type
+ */
+public interface PullTransformer extends Transformer {
+ /**
+ * Transform source data into the result type.
+ *
+ * @param source The source data
+ * @param context The context for the transformation
+ * @return The transformed result
+ */
+ R transform(S source, TransformationContext context);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.java
new file mode 100644
index 0000000000..d68b6aa772
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/PushTransformer.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.spi.databinding;
+
+/**
+ * A transformer that pushes data from its source into the sink
+ *
+ * @param
+ * @param
+ */
+public interface PushTransformer extends Transformer {
+ /**
+ * @param source The source data
+ * @param sink The sink to receive the data
+ * @param context
+ */
+ void transform(S source, R sink, TransformationContext context);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.java
new file mode 100644
index 0000000000..634d489c11
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/SimpleTypeMapper.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.spi.databinding;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Type Mapper between XML schema simple data types and java objects
+ */
+public interface SimpleTypeMapper {
+ /**
+ * Parse the XML lexical representation into a java object
+ * @param simpleType The XSD simple type
+ * @param value the XML lexical representation
+ * @param context The context of the transformation
+ * @return A java object for the XML value
+ */
+ Object toJavaObject(QName simpleType, String value, TransformationContext context);
+ /**
+ * Create the XML lexical representation for a java object
+ * @param simpleType The XSD simple type
+ * @param obj The java object
+ * @param context The context of the transformation
+ * @return The XML lexical representation
+ */
+ String toXMLLiteral(QName simpleType, Object obj, TransformationContext context);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.java
new file mode 100755
index 0000000000..8287de1707
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationContext.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.spi.databinding;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.DataType;
+
+/**
+ * Context for data transformation
+ *
+ */
+public interface TransformationContext {
+ /**
+ * Get the source data type
+ *
+ * @return
+ */
+ DataType getSourceDataType();
+
+ /**
+ * Get the target data type
+ *
+ * @return
+ */
+ DataType getTargetDataType();
+
+ /**
+ * Set the source data type
+ *
+ * @param sourceDataType
+ */
+ void setSourceDataType(DataType sourceDataType);
+
+ /**
+ * Set the target data type
+ *
+ * @param targetDataType
+ */
+ void setTargetDataType(DataType targetDataType);
+
+ /**
+ * Get the classloader
+ *
+ * @return
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ * Get a map of metadata
+ *
+ * @return
+ */
+ Map, Object> getMetadata();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.java
new file mode 100755
index 0000000000..9b57e1cf70
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformationException.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.spi.databinding;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * Reports problems during data transformation
+ */
+public class TransformationException extends TuscanyRuntimeException {
+
+ private static final long serialVersionUID = 7662385613693006428L;
+
+ public TransformationException() {
+ super();
+ }
+
+ public TransformationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TransformationException(String message) {
+ super(message);
+ }
+
+ public TransformationException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.java
new file mode 100755
index 0000000000..2f969e979d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/Transformer.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.spi.databinding;
+
+/**
+ * A transformer provides the data transformation from source type to target type. The cost of the transformation is
+ * modeled as weight.
+ */
+public interface Transformer {
+ /**
+ * Get the source type that this transformer transforms data from. The type is used as the key when the transformer
+ * is registered with TransformerRegistry.
+ *
+ * @return A key indentifying the source type
+ */
+ String getSourceDataBinding();
+
+ /**
+ * Get the target type that this transformer transforms data into. The type is used as the key when the transformer
+ * is registered with TransformerRegistry.
+ *
+ * @return A key indentifying the target type
+ */
+ String getTargetDataBinding();
+
+ /**
+ * Get the cost of the transformation. The weight can be used to choose the most efficient path if there are more
+ * than one available from the source to the target.
+ *
+ * @return An integer representing the cost of the transformation
+ */
+ int getWeight();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java
new file mode 100755
index 0000000000..5381dfa081
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/TransformerRegistry.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding;
+
+import java.util.List;
+
+/**
+ * Registry for data transformers
+ */
+public interface TransformerRegistry {
+ /**
+ * Register a transformer
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @param weight
+ * @param transformer
+ */
+ void registerTransformer(String sourceDataBinding,
+ String targetDataBinding,
+ int weight,
+ Transformer transformer);
+
+ /**
+ * Register a transformer
+ *
+ * @param transformer
+ */
+ void registerTransformer(Transformer transformer);
+
+ /**
+ * Unregister a transformer
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @return
+ */
+ boolean unregisterTransformer(String sourceDataBinding, String targetDataBinding);
+
+ /**
+ * Get the direct Transformer which can transform data from source type to
+ * result type
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @return
+ */
+ Transformer getTransformer(String sourceDataBinding, String targetDataBinding);
+
+ /**
+ * Get the a chain of Transformers which can transform data from source type
+ * to result type
+ *
+ * @param sourceDataBinding
+ * @param targetDataBinding
+ * @return
+ */
+ List getTransformerChain(String sourceDataBinding, String targetDataBinding);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.java
new file mode 100644
index 0000000000..9643ca280a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/WrapperHandler.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.spi.databinding;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.idl.ElementInfo;
+
+/**
+ * A contract for transformers to deal with wrapping/unwrapping for WSDL wrapper style operations
+ */
+public interface WrapperHandler {
+ /**
+ * Create a wrapper element
+ *
+ * @param element The XSD element
+ * @param context The transformation context
+ * @return An object representing the wrapper element
+ */
+ T create(ElementInfo element, TransformationContext context);
+
+ /**
+ * Set child element for the wrapper
+ *
+ * @param wrapper The wrapper
+ * @param i The index
+ * @param childElement The XSD element
+ * @param value The value of the child
+ */
+ void setChild(T wrapper, int i, ElementInfo childElement, Object value);
+
+ /**
+ * Get a list of child elements from the wrapper
+ * @param wrapper
+ * @return child elements under the wrapper
+ */
+ List getChildren(T wrapper);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.java
new file mode 100644
index 0000000000..2b927b8e55
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DOMHelper.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.spi.databinding.extension;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Helper for DOM
+ */
+public final class DOMHelper {
+ private static final DocumentBuilderFactory FACTORY = DocumentBuilderFactory.newInstance();
+ static {
+ FACTORY.setNamespaceAware(true);
+ }
+
+ private DOMHelper() {
+ }
+
+ public static Document newDocument() throws ParserConfigurationException {
+ return newDocumentBuilder().newDocument();
+ }
+
+ public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
+ return FACTORY.newDocumentBuilder();
+ }
+
+ public static QName getQName(Node node) {
+ String ns = node.getNamespaceURI();
+ if (ns == null) {
+ ns = "";
+ }
+ // node.getLocalName() will return null if it is created using DOM Level
+ // 1 method
+ // such as createElement()
+ return new QName(ns, node.getNodeName());
+ }
+
+ public static Element createElement(Document document, QName name) {
+ String prefix = name.getPrefix();
+ String qname =
+ (prefix != null && prefix.length() > 0) ? prefix + ":" + name.getLocalPart() : name
+ .getLocalPart();
+ return document.createElementNS(name.getNamespaceURI(), qname);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java
new file mode 100644
index 0000000000..1598637d4e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtension.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding.extension;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.databinding.ExceptionHandler;
+import org.apache.tuscany.spi.databinding.SimpleTypeMapper;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Base Implementation of DataBinding
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(DataBinding.class)
+@Scope("COMPOSITE")
+@EagerInit
+public abstract class DataBindingExtension implements DataBinding {
+
+ protected DataBindingRegistry registry;
+
+ protected Class> baseType;
+
+ protected String name;
+ protected String[] aliases;
+
+ /**
+ * Create a databinding with the base java type whose name will be used as
+ * the name of the databinding
+ *
+ * @param baseType The base java class or interface representing the
+ * databinding, for example, org.w3c.dom.Node
+ */
+ protected DataBindingExtension(Class> baseType) {
+ this(baseType.getName(), null, baseType);
+ }
+
+ /**
+ * Create a databinding with the name and base java type
+ *
+ * @param name The name of the databinding
+ * @param baseType The base java class or interface representing the
+ * databinding, for example, org.w3c.dom.Node
+ */
+ protected DataBindingExtension(String name, Class> baseType) {
+ this(name, null, baseType);
+ }
+
+ /**
+ * Create a databinding with the name and base java type
+ *
+ * @param name The name of the databinding
+ * @param aliases The aliases of the databinding
+ * @param baseType The base java class or interface representing the
+ * databinding, for example, org.w3c.dom.Node
+ */
+ protected DataBindingExtension(String name, String[] aliases, Class> baseType) {
+ this.name = name;
+ this.baseType = baseType;
+ this.aliases = aliases;
+ }
+
+ @Autowire
+ public void setDataBindingRegistry(DataBindingRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init
+ public void init() {
+ registry.register(this);
+ }
+
+ public boolean introspect(DataType type, Annotation[] annotations) {
+ assert type != null;
+ Type physical = type.getPhysical();
+ if (physical instanceof ParameterizedType) {
+ physical = ((ParameterizedType)physical).getRawType();
+ }
+ if (physical instanceof Class) {
+ Class cls = (Class)physical;
+ if (baseType != null && baseType.isAssignableFrom(cls)) {
+ type.setDataBinding(getName());
+ type.setLogical(baseType);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected static org.apache.tuscany.api.annotation.DataType getDataTypeAnnotation(Annotation[] annotations) {
+ for (Annotation a : annotations) {
+ if (a.annotationType() == org.apache.tuscany.api.annotation.DataType.class) {
+ return (org.apache.tuscany.api.annotation.DataType) a;
+ }
+ }
+ return null;
+ }
+
+ public DataType introspect(Object value) {
+ if (value == null) {
+ return null;
+ } else {
+ DataType dataType = new DataType(value.getClass(), value.getClass());
+ if (introspect(dataType, null)) {
+ return dataType;
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+ /**
+ * @see org.apache.tuscany.spi.databinding.DataBinding#getWrapperHandler()
+ */
+ public WrapperHandler getWrapperHandler() {
+ return null;
+ }
+
+ public ExceptionHandler getExceptionHandler() {
+ return null;
+ }
+
+ public Object copy(Object object) {
+ return object;
+ }
+
+ public SimpleTypeMapper getSimpleTypeMapper() {
+ return new SimpleTypeMapperExtension();
+ }
+
+ public String[] getAliases() {
+ return aliases;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.java
new file mode 100644
index 0000000000..14a4d8f66a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/Java2SimpleTypeTransformer.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.spi.databinding.extension;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.SimpleTypeMapper;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.idl.XMLType;
+
+/**
+ * Transformer to convert data from a simple java object to a databinding's representation
+ */
+public abstract class Java2SimpleTypeTransformer extends TransformerExtension implements
+ PullTransformer {
+
+ protected SimpleTypeMapper mapper;
+
+ public Java2SimpleTypeTransformer() {
+ this.mapper = new SimpleTypeMapperExtension();
+ }
+
+ public Java2SimpleTypeTransformer(SimpleTypeMapper mapper) {
+ this.mapper = (mapper != null) ? mapper : new SimpleTypeMapperExtension();
+ }
+
+ public T transform(Object source, TransformationContext context) {
+ XMLType xmlType = (XMLType) context.getTargetDataType().getLogical();
+ String text = mapper.toXMLLiteral(xmlType.getTypeName(), source, context);
+ return createElement(xmlType.getElementName(), text, context);
+ }
+
+ public Class getSourceType() {
+ return Object.class;
+ }
+
+ public int getWeight() {
+ return 10000;
+ }
+
+ protected abstract T createElement(QName element, String literal, TransformationContext context);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.java
new file mode 100644
index 0000000000..28b02f596a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleType2JavaTransformer.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.spi.databinding.extension;
+
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.SimpleTypeMapper;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.idl.XMLType;
+
+/**
+ * Transformer to convert data from a databinding's representation of simple
+ * types to Java Objects
+ */
+public abstract class SimpleType2JavaTransformer extends TransformerExtension implements
+ PullTransformer {
+
+ protected SimpleTypeMapper mapper;
+
+ public SimpleType2JavaTransformer() {
+ this.mapper = new SimpleTypeMapperExtension();
+ }
+
+ public SimpleType2JavaTransformer(SimpleTypeMapper mapper) {
+ this.mapper = (mapper != null) ? mapper : new SimpleTypeMapperExtension();
+ }
+
+ public Object transform(T source, TransformationContext context) {
+ XMLType xmlType = (XMLType) context.getSourceDataType().getLogical();
+ return mapper.toJavaObject(xmlType.getTypeName(), getText(source), context);
+ }
+
+ public Class getTargetType() {
+ return Object.class;
+ }
+
+ public int getWeight() {
+ // Cannot be used for imtermediate
+ return 10000;
+ }
+
+ /**
+ * Get the string value from the source
+ * @param source
+ * @return A string
+ */
+ protected abstract String getText(T source);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java
new file mode 100644
index 0000000000..e4671f621c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtension.java
@@ -0,0 +1,392 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding.extension;
+
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.databinding.SimpleTypeMapper;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.idl.TypeInfo;
+
+public class SimpleTypeMapperExtension extends XSDDataTypeConverter implements SimpleTypeMapper {
+
+ public static final Map JAVA2XML = new HashMap();
+
+ public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema";
+
+ public static final Map XML2JAVA = new HashMap();
+
+ public static final QName XSD_ANY = new QName(URI_2001_SCHEMA_XSD, "any");
+
+ public static final QName XSD_ANYSIMPLETYPE = new QName(URI_2001_SCHEMA_XSD, "anySimpleType");
+
+ public static final QName XSD_ANYTYPE = new QName(URI_2001_SCHEMA_XSD, "anyType");
+
+ public static final QName XSD_ANYURI = new QName(URI_2001_SCHEMA_XSD, "anyURI");
+
+ public static final QName XSD_BASE64 = new QName(URI_2001_SCHEMA_XSD, "base64Binary");
+
+ public static final QName XSD_BOOLEAN = new QName(URI_2001_SCHEMA_XSD, "boolean");
+
+ public static final QName XSD_BYTE = new QName(URI_2001_SCHEMA_XSD, "byte");
+
+ public static final QName XSD_DATE = new QName(URI_2001_SCHEMA_XSD, "date");
+
+ public static final QName XSD_DATETIME = new QName(URI_2001_SCHEMA_XSD, "dateTime");
+
+ public static final QName XSD_DAY = new QName(URI_2001_SCHEMA_XSD, "gDay");
+
+ public static final QName XSD_DECIMAL = new QName(URI_2001_SCHEMA_XSD, "decimal");
+
+ public static final QName XSD_DOUBLE = new QName(URI_2001_SCHEMA_XSD, "double");
+
+ public static final QName XSD_DURATION = new QName(URI_2001_SCHEMA_XSD, "duration");
+
+ public static final QName XSD_ENTITIES = new QName(URI_2001_SCHEMA_XSD, "ENTITIES");
+
+ public static final QName XSD_ENTITY = new QName(URI_2001_SCHEMA_XSD, "ENTITY");
+
+ public static final QName XSD_FLOAT = new QName(URI_2001_SCHEMA_XSD, "float");
+
+ public static final QName XSD_HEXBIN = new QName(URI_2001_SCHEMA_XSD, "hexBinary");
+
+ public static final QName XSD_IDREF = new QName(URI_2001_SCHEMA_XSD, "IDREF");
+
+ public static final QName XSD_IDREFS = new QName(URI_2001_SCHEMA_XSD, "IDREFS");
+
+ public static final QName XSD_INT = new QName(URI_2001_SCHEMA_XSD, "int");
+
+ public static final QName XSD_INTEGER = new QName(URI_2001_SCHEMA_XSD, "integer");
+
+ public static final QName XSD_LONG = new QName(URI_2001_SCHEMA_XSD, "long");
+
+ public static final QName XSD_MONTH = new QName(URI_2001_SCHEMA_XSD, "gMonth");
+
+ public static final QName XSD_MONTHDAY = new QName(URI_2001_SCHEMA_XSD, "gMonthDay");
+
+ public static final QName XSD_NAME = new QName(URI_2001_SCHEMA_XSD, "Name");
+
+ public static final QName XSD_NCNAME = new QName(URI_2001_SCHEMA_XSD, "NCName");
+
+ public static final QName XSD_NEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "negativeInteger");
+
+ public static final QName XSD_NMTOKEN = new QName(URI_2001_SCHEMA_XSD, "NMTOKEN");
+
+ public static final QName XSD_NMTOKENS = new QName(URI_2001_SCHEMA_XSD, "NMTOKENS");
+
+ public static final QName XSD_NONNEGATIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonNegativeInteger");
+
+ public static final QName XSD_NONPOSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "nonPositiveInteger");
+
+ public static final QName XSD_NORMALIZEDSTRING = new QName(URI_2001_SCHEMA_XSD, "normalizedString");
+
+ public static final QName XSD_NOTATION = new QName(URI_2001_SCHEMA_XSD, "NOTATION");
+
+ public static final QName XSD_POSITIVEINTEGER = new QName(URI_2001_SCHEMA_XSD, "positiveInteger");
+
+ public static final QName XSD_QNAME = new QName(URI_2001_SCHEMA_XSD, "QName");
+
+ public static final QName XSD_SHORT = new QName(URI_2001_SCHEMA_XSD, "short");
+
+ public static final Map XSD_SIMPLE_TYPES = new HashMap();
+
+ public static final QName XSD_STRING = new QName(URI_2001_SCHEMA_XSD, "string");
+
+ public static final QName XSD_TIME = new QName(URI_2001_SCHEMA_XSD, "time");
+
+ public static final QName XSD_TOKEN = new QName(URI_2001_SCHEMA_XSD, "token");
+
+ public static final QName XSD_UNSIGNEDBYTE = new QName(URI_2001_SCHEMA_XSD, "unsignedByte");
+
+ public static final QName XSD_UNSIGNEDINT = new QName(URI_2001_SCHEMA_XSD, "unsignedInt");
+
+ public static final QName XSD_UNSIGNEDLONG = new QName(URI_2001_SCHEMA_XSD, "unsignedLong");
+
+ public static final QName XSD_UNSIGNEDSHORT = new QName(URI_2001_SCHEMA_XSD, "unsignedShort");
+
+ public static final QName XSD_YEAR = new QName(URI_2001_SCHEMA_XSD, "gYear");
+
+ public static final QName XSD_YEARMONTH = new QName(URI_2001_SCHEMA_XSD, "gYearMonth");
+
+ private static final String[] XSD_TYPE_NAMES =
+ {"string", "boolean", "double", "float", "int", "integer", "long", "short", "byte", "decimal", "base64Binary",
+ "hexBinary", "anySimpleType", "anyType", "any", "QName", "dateTime", "date", "time", "normalizedString",
+ "token", "unsignedLong", "unsignedInt", "unsignedShort", "unsignedByte", "positiveInteger", "negativeInteger",
+ "nonNegativeInteger", "nonPositiveInteger", "gYearMonth", "gMonthDay", "gYear", "gMonth", "gDay", "duration",
+ "Name", "NCName", "NMTOKEN", "NMTOKENS", "NOTATION", "ENTITY", "ENTITIES", "IDREF", "IDREFS", "anyURI",
+ "language", "ID"};
+
+ static {
+ for (String type : XSD_TYPE_NAMES) {
+ TypeInfo simpleType = new TypeInfo(new QName(URI_2001_SCHEMA_XSD, type), true, null);
+ XSD_SIMPLE_TYPES.put(type, simpleType);
+ }
+ }
+
+ static {
+ JAVA2XML.put(boolean.class, "boolean");
+ JAVA2XML.put(byte.class, "byte");
+ JAVA2XML.put(short.class, "short");
+ JAVA2XML.put(int.class, "int");
+ JAVA2XML.put(long.class, "long");
+ JAVA2XML.put(float.class, "float");
+ JAVA2XML.put(double.class, "double");
+ JAVA2XML.put(Boolean.class, "boolean");
+ JAVA2XML.put(Byte.class, "byte");
+ JAVA2XML.put(Short.class, "short");
+ JAVA2XML.put(Integer.class, "int");
+ JAVA2XML.put(Long.class, "long");
+ JAVA2XML.put(Float.class, "float");
+ JAVA2XML.put(Double.class, "double");
+ JAVA2XML.put(java.lang.String.class, "string");
+ JAVA2XML.put(java.math.BigInteger.class, "integer");
+ JAVA2XML.put(java.math.BigDecimal.class, "decimal");
+ JAVA2XML.put(java.util.Calendar.class, "dateTime");
+ JAVA2XML.put(java.util.Date.class, "dateTime");
+ JAVA2XML.put(javax.xml.namespace.QName.class, "QName");
+ JAVA2XML.put(java.net.URI.class, "string");
+ JAVA2XML.put(javax.xml.datatype.XMLGregorianCalendar.class, "anySimpleType");
+ JAVA2XML.put(javax.xml.datatype.Duration.class, "duration");
+ JAVA2XML.put(java.lang.Object.class, "anyType");
+ JAVA2XML.put(java.awt.Image.class, "base64Binary");
+ JAVA2XML.put(byte[].class, "base64Binary");
+ // java2XSD.put(javax.activation.DataHandler.class, "base64Binary");
+ JAVA2XML.put(javax.xml.transform.Source.class, "base64Binary");
+ JAVA2XML.put(java.util.UUID.class, "string");
+ }
+
+ static {
+ XML2JAVA.put("string", java.lang.String.class);
+ XML2JAVA.put("integer", java.math.BigInteger.class);
+ XML2JAVA.put("int", int.class);
+ XML2JAVA.put("long", long.class);
+ XML2JAVA.put("short", short.class);
+ XML2JAVA.put("decimal", java.math.BigDecimal.class);
+ XML2JAVA.put("float", float.class);
+ XML2JAVA.put("double", double.class);
+ XML2JAVA.put("boolean", boolean.class);
+ XML2JAVA.put("byte", byte.class);
+ XML2JAVA.put("QName", javax.xml.namespace.QName.class);
+ XML2JAVA.put("dateTime", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("base64Binary", byte[].class);
+ XML2JAVA.put("hexBinary", byte[].class);
+ XML2JAVA.put("unsignedInt", long.class);
+ XML2JAVA.put("unsignedShort", int.class);
+ XML2JAVA.put("unsignedByte", short.class);
+ XML2JAVA.put("time", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("date", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYear", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gYearMonth", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("gMonthDay", javax.xml.datatype.XMLGregorianCalendar.class);
+ XML2JAVA.put("anySimpleType", java.lang.Object.class); // For elements
+ // XML2JAVA.put("anySimpleType", java.lang.String.class); // For
+ // attributes
+ XML2JAVA.put("duration", javax.xml.datatype.Duration.class);
+ XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class);
+ }
+
+ private DatatypeFactory factory;
+
+ public SimpleTypeMapperExtension() {
+ super();
+ try {
+ this.factory = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public Class getJavaType(QName xmlType) {
+ if (URI_2001_SCHEMA_XSD.equals(xmlType.getNamespaceURI())) {
+ return XML2JAVA.get(xmlType.getLocalPart());
+ } else {
+ return null;
+ }
+ }
+
+ public TypeInfo getXMLType(Class javaType) {
+ return XSD_SIMPLE_TYPES.get(JAVA2XML.get(javaType));
+ }
+
+ public Object toJavaObject(QName simpleType, String literal, TransformationContext context) {
+ /**
+ *
+ * xsd:string --- java.lang.String
+ * xsd:integer --- java.math.BigInteger
+ * xsd:int --- int
+ * xsd:long --- long
+ * xsd:short --- short
+ * xsd:decimal --- java.math.BigDecimal
+ * xsd:float --- float
+ * xsd:double --- double
+ * xsd:boolean --- boolean
+ * xsd:byte --- byte
+ * xsd:QName --- javax.xml.namespace.QName
+ * xsd:dateTime --- javax.xml.datatype.XMLGregorianCalendar
+ * xsd:base64Binary --- byte[]
+ * xsd:hexBinary --- byte[]
+ * xsd:unsignedInt --- long
+ * xsd:unsignedShort --- int
+ * xsd:unsignedByte --- short
+ * xsd:time --- javax.xml.datatype.XMLGregorianCalendar
+ * xsd:date --- javax.xml.datatype.XMLGregorianCalendar
+ * xsd:g* --- javax.xml.datatype.XMLGregorianCalendar
+ * xsd:anySimpleType (for xsd:element of this type)a
+ * java.lang.Object
+ * xsd:anySimpleType (for xsd:attribute of this type)
+ * java.lang.String
+ * xsd:duration javax.xml.datatype.Duration
+ * xsd:NOTATION javax.xml.namespace.QName
+ *
+ */
+
+ if (literal == null) {
+ return null;
+ }
+ String value = literal.trim();
+
+ QName type = simpleType;
+ if (type.equals(XSD_STRING)) {
+ return parseString(value);
+ } else if (type.equals(XSD_INT)) {
+ return parseInt(value);
+ } else if (type.equals(XSD_INTEGER)) {
+ return parseInteger(value);
+ } else if (type.equals(XSD_INT)) {
+ return parseInt(value);
+ } else if (type.equals(XSD_FLOAT)) {
+ return parseFloat(value);
+ } else if (type.equals(XSD_DOUBLE)) {
+ return parseDouble(value);
+ } else if (type.equals(XSD_SHORT)) {
+ return parseShort(value);
+ } else if (type.equals(XSD_DECIMAL)) {
+ return parseDecimal(value);
+ } else if (type.equals(XSD_BOOLEAN)) {
+ return parseBoolean(value);
+ } else if (type.equals(XSD_BYTE)) {
+ return parseByte(value);
+ } else if (type.equals(XSD_LONG)) {
+ return parseLong(value);
+ } else if (type.equals(XSD_UNSIGNEDBYTE)) {
+ return parseUnsignedShort(value);
+ } else if (type.equals(XSD_UNSIGNEDSHORT)) {
+ return parseUnsignedShort(value);
+ } else if (type.equals(XSD_UNSIGNEDINT)) {
+ return parseUnsignedInt(value);
+ } else if (type.equals(XSD_UNSIGNEDLONG)) {
+ return parseUnsignedInt(value);
+ } else if (type.equals(XSD_DATETIME)) {
+ return parseDateTime(value);
+ } else if (type.equals(XSD_DATE)) {
+ return parseDate(value);
+ } else if (type.equals(XSD_TIME)) {
+ return parseTime(value);
+ } else if (type.equals(XSD_DURATION)) {
+ return parseDuration(value);
+ } else if (type.equals(XSD_HEXBIN)) {
+ return parseHexBinary(value);
+ } else if (type.equals(XSD_BASE64)) {
+ return parseBase64Binary(value);
+ } else if (type.equals(XSD_QNAME)) {
+ NamespaceContext namespaceContext =
+ (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class) : null);
+ return parseQName(value, namespaceContext);
+ } else if (type.equals(XSD_NOTATION)) {
+ NamespaceContext namespaceContext =
+ (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class) : null);
+ return parseQName(value, namespaceContext);
+ } else if (type.equals(XSD_YEAR)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_MONTH)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_DAY)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_YEARMONTH)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else if (type.equals(XSD_MONTHDAY)) {
+ return factory.newXMLGregorianCalendar(value);
+ } else {
+ return value;
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ private XMLGregorianCalendar toXMLGregorianCalendar(Date date) {
+ GregorianCalendar c =
+ new GregorianCalendar(date.getYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(),
+ date.getSeconds());
+ return factory.newXMLGregorianCalendar(c);
+ }
+
+ private XMLGregorianCalendar toXMLGregorianCalendar(GregorianCalendar calendar) {
+ return factory.newXMLGregorianCalendar(calendar);
+ }
+
+ public String toXMLLiteral(QName simpleType, Object obj, TransformationContext context) {
+ if (obj instanceof Float || obj instanceof Double) {
+ if (obj instanceof Float) {
+ return printDouble(((Float)obj).floatValue());
+ } else {
+ return printDouble(((Double)obj).doubleValue());
+ }
+ } else if (obj instanceof GregorianCalendar) {
+ GregorianCalendar calendar = (GregorianCalendar)obj;
+ return toXMLGregorianCalendar(calendar).toXMLFormat();
+ } else if (obj instanceof Date) {
+ return toXMLGregorianCalendar((Date)obj).toXMLFormat();
+ } else if (obj instanceof XMLGregorianCalendar) {
+ return ((XMLGregorianCalendar)obj).toXMLFormat();
+ } else if (obj instanceof byte[]) {
+ if (simpleType != null) {
+ if (simpleType.equals(XSD_BASE64)) {
+ return printBase64Binary((byte[])obj);
+ } else if (simpleType.equals(XSD_HEXBIN)) {
+ return printHexBinary((byte[])obj);
+ }
+ }
+ } else if (obj instanceof QName) {
+ NamespaceContext namespaceContext =
+ (NamespaceContext)((context != null) ? context.getMetadata().get(NamespaceContext.class) : null);
+ return printQName((QName)obj, namespaceContext);
+ }
+ return obj.toString();
+ }
+
+ public static boolean isSimpleXSDType(QName typeName) {
+ if (typeName == null) {
+ return false;
+ }
+ return typeName.getNamespaceURI().equals(URI_2001_SCHEMA_XSD)
+ && XSD_SIMPLE_TYPES.get(typeName.getLocalPart()) != null;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java
new file mode 100644
index 0000000000..d54dbca1d1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/TransformerExtension.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.databinding.extension;
+
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.TransformerRegistry;
+
+/**
+ * Base Implementation of Transformer which provides the registration to the transformer registry
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(Transformer.class)
+@Scope("COMPOSITE")
+@EagerInit
+public abstract class TransformerExtension implements Transformer {
+
+ protected TransformerRegistry registry;
+
+ protected TransformerExtension() {
+ super();
+ }
+
+ @Autowire
+ public void setTransformerRegistry(TransformerRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init
+ public void init() {
+ registry.registerTransformer(this);
+ }
+
+ protected abstract Class getSourceType();
+
+ protected abstract Class getTargetType();
+
+ public String getSourceDataBinding() {
+ return getSourceType().getName();
+ }
+
+ public String getTargetDataBinding() {
+ return getTargetType().getName();
+ }
+
+ public int getWeight() {
+ // default to 50
+ return 50;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java
new file mode 100644
index 0000000000..a0c75570bd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverter.java
@@ -0,0 +1,940 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.databinding.extension;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.FieldPosition;
+import java.text.Format;
+import java.text.ParsePosition;
+import java.util.Calendar;
+import java.util.TimeZone;
+import javax.xml.XMLConstants;
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+/**
+ * Utility class for XSD data type conversions
+ */
+public class XSDDataTypeConverter {
+ public static final class Base64Binary {
+ private static final char[] S_BASE64CHAR =
+ {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
+ 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
+ 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4',
+ '5', '6', '7', '8', '9', '+', '/'};
+
+ private static final char S_BASE64PAD = '=';
+
+ private static final byte[] S_DECODETABLE = new byte[128];
+
+ static {
+ for (int i = 0; i < S_DECODETABLE.length; i++) {
+ S_DECODETABLE[i] = Byte.MAX_VALUE; // 127
+ }
+ for (int i = 0; i < S_BASE64CHAR.length; i++) {
+ // 0 to 63
+ S_DECODETABLE[S_BASE64CHAR[i]] = (byte) i;
+ }
+ }
+
+ private Base64Binary() {
+ }
+
+ /**
+ *
+ */
+ public static byte[] decode(char[] data, int off, int len) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[len / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
+ }
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public static void decode(char[] data, int off, int len, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = off; i < off + len; i++) {
+ char ch = data[i];
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public static byte[] decode(String data) {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[data.length() / 4 * 3 + 3];
+ int obufcount = 0;
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ obufcount += decode0(ibuf, obuf, obufcount);
+ }
+ }
+ }
+ if (obufcount == obuf.length) {
+ return obuf;
+ }
+ byte[] ret = new byte[obufcount];
+ System.arraycopy(obuf, 0, ret, 0, obufcount);
+ return ret;
+ }
+
+ /**
+ *
+ */
+ public static void decode(String data, OutputStream ostream) throws IOException {
+ char[] ibuf = new char[4];
+ int ibufcount = 0;
+ byte[] obuf = new byte[3];
+ for (int i = 0; i < data.length(); i++) {
+ char ch = data.charAt(i);
+ if (ch == S_BASE64PAD || ch < S_DECODETABLE.length && S_DECODETABLE[ch] != Byte.MAX_VALUE) {
+ ibuf[ibufcount++] = ch;
+ if (ibufcount == ibuf.length) {
+ ibufcount = 0;
+ int obufcount = decode0(ibuf, obuf, 0);
+ ostream.write(obuf, 0, obufcount);
+ }
+ }
+ }
+ }
+
+ private static int decode0(char[] ibuf, byte[] obuf, int index) {
+ int wp = index;
+ int outlen = 3;
+ if (ibuf[3] == S_BASE64PAD) {
+ outlen = 2;
+ }
+ if (ibuf[2] == S_BASE64PAD) {
+ outlen = 1;
+ }
+ int b0 = S_DECODETABLE[ibuf[0]];
+ int b1 = S_DECODETABLE[ibuf[1]];
+ int b2 = S_DECODETABLE[ibuf[2]];
+ int b3 = S_DECODETABLE[ibuf[3]];
+ switch (outlen) {
+ case 1:
+ obuf[wp] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ return 1;
+ case 2:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ return 2;
+ case 3:
+ obuf[wp++] = (byte) (b0 << 2 & 0xfc | b1 >> 4 & 0x3);
+ obuf[wp++] = (byte) (b1 << 4 & 0xf0 | b2 >> 2 & 0xf);
+ obuf[wp] = (byte) (b2 << 6 & 0xc0 | b3 & 0x3f);
+ return 3;
+ default:
+ throw new IllegalArgumentException("The character sequence is not base64 encoded.");
+ }
+ }
+
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data) {
+ return encode(data, 0, data.length);
+ }
+
+ /**
+ * Returns base64 representation of specified byte array.
+ */
+ public static String encode(byte[] data, int off, int len) {
+ if (len <= 0) {
+ return "";
+ }
+ char[] out = new char[len / 3 * 4 + 4];
+ int rindex = off;
+ int windex = 0;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i =
+ ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8)
+ + (data[rindex + 2] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 18];
+ out[windex++] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[windex++] = S_BASE64CHAR[i & 0x3f];
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[windex++] = S_BASE64CHAR[i >> 2];
+ out[windex++] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ out[windex++] = S_BASE64PAD;
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[windex++] = S_BASE64CHAR[i >> 10];
+ out[windex++] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[windex++] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[windex++] = S_BASE64PAD;
+ }
+ return new String(out, 0, windex);
+ }
+
+ /**
+ * Outputs base64 representation of the specified byte array to a byte stream.
+ */
+ public static void encode(byte[] data, int off, int len, OutputStream ostream) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ byte[] out = new byte[4];
+ int rindex = off;
+ int rest = len - off;
+ while (rest >= 3) {
+ int i =
+ ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8)
+ + (data[rindex + 2] & 0xff);
+ out[0] = (byte) S_BASE64CHAR[i >> 18];
+ out[1] = (byte) S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = (byte) S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = (byte) S_BASE64CHAR[i & 0x3f];
+ ostream.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = (byte) S_BASE64CHAR[i >> 2];
+ out[1] = (byte) S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = (byte) S_BASE64PAD;
+ out[3] = (byte) S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = (byte) S_BASE64CHAR[i >> 10];
+ out[1] = (byte) S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = (byte) S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = (byte) S_BASE64PAD;
+ ostream.write(out, 0, 4);
+ }
+ }
+
+ /**
+ * Outputs base64 representation of the specified byte array to a character stream.
+ */
+ public static void encode(byte[] data, int off, int len, Writer writer) throws IOException {
+ if (len <= 0) {
+ return;
+ }
+ char[] out = new char[4];
+ int rindex = off;
+ int rest = len - off;
+ int output = 0;
+ while (rest >= 3) {
+ int i =
+ ((data[rindex] & 0xff) << 16) + ((data[rindex + 1] & 0xff) << 8)
+ + (data[rindex + 2] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 18];
+ out[1] = S_BASE64CHAR[(i >> 12) & 0x3f];
+ out[2] = S_BASE64CHAR[(i >> 6) & 0x3f];
+ out[3] = S_BASE64CHAR[i & 0x3f];
+ writer.write(out, 0, 4);
+ rindex += 3;
+ rest -= 3;
+ output += 4;
+ if (output % 76 == 0) {
+ writer.write("\n");
+ }
+ }
+ if (rest == 1) {
+ int i = data[rindex] & 0xff;
+ out[0] = S_BASE64CHAR[i >> 2];
+ out[1] = S_BASE64CHAR[(i << 4) & 0x3f];
+ out[2] = S_BASE64PAD;
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ } else if (rest == 2) {
+ int i = ((data[rindex] & 0xff) << 8) + (data[rindex + 1] & 0xff);
+ out[0] = S_BASE64CHAR[i >> 10];
+ out[1] = S_BASE64CHAR[(i >> 4) & 0x3f];
+ out[2] = S_BASE64CHAR[(i << 2) & 0x3f];
+ out[3] = S_BASE64PAD;
+ writer.write(out, 0, 4);
+ }
+ }
+ }
+
+ /**
+ *
+ * Utility class for xs:hexbinary.
+ */
+ public static final class HexBinary {
+ private HexBinary() {
+ }
+
+ /**
+ * Converts the string pValue
into an array of hex bytes.
+ */
+ public static byte[] decode(String pValue) {
+ if ((pValue.length() % 2) != 0) {
+ throw new IllegalArgumentException("A HexBinary string must have even length.");
+ }
+ byte[] result = new byte[pValue.length() / 2];
+ int j = 0;
+ int i = 0;
+ while (i < pValue.length()) {
+ byte b;
+ char c = pValue.charAt(i++);
+ char d = pValue.charAt(i++);
+ if (c >= '0' && c <= '9') {
+ b = (byte) ((c - '0') << 4);
+ } else if (c >= 'A' && c <= 'F') {
+ b = (byte) ((c - 'A' + 10) << 4);
+ } else if (c >= 'a' && c <= 'f') {
+ b = (byte) ((c - 'a' + 10) << 4);
+ } else {
+ throw new IllegalArgumentException("Invalid hex digit: " + c);
+ }
+ if (d >= '0' && d <= '9') {
+ b += (byte) (d - '0');
+ } else if (d >= 'A' && d <= 'F') {
+ b += (byte) (d - 'A' + 10);
+ } else if (d >= 'a' && d <= 'f') {
+ b += (byte) (d - 'a' + 10);
+ } else {
+ throw new IllegalArgumentException("Invalid hex digit: " + d);
+ }
+ result[j++] = b;
+ }
+ return result;
+ }
+
+ /**
+ * Converts the byte array pHexBinary
into a string.
+ */
+ public static String encode(byte[] pHexBinary) {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < pHexBinary.length; i++) {
+ byte b = pHexBinary[i];
+ byte c = (byte) ((b & 0xf0) >> 4);
+ if (c <= 9) {
+ result.append((char) ('0' + c));
+ } else {
+ result.append((char) ('A' + c - 10));
+ }
+ c = (byte) (b & 0x0f);
+ if (c <= 9) {
+ result.append((char) ('0' + c));
+ } else {
+ result.append((char) ('A' + c - 10));
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Creates a clone of the given byte array.
+ */
+ public static byte[] getClone(byte[] pHexBinary) {
+ byte[] result = new byte[pHexBinary.length];
+ System.arraycopy(pHexBinary, 0, result, 0, pHexBinary.length);
+ return result;
+ }
+ }
+
+ public class XSDDateFormat extends XSDDateTimeFormat {
+ private static final long serialVersionUID = -1629412916827246627L;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDDateFormat() {
+ super(true, false);
+ }
+ }
+
+ /**
+ *
+ * An instance of {@link java.text.Format}, which may be used to parse and format xs:dateTime
values.
+ *
+ */
+ public static class XSDDateTimeFormat extends Format {
+ private static final long serialVersionUID = -1148332471737068969L;
+
+ final boolean parseDate;
+
+ final boolean parseTime;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDDateTimeFormat() {
+ this(true, true);
+ }
+
+ XSDDateTimeFormat(boolean pParseDate, boolean pParseTime) {
+ parseDate = pParseDate;
+ parseTime = pParseTime;
+ }
+
+ private void append(StringBuffer pBuffer, int pNum, int pMinLen) {
+ String s = Integer.toString(pNum);
+ for (int i = s.length(); i < pMinLen; i++) {
+ pBuffer.append('0');
+ }
+ pBuffer.append(s);
+ }
+
+ public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
+ assert pCalendar != null : "The Calendar argument must not be null.";
+ assert pBuffer != null : "The StringBuffer argument must not be null.";
+ assert pPos != null : "The FieldPosition argument must not be null.";
+
+ Calendar cal = (Calendar) pCalendar;
+ if (parseDate) {
+ int year = cal.get(Calendar.YEAR);
+ if (year < 0) {
+ pBuffer.append('-');
+ year = -year;
+ }
+ append(pBuffer, year, 4);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.MONTH) + 1, 2);
+ pBuffer.append('-');
+ append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2);
+ if (parseTime) {
+ pBuffer.append('T');
+ }
+ }
+ if (parseTime) {
+ append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.MINUTE), 2);
+ pBuffer.append(':');
+ append(pBuffer, cal.get(Calendar.SECOND), 2);
+ int millis = cal.get(Calendar.MILLISECOND);
+ if (millis > 0) {
+ pBuffer.append('.');
+ append(pBuffer, millis, 3);
+ }
+ }
+ TimeZone tz = cal.getTimeZone();
+ // JDK 1.4: int offset = tz.getOffset(cal.getTimeInMillis());
+ int offset = cal.get(Calendar.ZONE_OFFSET);
+ if (tz.inDaylightTime(cal.getTime())) {
+ offset += cal.get(Calendar.DST_OFFSET);
+ }
+ if (offset == 0) {
+ pBuffer.append('Z');
+ } else {
+ if (offset < 0) {
+ pBuffer.append('-');
+ offset = -offset;
+ } else {
+ pBuffer.append('+');
+ }
+ int minutes = offset / (60 * 1000);
+ int hours = minutes / 60;
+ minutes -= hours * 60;
+ append(pBuffer, hours, 2);
+ pBuffer.append(':');
+ append(pBuffer, minutes, 2);
+ }
+ return pBuffer;
+ }
+
+ private int parseInt(String pString, int offset, StringBuffer pDigits) {
+ int length = pString.length();
+ int pOffset = offset;
+ pDigits.setLength(0);
+ while (pOffset < length) {
+ char c = pString.charAt(pOffset);
+ if (Character.isDigit(c)) {
+ pDigits.append(c);
+ ++pOffset;
+ } else {
+ break;
+ }
+ }
+ return pOffset;
+ }
+
+ public Object parseObject(String pString, ParsePosition pParsePosition) {
+ assert pString != null : "The String argument must not be null.";
+ assert pParsePosition != null : "The ParsePosition argument must not be null.";
+ int offset = pParsePosition.getIndex();
+ int length = pString.length();
+
+ boolean isMinus = false;
+ StringBuffer digits = new StringBuffer();
+ int year = 0;
+ int month = 0;
+ int mday = 0;
+ if (parseDate) {
+ // Sign
+ if (offset < length) {
+ char c = pString.charAt(offset);
+ if (c == '+') {
+ ++offset;
+ } else if (c == '-') {
+ ++offset;
+ isMinus = true;
+ }
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() < 4) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ year = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '-') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ month = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '-') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ mday = Integer.parseInt(digits.toString());
+
+ if (parseTime) {
+ if (offset < length && pString.charAt(offset) == 'T') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ }
+ } else {
+ year = month = mday = 0;
+ }
+
+ int hour = 0;
+ int minute = 0;
+ int second = 0;
+ int millis = 0;
+ if (parseTime) {
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ hour = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == ':') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ minute = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == ':') {
+ ++offset;
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() != 2) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ second = Integer.parseInt(digits.toString());
+
+ if (offset < length && pString.charAt(offset) == '.') {
+ ++offset;
+ offset = parseInt(pString, offset, digits);
+ if (digits.length() > 0) {
+ millis = Integer.parseInt(digits.toString());
+ } else {
+ millis = 0;
+ }
+ } else {
+ millis = 0;
+ }
+ } else {
+ hour = minute = second = millis = 0;
+ }
+
+ digits.setLength(0);
+ digits.append("GMT");
+ if (offset < length) {
+ char c = pString.charAt(offset);
+ if (c == 'Z') {
+ // Ignore UTC, it is the default
+ ++offset;
+ } else if (c == '+' || c == '-') {
+ digits.append(c);
+ ++offset;
+ for (int i = 0; i < 5; i++) {
+ if (offset >= length) {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ c = pString.charAt(offset);
+ if ((i != 2 && Character.isDigit(c)) || (i == 2 && c == ':')) {
+ digits.append(c);
+ } else {
+ pParsePosition.setErrorIndex(offset);
+ return null;
+ }
+ ++offset;
+ }
+ }
+ }
+
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(digits.toString()));
+ cal.set(isMinus ? -year : year, parseDate ? month - 1 : month, mday, hour, minute, second);
+ cal.set(Calendar.MILLISECOND, millis);
+ pParsePosition.setIndex(offset);
+ return cal;
+ }
+ }
+
+ public static class XSDTimeFormat extends XSDDateTimeFormat {
+ private static final long serialVersionUID = 1346506860724640517L;
+
+ /**
+ * Creates a new instance.
+ */
+ public XSDTimeFormat() {
+ super(false, true);
+ }
+ }
+
+ private static final long MAX_UNSIGNED_INT = (((long) Integer.MAX_VALUE) * 2) + 1;
+
+ private static final int MAX_UNSIGNED_SHORT = Short.MAX_VALUE * 2 + 1;
+
+ public String parseAnySimpleType(String value) {
+ return value;
+ }
+
+ public byte[] parseBase64Binary(String value) {
+ return Base64Binary.decode(value);
+ }
+
+ public boolean parseBoolean(String value) {
+ return Boolean.valueOf(value).booleanValue();
+ }
+
+ public byte parseByte(String value) {
+ return Byte.parseByte(value);
+ }
+
+ public Calendar parseDate(String value) {
+ XSDDateFormat format = new XSDDateFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse date " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
+ }
+ return cal;
+ }
+
+ public Calendar parseDateTime(String value) {
+ XSDDateTimeFormat format = new XSDDateTimeFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse dateTime " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
+ }
+ return cal;
+ }
+
+ public BigDecimal parseDecimal(String value) {
+ return new BigDecimal(value);
+ }
+
+ public double parseDouble(String value) {
+ if ("INF".equals(value)) {
+ return Double.POSITIVE_INFINITY;
+ } else if ("-INF".equals(value)) {
+ return Double.NEGATIVE_INFINITY;
+ } else if ("NaN".equals(value)) {
+ return Double.NaN;
+ } else {
+ return Double.parseDouble(value);
+ }
+ }
+
+ public Duration parseDuration(String pDuration) {
+ try {
+ return DatatypeFactory.newInstance().newDuration(pDuration);
+ } catch (DatatypeConfigurationException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ public float parseFloat(String value) {
+ if ("INF".equals(value)) {
+ return Float.POSITIVE_INFINITY;
+ } else if ("-INF".equals(value)) {
+ return Float.NEGATIVE_INFINITY;
+ } else if ("NaN".equals(value)) {
+ return Float.NaN;
+ } else {
+ return Float.parseFloat(value);
+ }
+ }
+
+ public byte[] parseHexBinary(String value) {
+ return HexBinary.decode(value);
+ }
+
+ public int parseInt(String value) {
+ return Integer.parseInt(value);
+ }
+
+ public BigInteger parseInteger(String value) {
+ return new BigInteger(value);
+ }
+
+ public long parseLong(String value) {
+ return Long.parseLong(value);
+ }
+
+ public QName parseQName(String value, NamespaceContext context) {
+ int offset = value.indexOf(':');
+ String uri;
+ String localName;
+ switch (offset) {
+ case -1:
+ localName = value;
+ uri = context.getNamespaceURI("");
+ if (uri == null) {
+ // Should not happen, indicates an error in the
+ // NamespaceContext
+ // implementation
+ throw new IllegalArgumentException("The default prefix is not bound.");
+ }
+ break;
+ case 0:
+ throw new IllegalArgumentException("Default prefix must be indicated by not using a colon: "
+ + value);
+ default:
+ String prefix = value.substring(0, offset);
+ localName = value.substring(offset + 1);
+ uri = context.getNamespaceURI(prefix);
+ if (uri == null) {
+ throw new IllegalArgumentException("The prefix " + prefix + " is not bound.");
+ }
+ }
+ return new QName(uri, localName);
+ }
+
+ public short parseShort(String value) {
+ return Short.parseShort(value);
+ }
+
+ public String parseString(String value) {
+ return value;
+ }
+
+ public Calendar parseTime(String value) {
+ XSDTimeFormat format = new XSDTimeFormat();
+ ParsePosition pos = new ParsePosition(0);
+ Calendar cal = (Calendar) format.parseObject(value, pos);
+ if (cal == null) {
+ throw new IllegalArgumentException("Failed to parse time " + value + " at:"
+ + value.substring(pos.getErrorIndex()));
+ }
+ return cal;
+ }
+
+ public long parseUnsignedInt(String value) {
+ long l = Long.parseLong(value);
+ if (l < 0) {
+ throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
+ + ": result is negative");
+ }
+ if (l > MAX_UNSIGNED_INT) {
+ throw new IllegalArgumentException("Failed to parse UnsignedInt " + value
+ + ": result exceeds maximum value " + MAX_UNSIGNED_INT);
+ }
+ return l;
+ }
+
+ public int parseUnsignedShort(String value) {
+ int i = Integer.parseInt(value);
+ if (i < 0) {
+ throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
+ + ": result is negative");
+ }
+ if (i > MAX_UNSIGNED_SHORT) {
+ throw new IllegalArgumentException("Failed to parse UnsignedShort " + value
+ + ": result exceeds maximum value " + MAX_UNSIGNED_SHORT);
+ }
+ return i;
+ }
+
+ public String printAnySimpleType(String value) {
+ return value;
+ }
+
+ public String printBase64Binary(byte[] value) {
+ return Base64Binary.encode(value);
+ }
+
+ public String printBoolean(boolean value) {
+ return (value ? Boolean.TRUE : Boolean.FALSE).toString();
+ }
+
+ public String printByte(byte value) {
+ return Byte.toString(value);
+ }
+
+ public String printDate(Calendar value) {
+ return new XSDDateFormat().format(value);
+ }
+
+ public String printDateTime(Calendar value) {
+ return new XSDDateTimeFormat().format(value);
+ }
+
+ public String printDecimal(BigDecimal value) {
+ return value.toString();
+ }
+
+ public String printDouble(double value) {
+ return Double.toString(value);
+ }
+
+ public String printDuration(Duration pDuration) {
+ return pDuration.toString();
+ }
+
+ public String printFloat(float value) {
+ return Float.toString(value);
+ }
+
+ public String printHexBinary(byte[] value) {
+ return HexBinary.encode(value);
+ }
+
+ public String printInt(int value) {
+ return Integer.toString(value);
+ }
+
+ public String printInteger(BigInteger value) {
+ return value.toString();
+ }
+
+ public String printLong(long value) {
+ return Long.toString(value);
+ }
+
+ public String printQName(QName value, NamespaceContext context) {
+ String prefix = context.getPrefix(value.getNamespaceURI());
+ if (prefix == null) {
+ throw new IllegalArgumentException("The namespace URI " + value.getNamespaceURI()
+ + " is not bound.");
+ } else if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
+ return value.getLocalPart();
+ } else {
+ return prefix + ":" + value.getLocalPart();
+ }
+ }
+
+ public String printShort(short value) {
+ return Short.toString(value);
+ }
+
+ public String printString(String value) {
+ return value;
+ }
+
+ public String printTime(Calendar value) {
+ return new XSDTimeFormat().format(value);
+ }
+
+ public String printUnsignedInt(long value) {
+ return Long.toString(value);
+ }
+
+ public String printUnsignedShort(int value) {
+ return Integer.toString(value);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolver.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolver.java
new file mode 100644
index 0000000000..bd4c29e48b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolver.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.deployer;
+
+import java.net.URL;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.Contribution;
+
+
+/**
+ * SCA Assemblies reference many artifacts of a wide variety of types. These
+ * include:
+ *
+ * Reference from one SCA composite to another SCA composite
+ * Reference to PolicySet files
+ * Reference to interface definition files, either WSDL or Java interfaces
+ * Reference to XSD files
+ * Reference to any of a wide variety of implementation artifact files,
+ * including Java classes, BPEL scripts, C++ DLLs and classes, PHP scripts
+ *
+ * In the SCA assemblies, these various artifacts are referenced using either
+ * QNames or URIs that do not point to a specific entity. Resolution of these
+ * references to concrete artifacts is necessary as part of the operation of the
+ * SCA domain.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ArtifactResolver {
+ /**
+ * Resolve an artifact by the qualified name
+ *
+ * @param contribution the model of the contribution
+ * @param modelClass The java type of the artifact
+ * @param namespace The namespace of the artifact
+ * @param name The name of the artifact
+ * @param attributes Additional attributes that can be used to constrain the
+ * resolution
+ * @param context The deployment context
+ * @return The resolved artifact
+ */
+ T resolve(Contribution contribution,
+ Class modelClass,
+ String namespace,
+ String name,
+ Map attributes,
+ DeploymentContext context);
+
+ /**
+ * Resolve an artifact by the URI. Some typical use cases are:
+ *
+ * Reference a XML schema using
+ * {http://www.w3.org/2001/XMLSchema-instance}schemaLocation or
+ * Reference a list of WSDLs using
+ * {http://www.w3.org/2004/08/wsdl-instance}wsdlLocation
+ *
+ * @param targetNamespace The target namespace of the referenced artifact,
+ * if the targetNamespace is null, then it's not specified
+ * @param location The URI of the referenced artifact, it can be absolute or
+ * relative
+ * @param baseURI The URI of the owning artifact
+ *
+ * @return The URI of the resolved artifact
+ */
+ URL resolve(Contribution contribution, String targetNamespace, String location, String baseURI);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolverRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolverRegistry.java
new file mode 100644
index 0000000000..f24fb7269a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolverRegistry.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.spi.deployer;
+
+
+/**
+ * Registry for artifact resolvers
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ArtifactResolverRegistry extends ArtifactResolver {
+ /**
+ * Register a resolver by the type of artifacts. For example, you can
+ * register a resolver to resolve WSDL model objects and other resolver
+ * for java classes
+ *
+ * @param modelClass The java type of the model object
+ * @param resolver The resolver
+ */
+ void registerResolver(Class> modelClass, ArtifactResolver resolver);
+
+ /**
+ * Unregister all resolvers for the given model class
+ *
+ * @param modelClass
+ */
+ void unregisterResolver(Class> modelClass);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandler.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandler.java
new file mode 100644
index 0000000000..fead0453be
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandler.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.spi.deployer;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.tuscany.host.deployment.DeploymentException;
+
+/**
+ * Interface implemented by services that process assembly change sets.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ChangeSetHandler {
+ /**
+ * Returns the content type that this implementation can handle.
+ *
+ * @return the content type that this implementation can handle
+ */
+ String getContentType();
+
+ /**
+ * Apply the changes in the supplied changeSet stream to an Assembly.
+ * The content on the stream must match the content type this implementation can handle.
+ *
+ * @param changeSet the set of changes to apply represented as the supported content type
+ * @throws DeploymentException if there was a problem applying the changes
+ * @throws IOException if there was a problem reading the stream
+ */
+ void applyChanges(InputStream changeSet) throws DeploymentException, IOException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandlerRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandlerRegistry.java
new file mode 100644
index 0000000000..df0bf4109b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ChangeSetHandlerRegistry.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.spi.deployer;
+
+/**
+ * Registry for ChangeSetHandler implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ChangeSetHandlerRegistry {
+ void register(ChangeSetHandler handler);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.java
new file mode 100644
index 0000000000..63db5b9e24
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/CompositeClassLoader.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.spi.deployer;
+
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.net.URLStreamHandlerFactory;
+
+/**
+ * ClassLoader associated with a composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeClassLoader extends URLClassLoader {
+ private static final URL[] NOURLS = {};
+
+ public CompositeClassLoader(ClassLoader classLoader) {
+ super(NOURLS, classLoader);
+ }
+
+ public CompositeClassLoader(URL[] urls, ClassLoader classLoader) {
+ super(urls, classLoader);
+ }
+
+ public CompositeClassLoader(URL[] urls) {
+ super(urls);
+ }
+
+ public CompositeClassLoader(URL[] urls, ClassLoader classLoader, URLStreamHandlerFactory urlStreamHandlerFactory) {
+ super(urls, classLoader, urlStreamHandlerFactory);
+ }
+
+ public void addURL(URL url) {
+ super.addURL(url);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContentType.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContentType.java
new file mode 100644
index 0000000000..d29f935dc4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContentType.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.spi.deployer;
+
+public interface ContentType {
+ /**
+ * Archive specific content types
+ */
+ public static final String JAR = "application/x-compressed";
+ public static final String FOLDER = "application/vnd.tuscany.folder";
+
+ /**
+ * Artifact/File specific content types
+ */
+ public static final String CONTRIBUTION_METADATA = "application/vnd.tuscany.contribution.metadata";
+ public static final String COMPOSITE = "application/vnd.tuscany.composite";
+ public static final String WSDL = "application/vnd.tuscany.wsdl";
+ public static final String JAVA = "application/java-vm";
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContentTypeDescriber.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContentTypeDescriber.java
new file mode 100644
index 0000000000..667b3dec69
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContentTypeDescriber.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.spi.deployer;
+
+import java.net.URL;
+
+/**
+ * Provide content type for a given resource
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ContentTypeDescriber {
+ /**
+ * @param resourceURL
+ * @param defaultContentType
+ * @return
+ */
+ String getContentType(URL resourceURL, String defaultContentType);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java
new file mode 100644
index 0000000000..a1cf4d7c9b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.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.spi.deployer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.apache.tuscany.host.deployment.DeploymentException;
+import org.apache.tuscany.spi.model.Contribution;
+
+/**
+ * Interface for services that can process contributions.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ContributionProcessor {
+ /**
+ * Process a contribution or an artifact in the contribution from the input
+ * stream. The processor might add artifacts or model objects to the
+ * contribution object.
+ *
+ * @param contribution The contribution model that will be used to hold the
+ * results from the processing
+ * @param source The URI for the contribution/artifact
+ * @param inputStream The input stream for the contribution. The stream will
+ * not be closed but the read position after the call is
+ * undefined
+ * @throws DeploymentException if there was a problem with the contribution
+ * @throws IOException if there was a problem reading the stream
+ */
+ void processContent(Contribution contribution, URI source, InputStream inputStream) throws DeploymentException,
+ IOException;
+
+ /**
+ * Process a contribution from another model object. It will be used for the
+ * case that one artifact has other inline artifacts, for example, the WSDL
+ * with inline schemas. The schema contribution processor should be able to
+ * load the schema model from the WSDL definition.
+ *
+ * @param contribution The contribution model that will be used to hold the
+ * results from the processing
+ * @param source The URI for the contribution/artifact.
+ * @param modelObject A model object for further processing by the processor
+ * @throws DeploymentException
+ * @throws IOException
+ */
+ void processModel(Contribution contribution, URI source, Object modelObject) throws DeploymentException,
+ IOException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessorRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessorRegistry.java
new file mode 100644
index 0000000000..c1b6e93cb3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessorRegistry.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.spi.deployer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ContributionProcessorRegistry extends ContributionProcessor {
+ /**
+ * Register a ContributionProcessor using the content type as the key
+ * @param processor
+ */
+ void register(String contentType, ContributionProcessor processor);
+
+ /**
+ * Unregister a ContributionProcessor by content type
+ * @param contentType
+ */
+ void unregister(String contentType);
+}
\ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionRepository.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionRepository.java
new file mode 100644
index 0000000000..4721511cdd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionRepository.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.deployer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+public interface ContributionRepository {
+ /**
+ * Get the URI of the SCA domain
+ *
+ * @return
+ */
+ URI getDomain();
+
+ /**
+ * Copy a contribution to the repository.
+ *
+ * @param contribution A URl pointing to the contribution being copied to
+ * the repository
+ * @param contributionStream InputStream with the content of the
+ * distribution
+ */
+ URL store(URI contribution, InputStream contributionStream) throws IOException;
+
+ /**
+ * Copy a contribution from the source URL to the repository
+ * @param contribution
+ * @param sourceURL
+ * @return
+ * @throws IOException
+ */
+ URL store(URI contribution, URL sourceURL) throws IOException;
+
+ /**
+ * Look up the contribution by URI
+ *
+ * @param contribution The URI of the contribution
+ * @return A URL pointing to the content of the contribution in the
+ * repository, it will be null if the contribution cannot be found
+ * in the repository
+ */
+ URL find(URI contribution);
+
+ /**
+ * Remove a contribution from the repository
+ *
+ * @param contribution The URI of the contribution to be removed
+ */
+ void remove(URI contribution);
+
+ /**
+ * Get list of URIs for all the contributions in the repository
+ *
+ * @return A list of contribution URIs
+ */
+ List list();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java
new file mode 100644
index 0000000000..0e39a6fcf2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.deployer;
+
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.ComponentException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * Interface that can be used to deploy SCA bundles to a runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Deployer {
+ /**
+ * Deploy a component as a child of the supplied parent. This operation creates a new component in the runtime to represent the supplied component
+ * definition. The type of component created will depend on the component definition implementation; for example, if the implementation of the
+ * component definition is a composite then typically a CompositeComponent would be returned.
+ *
+ * @param parent
+ * the parent context
+ * @param componentDefinition
+ * the component definition as parsed from an assembly
+ * @return the newly deployed component
+ */
+ > Component deploy(CompositeComponent parent, ComponentDefinition componentDefinition)
+ throws LoaderException, BuilderException, ComponentException;
+
+ /**
+ * Deploy a component as a child of the supplied parent. This operation creates a new component in the runtime to represent the supplied component
+ * definition. The type of component created will depend on the component definition implementation; for example, if the implementation of the
+ * component definition is a composite then typically a CompositeComponent would be returned.
+ *
+ * @param parent
+ * the parent context
+ * @param componentDefinition
+ * the component definition as parsed from an assembly
+ * @return the newly deployed component
+ */
+ > Component deployFromContribution(CompositeComponent parent,
+ ComponentDefinition componentDefinition) throws BuilderException, ComponentException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java
new file mode 100644
index 0000000000..921781c484
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentContext.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.deployer;
+
+import java.net.URL;
+import javax.xml.stream.XMLInputFactory;
+
+import org.apache.tuscany.spi.component.ScopeContainer;
+
+/**
+ * A holder that can be used during the load process to store information that is not part of the logical assembly
+ * model. This should be regarded as transient and references to this context should not be stored inside the model.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DeploymentContext {
+ /**
+ * Returns the parent of this deployment context.
+ * Will be null for the context created at the root of a deployment.
+ *
+ * @return the parent of this deployment context; may be null
+ */
+ DeploymentContext getParent();
+
+ /**
+ * Returns a class loader that can be used to load application resources.
+ *
+ * @return a class loader that can be used to load application resources
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ * Returns a factory that can be used to obtain an StAX XMLStreamReader.
+ *
+ * @return a factory that can be used to obtain an StAX XMLStreamReader
+ */
+ XMLInputFactory getXmlFactory();
+
+ /**
+ * Returns the ScopeContainer for the COMPOSITE scope that will be associated with this deployment unit.
+ *
+ * @return the ScopeContainer for the COMPOSITE scope that will be associated with this deployment unit
+ */
+ ScopeContainer getCompositeScope();
+
+ /**
+ * Returns the location of the SCDL definition being deployed.
+ *
+ * @return the location of the SCDL definition being deployed
+ */
+ URL getScdlLocation();
+
+ /**
+ * Return the extension property with the supplied name.
+ *
+ * @param name the name of the property
+ * @return the property value; if null indicates that no property is present
+ */
+ Object getExtension(String name);
+
+ /**
+ * Set the value of an extension property.
+ *
+ * @param name the name of the property
+ * @param value the property value; if null then the extension property is removed
+ */
+ void putExtension(String name, Object value);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentMonitor.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentMonitor.java
new file mode 100644
index 0000000000..156f57c2e0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/DeploymentMonitor.java
@@ -0,0 +1,20 @@
+package org.apache.tuscany.spi.deployer;
+
+import org.apache.tuscany.api.TuscanyException;
+import org.apache.tuscany.api.annotation.LogLevel;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface DeploymentMonitor {
+
+ @LogLevel("FINER")
+ void startDeployment();
+
+ @LogLevel("FINER")
+ void endDeployment();
+
+ @LogLevel("SEVERE")
+ void deploymentError(TuscanyException e);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/AbstractEventPublisher.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/AbstractEventPublisher.java
new file mode 100644
index 0000000000..cc20866cbb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/AbstractEventPublisher.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.spi.event;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * Base implementation of an EventPublisher
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractEventPublisher implements EventPublisher {
+ protected static final EventFilter TRUE_FILTER = new TrueFilter();
+ protected Map> listeners;
+
+ public void addListener(RuntimeEventListener listener) {
+ addListener(TRUE_FILTER, listener);
+ }
+
+ public void removeListener(RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ for (List currentList : getListeners().values()) {
+ for (RuntimeEventListener current : currentList) {
+ if (current == listener) {
+ currentList.remove(current);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ public void addListener(EventFilter filter, RuntimeEventListener listener) {
+ assert listener != null : "Listener cannot be null";
+ synchronized (getListeners()) {
+ List list = getListeners().get(filter);
+ if (list == null) {
+ list = new CopyOnWriteArrayList();
+ listeners.put(filter, list);
+ }
+ list.add(listener);
+ }
+ }
+
+ public void publish(Event event) {
+ assert event != null : "Event object was null";
+ for (Map.Entry> entry : getListeners().entrySet()) {
+ if (entry.getKey().match(event)) {
+ for (RuntimeEventListener listener : entry.getValue()) {
+ listener.onEvent(event);
+ }
+ }
+ }
+ }
+
+ protected Map> getListeners() {
+ if (listeners == null) {
+ listeners = new ConcurrentHashMap>();
+ }
+ return listeners;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.java
new file mode 100644
index 0000000000..b874ca43c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/Event.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.spi.event;
+
+/**
+ * Represents an event that is propagated in the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface Event {
+
+ /**
+ * Returns the source of the event
+ */
+ Object getSource();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.java
new file mode 100644
index 0000000000..d61d04cdc8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventFilter.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.spi.event;
+
+/**
+ * Evaluates whether a {@link RuntimeEventListener} is applicable to a given runtime event
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface EventFilter {
+
+ /**
+ * Performs the actual evaluation on an event
+ */
+ boolean match(Event event);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.java
new file mode 100644
index 0000000000..35df22fb9c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/EventPublisher.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.spi.event;
+
+/**
+ * Publishes events in the runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface EventPublisher {
+
+ /**
+ * Publish an event
+ */
+ void publish(Event object);
+
+ /**
+ * Registers a listener to receive notifications for the context
+ */
+ void addListener(RuntimeEventListener listener);
+
+ /**
+ * Registers a listener to receive notifications for the context
+ */
+ void addListener(EventFilter filter, RuntimeEventListener listener);
+
+
+ /**
+ * Removes a previously registered listener
+ */
+ void removeListener(RuntimeEventListener listener);
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.java
new file mode 100644
index 0000000000..5146559098
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/RuntimeEventListener.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.spi.event;
+
+import java.util.EventListener;
+
+/**
+ * Listeners observe events fired in the SCA runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeEventListener extends EventListener {
+
+ void onEvent(Event event);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.java
new file mode 100644
index 0000000000..81382b86ac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/event/TrueFilter.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.spi.event;
+
+/**
+ * An event filter that always returns a true condition
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class TrueFilter implements EventFilter {
+
+ public boolean match(Event event) {
+ return true;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AbstractComponentExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AbstractComponentExtension.java
new file mode 100644
index 0000000000..a6c1ff086f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AbstractComponentExtension.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.model.PropertyValue;
+
+/**
+ * @version Provides support for property accessors.
+ */
+public abstract class AbstractComponentExtension extends AbstractSCAObject implements Component {
+ protected ScopeContainer scopeContainer;
+
+ /**
+ * Default property values.
+ */
+ private Map> defaultPropertyValues;
+
+ /**
+ * Initializes component name and parent.
+ *
+ * @param name Name of the component.
+ * @param parent Parent of the component.
+ */
+ public AbstractComponentExtension(String name, CompositeComponent parent) {
+ super(name, parent);
+ }
+
+ public void setScopeContainer(ScopeContainer scopeContainer) {
+ this.scopeContainer = scopeContainer;
+ }
+
+ public Map> getDefaultPropertyValues() {
+ return defaultPropertyValues;
+ }
+
+ public void setDefaultPropertyValues(Map> defaultPropertyValues) {
+ this.defaultPropertyValues = defaultPropertyValues;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ArtifactResolverExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ArtifactResolverExtension.java
new file mode 100644
index 0000000000..307dc52656
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ArtifactResolverExtension.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.extension;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.deployer.ArtifactResolver;
+import org.apache.tuscany.spi.deployer.ArtifactResolverRegistry;
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * The base class for ContributionProcessor implementations
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+@Service(ArtifactResolver.class)
+public abstract class ArtifactResolverExtension implements ArtifactResolver {
+ /**
+ * The ArtifactResolverRegistry that this resolver should register with; usually set by injection.
+ */
+ protected final ArtifactResolverRegistry registry;
+
+ /**
+ * @param registry the registry to set
+ */
+ @Constructor
+ public ArtifactResolverExtension(@Autowire ArtifactResolverRegistry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Initialize the resolver. It registers itself to the registry by model type it supports.
+ */
+ @Init
+ public void start() {
+ this.registry.registerResolver(this.getType(), this);
+ }
+
+ /**
+ * Destroy the resolver. It unregisters itself from the registry.
+ */
+ @Destroy
+ public void stop() {
+ registry.unregisterResolver(this.getType());
+ }
+
+ /**
+ * Returns the model type that this resolver can handle.
+ *
+ * @return the model type that this resolver can handle
+ */
+ public abstract Class> getType();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java
new file mode 100644
index 0000000000..3124b770fd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/AtomicComponentExtension.java
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.ComponentException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.PrepareException;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.TargetDestructionException;
+import org.apache.tuscany.spi.component.TargetInitializationException;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * An extension point for atomic component type, which new implementation types may extend
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public abstract class AtomicComponentExtension extends AbstractComponentExtension implements AtomicComponent {
+ protected ScopeContainer scopeContainer;
+ protected Scope scope;
+ protected Map serviceWires = new HashMap();
+ protected Map> referenceWires = new HashMap>();
+ protected WireService wireService;
+ protected WorkContext workContext;
+ protected WorkScheduler workScheduler;
+ protected ExecutionMonitor monitor;
+ private final int initLevel;
+ private final long maxIdleTime;
+ private final long maxAge;
+ private boolean allowsPassByReference;
+ private List passByReferenceMethods;
+
+ protected AtomicComponentExtension(String name,
+ CompositeComponent parent,
+ WireService wireService,
+ WorkContext workContext,
+ WorkScheduler workScheduler,
+ ExecutionMonitor monitor,
+ int initLevel) {
+ this(name, parent, wireService, workContext, workScheduler, monitor, initLevel, -1, -1);
+
+ }
+
+ protected AtomicComponentExtension(String name,
+ CompositeComponent parent,
+ WireService wireService,
+ WorkContext workContext,
+ WorkScheduler workScheduler,
+ ExecutionMonitor monitor,
+ int initLevel,
+ long maxIdleTime,
+ long maxAge) {
+ super(name, parent);
+ assert !(maxIdleTime > 0 && maxAge > 0);
+ this.wireService = wireService;
+ this.workContext = workContext;
+ this.workScheduler = workScheduler;
+ this.monitor = monitor;
+ this.initLevel = initLevel;
+ this.maxIdleTime = maxIdleTime;
+ this.maxAge = maxAge;
+ }
+
+ public Scope getScope() {
+ return scope;
+ }
+
+ public int getInitLevel() {
+ return initLevel;
+ }
+
+ public boolean isEagerInit() {
+ return initLevel > 0;
+ }
+
+ public boolean isDestroyable() {
+ return false;
+ }
+
+ public long getMaxIdleTime() {
+ return maxIdleTime;
+ }
+
+ public long getMaxAge() {
+ return maxAge;
+ }
+
+ public boolean isAllowsPassByReference() {
+ return allowsPassByReference;
+ }
+
+ public void setAllowsPassByReference(boolean allowsPassByReference) {
+ this.allowsPassByReference = allowsPassByReference;
+ }
+
+
+ public void setScopeContainer(ScopeContainer scopeContainer) {
+ this.scopeContainer = scopeContainer;
+ scope = scopeContainer.getScope();
+ }
+
+ public void start() throws CoreRuntimeException {
+ super.start();
+ scopeContainer.register(this);
+ }
+
+ public void init(Object instance) throws TargetInitializationException {
+
+ }
+
+ public void destroy(Object instance) throws TargetDestructionException {
+
+ }
+
+ public void addInboundWire(InboundWire wire) {
+ serviceWires.put(wire.getServiceName(), wire);
+ onServiceWire(wire);
+ }
+
+ public InboundWire getInboundWire(String serviceName) {
+ if (serviceName == null) {
+ if (serviceWires.size() < 1) {
+ return null;
+ }
+ return serviceWires.values().iterator().next();
+ } else {
+ return serviceWires.get(serviceName);
+ }
+ }
+
+ public Collection getInboundWires() {
+ return Collections.unmodifiableCollection(serviceWires.values());
+ }
+
+ public void addOutboundWire(OutboundWire wire) {
+ List list = new ArrayList();
+ list.add(wire);
+ referenceWires.put(wire.getReferenceName(), list);
+ onReferenceWire(wire);
+ }
+
+ public Map> getOutboundWires() {
+ return Collections.unmodifiableMap(referenceWires);
+ }
+
+ public void addOutboundWires(List wires) {
+ assert wires != null && wires.size() > 0;
+ referenceWires.put(wires.get(0).getReferenceName(), wires);
+ onReferenceWires(wires);
+ }
+
+ public void removeInstance() throws ComponentException {
+ scopeContainer.remove(this);
+ }
+
+ protected void onReferenceWire(OutboundWire wire) {
+ }
+
+ protected void onReferenceWires(List wires) {
+ }
+
+ protected void onServiceWire(InboundWire wire) {
+ }
+
+
+ public void prepare() throws PrepareException {
+ // connect inbound wires for atomic components
+ for (InboundWire inboundWire : getInboundWires()) {
+ for (InboundInvocationChain chain : inboundWire.getInvocationChains().values()) {
+ Operation> operation = chain.getOperation();
+ String serviceName = inboundWire.getServiceName();
+ TargetInvoker invoker;
+ try {
+ invoker = createTargetInvoker(serviceName, operation, null);
+ } catch (TargetInvokerCreationException e) {
+ throw new PrepareException("Error processing inbound wire", serviceName, e);
+ }
+ chain.setTargetInvoker(invoker);
+ chain.prepare();
+ }
+ }
+ }
+
+ public List getPassByReferenceMethods() {
+ return passByReferenceMethods;
+ }
+
+ public void setPassByReferenceMethods(List passByReferenceMethods) {
+ this.passByReferenceMethods = passByReferenceMethods;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.java
new file mode 100644
index 0000000000..b5bf570de0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/BindingBuilderExtension.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.spi.extension;
+
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BindingBuilder;
+import org.apache.tuscany.spi.builder.BuilderException;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ReferenceBinding;
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.BindingDefinition;
+import org.apache.tuscany.spi.model.AbstractReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+import org.apache.tuscany.spi.wire.WireService;
+
+/**
+ * An extension point for binding builders. When adding support for new serviceBindings, implementations may extend this
+ * class as a convenience.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+@EagerInit
+public abstract class BindingBuilderExtension implements BindingBuilder {
+
+ protected BuilderRegistry builderRegistry;
+ protected WireService wireService;
+
+ @Autowire
+ public void setBuilderRegistry(BuilderRegistry registry) {
+ this.builderRegistry = registry;
+ }
+
+ @Autowire
+ public void setWireService(WireService wireService) {
+ this.wireService = wireService;
+ }
+
+ @Init
+ public void init() {
+ builderRegistry.register(getBindingType(), this);
+ }
+
+ public ServiceBinding build(CompositeComponent parent,
+ ServiceDefinition serviceDefinition,
+ B bindingDefinition,
+ DeploymentContext deploymentContext) throws BuilderException {
+ return null;
+ }
+
+ public ReferenceBinding build(CompositeComponent parent,
+ AbstractReferenceDefinition boundReferenceDefinition,
+ B bindingDefinition,
+ DeploymentContext deploymentContext) throws BuilderException {
+ return null;
+ }
+
+ protected abstract Class getBindingType();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java
new file mode 100644
index 0000000000..d58cb55131
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentBuilderExtension.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.builder.ComponentBuilder;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.policy.PolicyBuilderRegistry;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.wire.WireService;
+
+import org.apache.tuscany.api.annotation.Monitor;
+
+/**
+ * An extension point for component builders. When adding support for new component types, implementations may extend
+ * this class as a convenience.
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+@EagerInit
+public abstract class ComponentBuilderExtension> implements ComponentBuilder {
+ protected BuilderRegistry builderRegistry;
+ protected ScopeRegistry scopeRegistry;
+ protected WireService wireService;
+ protected WorkScheduler workScheduler;
+ protected WorkContext workContext;
+ protected PolicyBuilderRegistry policyBuilderRegistry;
+ protected Connector connector;
+ protected ExecutionMonitor monitor;
+
+ @Autowire
+ public void setBuilderRegistry(BuilderRegistry registry) {
+ this.builderRegistry = registry;
+ }
+
+ @Autowire
+ public void setScopeRegistry(ScopeRegistry scopeRegistry) {
+ this.scopeRegistry = scopeRegistry;
+ }
+
+ @Autowire
+ public void setWireService(WireService wireService) {
+ this.wireService = wireService;
+ }
+
+ @Autowire
+ public void setWorkScheduler(WorkScheduler workScheduler) {
+ this.workScheduler = workScheduler;
+ }
+
+ @Autowire
+ public void setWorkContext(WorkContext workContext) {
+ this.workContext = workContext;
+ }
+
+ @Autowire
+ public void setPolicyBuilderRegistry(PolicyBuilderRegistry registry) {
+ policyBuilderRegistry = registry;
+ }
+
+ @Autowire
+ public void setConnector(Connector connector) {
+ this.connector = connector;
+ }
+
+ @Monitor
+ public void setMonitor(ExecutionMonitor monitor) {
+ this.monitor = monitor;
+ }
+
+ @Init
+ public void init() {
+ builderRegistry.register(getImplementationType(), this);
+ }
+
+ protected abstract Class getImplementationType();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.java
new file mode 100644
index 0000000000..ceebcbc490
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtension.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.spi.extension;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.EagerInit;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.loader.ComponentTypeLoader;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Scope("COMPOSITE")
+@EagerInit
+public abstract class ComponentTypeLoaderExtension implements ComponentTypeLoader {
+ protected LoaderRegistry loaderRegistry;
+
+ protected ComponentTypeLoaderExtension() {
+ }
+
+ protected ComponentTypeLoaderExtension(LoaderRegistry loaderRegistry) {
+ this.loaderRegistry = loaderRegistry;
+ }
+
+ @Autowire
+ public void setLoaderRegistry(LoaderRegistry loaderRegistry) {
+ this.loaderRegistry = loaderRegistry;
+ }
+
+ @Init
+ public void start() {
+ loaderRegistry.registerLoader(getImplementationClass(), this);
+ }
+
+ @Destroy
+ public void stop() {
+ loaderRegistry.unregisterLoader(getImplementationClass());
+ }
+
+ protected abstract Class getImplementationClass();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java
new file mode 100644
index 0000000000..e5358643e0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/CompositeComponentExtension.java
@@ -0,0 +1,564 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.w3c.dom.Document;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.builder.WiringException;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.ComponentRegistrationException;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.DuplicateNameException;
+import org.apache.tuscany.spi.component.InvalidAutowireInterface;
+import org.apache.tuscany.spi.component.PrepareException;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.ReferenceBinding;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.services.management.TuscanyManagementService;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.Wire;
+
+/**
+ * An extension point for composite components, which new types may extend
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public abstract class CompositeComponentExtension extends AbstractComponentExtension implements CompositeComponent {
+ protected final Map children = new ConcurrentHashMap();
+ protected final List services = new ArrayList();
+ protected final List references = new ArrayList();
+
+ protected final Map propertyValues;
+ protected final Connector connector;
+
+ protected final Map systemChildren = new ConcurrentHashMap();
+ protected final List systemServices = new ArrayList();
+ protected final List systemReferenceBindings = new ArrayList();
+
+ // autowire mappings
+ protected final Map autowireInternal = new ConcurrentHashMap();
+ protected final Map autowireExternal = new ConcurrentHashMap();
+ protected final Map systemAutowireInternal = new ConcurrentHashMap();
+ protected final Map systemAutowireExternal = new ConcurrentHashMap();
+
+ /**
+ * Management service to use.
+ */
+ private TuscanyManagementService managementService;
+
+ protected CompositeComponentExtension(String name,
+ CompositeComponent parent,
+ Connector connector,
+ Map propertyValues) {
+ super(name, parent);
+ this.propertyValues = propertyValues;
+ this.connector = connector;
+ }
+
+ /**
+ * Autowires the management service.
+ *
+ * @param managementService Management service used for registering components.
+ */
+ @Autowire
+ public final void setManagementService(TuscanyManagementService managementService) {
+ this.managementService = managementService;
+ }
+
+ public Scope getScope() {
+ return Scope.SYSTEM;
+ }
+
+ public void onEvent(Event event) {
+ publish(event);
+ }
+
+ public void registerJavaObject(String name, Class service, I instance)
+ throws ComponentRegistrationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void registerJavaObject(String name, List> services, I instance)
+ throws ComponentRegistrationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Document getPropertyValue(String name) {
+ return propertyValues.get(name);
+ }
+
+ public SCAObject getChild(String name) {
+ assert name != null;
+ return children.get(name);
+ }
+
+ public SCAObject getSystemChild(String name) {
+ assert name != null;
+ return systemChildren.get(name);
+ }
+
+ public void register(SCAObject child) throws ComponentRegistrationException {
+ assert child instanceof Service || child instanceof Reference || child instanceof Component;
+ if (child.isSystem()) {
+ if (systemChildren.get(child.getName()) != null) {
+ throw new DuplicateNameException("A system child is already registered with the name", child.getName());
+ }
+ systemChildren.put(child.getName(), child);
+ } else {
+ if (children.get(child.getName()) != null) {
+ throw new DuplicateNameException("A child is already registered with the name", child.getName());
+ }
+ children.put(child.getName(), child);
+ }
+ if (child instanceof Service) {
+ Service service = (Service) child;
+ synchronized (services) {
+ if (service.isSystem()) {
+ systemServices.add(service);
+ } else {
+ services.add(service);
+ }
+ }
+ registerAutowire(service);
+ } else if (child instanceof Reference) {
+ Reference reference = (Reference) child;
+ synchronized (references) {
+ if (reference.isSystem()) {
+ systemReferenceBindings.add(reference);
+ } else {
+ references.add(reference);
+ }
+ }
+ registerAutowire(reference);
+ } else if (child instanceof AtomicComponent) {
+ AtomicComponent atomic = (AtomicComponent) child;
+ registerAutowire(atomic);
+ if (managementService != null) {
+ managementService.registerComponent(atomic.getName(), atomic);
+ }
+ } else if (child instanceof CompositeComponent) {
+ CompositeComponent component = (CompositeComponent) child;
+ if (lifecycleState == RUNNING && component.getLifecycleState() == UNINITIALIZED) {
+ component.start();
+ }
+ registerAutowire(component);
+ addListener(component);
+ }
+ }
+
+ public Map> getOutboundWires() {
+ synchronized (references) {
+ Map> map = new HashMap>();
+ for (Reference reference : references) {
+ List wires = new ArrayList();
+ map.put(reference.getName(), wires);
+ for (ReferenceBinding binding : reference.getReferenceBindings()) {
+ OutboundWire wire = binding.getOutboundWire();
+ if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) {
+ wires.add(wire);
+ }
+ }
+ }
+ return map;
+ }
+ }
+
+ public InboundWire getInboundWire(String serviceName) {
+ Service service;
+ if (serviceName == null) {
+ if (services.size() != 1) {
+ return null;
+ }
+ service = services.get(0);
+ } else {
+ SCAObject object = children.get(serviceName);
+ if (!(object instanceof Service)) {
+ return null;
+ }
+ service = (Service) object;
+ }
+ for (ServiceBinding binding : service.getServiceBindings()) {
+ InboundWire wire = binding.getInboundWire();
+ if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) {
+ return wire;
+ }
+ }
+ return null;
+ }
+
+ public InboundWire getInboundSystemWire(String serviceName) {
+ Service service;
+ if (serviceName == null) {
+ if (systemServices.size() != 1) {
+ return null;
+ }
+ service = systemServices.get(0);
+ } else {
+ SCAObject object = systemChildren.get(serviceName);
+ if (!(object instanceof Service)) {
+ return null;
+ }
+ service = (Service) object;
+ }
+ for (ServiceBinding binding : service.getServiceBindings()) {
+ InboundWire wire = binding.getInboundWire();
+ if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) {
+ return wire;
+ }
+ }
+ return null;
+ }
+
+ public Collection getInboundWires() {
+ synchronized (services) {
+ List map = new ArrayList();
+ for (Service service : services) {
+ for (ServiceBinding binding : service.getServiceBindings()) {
+ InboundWire wire = binding.getInboundWire();
+ if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) {
+ map.add(wire);
+ }
+ }
+ }
+ return map;
+ }
+ }
+
+ public Collection getInboundSystemWires() {
+ synchronized (systemServices) {
+ List map = new ArrayList();
+ for (Service service : systemServices) {
+ for (ServiceBinding binding : service.getServiceBindings()) {
+ InboundWire wire = binding.getInboundWire();
+ if (Wire.LOCAL_BINDING.equals(wire.getBindingType())) {
+ map.add(wire);
+ }
+ }
+ }
+ return map;
+ }
+ }
+
+ public InboundWire resolveAutowire(Class> instanceInterface) throws TargetResolutionException {
+ // FIXME JNB make this faster and thread safe
+ for (Map.Entry service : autowireInternal.entrySet()) {
+ if (instanceInterface.isAssignableFrom(service.getKey())) {
+ return service.getValue();
+ }
+ }
+
+ // FIXME: [rfeng] Try to lookup from system. Is it reasonable?
+ InboundWire inboundWire = resolveSystemAutowire(instanceInterface);
+
+ if (inboundWire != null) {
+ return inboundWire;
+ }
+ if (getParent() != null) {
+ return getParent().resolveAutowire(instanceInterface);
+ }
+ return null;
+ }
+
+ public InboundWire resolveSystemAutowire(Class> instanceInterface) throws TargetResolutionException {
+ // FIXME JNB make this faster and thread safe
+ for (Map.Entry service : systemAutowireInternal.entrySet()) {
+ if (instanceInterface.isAssignableFrom(service.getKey())) {
+ return service.getValue();
+ }
+ }
+ if (getParent() != null) {
+ return getParent().resolveSystemAutowire(instanceInterface);
+ }
+ return null;
+ }
+
+ public InboundWire resolveExternalAutowire(Class> instanceInterface) throws TargetResolutionException {
+ // FIXME JNB make this faster and thread safe
+ for (Map.Entry service : autowireExternal.entrySet()) {
+ if (instanceInterface.isAssignableFrom(service.getKey())) {
+ return service.getValue();
+ }
+ }
+ if (getParent() != null) {
+ return getParent().resolveAutowire(instanceInterface);
+ }
+ return null;
+ }
+
+ public InboundWire resolveSystemExternalAutowire(Class> instanceInterface) throws TargetResolutionException {
+ // FIXME JNB make this faster and thread safe
+ for (Map.Entry service : systemAutowireExternal.entrySet()) {
+ if (instanceInterface.isAssignableFrom(service.getKey())) {
+ return service.getValue();
+ }
+ }
+ if (getParent() != null) {
+ return getParent().resolveAutowire(instanceInterface);
+ }
+ return null;
+ }
+
+ public void prepare() throws PrepareException {
+ // Connect services and references first so that their wires are linked first
+ List childList = new ArrayList();
+ for (SCAObject child : systemChildren.values()) {
+ if (child instanceof Component) {
+ childList.add(child);
+ } else {
+ childList.add(0, child);
+ }
+ }
+ // connect system artifacts
+ for (SCAObject child : childList) {
+ // connect all children
+ // TODO for composite wires, should delegate down
+ try {
+ connector.connect(child);
+ child.prepare();
+ } catch (PrepareException e) {
+ e.addContextName(getName());
+ } catch (WiringException e) {
+ throw new PrepareException("Error preparing composite", getName(), e);
+ }
+ }
+
+ // connect application artifacts
+ childList.clear();
+ for (SCAObject child : children.values()) {
+ if (child instanceof Component) {
+ childList.add(child);
+ } else {
+ childList.add(0, child);
+ }
+ }
+ for (SCAObject child : childList) {
+ // connect all children
+ // TODO for composite wires, should delegate down
+ try {
+ connector.connect(child);
+ child.prepare();
+ } catch (PrepareException e) {
+ e.addContextName(getName());
+ throw e;
+ } catch (WiringException e) {
+ throw new PrepareException("Error preparing composite", getName(), e);
+ }
+ }
+ }
+
+ protected void registerAutowireExternal(Class> interfaze, Service service) throws InvalidAutowireInterface {
+ if (interfaze == null) {
+ // The ServiceContract is not from Java
+ return;
+ }
+ if (service.isSystem()) {
+ if (systemAutowireExternal.containsKey(interfaze)) {
+ return;
+ }
+ // TODO autowire should allow multiple interfaces
+ List bindings = service.getServiceBindings();
+ if (bindings.size() == 0) {
+ return;
+ }
+ // pick the first binding until autowire allows multiple interfaces
+ InboundWire wire = bindings.get(0).getInboundWire();
+ if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) {
+ throw new InvalidAutowireInterface("Matching inbound wire not found for interface",
+ interfaze.getName());
+ }
+ systemAutowireExternal.put(interfaze, wire);
+ } else {
+ if (autowireExternal.containsKey(interfaze)) {
+ return;
+ }
+ // TODO autowire should allow multiple interfaces
+ List bindings = service.getServiceBindings();
+ if (bindings.size() == 0) {
+ return;
+ }
+ // pick the first binding until autowire allows multiple interfaces
+ InboundWire wire = bindings.get(0).getInboundWire();
+ if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) {
+ String iName = interfaze.getName();
+ throw new InvalidAutowireInterface("Matching inbound wire not found for interface", iName);
+ }
+ autowireExternal.put(interfaze, wire);
+ }
+ }
+
+ protected void registerAutowireInternal(Class> interfaze, InboundWire wire, boolean system)
+ throws InvalidAutowireInterface {
+ if (interfaze == null) {
+ // The ServiceContract is not from Java
+ return;
+ }
+ if (system) {
+ if (systemAutowireInternal.containsKey(interfaze)) {
+ return;
+ }
+ systemAutowireInternal.put(interfaze, wire);
+ } else {
+ if (autowireInternal.containsKey(interfaze)) {
+ return;
+ }
+ if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) {
+ String iName = interfaze.getName();
+ throw new InvalidAutowireInterface("Matching inbound wire not found for interface", iName);
+ }
+ autowireInternal.put(interfaze, wire);
+ }
+ }
+
+ protected void registerAutowireInternal(Class> interfaze, Reference reference) throws InvalidAutowireInterface {
+ if (interfaze == null) {
+ // The ServiceContract is not from Java
+ return;
+ }
+ if (reference.isSystem()) {
+ if (systemAutowireInternal.containsKey(interfaze)) {
+ return;
+ }
+ List bindings = reference.getReferenceBindings();
+ if (bindings.size() == 0) {
+ return;
+ }
+ // pick the first binding until autowire allows multiple interfaces
+ InboundWire wire = bindings.get(0).getInboundWire();
+ if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) {
+ throw new InvalidAutowireInterface("Matching inbound wire not found for interface",
+ interfaze.getName());
+ }
+ systemAutowireInternal.put(interfaze, wire);
+ } else {
+ if (autowireInternal.containsKey(interfaze)) {
+ return;
+ }
+ List bindings = reference.getReferenceBindings();
+ if (bindings.size() == 0) {
+ return;
+ }
+ // pick the first binding until autowire allows multiple interfaces
+ InboundWire wire = bindings.get(0).getInboundWire();
+ if (!interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) {
+ String iName = interfaze.getName();
+ throw new InvalidAutowireInterface("Matching inbound wire not found for interface", iName);
+ }
+ autowireInternal.put(interfaze, wire);
+ }
+ }
+
+ protected void registerAutowireInternal(Class> interfaze, AtomicComponent component)
+ throws InvalidAutowireInterface {
+ if (interfaze == null) {
+ // The ServiceContract is not from Java
+ return;
+ }
+ if (component.isSystem()) {
+ if (systemAutowireInternal.containsKey(interfaze) || component.getInboundWires().size() == 0) {
+ return;
+ }
+ for (InboundWire wire : component.getInboundWires()) {
+ Class> clazz = wire.getServiceContract().getInterfaceClass();
+ if (clazz.isAssignableFrom(interfaze)) {
+ systemAutowireInternal.put(interfaze, wire);
+ return;
+ }
+ }
+ throw new InvalidAutowireInterface("Matching inbound wire not found for interface", interfaze.getName());
+ } else {
+ if (autowireInternal.containsKey(interfaze) || component.getInboundWires().size() == 0) {
+ return;
+ }
+ for (InboundWire wire : component.getInboundWires()) {
+ if (interfaze.isAssignableFrom(wire.getServiceContract().getInterfaceClass())) {
+ autowireInternal.put(interfaze, wire);
+ return;
+ }
+ }
+ throw new InvalidAutowireInterface("Matching inbound wire not found for interface", interfaze.getName());
+ }
+ }
+
+ protected void registerAutowire(CompositeComponent component) throws InvalidAutowireInterface {
+ if (component.isSystem()) {
+ // the composite is under the system hierarchy so only register its system services
+ Collection wires = component.getInboundSystemWires();
+ for (InboundWire wire : wires) {
+ Class> clazz = wire.getServiceContract().getInterfaceClass();
+ registerAutowireInternal(clazz, wire, true);
+ }
+
+ } else {
+ // the composite is under the application hierarchy so only register its non-system services
+ Collection wires = component.getInboundWires();
+ for (InboundWire wire : wires) {
+ Class> clazz = wire.getServiceContract().getInterfaceClass();
+ registerAutowireInternal(clazz, wire, false);
+ }
+ }
+ }
+
+ protected void registerAutowire(AtomicComponent component) throws InvalidAutowireInterface {
+ for (InboundWire wire : component.getInboundWires()) {
+ registerAutowireInternal(wire.getServiceContract().getInterfaceClass(), component);
+ }
+ }
+
+ protected void registerAutowire(Reference reference) throws InvalidAutowireInterface {
+ // TODO autowire should allow multiple interfaces
+ List bindings = reference.getReferenceBindings();
+ if (bindings.size() == 0) {
+ return;
+ }
+ // pick the first binding until autowire allows multiple interfaces
+ InboundWire wire = bindings.get(0).getInboundWire();
+ Class> clazz = wire.getServiceContract().getInterfaceClass();
+ registerAutowireInternal(clazz, reference);
+
+
+ }
+
+ protected void registerAutowire(Service service) throws InvalidAutowireInterface {
+ // TODO autowire should allow multiple interfaces
+ List bindings = service.getServiceBindings();
+ if (bindings.size() == 0) {
+ return;
+ }
+ // pick the first binding until autowire allows multiple interfaces
+ InboundWire wire = bindings.get(0).getInboundWire();
+ Class> clazz = wire.getServiceContract().getInterfaceClass();
+ registerAutowireExternal(clazz, service);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java
new file mode 100644
index 0000000000..a732b86184
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ContributionProcessorExtension.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.extension;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.deployer.ContributionProcessor;
+import org.apache.tuscany.spi.deployer.ContributionProcessorRegistry;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * The base class for ContributionProcessor implementations
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+@Service(ContributionProcessor.class)
+public abstract class ContributionProcessorExtension implements ContributionProcessor {
+ /**
+ * The ContributionProcessorRegistry that this processor should register with; usually set by injection. This registry may also be used to process
+ * other sub-artifacts.
+ */
+ protected ContributionProcessorRegistry registry;
+
+ /**
+ * @param registry the registry to set
+ */
+ @Autowire
+ public void setContributionProcessorRegistry(ContributionProcessorRegistry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Initialize the processor. It registers itself to the registry by content type it supports.
+ */
+ @Init
+ public void start() {
+ registry.register(this.getContentType(), this);
+ }
+
+ /**
+ * Destroy the processor. It unregisters itself from the registry.
+ */
+ @Destroy
+ public void stop() {
+ registry.unregister(this.getContentType());
+ }
+
+ /**
+ * Returns the content type that this implementation can handle.
+ *
+ * @return the content type that this implementation can handle
+ */
+ public abstract String getContentType();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ExecutionMonitor.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ExecutionMonitor.java
new file mode 100644
index 0000000000..fc6e5b7a14
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ExecutionMonitor.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.spi.extension;
+
+/**
+ * A monitor used to log events during an invocation
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface ExecutionMonitor {
+
+ /**
+ * Logs an exception thrown during an invocation
+ */
+ void executionError(Throwable e);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/GenericBuilderExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/GenericBuilderExtension.java
new file mode 100644
index 0000000000..42893682e0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/GenericBuilderExtension.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.spi.extension;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.builder.GenericBuilder;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * An extension point for generic builders which can deal with SCDL
+ * extensibility elements
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+@EagerInit
+public abstract class GenericBuilderExtension implements
+ GenericBuilder {
+
+ protected BuilderRegistry builderRegistry;
+
+ @Autowire
+ public void setBuilderRegistry(BuilderRegistry registry) {
+ this.builderRegistry = registry;
+ }
+
+ @Init
+ public void init() {
+ builderRegistry.register(getModelType(), this);
+ }
+
+ protected abstract Class getModelType();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.java
new file mode 100644
index 0000000000..d256ef1fdd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/LoaderExtension.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.spi.extension;
+
+import javax.xml.namespace.QName;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.EagerInit;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.StAXElementLoader;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * Support class for extending the Loader mechanism.
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+public abstract class LoaderExtension implements StAXElementLoader {
+ /**
+ * The LoaderRegistry that this loader should register with; usually set by injection. This registry may also be
+ * used to load sub-elements.
+ */
+ protected LoaderRegistry registry;
+
+ /**
+ * Constructor specifies the registry to register with.
+ *
+ * @param registry the LoaderRegistry this loader should register with
+ */
+ protected LoaderExtension(@Autowire LoaderRegistry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Initialize the loader. The base implementation registers this loader with the registry as a handler for the XML
+ * type returned by {@link #getXMLType()}. Implementations may override this to register the loader as a handler for
+ * multiple XML types.
+ */
+ @Init
+ public void start() {
+ registry.registerLoader(getXMLType(), this);
+ }
+
+ /**
+ * Destroy the loader. The base implementation unregisters the loader from the regsitry based on the type returned
+ * by {@link #getXMLType()}.
+ */
+ @Destroy
+ public void stop() {
+ registry.unregisterLoader(getXMLType(), this);
+ }
+
+ /**
+ * Returns the QName of the element that this implementation handles.
+ *
+ * @return the QName of the element that this implementation handles
+ */
+ public abstract QName getXMLType();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceBindingExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceBindingExtension.java
new file mode 100644
index 0000000000..1653e87dc2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ReferenceBindingExtension.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.ReferenceBinding;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * The default implementation of an SCA reference
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ReferenceBindingExtension extends AbstractSCAObject implements ReferenceBinding {
+ protected Reference reference;
+ protected InboundWire inboundWire;
+ protected OutboundWire outboundWire;
+ protected ServiceContract> bindingServiceContract;
+
+ protected ReferenceBindingExtension(String name, CompositeComponent parent) {
+ super(name, parent);
+ }
+
+ public Scope getScope() {
+ return Scope.SYSTEM;
+ }
+
+ public void setReference(Reference reference) {
+ this.reference = reference;
+ }
+
+ public void setInboundWire(InboundWire wire) {
+ this.inboundWire = wire;
+ }
+
+ public InboundWire getInboundWire() {
+ return inboundWire;
+ }
+
+ public OutboundWire getOutboundWire() {
+ return outboundWire;
+ }
+
+ public void setOutboundWire(OutboundWire outboundWire) {
+ this.outboundWire = outboundWire;
+ }
+
+ public ServiceContract> getBindingServiceContract() {
+ return bindingServiceContract;
+ }
+
+ @Override
+ public boolean isSystem() {
+ return reference != null && reference.isSystem();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceBindingExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceBindingExtension.java
new file mode 100644
index 0000000000..9e4be85406
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/ServiceBindingExtension.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import org.apache.tuscany.spi.CoreRuntimeException;
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.component.ServiceBinding;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * The default implementation of an SCA service
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class ServiceBindingExtension extends AbstractSCAObject implements ServiceBinding {
+ protected Service service;
+ protected InboundWire inboundWire;
+ protected OutboundWire outboundWire;
+ protected ServiceContract> bindingServiceContract;
+
+ public ServiceBindingExtension(String name, CompositeComponent parent) throws CoreRuntimeException {
+ super(name, parent);
+ }
+
+ public Scope getScope() {
+ return Scope.SYSTEM;
+ }
+
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ public InboundWire getInboundWire() {
+ return inboundWire;
+ }
+
+ public void setInboundWire(InboundWire wire) {
+ inboundWire = wire;
+ }
+
+ public OutboundWire getOutboundWire() {
+ return outboundWire;
+ }
+
+ public void setOutboundWire(OutboundWire outboundWire) {
+ this.outboundWire = outboundWire;
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation)
+ throws TargetInvokerCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServiceContract> getBindingServiceContract() {
+ return bindingServiceContract;
+ }
+
+ @Override
+ public boolean isSystem() {
+ return service != null && service.isSystem();
+ }
+
+ public boolean allowsPassByReference() {
+ return false;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.java
new file mode 100644
index 0000000000..6c502702e9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/SystemAtomicComponentExtension.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.spi.extension;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class SystemAtomicComponentExtension extends AtomicComponentExtension {
+
+ public SystemAtomicComponentExtension(String name,
+ CompositeComponent parent,
+ int initLevel) {
+ super(name, parent, null, null, null, null, initLevel);
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation, InboundWire callbackWire) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSystem() {
+ return true;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java
new file mode 100644
index 0000000000..88949646ff
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/extension/TargetInvokerExtension.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.extension;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.LinkedList;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * The default implementation of a TargetInvoker
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class TargetInvokerExtension implements TargetInvoker {
+
+ protected InboundWire wire;
+ protected WorkContext workContext;
+ protected ExecutionMonitor monitor;
+ protected boolean cacheable;
+
+ /**
+ * Creates a new invoker
+ *
+ * @param wire the callback wire
+ * @param workContext the work context to use for setting correlation information
+ * @param monitor the event monitor
+ */
+ public TargetInvokerExtension(InboundWire wire, WorkContext workContext, ExecutionMonitor monitor) {
+ this.wire = wire;
+ this.workContext = workContext;
+ this.monitor = monitor;
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ try {
+ Object messageId = msg.getMessageId();
+ if (messageId != null) {
+ workContext.setCurrentCorrelationId(messageId);
+ }
+ if (wire != null) {
+ LinkedList callbackRoutingChain = msg.getCallbackRoutingChain();
+ if (callbackRoutingChain != null) {
+ workContext.setCurrentCallbackRoutingChain(callbackRoutingChain);
+ }
+ }
+ Object resp = invokeTarget(msg.getBody(), msg.getConversationSequence());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setBodyWithFault(e.getCause());
+ }
+ return msg;
+ }
+
+ public boolean isCacheable() {
+ return cacheable;
+ }
+
+ public void setCacheable(boolean cacheable) {
+ this.cacheable = cacheable;
+ }
+
+ public boolean isOptimizable() {
+ return isCacheable();
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ // TargetInvoker extends Cloneable so this should not have been thrown
+ throw new AssertionError(e);
+ }
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHost.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHost.java
new file mode 100644
index 0000000000..b273ec6729
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/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.spi.host;
+
+/**
+ * Interface implemented by host environments that allow for resolution of component implementation resources, e.g.
+ * items bound in a JNDI tree.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ResourceHost {
+
+ /**
+ * Resolve a resource matching the given type
+ *
+ * @param type the type of the resources
+ * @throws ResourceResolutionException if an error is encountered during resolution
+ */
+ T resolveResource(Class type) throws ResourceResolutionException;
+
+ /**
+ * Resolve a resource matching the given type and name
+ *
+ * @param type the type of the resources
+ * @param mappedName the mapped name of the resource
+ * @throws ResourceResolutionException if an error is encountered during resolution
+ */
+ T resolveResource(Class type, String mappedName) throws ResourceResolutionException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHostRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHostRegistry.java
new file mode 100644
index 0000000000..b4964cce3b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceHostRegistry.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.spi.host;
+
+/**
+ * Implementations manage a registry of resources and resource hosts in the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ResourceHostRegistry {
+ /**
+ * Registers a resource host for the given uri prefix
+ *
+ * @param uri the uri prefix the host resolves resources for
+ * @param host the resource host
+ */
+ void registerResourceHost(String uri, ResourceHost host);
+
+ /**
+ * Removes a resource host registered for the given uri prefix
+ */
+ void unregisterResourceHost(String uri);
+
+ /**
+ * Register a resource by type
+ *
+ * @param type the type of the resource
+ * @param resource the resource
+ */
+ void registerResource(Class> type, Object resource);
+
+ /**
+ * Register a resource by type and name
+ *
+ * @param type the type of the resource
+ * @param name the mapped resource name
+ * @param resource the resource
+ */
+ void registerResource(Class> type, String name, Object resource);
+
+ /**
+ * Unregister a resource
+ *
+ * @param type the type the resource was registered with
+ * @param name the mapped name the resource was registered with
+ */
+ void unregisterResource(Class> type, String name);
+
+ /**
+ * Unregister a resource
+ *
+ * @param type the type the resource was registered with
+ */
+ void unregisterResource(Class> type);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceResolutionException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceResolutionException.java
new file mode 100644
index 0000000000..23c18f5115
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ResourceResolutionException.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.spi.host;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ResourceResolutionException extends TuscanyException {
+
+ public ResourceResolutionException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java
new file mode 100644
index 0000000000..37937808d4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/host/ServletHost.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.host;
+
+import javax.servlet.Servlet;
+
+/**
+ * Interface implemented by host environments that allow Servlets to be registered.
+ *
+ * This interface allows an SCA system service to register a servlet to handle inbound requests.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ServletHost {
+ /**
+ * Register a mapping for an instance of a Servlet. This requests that the servlet container direct all requests to
+ * the designated mapping to the supplied Servlet instance.
+ *
+ * @param mapping the uri-mapping for the Servlet
+ * @param servlet the Servlet that should be invoked
+ */
+ void registerMapping(String mapping, Servlet servlet);
+
+ /**
+ * Unregister a servlet mapping. This directs the servlet contain not to direct any more requests to a previously
+ * registered Servlet.
+ *
+ * @param mapping the uri-mapping for the Servlet
+ * @return the servlet that was registered to the mapping, null if nothing was registered to the mapping
+ */
+ Servlet unregisterMapping(String mapping);
+
+ /**
+ * Check to see if a mapping exists.
+ *
+ * @param mapping the uri-mapping for the Servlet
+ * @return true if mapping is registered, false otherwise
+ */
+ boolean isMappingRegistered(String mapping);
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.java
new file mode 100644
index 0000000000..5a0bd3bb5f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ElementInfo.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.spi.idl;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema elements
+ */
+public class ElementInfo {
+ private QName name;
+ private TypeInfo type;
+
+ /**
+ * @param name
+ * @param type
+ */
+ public ElementInfo(QName name, TypeInfo type) {
+ super();
+ this.name = name;
+ this.type = type;
+ }
+
+ /**
+ * @return the name
+ */
+ public QName getQName() {
+ return name;
+ }
+
+ /**
+ * @return the type
+ */
+ public TypeInfo getType() {
+ return type;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidConversationalOperationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidConversationalOperationException.java
new file mode 100644
index 0000000000..e2b4acec24
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidConversationalOperationException.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.spi.idl;
+
+import java.lang.reflect.Method;
+
+/**
+ * Denotes an invalid conversational interface definition
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidConversationalOperationException extends InvalidServiceContractException {
+ private final Method operation;
+
+ public InvalidConversationalOperationException(String message, String identifier, Method operation) {
+ super(message, identifier);
+ this.operation = operation;
+ }
+
+ public Method getOperation() {
+ return operation;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.java
new file mode 100644
index 0000000000..e977592df0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/InvalidServiceContractException.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.spi.idl;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class InvalidServiceContractException extends TuscanyException {
+
+ public InvalidServiceContractException() {
+ }
+
+ public InvalidServiceContractException(String message) {
+ super(message);
+ }
+
+ protected InvalidServiceContractException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public InvalidServiceContractException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ protected InvalidServiceContractException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public InvalidServiceContractException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.java
new file mode 100644
index 0000000000..b1d4cb4e7c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/OverloadedOperationException.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.spi.idl;
+
+import java.lang.reflect.Method;
+
+/**
+ * Exception thrown to indicate that a service contract specification contains an overloaded method.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OverloadedOperationException extends InvalidServiceContractException {
+ private static final long serialVersionUID = -4658711318608885638L;
+ private final Method operation;
+
+ public OverloadedOperationException(Method operation) {
+ super(null, operation.getDeclaringClass().getName());
+ this.operation = operation;
+ }
+
+ public Method getOperation() {
+ return operation;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ServiceFaultException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ServiceFaultException.java
new file mode 100644
index 0000000000..1c8a8c81e9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/ServiceFaultException.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.idl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * The generic java exception to wrap service faults
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceFaultException extends TuscanyException {
+ private static final long serialVersionUID = -8002583655240625792L;
+ private Object faultInfo;
+ private QName logical;
+
+ /**
+ * @param message
+ * @param faultInfo
+ */
+ public ServiceFaultException(String message, Object faultInfo) {
+ super(message);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @param message
+ * @param faultInfo
+ * @param cause
+ */
+ public ServiceFaultException(String message, Object faultInfo, Throwable cause) {
+ super(message, cause);
+ this.faultInfo = faultInfo;
+ }
+
+ /**
+ * @return the faultInfo
+ */
+ public Object getFaultInfo() {
+ return faultInfo;
+ }
+
+ public QName getLogical() {
+ return logical;
+ }
+
+ public void setLogical(QName logical) {
+ this.logical = logical;
+ }
+
+ public boolean isMatchingType(Object type) {
+ if (logical == null)
+ return false;
+
+ if ((type instanceof QName) && logical.equals(type)) {
+ return true;
+ }
+ if (type instanceof XMLType && logical.equals(((XMLType)type).getElementName()))
+ return true;
+ return false;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.java
new file mode 100644
index 0000000000..9bb107812c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/TypeInfo.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.spi.idl;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema types
+ */
+public class TypeInfo {
+ private QName name;
+
+ private boolean isSimpleType;
+
+ private TypeInfo baseType;
+
+ /**
+ * @param name
+ * @param isSimpleType
+ */
+ public TypeInfo(QName name, boolean isSimpleType, TypeInfo baseType) {
+ super();
+ this.name = name;
+ this.isSimpleType = isSimpleType;
+ this.baseType = baseType;
+ }
+
+ /**
+ * @return the isSimpleType
+ */
+ public boolean isSimpleType() {
+ return isSimpleType;
+ }
+
+ /**
+ * @return the name
+ */
+ public QName getQName() {
+ return name;
+ }
+
+ /**
+ * @return the baseType
+ */
+ public TypeInfo getBaseType() {
+ return baseType;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/XMLType.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/XMLType.java
new file mode 100644
index 0000000000..1d626516b0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/XMLType.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.idl;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The metadata for an XML element or type
+ */
+public class XMLType {
+ public static final XMLType UNKNOWN = new XMLType(null, null);
+ private QName element;
+ private QName type;
+
+ /**
+ * @param element
+ */
+ public XMLType(ElementInfo element) {
+ super();
+ this.element = element.getQName();
+ if (element.getType() != null) {
+ this.type = element.getType().getQName();
+ }
+ }
+
+ /**
+ * @param element
+ */
+ public XMLType(TypeInfo type) {
+ this.element = null;
+ this.type = type.getQName();
+ }
+
+ public XMLType(QName element, QName type) {
+ this.element = element;
+ this.type = type;
+ }
+
+ /**
+ * @return the type
+ */
+ public QName getTypeName() {
+ return type;
+ }
+
+ public boolean isElement() {
+ return element != null;
+ }
+
+ public QName getElementName() {
+ return element;
+ }
+
+ public static XMLType getType(QName type) {
+ return new XMLType(null, type);
+ }
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((element == null) ? 0 : element.hashCode());
+ result = PRIME * result + ((type == null) ? 0 : type.hashCode());
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final XMLType other = (XMLType)obj;
+ if (element == null) {
+ if (other.element != null) {
+ return false;
+ }
+ } else if (!element.equals(other.element)) {
+ return false;
+ }
+ if (type == null) {
+ if (other.type != null) {
+ return false;
+ }
+ } else if (!type.equals(other.type)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Element: " + element + " Type: " + type;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.java
new file mode 100644
index 0000000000..9701b08df1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/InterfaceJavaIntrospector.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.spi.idl.java;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+
+/**
+ * Processor for creating JavaServiceContract definitions from Java Classes.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface InterfaceJavaIntrospector {
+
+ /**
+ * Introspect a Java interface and return a service contract definition.
+ *
+ * @param type the interface to inspect
+ * @return a JavaServiceContract corresponding to the Java interface
+ */
+ JavaServiceContract introspect(Class type) throws InvalidServiceContractException;
+
+ /**
+ * Introspect a Java interface and return a service contract definition.
+ *
+ * @param type the interface to inspect
+ * @param deep Indicate if deep introspection is required
+ * @return a JavaServiceContract corresponding to the Java interface
+ */
+ JavaServiceContract introspect(Class type, boolean deep) throws InvalidServiceContractException;
+
+ /**
+ * Introspect a Java interface and return a service contract definition.
+ *
+ * @param type the interface to inspect
+ * @param callback the callback interface to inspec
+ * @param deep Indicate if deep introspection is required
+ * @return a JavaServiceContract corresponding to the Java interface
+ */
+ JavaServiceContract introspect(Class type, Class callback, boolean deep)
+ throws InvalidServiceContractException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java
new file mode 100644
index 0000000000..17fcd8d4a3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaIDLUtils.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.idl.java;
+
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * Contains methods for mapping between an operation in a {@link org.apache.tuscany.spi.model.ServiceContract} and a
+ * method defined by a Java interface
+ *
+ * @version $Rev$ $Date$
+ */
+public final class JavaIDLUtils {
+
+ private JavaIDLUtils() {
+ }
+
+ /**
+ * Searches an array of methods for a match against the given operation
+ *
+ * @param operation the operation to match
+ * @param methods the methods to match against
+ * @return a matching method or null
+ */
+ public static Method findMethod(Operation> operation, Method[] methods) {
+ for (Method method : methods) {
+ if (match(operation, method)) {
+ return method;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Searches a collection of operations for a match against the given method
+ *
+ * @param method the method to match
+ * @param operations the operations to match against
+ * @return a matching operation or null
+ */
+ public static Operation findOperation(Method method, Collection> operations) {
+ for (Operation> operation : operations) {
+ if (match(operation, method)) {
+ return operation;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Determines if the given operation matches the given method
+ *
+ * @return true if the operation matches, false if does not
+ */
+ private static boolean match(Operation operation, Method method) {
+ // TODO: TUSCANY-1111, comparing different IDLs fail so use simple name
+ // matching
+ ServiceContract contract = operation.getServiceContract();
+ if (contract != null && contract.isRemotable()) {
+ // No method overloading for remotable interfaces
+ return operation.getName().equals(method.getName());
+ }
+ Class>[] params = method.getParameterTypes();
+ DataType>> inputType = operation.getInputType();
+ List> types = inputType.getLogical();
+ boolean found = true;
+ if (types.size() == params.length && method.getName().equals(operation.getName())) {
+ for (int i = 0; i < params.length; i++) {
+ Class> clazz = params[i];
+ if (!clazz.equals(operation.getInputType().getLogical().get(i).getPhysical())) {
+ found = false;
+ }
+ }
+ } else {
+ found = false;
+ }
+ return found;
+
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.java
new file mode 100644
index 0000000000..afe98f0773
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessor.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.spi.idl.java;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+
+/**
+ * Implementations introspect metadata on a Java interface, populating the
+ * corresponding {@link JavaServiceContract}
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaInterfaceProcessor {
+
+ void visitInterface(Class> clazz, Class> callbackClass, JavaServiceContract contract)
+ throws InvalidServiceContractException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.java
new file mode 100644
index 0000000000..950ce1858c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorExtension.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.spi.idl.java;
+
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+
+/**
+ * A convenience class for JavaInterfaceProcessor
extensions that performs autowiring
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+public abstract class JavaInterfaceProcessorExtension implements JavaInterfaceProcessor {
+
+ protected JavaInterfaceProcessorRegistry registry;
+
+ @Autowire
+ public void setRegistry(JavaInterfaceProcessorRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init
+ public void init() {
+ registry.registerProcessor(this);
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.java
new file mode 100644
index 0000000000..38c64e6f88
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaInterfaceProcessorRegistry.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.spi.idl.java;
+
+/**
+ * A registry of {@link JavaInterfaceProcessor}s. Interface processors update a service contract definition based on a
+ * Java interface
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaInterfaceProcessorRegistry extends InterfaceJavaIntrospector {
+
+ /**
+ * Registers the given processor
+ */
+ void registerProcessor(JavaInterfaceProcessor processor);
+
+ /**
+ * Deregisters the given processor
+ */
+ void unregisterProcessor(JavaInterfaceProcessor processor);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.java
new file mode 100644
index 0000000000..ee29846e26
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/idl/java/JavaServiceContract.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.spi.idl.java;
+
+import java.lang.reflect.Type;
+
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * Represents a service contract specified using a Java interface
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaServiceContract extends ServiceContract {
+
+ public JavaServiceContract() {
+ }
+
+ public JavaServiceContract(Class> interfaceClass) {
+ super(interfaceClass);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java
new file mode 100644
index 0000000000..b0682bc778
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessor.java
@@ -0,0 +1,205 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.tuscany.api.annotation.DataType;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Base class for ImplementationProcessors that handle annotations that add Properties.
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractPropertyProcessor extends ImplementationProcessorExtension {
+ private final Class annotationClass;
+ private ImplementationProcessorService service;
+
+ protected AbstractPropertyProcessor(Class annotationClass, ImplementationProcessorService service) {
+ this.annotationClass = annotationClass;
+ this.service = service;
+ }
+
+ public void visitMethod(CompositeComponent parent,
+ Method method,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException {
+ A annotation = method.getAnnotation(annotationClass);
+ if (annotation == null) {
+ return;
+ }
+
+ if (!Void.TYPE.equals(method.getReturnType())) {
+ throw new IllegalPropertyException("Method does not have void return type", method.toString());
+ }
+ Class[] paramTypes = method.getParameterTypes();
+ if (paramTypes.length != 1) {
+ throw new IllegalPropertyException("Method must have a single parameter", method.toString());
+ }
+ Class> javaType = paramTypes[0];
+
+ String name = getName(annotation);
+ if (name == null || name.length() == 0) {
+ name = method.getName();
+ if (name.startsWith("set")) {
+ name = toPropertyName(method.getName());
+ }
+ }
+
+ Map> properties = type.getProperties();
+ if (properties.containsKey(name)) {
+ throw new DuplicatePropertyException(name);
+ }
+
+ Class> baseType = getBaseType(javaType, method.getGenericParameterTypes()[0]);
+ JavaMappedProperty> property = createProperty(name, baseType, method);
+ if (javaType.isArray() || Collection.class.isAssignableFrom(javaType)) {
+ property.setMany(true);
+ }
+
+ //add databinding available as annotations, as extensions
+ DataType propertyDataBinding = method.getAnnotation(DataType.class);
+ if (propertyDataBinding != null) {
+ property.getExtensions().put(DataBinding.class.getName(), propertyDataBinding.name());
+ }
+ initProperty(property, annotation, parent, context);
+ properties.put(name, property);
+ }
+
+ public void visitField(CompositeComponent parent,
+ Field field,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException {
+
+ A annotation = field.getAnnotation(annotationClass);
+ if (annotation == null) {
+ return;
+ }
+
+ Class> javaType = field.getType();
+
+ String name = getName(annotation);
+ if (name == null || name.length() == 0) {
+ name = field.getName();
+ }
+
+ Map> properties = type.getProperties();
+ if (properties.containsKey(name)) {
+ throw new DuplicatePropertyException(name);
+ }
+
+ Class> baseType = getBaseType(javaType, field.getGenericType());
+ JavaMappedProperty> property = createProperty(name, baseType, field);
+ if (javaType.isArray() || Collection.class.isAssignableFrom(javaType)) {
+ property.setMany(true);
+ }
+
+ //add databinding available as annotations, as extensions
+ DataType propertyDataBinding = field.getAnnotation(DataType.class);
+ if (propertyDataBinding != null) {
+ property.getExtensions().put(DataBinding.class.getName(), propertyDataBinding.name());
+ }
+
+ initProperty(property, annotation, parent, context);
+ properties.put(name, property);
+ }
+
+ public void visitConstructor(CompositeComponent parent, Constructor constructor,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException {
+
+ ConstructorDefinition> definition = type.getConstructorDefinition();
+ Class[] params = constructor.getParameterTypes();
+ Map> properties = type.getProperties();
+ Annotation[][] annotations = constructor.getParameterAnnotations();
+
+ for (int i = 0; i < params.length; i++) {
+ Class> param = params[i];
+ Annotation[] paramAnnotations = annotations[i];
+ JavaMappedProperty> property = null;
+ DataType propertyDataBinding = null;
+ A monitorAnnot = null;
+ String name = null;
+ for (Annotation annotation : paramAnnotations) {
+ if (annotation.annotationType().equals(annotationClass)) {
+ if (definition == null) {
+ definition = new ConstructorDefinition(constructor);
+ type.setConstructorDefinition(definition);
+ }
+ monitorAnnot = annotationClass.cast(annotation);
+ name = getName(monitorAnnot);
+ if (name == null || name.length() == 0) {
+ name = param.getName();
+ }
+
+ Class> baseType = getBaseType(param, constructor.getGenericParameterTypes()[i]);
+ //JavaMappedProperty> property = createProperty(name, baseType, constructor);
+ property = createProperty(name, baseType, constructor);
+ if (param.isArray() || Collection.class.isAssignableFrom(param)) {
+ property.setMany(true);
+ }
+ } else if (annotation.annotationType().equals(DataType.class)) {
+ //if there is databinding information capture it
+ propertyDataBinding = DataType.class.cast(annotation);
+ }
+ }
+ //if there has been a property annotation then a property would have been created
+ if (property != null) {
+ initProperty(property, monitorAnnot, parent, context);
+ properties.put(name, property);
+ service.addName(definition.getInjectionNames(), i, name);
+ if (propertyDataBinding != null) {
+ property.getExtensions().put(DataBinding.class.getName(), propertyDataBinding.name());
+ }
+ }
+ }
+ }
+
+ protected abstract String getName(A annotation);
+
+ protected void initProperty(JavaMappedProperty property,
+ A annotation,
+ CompositeComponent parent,
+ DeploymentContext context) throws ProcessingException {
+ }
+
+ protected JavaMappedProperty createProperty(String name, Class javaType, Member member)
+ throws ProcessingException {
+ return new JavaMappedProperty(name, null, javaType, member);
+ }
+
+
+ public static String toPropertyName(String name) {
+ if (!name.startsWith("set")) {
+ return name;
+ }
+ return Character.toLowerCase(name.charAt(3)) + name.substring(4);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.java
new file mode 100644
index 0000000000..94c185966f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ConstructorDefinition.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.spi.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Hold injection information for the constructor used to instantiate a component implementation instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class ConstructorDefinition {
+
+ private Constructor constructor;
+ private List injectionNames;
+
+ public ConstructorDefinition(Constructor constructor) {
+ this.constructor = constructor;
+ injectionNames = new ArrayList();
+ }
+
+ public Constructor getConstructor() {
+ return constructor;
+ }
+
+ public List getInjectionNames() {
+ return injectionNames;
+ }
+
+ public void setInjectionNames(List injectionNames) {
+ this.injectionNames = injectionNames;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.java
new file mode 100644
index 0000000000..87c4074fe7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/DuplicatePropertyException.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.spi.implementation.java;
+
+/**
+ * Thrown when an implementation has more than one property injection site with the same name
+ *
+ * @version $Rev$ $Date$
+ */
+public class DuplicatePropertyException extends ProcessingException {
+
+ public DuplicatePropertyException(String message) {
+ super(message);
+ }
+
+ public DuplicatePropertyException(String message, String identifier) {
+ super(message, identifier);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.java
new file mode 100644
index 0000000000..f251f60630
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IllegalPropertyException.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.spi.implementation.java;
+
+/**
+ * Denotes an illegal property definition in a component type
+ *
+ * @version $Rev$ $Date$
+ */
+public class IllegalPropertyException extends ProcessingException {
+
+ public IllegalPropertyException(String message) {
+ super(message);
+ }
+
+
+ public IllegalPropertyException(String message, String identifier) {
+ super(message, identifier);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java
new file mode 100644
index 0000000000..fb9beca53c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessor.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Implementations process class-level metadata, typically parsing annotations and updating the corresponding
+ * ComponentType
. A processor may, for example, create a {@link JavaMappedProperty} which is responsible
+ * for injecting a complex type on a component implementation instance when it is instantiated.
+ *
+ * Processors will receive callbacks as the implementation class is walked while evalauting an assembly. It is the
+ * responsibility of the parser to determine whether to perform an action during the callback.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ImplementationProcessor {
+
+ /**
+ * A callback received when the component implementation class is first loaded
+ *
+ * @param parent the parent composite
+ * @param clazz the component implementation class
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ void visitClass(CompositeComponent parent,
+ Class clazz,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation class hierarchy is evaluated
+ *
+ * @param parent the parent composite
+ * @param clazz the superclass in the component implmentation's class hierarchy
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ void visitSuperClass(CompositeComponent parent,
+ Class clazz,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation's public and protected methods are evaluated
+ *
+ * @param parent the parent composite
+ * @param method the current public or protected method being evaluated
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ void visitMethod(CompositeComponent parent,
+ Method method,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation's constructor used for instantiation by the runtime is
+ * evaluated. If an implementation contains more than one constructor, the constructor passed to the callback will
+ * be chosen according to the algorithm described in the SCA Java Client and Implementation Model Specification.
+ *
+ * @param parent the parent composite
+ * @param constructor the constructor used for instantiating component implementation instances
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ void visitConstructor(CompositeComponent parent,
+ Constructor constructor,
+ PojoComponentType> type,
+ DeploymentContext context)
+ throws ProcessingException;
+
+ /**
+ * A callback received as the component implementation's public and protected fields are evaluated
+ *
+ * @param parent the parent composite
+ * @param field the current public or protected field being evaluated
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ void visitField(CompositeComponent parent,
+ Field field,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException;
+
+ /**
+ * The final callback received when all other callbacks during evaluation of the component implementation have been
+ * issued
+ *
+ * @param parent the parent composite
+ * @param clazz the component implementation class
+ * @param type the incomplete component type associated with the implementation class
+ * @param context the current deployment context
+ * @throws ProcessingException if an error is encountered while processing metadata
+ */
+ void visitEnd(CompositeComponent parent,
+ Class clazz,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.java
new file mode 100644
index 0000000000..fc1b6cd4fe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorExtension.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.spi.implementation.java;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Collection;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Init;
+
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * A convenience class for annotation processors which alleviates the need to implement unused callbacks
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+public abstract class ImplementationProcessorExtension implements ImplementationProcessor {
+ private IntrospectionRegistry registry;
+
+ @Autowire
+ public void setRegistry(IntrospectionRegistry registry) {
+ this.registry = registry;
+ }
+
+ @Init
+ public void init() {
+ registry.registerProcessor(this);
+ }
+
+ @Destroy
+ public void destroy() {
+ registry.unregisterProcessor(this);
+ }
+
+ public void visitClass(CompositeComponent parent, Class clazz,
+ PojoComponentType> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ }
+
+ public void visitSuperClass(CompositeComponent parent, Class clazz,
+ PojoComponentType> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ }
+
+ public void visitMethod(CompositeComponent parent, Method method,
+ PojoComponentType> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ }
+
+ public void visitConstructor(CompositeComponent parent, Constructor constructor,
+ PojoComponentType> type,
+ DeploymentContext context)
+ throws ProcessingException {
+ }
+
+ public void visitField(CompositeComponent parent, Field field,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException {
+ }
+
+ public void visitEnd(CompositeComponent parent, Class clazz,
+ PojoComponentType> type,
+ DeploymentContext context) throws ProcessingException {
+
+ }
+
+ protected static Class> getBaseType(Class> cls, Type genericType) {
+ if (cls.isArray()) {
+ return cls.getComponentType();
+ } else if (Collection.class.isAssignableFrom(cls)) {
+ if (genericType == cls) {
+ return Object.class;
+ } else {
+ ParameterizedType parameterizedType = (ParameterizedType)genericType;
+ Type baseType = parameterizedType.getActualTypeArguments()[0];
+ if (baseType instanceof Class) {
+ return (Class>)baseType;
+ } else if (baseType instanceof ParameterizedType) {
+ return (Class>)((ParameterizedType)baseType).getRawType();
+ } else {
+ return null;
+ }
+ }
+ } else {
+ return cls;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java
new file mode 100644
index 0000000000..d37a39011f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ImplementationProcessorService.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+import java.util.List;
+
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * Provides utility methods for Java implementation processing
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ImplementationProcessorService {
+
+ /**
+ * Introspects the given interface to produce a mapped service
+ */
+ JavaMappedService createService(Class> interfaze) throws InvalidServiceContractException;
+
+ JavaMappedReference createReference(String name, Member member, Class> paramType) throws ProcessingException;
+
+ /**
+ * Processes the callback contract for a given interface type
+ *
+ * @param interfaze the interface type to examine
+ * @param contract the service contract the callback is associated wth
+ * @throws InvalidServiceContractException
+ *
+ */
+ void processCallback(Class> interfaze, ServiceContract> contract) throws InvalidServiceContractException;
+
+ /**
+ * Determines if all the members of a collection have unique types
+ *
+ * @param collection the collection to analyze
+ * @return true if the types are unique
+ */
+ boolean areUnique(Class[] collection);
+
+ /**
+ * Inserts a name at the specified position, paddiling the list if its size is less than the position
+ */
+ void addName(List names, int pos, String name);
+
+ /**
+ * Processes a constructor parameter by introspecting its annotations
+ *
+ * @param param the parameter to process
+ * @param genericParam the generic type of the parameter
+ * @param paramAnnotations the parameter annotations
+ * @param constructorNames the array of constructorNames specified by
+ * @param pos the declaration position of the constructor parameter
+ * @param type the component type associated with implementation being reflected
+ * @param injectionNames the list of parameter constructorNames specified on parameter annotations
+ * @throws ProcessingException
+ */
+ boolean processParam(Class> param,
+ Type genericParam,
+ Annotation[] paramAnnotations,
+ String[] constructorNames,
+ int pos,
+ PojoComponentType> type,
+ List injectionNames) throws ProcessingException;
+
+ /**
+ * Returns true if {@link @Autowire}, {@link @Property}, or {@link @Reference} are present in the given array
+ */
+ boolean injectionAnnotationsPresent(Annotation[][] annots);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.java
new file mode 100644
index 0000000000..a6122a6ff1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/IntrospectionRegistry.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.spi.implementation.java;
+
+/**
+ * A system service which tracks {@link ImplementationProcessor}s
+ *
+ * @version $Rev$ $Date$
+ */
+public interface IntrospectionRegistry extends Introspector {
+
+ /**
+ * Registers the given processor and makes it available during assembly evaluation (i.e. build)
+ */
+ void registerProcessor(ImplementationProcessor processor);
+
+ /**
+ * Deregisters the given processor
+ */
+ void unregisterProcessor(ImplementationProcessor processor);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.java
new file mode 100644
index 0000000000..66abc1f686
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Introspector.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.spi.implementation.java;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+/**
+ * Implementations are responsible for walking a component implementation class, adding additional component type
+ * information as appropriate
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Introspector {
+
+ /**
+ * Walks the given component implementation class
+ *
+ * @param parent the parent composite
+ * @param clazz the component implementation class
+ * @param type the component type associated with the implementation class
+ * @return the updated component type
+ * @throws ProcessingException if an error is encountered evaluating the implementation class
+ */
+ PojoComponentType introspect(CompositeComponent parent,
+ Class> clazz,
+ PojoComponentType> type,
+ DeploymentContext context)
+ throws ProcessingException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.java
new file mode 100644
index 0000000000..34ac8f53f9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedComponentType.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.spi.implementation.java;
+
+import org.apache.tuscany.spi.model.ComponentType;
+
+/**
+ * A specialized component type definition whose services, references and properties can be mapped to the Java
+ * programming model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaMappedComponentType<
+ S extends JavaMappedService,
+ R extends JavaMappedReference,
+ P extends JavaMappedProperty>
+ > extends ComponentType {
+
+ private Class> implClass;
+
+ public JavaMappedComponentType() {
+ }
+
+ public JavaMappedComponentType(Class> implClass) {
+ this.implClass = implClass;
+ }
+
+ /**
+ * Returns the implementation class associated with this component type.
+ *
+ * @return the implementation class associated with this component type
+ */
+ public Class> getImplClass() {
+ return implClass;
+ }
+
+ /**
+ * Sets the implementation class associated with this component type.
+ *
+ * @param implClass the implementation class associated with this component type
+ */
+ public void setImplClass(Class> implClass) {
+ this.implClass = implClass;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.java
new file mode 100644
index 0000000000..6d1715a035
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedProperty.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.spi.implementation.java;
+
+import java.lang.reflect.Member;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.model.Property;
+
+/**
+ * A Property definition that is mapped to a specific location in the implementation class. This location will typically
+ * be used to inject property values.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaMappedProperty extends Property {
+ private Member member;
+
+ public JavaMappedProperty() {
+ }
+
+ public JavaMappedProperty(String name, QName xmlType, Class javaType) {
+ super(name, xmlType, javaType);
+ }
+
+ public JavaMappedProperty(String name, QName xmlType, Class javaType, Member member) {
+ super(name, xmlType, javaType);
+ this.member = member;
+ }
+
+ /**
+ * Returns the Member that this property is mapped to.
+ *
+ * @return the Member that this property is mapped to
+ */
+ public Member getMember() {
+ return member;
+ }
+
+ /**
+ * Sets the Member that this property is mapped to
+ *
+ * @param member the Member that this property is mapped to
+ */
+ public void setMember(Member member) {
+ this.member = member;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.java
new file mode 100644
index 0000000000..edcbf9a281
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedReference.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.spi.implementation.java;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.spi.model.ComponentTypeReferenceDefinition;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+/**
+ * A ReferenceDefinition definition that is mapped to a specific location in the implementation class. This location
+ * will typically be used to inject reference values.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaMappedReference extends ComponentTypeReferenceDefinition {
+ private Member member;
+
+ public JavaMappedReference() {
+ }
+
+ public JavaMappedReference(String name, ServiceContract serviceContract, Member member) {
+ super(name, serviceContract);
+ this.member = member;
+ }
+
+ /**
+ * Returns the Member that this reference is mapped to.
+ *
+ * @return the Member that this reference is mapped to
+ */
+ public Member getMember() {
+ return member;
+ }
+
+ /**
+ * Sets the Member that this reference is mapped to
+ *
+ * @param member the Member that this reference is mapped to
+ */
+ public void setMember(Member member) {
+ this.member = member;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java
new file mode 100644
index 0000000000..ee5e0bb2a7
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/JavaMappedService.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * A ServiceDefinition definition that is mapped to a Java interface. The mapped interface is not required to be the
+ * same as the interface specified in the service contract. This is to allow the service contract to be specified using
+ * different interface definition languages or, in the case were the IDL is Java, to allow the service definition to be
+ * loaded from a different classloader.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaMappedService extends ServiceDefinition {
+ private Class> serviceInterface;
+ private Member callbackMember;
+
+ public JavaMappedService() {
+ }
+
+ public JavaMappedService(Class> serviceInterface) {
+ this.serviceInterface = serviceInterface;
+ }
+
+ public JavaMappedService(String name, ServiceContract contract, boolean remotable) {
+ super(name, contract, remotable);
+ }
+
+ public JavaMappedService(String name,
+ ServiceContract contract,
+ boolean remotable,
+ String callbackRefName,
+ Member callbackMember) {
+ super(name, contract, remotable, callbackRefName);
+ this.callbackMember = callbackMember;
+ }
+
+ public JavaMappedService(String name, ServiceContract contract, Class> serviceInterface, boolean remotable) {
+ super(name, contract, remotable);
+ this.serviceInterface = serviceInterface;
+ }
+
+ /**
+ * Returns the Java interface for this service. This may be different from the interface that defines the service
+ * contract.
+ *
+ * @return the Java interface for this service
+ */
+ public Class> getServiceInterface() {
+ return serviceInterface;
+ }
+
+ /**
+ * Sets the Java interface for this service. This may be different from the interface used to define the service
+ * contract.
+ *
+ * @param serviceInterface the Java interface for this service
+ */
+ public void setServiceInterface(Class> serviceInterface) {
+ this.serviceInterface = serviceInterface;
+ }
+
+ public Member getCallbackMember() {
+ return callbackMember;
+ }
+
+ public void setCallbackMember(Member callbackMember) {
+ this.callbackMember = callbackMember;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java
new file mode 100644
index 0000000000..2c0ff57b7c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/PojoComponentType.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.ComponentType;
+import org.apache.tuscany.spi.model.ComponentTypeReferenceDefinition;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+/**
+ * A component type specialization for POJO implementations
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public class PojoComponentType>
+ extends ComponentType {
+ private boolean allowsPassByReference;
+ private ConstructorDefinition> constructorDefinition;
+ private Method initMethod;
+ private Method destroyMethod;
+ private final Map resources = new HashMap();
+ private Member conversationIDMember;
+ private List passByReferenceMethods = new ArrayList();
+
+ /**
+ * Returns the constructor used to instantiate implementation instances
+ */
+ public ConstructorDefinition> getConstructorDefinition() {
+ return constructorDefinition;
+ }
+
+ /**
+ * Sets the constructor used to instantiate implementation instances
+ */
+ public void setConstructorDefinition(ConstructorDefinition> definition) {
+ this.constructorDefinition = definition;
+ }
+
+ /**
+ * Returns the component initializer method
+ */
+ public Method getInitMethod() {
+ return initMethod;
+ }
+
+ /**
+ * Sets the component initializer method
+ */
+ public void setInitMethod(Method initMethod) {
+ this.initMethod = initMethod;
+ }
+
+ /**
+ * Returns the component destructor method
+ */
+ public Method getDestroyMethod() {
+ return destroyMethod;
+ }
+
+ /**
+ * Sets the component destructor method
+ */
+ public void setDestroyMethod(Method destroyMethod) {
+ this.destroyMethod = destroyMethod;
+ }
+
+ public Map getResources() {
+ return resources;
+ }
+
+ public void add(Resource resource) {
+ resources.put(resource.getName(), resource);
+ }
+
+ public boolean isAllowsPassByReference() {
+ return allowsPassByReference;
+ }
+
+ public void setAllowsPassByReference(boolean allowsPassByReference) {
+ this.allowsPassByReference = allowsPassByReference;
+ }
+
+ public Member getConversationIDMember() {
+ return this.conversationIDMember;
+ }
+
+ public void setConversationIDMember(Member conversationIDMember) {
+ this.conversationIDMember = conversationIDMember;
+ }
+
+ public List getPassByReferenceMethods() {
+ return passByReferenceMethods;
+ }
+
+ public void setPassByReferenceMethods(List passByReferenceMethods) {
+ this.passByReferenceMethods = passByReferenceMethods;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java
new file mode 100644
index 0000000000..40fd1dfd15
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/ProcessingException.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.spi.loader.LoaderException;
+
+/**
+ * Denotes a problem processing annotations on a POJO implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class ProcessingException extends LoaderException {
+ private Member member;
+
+ public ProcessingException() {
+ }
+
+ public ProcessingException(String message) {
+ super(message);
+ }
+
+ public ProcessingException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public ProcessingException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public ProcessingException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ProcessingException(Throwable cause) {
+ super(cause);
+ }
+
+
+ public Member getMemberName() {
+ return member;
+ }
+
+ public void setMember(Member member) {
+ this.member = member;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Resource.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Resource.java
new file mode 100644
index 0000000000..5df4c3716d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/implementation/java/Resource.java
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.implementation.java;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.spi.ObjectFactory;
+
+/**
+ * A resource dependency declared by a Java component implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public class Resource {
+
+ private String name;
+ private String mappedName;
+ private boolean optional;
+ private Member member;
+ private Class> type;
+ private ObjectFactory> objectFactory;
+
+ /**
+ * The name of the resource
+ *
+ * @return the name of the resource
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of the resource
+ *
+ * @param name the name of the resource
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the URI of the resource
+ *
+ * @return the URI of the resource
+ */
+ public String getMappedName() {
+ return mappedName;
+ }
+
+ /**
+ * Sets the resource URI
+ */
+ public void setMappedName(String mappedName) {
+ this.mappedName = mappedName;
+ }
+
+ /**
+ * If true, the resource is optional
+ *
+ * @return true if the resource is optional
+ */
+ public boolean isOptional() {
+ return optional;
+ }
+
+ /**
+ * Sets whether the resource is optional
+ */
+ public void setOptional(boolean optional) {
+ this.optional = optional;
+ }
+
+ /**
+ * Returns the Member that this resource is mapped to.
+ *
+ * @return the Member that this resource is mapped to
+ */
+ public Member getMember() {
+ return member;
+ }
+
+ /**
+ * Sets the Member that this resource is mapped to
+ *
+ * @param member the Member that this resource is mapped to
+ */
+ public void setMember(Member member) {
+ this.member = member;
+ }
+
+ /**
+ * Returns the resource type
+ *
+ * @return the resource type
+ */
+ public Class> getType() {
+ return type;
+ }
+
+ /**
+ * Sets the resource type
+ */
+ public void setType(Class> type) {
+ this.type = type;
+ }
+
+ /**
+ * Returns the obeject factory
+ *
+ * @return the object factory
+ */
+ public ObjectFactory> getObjectFactory() {
+ return objectFactory;
+ }
+
+ /**
+ * Sets the object factory
+ */
+ public void setObjectFactory(ObjectFactory> objectFactory) {
+ this.objectFactory = objectFactory;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.java
new file mode 100644
index 0000000000..8ad01d8197
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ComponentTypeLoader.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.spi.loader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.Implementation;
+
+/**
+ * Loader that will load the ComponentType definition for the supplied implementation. The actual mechanism used to load
+ * that definition is determined by the Client and Implementation Specification for the implementaion type. In some
+ * cases the definition may be contained in a XML file related to the implementation artifact in some well defined
+ * manner; other implementations may obtain this information from introspection of the artifact itself (for example, by
+ * examining Java annotations).
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ComponentTypeLoader {
+ /**
+ * Load the component type definition for the supplied implementation.
+ *
+ * @param parent the parent composite
+ * @param implementation the implementation whose component type information should be loaded
+ * @param deploymentContext the current deployment context
+ * @throws LoaderException if there was a problem loading the configuration type
+ */
+ void load(CompositeComponent parent, I implementation, DeploymentContext deploymentContext)
+ throws LoaderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/DuplicateReferenceNameException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/DuplicateReferenceNameException.java
new file mode 100644
index 0000000000..34212a164b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/DuplicateReferenceNameException.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.loader;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Denotes a duplicate reference name
+ *
+ * @version $Rev: 487877 $ $Date: 2006-12-17 02:02:16 +0530 (Sun, 17 Dec 2006) $
+ */
+public class DuplicateReferenceNameException extends LoaderException {
+ public static final String COMPOSITE = "Composite";
+ public static final String COMPONENT_TYPE = "ComponentType";
+ public static final String MESSAGE = "Duplicat reference name ";
+
+ private static final long serialVersionUID = -9127740669182714792L;
+ private String duplicateName;
+ private String container;
+ private String containerName;
+
+ public DuplicateReferenceNameException(String dupName, String container, String containerName) {
+ super(MESSAGE, (String) null);
+ this.duplicateName = dupName;
+ this.container = container;
+ this.containerName = containerName;
+ }
+
+ public String getMessage() {
+ return MESSAGE + duplicateName + " in " + containerName + " " + container;
+ }
+
+ public String getContainer() {
+ return container;
+ }
+
+
+ public void setContainer(String container) {
+ this.container = container;
+ }
+
+
+ public String getContainerName() {
+ return containerName;
+ }
+
+
+ public void setContainerName(String containerName) {
+ this.containerName = containerName;
+ }
+
+
+ public String getDuplicateName() {
+ return duplicateName;
+ }
+
+
+ public void setDuplicateName(String duplicateName) {
+ this.duplicateName = duplicateName;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/IncompatibleOverridingServiceContractException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/IncompatibleOverridingServiceContractException.java
new file mode 100644
index 0000000000..caa4ffdc81
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/IncompatibleOverridingServiceContractException.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.loader;
+
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Denotes imcompatible service contracts for a wire
+ *
+ * @version $Rev: 487877 $ $Date: 2006-12-17 02:02:16 +0530 (Sun, 17 Dec 2006) $
+ */
+public class IncompatibleOverridingServiceContractException extends LoaderException {
+ private static final long serialVersionUID = 5127478601823295587L;
+ private final ServiceContract> source;
+ private final ServiceContract> target;
+ private final Operation> sourceOperation;
+ private final Operation> targetOperation;
+
+ public IncompatibleOverridingServiceContractException(String message, ServiceContract> source, ServiceContract> target) {
+ super(message, (String) null);
+ this.source = source;
+ this.target = target;
+ this.sourceOperation = null;
+ this.targetOperation = null;
+ }
+
+
+ public IncompatibleOverridingServiceContractException(String message,
+ ServiceContract> source,
+ ServiceContract> target,
+ Operation> sourceOperation, Operation> targetOperation) {
+ super(message, (String) null);
+ this.source = source;
+ this.target = target;
+ this.sourceOperation = sourceOperation;
+ this.targetOperation = targetOperation;
+ }
+
+ public ServiceContract> getTarget() {
+ return target;
+ }
+
+ public ServiceContract> getSource() {
+ return source;
+ }
+
+ public Operation> getSourceOperation() {
+ return sourceOperation;
+ }
+
+ public Operation> getTargetOperation() {
+ return targetOperation;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidConfigurationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidConfigurationException.java
new file mode 100644
index 0000000000..1c7f3e073d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidConfigurationException.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.spi.loader;
+
+/**
+ * Denotes an invalid configuration artifact
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidConfigurationException extends LoaderException {
+
+ public InvalidConfigurationException(String message) {
+ super(message);
+ }
+
+ public InvalidConfigurationException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidPromotedReferenceException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidPromotedReferenceException.java
new file mode 100644
index 0000000000..0a83bc2815
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidPromotedReferenceException.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.spi.loader;
+
+/**
+ * Used when a reference promoted by a composite is not found in any of the components defined within
+ * the composite
+ */
+public class InvalidPromotedReferenceException extends LoaderException {
+ private static final long serialVersionUID = -2056138384524620064L;
+
+ public InvalidPromotedReferenceException(String message) {
+ super(message);
+ }
+
+ public InvalidPromotedReferenceException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public InvalidPromotedReferenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.java
new file mode 100644
index 0000000000..40ae50bfe5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidReferenceException.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.spi.loader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidReferenceException extends LoaderException {
+ private static final long serialVersionUID = -4346666572527197558L;
+
+ public InvalidReferenceException(String message) {
+ super(message);
+ }
+
+ public InvalidReferenceException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public InvalidReferenceException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidServiceException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidServiceException.java
new file mode 100644
index 0000000000..1717cae0c3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidServiceException.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.spi.loader;
+
+/**
+ * @version $Rev: 430937 $ $Date: 2006-08-12 06:47:56 +0530 (Sat, 12 Aug 2006) $
+ */
+public class InvalidServiceException extends LoaderException {
+
+ public InvalidServiceException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.java
new file mode 100644
index 0000000000..b0ad8594ca
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidValueException.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.spi.loader;
+
+/**
+ * Exception that indicates the loader encountered an invalid value.
+ * The message should be set to the invalid value.
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidValueException extends LoaderException {
+
+ public InvalidValueException(String message) {
+ super(message);
+ }
+
+ public InvalidValueException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidValueException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidWireException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidWireException.java
new file mode 100644
index 0000000000..b26c81168f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/InvalidWireException.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.spi.loader;
+
+/**
+ * @version $Rev: 430937 $ $Date: 2006-08-12 06:47:56 +0530 (Sat, 12 Aug 2006) $
+ */
+public class InvalidWireException extends LoaderException {
+
+ public InvalidWireException() {
+ }
+
+ public InvalidWireException(String message) {
+ super(message);
+ }
+
+
+ public InvalidWireException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public InvalidWireException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public InvalidWireException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java
new file mode 100644
index 0000000000..e890d470a3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/Loader.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import java.net.URL;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * System service for loading physical artifacts that represent SCDL configurations and creating the model objects that
+ * represent them.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Loader {
+ /**
+ * Parse the supplied XML stream, dispatching to the appropriate registered loader for each element encountered in
+ * the stream.
+ *
+ * This method must be called with the XML cursor positioned on a START_ELEMENT event. When this method returns, the
+ * stream will be positioned on the corresponding END_ELEMENT event.
+ *
+ * @param parent the composite in which the model object is contained
+ * @param object the model object to load configuration data into. If null, the loader dispatched to is
+ * responsible for creating a model object itself
+ * @param reader the XML stream to parse
+ * @param deploymentContext the current deployment context
+ * @return the model object obtained by parsing the current element on the stream
+ * @throws XMLStreamException if there was a problem reading the stream
+ */
+ ModelObject load(CompositeComponent parent,
+ ModelObject object,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException;
+
+ /**
+ * Load a model object from a specified location.
+ *
+ * @param parent the composite in which the model object is contained
+ * @param object the model object to load configuration data into. If null, the loader dispatched to is
+ * responsible for creating a model object itself
+ * @param url the location of an XML document to be loaded
+ * @param type the type of ModelObject that is expected to be in the document
+ * @param deploymentContext the current deployment context
+ * @return the model ojbect loaded from the document
+ * @throws LoaderException if there was a problem loading the document
+ */
+ MO load(CompositeComponent parent,
+ ModelObject object,
+ URL url,
+ Class type,
+ DeploymentContext deploymentContext)
+ throws LoaderException;
+
+ /**
+ * Load the component type definition for a given implementation. How the component type information is located is
+ * defined by the implementation specification. It may include loading from an XML sidefile, introspection of some
+ * artifact related to the implementation, some combination of those techniques or any other implementation-defined
+ * mechanism.
+ *
+ * @param parent the parent composite
+ * @param implementation the implementation whose component type should be loaded
+ * @param deploymentContext the current deployment context
+ * @throws LoaderException if there was a problem loading the component type definition
+ */
+ > void loadComponentType(CompositeComponent parent,
+ I implementation,
+ DeploymentContext deploymentContext)
+ throws LoaderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java
new file mode 100644
index 0000000000..defc6b06c9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderException.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Base class for Exceptions raised during the loading process. Loader implementations should throw a subclass of this
+ * to indicate the actual problem.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LoaderException extends TuscanyException {
+ public static final int UNDEFINED = -1;
+ private static final long serialVersionUID = -7459051598906813461L;
+ private String resourceURI;
+ private int line = UNDEFINED;
+ private int column = UNDEFINED;
+
+ public LoaderException() {
+ }
+
+ public LoaderException(String message) {
+ super(message);
+ }
+
+ public LoaderException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ public LoaderException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public LoaderException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+
+ public LoaderException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns the location of the resource that was being loaded.
+ *
+ * @return the location of the resource that was being loaded
+ */
+ public String getResourceURI() {
+ return resourceURI;
+ }
+
+ /**
+ * Sets the location of the resource that was being loaded.
+ *
+ * @param resourceURI the location of the resource that was being loaded
+ */
+ public void setResourceURI(String resourceURI) {
+ this.resourceURI = resourceURI;
+ }
+
+ public int getLine() {
+ return line;
+ }
+
+ public void setLine(int line) {
+ this.line = line;
+ }
+
+ public int getColumn() {
+ return column;
+ }
+
+ public void setColumn(int column) {
+ this.column = column;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.java
new file mode 100644
index 0000000000..ea88b99b22
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderRegistry.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.spi.loader;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * Registry for XML loaders that can parse a StAX input stream and return model objects.
+ *
+ * Loaders will typically be contributed to the system by any extension that needs to handle extension specific
+ * information contained in some XML configuration file. The loader can be contributed as a system component with an
+ * autowire reference to this builderRegistry which is used during initialization to actually register. This
+ * builderRegistry can also be used to parse an input stream, dispatching to the appropriate loader for each element
+ * accepted. Loaders can call back to the builderRegistry to load sub-elements that they are not able to handle
+ * directly.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface LoaderRegistry extends Loader {
+ /**
+ * Register a loader. This operation will typically be called by a loader during its initialization.
+ *
+ * @param element the element that should be delegated to the contibuted loader
+ * @param loader a loader that is being contributed to the system
+ */
+ void registerLoader(QName element, StAXElementLoader loader);
+
+ /**
+ * Unregister a loader. This will typically be called by a loader as it is being destroyed.
+ *
+ * @param element the element that was being delegated to the contibuted loader
+ * @param loader a loader that should no longer be used
+ */
+ void unregisterLoader(QName element, StAXElementLoader loader);
+
+ /**
+ * Regsiter a component type loader.
+ *
+ * @param key a type of implementation this loader can load component types for
+ * @param loader the loader that is being contributed to the system
+ */
+ > void registerLoader(Class key, ComponentTypeLoader loader);
+
+ /**
+ * Unregister a component type loader form the system.
+ *
+ * @param key a type of implementation whose loader should be unregistered
+ */
+ > void unregisterLoader(Class key);
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java
new file mode 100644
index 0000000000..bf48f91a74
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/LoaderUtil.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamConstants;
+
+/**
+ * Utility functions to support loader implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class LoaderUtil {
+ private LoaderUtil() {
+ }
+
+ /**
+ * Advance the stream to the next END_ELEMENT event skipping any nested content.
+ *
+ * @param reader the reader to advance
+ * @throws XMLStreamException if there was a problem reading the stream
+ */
+ public static void skipToEndElement(XMLStreamReader reader) throws XMLStreamException {
+ int depth = 0;
+ while (true) {
+ int event = reader.next();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ depth++;
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
+ if (depth == 0) {
+ return;
+ }
+ depth--;
+ }
+ }
+ }
+
+ /**
+ * Load the class using the supplied ClassLoader.
+ * The class will be defined so any initializers present will be fired.
+ * As the class is being loaded, the Thread context ClassLoader will be
+ * set to the supplied classloader.
+ *
+ * @param name the name of the class to load
+ * @param cl the classloader to use to load it
+ * @return the class
+ * @throws MissingResourceException if the class could not be found
+ */
+ public static Class> loadClass(String name, ClassLoader cl) throws MissingResourceException {
+ final Thread thread = Thread.currentThread();
+ final ClassLoader oldCL = thread.getContextClassLoader();
+ try {
+ thread.setContextClassLoader(cl);
+ return Class.forName(name, true, cl);
+ } catch (ClassNotFoundException e) {
+ throw new MissingResourceException(name, e);
+ } finally {
+ thread.setContextClassLoader(oldCL);
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.java
new file mode 100644
index 0000000000..89a44083cc
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingImplementationException.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.spi.loader;
+
+/**
+ * Exception that indicates that an implementation was not provided.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingImplementationException extends LoaderException {
+ private static final long serialVersionUID = -2917278473974880124L;
+
+ /**
+ * Default constructor.
+ */
+ public MissingImplementationException() {
+ super();
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.java
new file mode 100644
index 0000000000..10e40f9288
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingIncludeException.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.spi.loader;
+
+/**
+ * Exception that indicates that an include was not provided.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingIncludeException extends LoaderException {
+ private static final long serialVersionUID = -2917278473974880124L;
+
+ public MissingIncludeException(String message, String identifier) {
+ super(message, identifier);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.java
new file mode 100644
index 0000000000..78856784e5
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingMustOverridePropertyException.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.spi.loader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MissingMustOverridePropertyException extends LoaderException {
+
+ public MissingMustOverridePropertyException(String name) {
+ super(name);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingPropertyValueException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingPropertyValueException.java
new file mode 100644
index 0000000000..c84169148d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingPropertyValueException.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.spi.loader;
+
+/**
+ * @version $Rev: 486986 $ $Date: 2006-12-14 11:48:28 +0530 (Thu, 14 Dec 2006) $
+ */
+public class MissingPropertyValueException extends LoaderException {
+
+ public MissingPropertyValueException(String name) {
+ super(name);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingReferenceException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingReferenceException.java
new file mode 100644
index 0000000000..7bc206de34
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingReferenceException.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.spi.loader;
+
+/**
+ * Indicates a required reference was not configured
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingReferenceException extends LoaderException {
+
+ public MissingReferenceException(String message) {
+ super(message);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
new file mode 100644
index 0000000000..3b6a21aa74
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingResourceException.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.loader;
+
+/**
+ * Exception that indicates an expected resource could not be found. The message should be set to the name of the
+ * resource.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MissingResourceException extends LoaderException {
+ private static final long serialVersionUID = 3775013318397916445L;
+
+ /**
+ * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the
+ * message.
+ *
+ * @param resource the resource that could not be found
+ */
+ public MissingResourceException(String resource) {
+ super("Missing resource", resource);
+ }
+
+ public MissingResourceException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+ /**
+ * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the
+ * message.
+ *
+ * @param resource the resource that could not be found
+ * @param cause the error thrown resolving the resource
+ */
+ public MissingResourceException(String resource, Throwable cause) {
+ super("Missing resource", resource, cause);
+ }
+
+
+ /**
+ * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the
+ * message.
+ *
+ * @param message the message set on the exception
+ * @param identifier the resource that could not be found
+ * @param cause the error thrown resolving the resource
+ */
+ public MissingResourceException(String message, String identifier, Throwable cause) {
+ super(message, identifier, cause);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingSideFileException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingSideFileException.java
new file mode 100644
index 0000000000..67bcc6d7a0
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/MissingSideFileException.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.spi.loader;
+
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MissingSideFileException extends LoaderException {
+
+ public MissingSideFileException(String message, String identifier) {
+ super(message, identifier);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.java
new file mode 100644
index 0000000000..4672f22a6a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/NotOverridablePropertyException.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.spi.loader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class NotOverridablePropertyException extends LoaderException {
+ private static final long serialVersionUID = 1483304023970967982L;
+
+ public NotOverridablePropertyException(String name) {
+ super(name);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.java
new file mode 100644
index 0000000000..3fbeb6064f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/PropertyObjectFactory.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.spi.loader;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.Property;
+import org.apache.tuscany.spi.model.PropertyValue;
+
+/**
+ * A factory that will create an ObjectFactory for a property
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PropertyObjectFactory {
+ /**
+ * Return an ObjectFactory for instances of a property defined in an XML. The ObjectFactory must return instances
+ * that can safely be supplied to component implementations. If the instance is mutable and isolation between
+ * components is required, then the factory must clone or otherwise protect the implementation from unexpected
+ * modifications by other implementation instances.
+ *
+ * @param property the Property definition that the resulting ObjectFactory must be able to assign to
+ * @param propertyValue The component configuration of the property
+ * @return an ObjectFactory that can produce instances that can be assigned to the supplied Property
+ * @throws LoaderException if there is a problem creating the ObjectFactory
+ */
+ ObjectFactory createObjectFactory(Property property, PropertyValue propertyValue)
+ throws LoaderException;
+
+ ObjectFactory> createListObjectFactory(Property property, PropertyValue propertyValue)
+ throws LoaderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ReferenceMultiplicityOverridingException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ReferenceMultiplicityOverridingException.java
new file mode 100644
index 0000000000..37a4b594c4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ReferenceMultiplicityOverridingException.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.loader;
+
+import org.apache.tuscany.spi.model.Multiplicity;
+
+/**
+ * Denote the violation in overriding of multiplicity declaration for a reference either when a
+ * Component is overriding what is original in the underlying ComponentType or when a Composite is
+ * overriding while promoting a Component reference definition.
+ *
+ * @version $Rev $Date
+ */
+public class ReferenceMultiplicityOverridingException extends LoaderException {
+ private static final long serialVersionUID = -5827228144446207988L;
+ private final Multiplicity originalMultiplicity;
+ private final Multiplicity overridenMultiplicity;
+
+ /**
+ * @param message
+ * @param identifier
+ * @param multiplicity
+ * @param numberOfTargets
+ */
+ public ReferenceMultiplicityOverridingException(String message,
+ String identifier,
+ Multiplicity original,
+ Multiplicity overriden) {
+ super(message, identifier);
+ this.originalMultiplicity = original;
+ this.overridenMultiplicity = overriden;
+ }
+
+ /**
+ * @param identifier
+ * @param multiplicity
+ * @param numberOfTargets
+ */
+ public ReferenceMultiplicityOverridingException(String identifier, Multiplicity original, Multiplicity overriden) {
+ this("Multiplicity Overriding is violated", identifier, original, overriden);
+ }
+
+
+ /**
+ * Get the original multiplicity for the reference definition
+ *
+ * @return multiplicity of the reference definition
+ */
+ public Multiplicity getoriginalMultiplicity() {
+ return originalMultiplicity;
+ }
+
+ /**
+ * Get the overriden multiplicity for the reference definition
+ *
+ * @return multiplicity of the reference definition
+ */
+ public Multiplicity getOverridenMultiplicity() {
+ return overridenMultiplicity;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ReferenceMultiplicityViolationException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ReferenceMultiplicityViolationException.java
new file mode 100644
index 0000000000..ce9acb8750
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/ReferenceMultiplicityViolationException.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.spi.loader;
+
+import org.apache.tuscany.spi.model.Multiplicity;
+
+/**
+ * Denote the violation of multiplicity declaration for a reference
+ *
+ * @version $Rev $Date
+ */
+public class ReferenceMultiplicityViolationException extends LoaderException {
+ private static final long serialVersionUID = -4049116356211578827L;
+
+ private final Multiplicity multiplicity;
+ private final int numberOfTargets;
+
+ /**
+ * @param message
+ * @param identifier
+ * @param multiplicity
+ * @param numberOfTargets
+ */
+ public ReferenceMultiplicityViolationException(String message,
+ String identifier,
+ Multiplicity multiplicity,
+ int numberOfTargets) {
+ super(message, identifier);
+ this.multiplicity = multiplicity;
+ this.numberOfTargets = numberOfTargets;
+ }
+
+ /**
+ * @param identifier
+ * @param multiplicity
+ * @param numberOfTargets
+ */
+ public ReferenceMultiplicityViolationException(String identifier, Multiplicity multiplicity, int numberOfTargets) {
+ this("Multiplicity is violated", identifier, multiplicity, numberOfTargets);
+ }
+
+ /**
+ * Get the multiplicity for the reference definition
+ *
+ * @return multiplicity of the reference definition
+ */
+ public Multiplicity getMultiplicity() {
+ return multiplicity;
+ }
+
+ /**
+ * Get the number of targets defined for this reference
+ * @return number of targets for this reference
+ */
+ public int getNumberOfTargets() {
+ return numberOfTargets;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.java
new file mode 100644
index 0000000000..401e34cb71
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/StAXElementLoader.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.spi.loader;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * A loader that creates a model object from a StAX input stream.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface StAXElementLoader {
+ /**
+ * Create the model object for an element in an XML stream. When this method returns the stream will be positioned
+ * on the corresponding END_ELEMENT.
+ *
+ * @param parent the composite the model object being loaded is contained within
+ * @param object the model object to load configuration data into. An implementation may choose to return
+ * a different model object than the one passed in, in which case it is responsible for
+ * copying data. If null, the loader is responsible for creating a model object itself
+ * @param reader the XML stream reader positioned on the applicable START_ELEMENT
+ * @param deploymentContext the context for the load operation
+ * @return the model object for that element
+ */
+ T load(CompositeComponent parent, ModelObject object, XMLStreamReader reader, DeploymentContext deploymentContext)
+ throws XMLStreamException, LoaderException;
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.java
new file mode 100644
index 0000000000..bf3aa205d2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedPropertyException.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.spi.loader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UndefinedPropertyException extends LoaderException {
+ public UndefinedPropertyException(String name) {
+ super("Property not found on implementation", name);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedReferenceException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedReferenceException.java
new file mode 100644
index 0000000000..f9aa8812ac
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UndefinedReferenceException.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.spi.loader;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class UndefinedReferenceException extends LoaderException {
+ private static final long serialVersionUID = -2897448857974015706L;
+
+ public UndefinedReferenceException(String name) {
+ super("Reference not found on implementation", name);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedComponentTypeException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedComponentTypeException.java
new file mode 100644
index 0000000000..750762d839
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedComponentTypeException.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.spi.loader;
+
+/**
+ * Exception that indicates an component type was encountered that could not be handled.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnrecognizedComponentTypeException extends LoaderException {
+ private final Class> type;
+
+ /**
+ * Constructor that indicates which component type loader could not be found.
+ *
+ * @param type the component type type that could not be handled
+ */
+ public UnrecognizedComponentTypeException(Class> type) {
+ super("Unrecognized element", type.getName());
+ this.type = type;
+ }
+
+ public Class> getType() {
+ return type;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.java
new file mode 100644
index 0000000000..7991105da8
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/loader/UnrecognizedElementException.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.spi.loader;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Exception that indicates an element was encountered that could not be handled.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnrecognizedElementException extends LoaderException {
+ private static final long serialVersionUID = 2549543622209829032L;
+ private final QName element;
+
+ /**
+ * Constructor that indicates which resource could not be found. The supplied parameter is also returned as the
+ * message.
+ *
+ * @param element the element that could not be handled
+ */
+ public UnrecognizedElementException(QName element) {
+ super("Unrecognized element", element.toString());
+ this.element = element;
+ }
+
+ public QName getElement() {
+ return element;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/marshaller/MarshalException.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/marshaller/MarshalException.java
new file mode 100644
index 0000000000..5693ee08e1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/marshaller/MarshalException.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.spi.marshaller;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Super class for all marshalling/unmarshalling exceptions.
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+@SuppressWarnings("serial")
+public class MarshalException extends TuscanyException {
+
+ /**
+ * Initializes the exception message.
+ * @param message Message for the exception.
+ */
+ public MarshalException(String message) {
+ super(message);
+ }
+
+ /**
+ * Initializes the root cause.
+ * @param cause Root cause for the exception.
+ */
+ public MarshalException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/marshaller/ModelMarshaller.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/marshaller/ModelMarshaller.java
new file mode 100644
index 0000000000..da1ec90c8b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/marshaller/ModelMarshaller.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.spi.marshaller;
+
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.spi.model.ModelObject;
+
+/**
+ * Interface for marshalling/unmarshalling internal model objects.
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+public interface ModelMarshaller {
+
+ /**
+ * Marshalls the model object to the specified stream writer.
+ *
+ * @param modelObject Model object to be serialized.
+ * @param writer Stream writer to which the infoset is serialized.
+ * @throws MarshalException In case of any marshalling error.
+ */
+ void marshall(MD modelObject, XMLStreamWriter writer) throws MarshalException;
+
+ /**
+ * Unmarshalls an XML stream to a model object.
+ *
+ * @param reader XML stream from where the marshalled XML is read.
+ * @param upconvert Whether to upconvert the object is the current runtime
+ * supports a higher version of the model object.
+ * @return Hydrated model object.
+ * @throws MarshalException In case of any unmarshalling error.
+ */
+ MD unmarshall(XMLStreamReader reader, boolean upconvert) throws MarshalException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AbstractReferenceDefinition.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AbstractReferenceDefinition.java
new file mode 100644
index 0000000000..3e38abf103
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AbstractReferenceDefinition.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Represents a component reference
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractReferenceDefinition extends ModelObject {
+ private String name;
+ private ServiceContract serviceContract;
+ private Multiplicity multiplicity;
+ private boolean autowire;
+ private List bindings;
+ private List targets = new ArrayList();
+ private boolean wiredByImpl;
+ private List requiredIntents = new ArrayList();
+ private List policySets = new ArrayList();
+
+ public AbstractReferenceDefinition() {
+ autowire = false;
+ multiplicity = Multiplicity.ONE_ONE;
+ bindings = new ArrayList();
+ }
+
+ public AbstractReferenceDefinition(String name, ServiceContract serviceContract) {
+ this.name = name;
+ this.serviceContract = serviceContract;
+ bindings = new ArrayList();
+ autowire = false;
+ multiplicity = Multiplicity.ONE_ONE;
+ }
+
+ public AbstractReferenceDefinition(String name, ServiceContract serviceContract, Multiplicity multiplicity) {
+ this.name = name;
+ this.serviceContract = serviceContract;
+ this.multiplicity = multiplicity;
+ bindings = new ArrayList();
+ autowire = false;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ServiceContract> getServiceContract() {
+ return serviceContract;
+ }
+
+ public void setServiceContract(ServiceContract serviceContract) {
+ this.serviceContract = serviceContract;
+ }
+
+ public Multiplicity getMultiplicity() {
+ return multiplicity;
+ }
+
+ public void setMultiplicity(Multiplicity multiplicity) {
+ this.multiplicity = multiplicity;
+ }
+
+ public boolean isAutowire() {
+ return autowire;
+ }
+
+ public void setAutowire(boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public List getBindings() {
+ return Collections.unmodifiableList(bindings);
+ }
+
+ public void addBinding(BindingDefinition binding) {
+ this.bindings.add(binding);
+ }
+
+ public List getTargets() {
+ return Collections.unmodifiableList(targets);
+ }
+
+ public void addTarget(URI targetURI) {
+ this.targets.add(targetURI);
+ }
+
+ public boolean isWiredByImpl() {
+ return wiredByImpl;
+ }
+
+ public void setWiredByImpl(boolean wiredByImpl) {
+ this.wiredByImpl = wiredByImpl;
+ }
+
+ public List getPolicySets() {
+ return policySets;
+ }
+
+ public void setPolicySets(List policySets) {
+ this.policySets = policySets;
+ }
+
+ public List getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public void setRequiredIntents(List requiredIntents) {
+ this.requiredIntents = requiredIntents;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.java
new file mode 100644
index 0000000000..8e12e970ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/AtomicImplementation.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.spi.model;
+
+/**
+ * The base representation of an atomic component implementation
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AtomicImplementation extends Implementation {
+ protected AtomicImplementation() {
+ }
+
+ protected AtomicImplementation(T componentType) {
+ super(componentType);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindingDefinition.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindingDefinition.java
new file mode 100644
index 0000000000..85af2a7985
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/BindingDefinition.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.spi.model;
+
+import java.net.URI;
+
+/**
+ * The base representation of a binding specified in an assembly
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BindingDefinition extends ModelObject implements Cloneable {
+ private URI targetUri;
+
+ protected BindingDefinition() {
+ }
+
+ public BindingDefinition(URI targetUri) {
+ this.targetUri = targetUri;
+ }
+
+ public URI getTargetUri() {
+ return targetUri;
+ }
+
+ public void setTargetUri(URI targetUri) {
+ this.targetUri = targetUri;
+ }
+
+ abstract public Object clone();
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.java
new file mode 100644
index 0000000000..f9ef20add9
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentDefinition.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.spi.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Represents a component.
+ * A component is a configured instance of an implementation. The services provided and consumed
+ * and the available configuration properties are defined by the implementation (represented by
+ * its componentType).
+ * Every component has a name which uniquely identifies it within the scope of the composite
+ * that contains it; the name must be different from the names of all other components, services and references
+ * immediately contained in the composite (directly or through an <include> element).
+ * A component may define a {@link PropertyValue} that overrides the default value of a {@link Property}
+ * defined in the componentType.
+ * It may also define a {@link ReferenceTarget} for a {@link AbstractReferenceDefinition} defined in the componentType.
+ * The ReferenceTarget must resolve to another component or a reference in the enclosing composite.
+ * Components may specify an initialization level that will determine the order in which it will be eagerly
+ * initialized relative to other components from the enclosing composite that are in the same scope. This can be
+ * used to define a startup sequence for components that are otherwise independent. Any initialization required
+ * to resolve references between components will override this initialization order.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentDefinition> extends ModelObject {
+ private String name;
+ private Integer initLevel;
+ private final I implementation;
+ private final Map references = new HashMap();
+ private final Map> propertyValues = new HashMap>();
+ private boolean autowire;
+
+ /**
+ * Constructor specifying the component's name and implementation.
+ *
+ * @param name the name of this component
+ * @param implementation the implementation of this component
+ */
+ public ComponentDefinition(String name, I implementation) {
+ this.name = name;
+ this.implementation = implementation;
+ }
+
+ /**
+ * Constructor specifying the implementation of this component.
+ *
+ * @param implementation the implementation of this component
+ */
+ public ComponentDefinition(I implementation) {
+ this.implementation = implementation;
+ }
+
+ /**
+ * Returns the {@link Implementation} of this component.
+ *
+ * @return the implementation of this component
+ */
+ public I getImplementation() {
+ return implementation;
+ }
+
+ /**
+ * Returns the name of this component.
+ *
+ * @return the name of this component
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the name of this component.
+ *
+ * @param name the name of this component
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the initialization level of this component.
+ *
+ * @return the initialization level of this component
+ */
+ public Integer getInitLevel() {
+ return initLevel;
+ }
+
+ /**
+ * Sets the initialization level of this component.
+ * If set to null then the level from the componentType is used.
+ * If set to zero or a negative value then the component will not be eagerly initialized.
+ *
+ * @param initLevel the initialization level of this component
+ */
+ public void setInitLevel(Integer initLevel) {
+ this.initLevel = initLevel;
+ }
+
+ /**
+ * Returns a live Map of {@link PropertyValue property values} configured by this component definition.
+ *
+ * @return the property values configured by this component
+ */
+ public Map> getPropertyValues() {
+ return propertyValues;
+ }
+
+ /**
+ * Add a property value configuration to this component.
+ * Any existing configuration for the property names in the property value is replaced.
+ *
+ * @param value the property value to add
+ */
+ public void add(PropertyValue> value) {
+ propertyValues.put(value.getName(), value);
+ }
+
+ public boolean isAutowire() {
+ return autowire;
+ }
+
+ public void setAutowire(boolean autowire) {
+ this.autowire = autowire;
+ }
+
+ public Map getReferences() {
+ return references;
+ }
+
+ public void add(ComponentReferenceDefinition ref) {
+ references.put(ref.getName(), ref);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentReferenceDefinition.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentReferenceDefinition.java
new file mode 100644
index 0000000000..0f8e162c62
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentReferenceDefinition.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.net.URI;
+import java.util.List;
+
+/**
+ * Represents reference defintion that is part of a Component definition
+ *
+ */
+public class ComponentReferenceDefinition extends AbstractReferenceDefinition {
+ private ComponentTypeReferenceDefinition associatedCompTypeRefDefn;
+
+ public ComponentReferenceDefinition(ComponentTypeReferenceDefinition ctRefDefn) {
+ super();
+ setMultiplicity(null);
+ this.associatedCompTypeRefDefn = ctRefDefn;
+ }
+
+ public ComponentReferenceDefinition(String name, ServiceContract serviceContract, ComponentTypeReferenceDefinition ctRefDefn) {
+ super(name, serviceContract, null);
+ this.associatedCompTypeRefDefn = ctRefDefn;
+ }
+
+ public ComponentReferenceDefinition(String name, ServiceContract serviceContract, Multiplicity multiplicity, ComponentTypeReferenceDefinition ctRefDefn) {
+ super(name, serviceContract, multiplicity);
+ this.associatedCompTypeRefDefn = ctRefDefn;
+ }
+
+ @Override
+ public String getName() {
+ return associatedCompTypeRefDefn.getName();
+ }
+
+ public ComponentTypeReferenceDefinition getAssociatedCompTypeRefDefn() {
+ return associatedCompTypeRefDefn;
+ }
+
+ public void setAssociatedCompTypeRefDefn(ComponentTypeReferenceDefinition associatedCompTypeRefDefn) {
+ this.associatedCompTypeRefDefn = associatedCompTypeRefDefn;
+ }
+
+ @Override
+ public Multiplicity getMultiplicity() {
+ if (super.getMultiplicity() != null) {
+ return super.getMultiplicity();
+ } else {
+ return associatedCompTypeRefDefn.getMultiplicity();
+ }
+ }
+
+ @Override
+ public List getTargets() {
+ if (super.getTargets() == null || super.getTargets().isEmpty()) {
+ return associatedCompTypeRefDefn.getTargets();
+ } else {
+ return super.getTargets();
+ }
+ }
+
+ @Override
+ public ServiceContract> getServiceContract() {
+ if (super.getServiceContract() == null) {
+ return associatedCompTypeRefDefn.getServiceContract();
+ } else {
+ return super.getServiceContract();
+ }
+ }
+
+ @Override
+ public List getBindings() {
+ if (super.getBindings() == null || super.getBindings().size() == 0) {
+ return associatedCompTypeRefDefn.getBindings();
+ } else {
+ return super.getBindings();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java
new file mode 100644
index 0000000000..af3fcc6f48
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * The definition of the configurable aspects of an implementation in terms of the services it exposes, the services
+ * it references, and properties that can be used to configure it.
A service represents an addressable interface
+ * provided by the implementation. Such a service may be the target of a wire from another component.
A reference
+ * represents a requirement that an implementation has on a service provided by another component or by a resource
+ * outside the SCA system. Such a reference may be the source of a wire to another component.
A property allows
+ * the behaviour of the implementation to be configured through externally set values.
A component type may also
+ * declare that it wishes to be initialized upon activation of the scope that contains it and may specify an order
+ * relative to other eagerly initializing components. For example, an implementation that pre-loads some form of cache
+ * could declare that it should be eagerly initialized at the start of the scope so that the cache load occured on
+ * startup rather than first use.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentType>
+ extends ModelObject {
+ protected Scope implementationScope = Scope.UNDEFINED;
+ private int initLevel;
+ private long maxAge = -1;
+ private long maxIdleTime = -1;
+ private final Map services = new HashMap();
+ private final Map references = new HashMap();
+ private final Map properties = new HashMap();
+
+ /**
+ * Returns the component implementation scope
+ */
+ public Scope getImplementationScope() {
+ return implementationScope;
+ }
+
+ /**
+ * Sets the component implementation scope
+ */
+ public void setImplementationScope(Scope implementationScope) {
+ this.implementationScope = implementationScope;
+ }
+
+ /**
+ * Returns the default initialization level for components of this type. A value greater than zero indicates that
+ * components should be eagerly initialized.
+ *
+ * @return the default initialization level
+ */
+ public int getInitLevel() {
+ return initLevel;
+ }
+
+ /**
+ * Sets the default initialization level for components of this type. A value greater than zero indicates that
+ * components should be eagerly initialized.
+ *
+ * @param initLevel default initialization level for components of this type
+ */
+ public void setInitLevel(int initLevel) {
+ this.initLevel = initLevel;
+ }
+
+ /**
+ * Returns true if this component should be eagerly initialized.
+ *
+ * @return true if this component should be eagerly initialized
+ */
+ public boolean isEagerInit() {
+ return initLevel > 0;
+ }
+
+ /**
+ * Returns the idle time allowed between operations in milliseconds if the implementation is conversational
+ *
+ * @return the idle time allowed between operations in milliseconds if the implementation is conversational
+ */
+ public long getMaxIdleTime() {
+ return maxIdleTime;
+ }
+
+ /**
+ * Sets the idle time allowed between operations in milliseconds if the implementation is conversational
+ */
+ public void setMaxIdleTime(long maxIdleTime) {
+ this.maxIdleTime = maxIdleTime;
+ }
+
+ /**
+ * Returns the maximum age a conversation may remain active in milliseconds if the implementation is conversational
+ *
+ * @return the maximum age a conversation may remain active in milliseconds if the implementation is conversational
+ */
+ public long getMaxAge() {
+ return maxAge;
+ }
+
+ /**
+ * Sets the maximum age a conversation may remain active in milliseconds if the implementation is conversational
+ */
+ public void setMaxAge(long maxAge) {
+ this.maxAge = maxAge;
+ }
+
+ /**
+ * Returns a live Map of the services provided by the implementation.
+ *
+ * @return a live Map of the services provided by the implementation
+ */
+ public Map getServices() {
+ return services;
+ }
+
+ /**
+ * Add a service to those provided by the implementation. Any existing service with the same name is replaced.
+ *
+ * @param service a service provided by the implementation
+ */
+ public void add(S service) {
+ services.put(service.getName(), service);
+ }
+
+ /**
+ * Returns a live Map of references to services consumed by the implementation.
+ *
+ * @return a live Map of references to services consumed by the implementation
+ */
+ public Map getReferences() {
+ return references;
+ }
+
+ /**
+ * Add a reference to a service consumed by the implementation. Any existing reference with the same name is
+ * replaced.
+ *
+ * @param reference a reference to a service consumed by the implementation
+ */
+ public void add(R reference) {
+ references.put(reference.getName(), reference);
+ }
+
+ /**
+ * Returns a live Map of properties that can be used to configure the implementation.
+ *
+ * @return a live Map of properties that can be used to configure the implementation
+ */
+ public Map getProperties() {
+ return properties;
+ }
+
+ /**
+ * Add a property that can be used to configure the implementation. Any existing property with the same name is
+ * replaced.
+ *
+ * @param property a property that can be used to configure the implementation
+ */
+ public void add(P property) {
+ properties.put(property.getName(), property);
+ }
+
+ /**
+ * Get a specific property that can be used to configure the implementation.
+ *
+ * @param name the name of the property
+ * @return the property that can be used to configure the implementation or null if no such property exists
+ */
+ public Property getProperty(String name) {
+ return properties.get(name);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentTypeReferenceDefinition.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentTypeReferenceDefinition.java
new file mode 100644
index 0000000000..688d09b7df
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentTypeReferenceDefinition.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.spi.model;
+
+
+
+/**
+ * Represents reference defintion that is part of a ComponentType definition
+ *
+ */
+public class ComponentTypeReferenceDefinition extends AbstractReferenceDefinition {
+ public ComponentTypeReferenceDefinition() {
+ super();
+ }
+
+ public ComponentTypeReferenceDefinition(String name, ServiceContract serviceContract) {
+ super(name, serviceContract);
+ }
+
+ public ComponentTypeReferenceDefinition(String name, ServiceContract serviceContract, Multiplicity multiplicity) {
+ super(name, serviceContract, multiplicity);
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java
new file mode 100644
index 0000000000..d9355d89c4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-integration/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/CompositeComponentType.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.spi.model;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A specialization of component type for composite components.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeComponentType> extends ComponentType {
+
+ private String name;
+ private final Map>> components =
+ new HashMap>>();
+ private final Map includes = new HashMap();
+ private final List wires = new ArrayList();
+ private boolean autowire;
+
+ public CompositeComponentType() {
+ implementationScope = Scope.SYSTEM;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ /**
+ * Get all properties including the ones are from included composites
+ * @return
+ */
+ public Map getProperties() {
+ Map view = new HashMap(super.getProperties());
+ for (Include i : includes.values()) {
+ view.putAll(i.getIncluded().getProperties());
+ }
+ return Collections.unmodifiableMap(view);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ /**
+ * Get all references including the ones are from included composites
+ * @return
+ */
+ public Map getReferences() {
+ Map view = new HashMap(super.getReferences());
+ for (Include i : includes.values()) {
+ view.putAll(i.getIncluded().getReferences());
+ }
+ return Collections.unmodifiableMap(view);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ /**
+ * Get all services including the ones are from included composites
+ * @return
+ */
+ public Map getServices() {
+ Map view = new HashMap(super.getServices());
+ for (Include i : includes.values()) {
+ view.putAll(i.getIncluded().getServices());
+ }
+ return Collections.unmodifiableMap(view);
+ }
+
+ /**
+ * Get all components including the ones are from included composites
+ */
+ @SuppressWarnings("unchecked")
+ public Map