summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-20 20:10:37 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-02-20 20:10:37 +0000
commit3a8a64103bcc4891fb1a1f4cc4538f9d5b62a7ba (patch)
treeccd8919c277ad88c032acb3167fdd4645586cb07
parent7b9fa54dced70baffa6578b0be902b06092584a7 (diff)
Start to implement the SCA policy framework 1.1 spec draft from OASIS OpenCSA
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@746356 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java354
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java15
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java264
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java112
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java9
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java10
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java (renamed from java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java)47
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java18
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java6
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java16
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java37
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java67
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite5
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite3
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml7
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml339
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java4
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java4
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java9
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java1
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java5
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java4
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java4
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java4
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java61
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java4
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java4
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java2
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java70
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java33
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java3
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java5
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java2
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java10
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java12
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java66
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointBuilderImpl.java8
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java427
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java21
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java7
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java (renamed from java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java)170
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java21
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java36
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java20
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java15
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java24
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java73
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java27
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java6
-rw-r--r--java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java17
-rw-r--r--java/sca/modules/binding-sca-xml/src/main/java/org/apache/tuscany/sca/binding/sca/xml/SCABindingProcessor.java21
-rw-r--r--java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java12
-rw-r--r--java/sca/modules/binding-sca/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml6
-rw-r--r--java/sca/modules/binding-sca/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java4
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java4
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java6
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java6
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java3
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java3
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java4
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java7
-rw-r--r--java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java6
-rw-r--r--java/sca/modules/binding-ws-axis2/pom.xml7
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java17
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java9
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java6
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java6
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java6
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java33
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java19
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java6
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java52
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java12
-rw-r--r--java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml6
-rw-r--r--java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml4
-rw-r--r--java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml4
-rw-r--r--java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml4
-rw-r--r--java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml4
-rw-r--r--java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java6
-rw-r--r--java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java33
-rw-r--r--java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java4
-rw-r--r--java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java36
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java2
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java2
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java2
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java2
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java2
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java2
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java2
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultDefinitionsProviderExtensionPoint.java12
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java2
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java3
-rw-r--r--java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java2
-rw-r--r--java/sca/modules/definitions-xml/pom.xml1
-rw-r--r--java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java53
-rw-r--r--java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java105
-rw-r--r--java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor2
-rw-r--r--java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor2
-rw-r--r--java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/ReadDocumentTestCase.java162
-rw-r--r--java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/TestPolicyProcessor.java1
-rw-r--r--java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml415
-rw-r--r--java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java7
-rw-r--r--java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java131
-rw-r--r--java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java11
-rw-r--r--java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java2
-rw-r--r--java/sca/modules/endpoint/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml6
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java2
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java6
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java11
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PolicyHandlingInterceptor.java74
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java8
-rw-r--r--java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java37
-rw-r--r--java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java26
-rw-r--r--java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml2
-rw-r--r--java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml188
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java12
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java10
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java18
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java10
-rw-r--r--java/sca/modules/implementation-node/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/ConfiguredNodeImplementationImpl.java3
-rw-r--r--java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/NodeImplementationImpl.java3
-rw-r--r--java/sca/modules/implementation-web/META-INF/MANIFEST.MF5
-rw-r--r--java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java3
-rw-r--r--java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java2
-rw-r--r--java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java4
-rw-r--r--java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java4
-rw-r--r--java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java8
-rw-r--r--java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java8
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java4
-rw-r--r--java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java19
-rw-r--r--java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java4
-rw-r--r--java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java6
-rw-r--r--java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java6
-rw-r--r--java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java4
-rw-r--r--java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java4
-rw-r--r--java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java4
-rw-r--r--java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java4
-rw-r--r--java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java4
-rw-r--r--java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java3
-rw-r--r--java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml12
-rw-r--r--java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml4
-rw-r--r--java/sca/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.java15
-rw-r--r--java/sca/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml6
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java21
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java (renamed from java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java)100
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java21
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java383
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java25
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java420
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java169
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ProfileIntentProcessor.java45
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/QualifiedIntentProcessor.java45
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SimpleIntentProcessor.java45
-rw-r--r--java/sca/modules/policy-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor10
-rw-r--r--java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties3
-rw-r--r--java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java133
-rw-r--r--java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java28
-rw-r--r--java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml412
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/DefaultIntentAttachPointTypeFactory.java)56
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointType.java)152
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Policy.java)60
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java82
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointTypeFactory.java43
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java56
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ProfileIntent.java)67
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyContext.java38
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetReference.java)108
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java23
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyResolver.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetAttachPoint.java)41
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java65
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPoint.java)44
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/QualifiedIntent.java)85
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java64
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java97
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java61
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentAttachPointTypeFactoryImpl.java39
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java123
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java30
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyContextImpl.java93
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java86
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java32
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java122
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetReferenceImpl.java48
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifiedIntentImpl.java50
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java (renamed from java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ProfileIntentImpl.java)87
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java134
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandler.java38
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java87
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java91
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerUtils.java64
-rw-r--r--java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java53
-rw-r--r--java/sca/modules/policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory18
-rw-r--r--java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/builder/DefaultContributionBuilderExtensionPoint.java2
194 files changed, 3139 insertions, 5379 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
index fa58232703..188603afeb 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
@@ -58,7 +58,6 @@ import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Extensible;
@@ -66,7 +65,6 @@ import org.apache.tuscany.sca.assembly.Extension;
import org.apache.tuscany.sca.assembly.ExtensionFactory;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Multiplicity;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
@@ -82,13 +80,8 @@ import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
-import org.apache.tuscany.sca.policy.util.PolicyValidationException;
-import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -106,7 +99,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
protected ExtensionFactory extensionFactory;
protected PolicyFactory policyFactory;
protected StAXArtifactProcessor<Object> extensionProcessor;
- protected PolicyAttachPointProcessor policyProcessor;
+ protected PolicySubjectProcessor policyProcessor;
private DocumentBuilderFactory documentBuilderFactory;
private Monitor monitor;
@@ -117,7 +110,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
*/
@SuppressWarnings("unchecked")
protected BaseAssemblyProcessor(AssemblyFactory assemblyFactory,
- ExtensionFactory extensionFactory,
+ ExtensionFactory extensionFactory,
PolicyFactory policyFactory,
DocumentBuilderFactory documentBuilderFactory,
StAXArtifactProcessor extensionProcessor,
@@ -127,10 +120,10 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
this.policyFactory = policyFactory;
this.documentBuilderFactory = documentBuilderFactory;
this.extensionProcessor = (StAXArtifactProcessor<Object>)extensionProcessor;
- this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
this.monitor = monitor;
}
-
+
/**
* @param modelFactories
* @param staxProcessor
@@ -144,10 +137,10 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
- this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
this.monitor = monitor;
}
-
+
/**
* Marshals warnings into the monitor
*
@@ -156,12 +149,18 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
* @param messageParameters
*/
protected void warning(String message, Object model, String... messageParameters) {
- if (monitor != null){
- Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-xml-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "assembly-xml-validation-messages",
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
monitor.problem(problem);
}
}
-
+
/**
* Marshals errors into the monitor
*
@@ -170,12 +169,18 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
* @param model
*/
protected void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-xml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "assembly-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
}
-
+
/**
* Marshals exceptions into the monitor
*
@@ -184,10 +189,16 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
* @param model
*/
protected void error(String message, Object model, Exception ex) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-xml-validation-messages", Severity.ERROR, model, message, ex);
- monitor.problem(problem);
- }
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "assembly-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
}
/**
@@ -261,7 +272,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
reference.setMultiplicity(Multiplicity.ONE_ONE);
}
}
-
+
protected XAttr writeMultiplicity(AbstractReference reference) {
Multiplicity multiplicity = reference.getMultiplicity();
if (multiplicity != null) {
@@ -323,7 +334,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
* @throws ContributionResolveException
*/
protected Implementation resolveImplementation(Implementation implementation, ModelResolver resolver)
- throws ContributionResolveException, PolicyValidationException {
+ throws ContributionResolveException {
if (implementation != null) {
if (implementation.isUnresolved()) {
implementation = resolver.resolveModel(Implementation.class, implementation);
@@ -332,71 +343,24 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
if (implementation.isUnresolved()) {
extensionProcessor.resolve(implementation, resolver);
if (!implementation.isUnresolved()) {
- //resolve policies
- if ( implementation instanceof PolicySetAttachPoint ) {
- PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
- resolveIntents(policiedImpl.getRequiredIntents(), resolver);
- PolicyValidationUtils.validateIntents(policiedImpl, policiedImpl.getType());
-
- resolvePolicySets(policiedImpl.getPolicySets(), resolver);
- PolicyValidationUtils.validatePolicySets(policiedImpl);
-
- if ( implementation instanceof OperationsConfigurator ) {
- OperationsConfigurator opsConfigurator = (OperationsConfigurator)implementation;
- for ( ConfiguredOperation implOp : opsConfigurator.getConfiguredOperations() ) {
- resolveIntents(implOp.getRequiredIntents(), resolver);
- PolicyValidationUtils.validateIntents(implOp, policiedImpl.getType());
-
- resolvePolicySets(implOp.getPolicySets(), resolver);
- PolicyValidationUtils.validatePolicySets(implOp,
- policiedImpl.getType(),
- policiedImpl.getApplicablePolicySets());
- }
- }
-
- for ( Service service : implementation.getServices() ) {
- resolveIntents(service.getRequiredIntents(), resolver);
- resolvePolicySets(service.getPolicySets(), resolver);
-
- for ( ConfiguredOperation svcOp : service.getConfiguredOperations() ) {
- resolveIntents(svcOp.getRequiredIntents(), resolver);
- resolvePolicySets(svcOp.getPolicySets(), resolver);
- }
- }
-
- for ( Reference reference : implementation.getReferences() ) {
- resolveIntents(reference.getRequiredIntents(), resolver);
- resolvePolicySets(reference.getPolicySets(), resolver);
- }
- }
-
resolver.addModel(implementation);
}
}
}
-
- if ( implementation instanceof IntentAttachPoint &&
- ((IntentAttachPoint)implementation).getType() != null &&
- ((IntentAttachPoint)implementation).getType().isUnresolved() ) {
- ((IntentAttachPoint)implementation).setType(
- resolver.resolveModel(IntentAttachPointType.class,
- ((IntentAttachPoint)implementation).getType()));
- }
}
return implementation;
}
-
+
/**
* Resolve interface, callback interface and bindings on a list of contracts.
* @param contracts the list of contracts
* @param resolver the resolver to use to resolve models
*/
protected <C extends Contract> void resolveContracts(List<C> contracts, ModelResolver resolver)
- throws ContributionResolveException {
+ throws ContributionResolveException {
resolveContracts(null, contracts, resolver);
}
-
/**
* Resolve interface, callback interface and bindings on a list of contracts.
* @param parent element for the contracts
@@ -405,143 +369,32 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
*/
protected <C extends Contract> void resolveContracts(Base parent, List<C> contracts, ModelResolver resolver)
throws ContributionResolveException {
-
- String parentName = (parent instanceof Composite) ? ((Composite)parent).getName().toString() :
- (parent instanceof Component) ? ((Component)parent).getName() : "UNKNOWN";
-
+
+ String parentName =
+ (parent instanceof Composite) ? ((Composite)parent).getName().toString() : (parent instanceof Component)
+ ? ((Component)parent).getName() : "UNKNOWN";
+
for (Contract contract : contracts) {
- try {
- //resolve the intents and policysets as they need to be copied over into the
- //child binding elements
- resolveIntents(contract.getRequiredIntents(), resolver);
- resolvePolicySets(contract.getPolicySets(), resolver);
- resolvePolicySets(contract.getApplicablePolicySets(), resolver);
-
- // Inherit the composite / component level applicable policy sets.
- if ( parent != null && parent instanceof PolicySetAttachPoint ) {
- addInheritedPolicySets(((PolicySetAttachPoint)parent).getApplicablePolicySets(), contract.getApplicablePolicySets());
- }
-
- for ( ConfiguredOperation confOp : contract.getConfiguredOperations() ) {
- resolveIntents(confOp.getRequiredIntents(), resolver);
- resolvePolicySets(confOp.getPolicySets(), resolver);
- resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
-
- //inherit applicable policy sets from parent contract
- addInheritedPolicySets(contract.getApplicablePolicySets(), confOp.getApplicablePolicySets());
- }
-
- // Resolve the interface contract
- InterfaceContract interfaceContract = contract.getInterfaceContract();
- if (interfaceContract != null) {
- extensionProcessor.resolve(interfaceContract, resolver);
- }
-
- // Resolve bindings
- for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
- Binding binding = contract.getBindings().get(i);
+ // Resolve the interface contract
+ InterfaceContract interfaceContract = contract.getInterfaceContract();
+ if (interfaceContract != null) {
+ extensionProcessor.resolve(interfaceContract, resolver);
+ }
+
+ // Resolve bindings
+ for (int i = 0, n = contract.getBindings().size(); i < n; i++) {
+ Binding binding = contract.getBindings().get(i);
+ extensionProcessor.resolve(binding, resolver);
+
+ }
+
+ // Resolve callback bindings
+ if (contract.getCallback() != null) {
+
+ for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
+ Binding binding = contract.getCallback().getBindings().get(i);
extensionProcessor.resolve(binding, resolver);
-
- if (binding instanceof IntentAttachPoint) {
- IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
-
- if ( policiedBinding.getType() != null && policiedBinding.getType().isUnresolved() ) {
- IntentAttachPointType resolved =
- resolver.resolveModel(IntentAttachPointType.class,
- policiedBinding.getType());
- policiedBinding.setType(resolved);
- }
-
- resolveIntents(policiedBinding.getRequiredIntents(), resolver);
- PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
- }
-
- if (binding instanceof PolicySetAttachPoint) {
- PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
- resolvePolicySets(policiedBinding.getPolicySets(), resolver);
- //validate if attached policysets apply to the binding
- resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
- //inherit the applicable policysets from parent contract as whatever applies to that
- //applies to the binding as well
- addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
- PolicyValidationUtils.validatePolicySets(policiedBinding);
- }
-
- if (binding instanceof OperationsConfigurator) {
- OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
- for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
- resolveIntents(confOp.getRequiredIntents(), resolver);
- PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType());
-
- resolvePolicySets(confOp.getPolicySets(), resolver);
- resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
- //inherit the applicable policysets from parent binding as whatever applies to that
- //applies to the binding as well
- addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
- confOp.getApplicablePolicySets());
- PolicyValidationUtils.validatePolicySets(confOp, ((PolicySetAttachPoint)binding).getType());
- }
- }
}
-
- // Resolve callback bindings
- if (contract.getCallback() != null) {
- resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
- resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
- resolvePolicySets(contract.getCallback().getApplicablePolicySets(), resolver);
- //inherit the contract's policy intents and policysets
- addInheritedPolicySets(contract.getApplicablePolicySets(), contract.getCallback().getApplicablePolicySets());
-
- for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
- Binding binding = contract.getCallback().getBindings().get(i);
- extensionProcessor.resolve(binding, resolver);
-
- if (binding instanceof IntentAttachPoint) {
- IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
-
- if ( policiedBinding.getType().isUnresolved() ) {
- IntentAttachPointType resolved =
- resolver.resolveModel(IntentAttachPointType.class,
- policiedBinding.getType());
- policiedBinding.setType(resolved);
- }
-
- resolveIntents(policiedBinding.getRequiredIntents(), resolver);
- PolicyValidationUtils.validateIntents(policiedBinding, policiedBinding.getType());
- }
-
- if (binding instanceof PolicySetAttachPoint) {
- PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
- resolvePolicySets(policiedBinding.getPolicySets(), resolver);
- //validate if attached policysets apply to the binding
- resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
- //inherit the applicable policysets from parent contract as whatever applies to that
- //applies to the binding as well
- addInheritedPolicySets(contract.getApplicablePolicySets(), policiedBinding.getApplicablePolicySets());
- PolicyValidationUtils.validatePolicySets(policiedBinding);
- }
-
- if (binding instanceof OperationsConfigurator) {
- OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
- for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
- resolveIntents(confOp.getRequiredIntents(), resolver);
- PolicyValidationUtils.validateIntents(confOp, ((PolicySetAttachPoint)binding).getType());
-
- resolvePolicySets(confOp.getPolicySets(), resolver);
- resolvePolicySets(confOp.getApplicablePolicySets(), resolver);
- //inherit the applicable policysets from parent binding as whatever applies to that
- //applies to the binding as well
- addInheritedPolicySets(((PolicySetAttachPoint)binding).getApplicablePolicySets(),
- confOp.getApplicablePolicySets());
- PolicyValidationUtils.validatePolicySets(confOp, ((PolicySetAttachPoint)binding).getType());
- }
- }
- }
- }
- } catch ( PolicyValidationException e ) {
- error("PolicyServiceValidationException", contract, contract.getName(), parentName, e.getMessage());
- //throw new ContributionResolveException("PolicyValidation exceptions when processing service/reference '"
- //+ contract.getName() + "' in '" + parentName + "'");
}
}
}
@@ -597,8 +450,8 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
}
document = documentBuilderFactory.newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e) {
- ContributionReadException ce = new ContributionReadException(e);
- error("ContributionReadException", documentBuilderFactory, ce);
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", documentBuilderFactory, ce);
throw ce;
}
@@ -748,42 +601,6 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
}
/**
- * Resolve policy intents attached to a specific SCA Artifact
- * @param policyIntents list of policy intents
- * @param resolver
- */
- protected void resolveIntents(List<Intent> policyIntents, ModelResolver resolver) {
- List<Intent> requiredIntents = new ArrayList<Intent>();
- Intent resolvedIntent = null;
- for (Intent intent : policyIntents) {
- resolvedIntent = resolver.resolveModel(Intent.class, intent);
- requiredIntents.add(resolvedIntent);
- }
- policyIntents.clear();
- policyIntents.addAll(requiredIntents);
- }
-
- /**
- * Resolve policy sets attached to a specific SCA Construct
- * @param policySets list of attached policy sets
- * @param resolver
- */
- protected void resolvePolicySets(List<PolicySet> policySets, ModelResolver resolver) {
- List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
- PolicySet resolvedPolicySet = null;
- for (PolicySet policySet : policySets) {
- if (policySet.isUnresolved()) {
- resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet);
- resolvedPolicySets.add(resolvedPolicySet);
- } else {
- resolvedPolicySets.add(policySet);
- }
- }
- policySets.clear();
- policySets.addAll(resolvedPolicySets);
- }
-
- /**
* Write the value of a property
* @param document
* @param element
@@ -802,8 +619,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
Node node = nodeList.item(item);
int nodeType = node.getNodeType();
if (nodeType == Node.ELEMENT_NODE) {
- XMLStreamReader reader =
- XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(node));
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(node));
while (reader.hasNext()) {
switch (reader.next()) {
@@ -851,19 +667,19 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
}
}
}
-
+
protected void addInheritedIntents(List<Intent> sourceList, List<Intent> targetList) {
if (sourceList != null) {
targetList.addAll(sourceList);
}
}
-
- protected void addInheritedPolicySets(List<PolicySet> sourceList, List<PolicySet> targetList) {
+
+ protected void addInheritedPolicySets(List<PolicySet> sourceList, List<PolicySet> targetList) {
if (sourceList != null) {
targetList.addAll(sourceList);
}
}
-
+
/**
*
* @param reader
@@ -873,15 +689,19 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
* @throws ContributionReadException
* @throws XMLStreamException
*/
- protected void readExtendedAttributes(XMLStreamReader reader, QName elementName, Extensible estensibleElement, StAXAttributeProcessor extensionAttributeProcessor) throws ContributionReadException, XMLStreamException {
+ protected void readExtendedAttributes(XMLStreamReader reader,
+ QName elementName,
+ Extensible estensibleElement,
+ StAXAttributeProcessor extensionAttributeProcessor)
+ throws ContributionReadException, XMLStreamException {
for (int a = 0; a < reader.getAttributeCount(); a++) {
QName attributeName = reader.getAttributeName(a);
- if( attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
- if( ! elementName.getNamespaceURI().equals(attributeName.getNamespaceURI()) ) {
+ if (attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0) {
+ if (!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI())) {
Object attributeValue = extensionAttributeProcessor.read(attributeName, reader);
Extension attributeExtension;
if (attributeValue instanceof Extension) {
- attributeExtension = (Extension) attributeValue;
+ attributeExtension = (Extension)attributeValue;
} else {
attributeExtension = extensionFactory.createExtension(attributeName, attributeValue, true);
}
@@ -890,7 +710,6 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
}
}
}
-
/**
*
@@ -901,26 +720,29 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
* @throws ContributionWriteException
* @throws XMLStreamException
*/
- protected void writeExtendedAttributes(XMLStreamWriter writer, Extensible extensibleElement, StAXAttributeProcessor extensionAttributeProcessor) throws ContributionWriteException, XMLStreamException {
- for(Extension extension : extensibleElement.getAttributeExtensions()) {
- if(extension.isAttribute()) {
+ protected void writeExtendedAttributes(XMLStreamWriter writer,
+ Extensible extensibleElement,
+ StAXAttributeProcessor extensionAttributeProcessor)
+ throws ContributionWriteException, XMLStreamException {
+ for (Extension extension : extensibleElement.getAttributeExtensions()) {
+ if (extension.isAttribute()) {
extensionAttributeProcessor.write(extension, writer);
}
}
}
-
- /*protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint)
+
+ /*protected void validatePolicySets(PolicySubject policySetAttachPoint)
throws ContributionResolveException {
validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets());
}
- protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint,
+ protected void validatePolicySets(PolicySubject policySetAttachPoint,
List<PolicySet> applicablePolicySets) throws ContributionResolveException {
//Since the applicablePolicySets in a policySetAttachPoint will already have the
//list of policysets that might ever be applicable to this attachPoint, just check
//if the defined policysets feature in the list of applicable policysets
- IntentAttachPointType attachPointType = policySetAttachPoint.getType();
+ ExtensionType attachPointType = policySetAttachPoint.getType();
for ( PolicySet definedPolicySet : policySetAttachPoint.getPolicySets() ) {
if ( !definedPolicySet.isUnresolved() ) {
if ( !applicablePolicySets.contains(definedPolicySet)) {
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
index a8c2d6a7e9..0ea78177ff 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
@@ -63,8 +63,7 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.w3c.dom.Document;
/**
@@ -347,13 +346,13 @@ public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StA
// Write <implementation> elements if the componentType has
// any intents or policySets
boolean writeImplementation = false;
- if (componentType instanceof IntentAttachPoint) {
- if (!((IntentAttachPoint)componentType).getRequiredIntents().isEmpty()) {
+ if (componentType instanceof PolicySubject) {
+ if (!((PolicySubject)componentType).getRequiredIntents().isEmpty()) {
writeImplementation = true;
}
}
- if (componentType instanceof PolicySetAttachPoint) {
- if (!((PolicySetAttachPoint)componentType).getPolicySets().isEmpty()) {
+ if (componentType instanceof PolicySubject) {
+ if (!((PolicySubject)componentType).getPolicySets().isEmpty()) {
writeImplementation = true;
}
}
@@ -370,10 +369,6 @@ public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StA
// Resolve component type services and references
resolveContracts(componentType.getServices(), resolver);
resolveContracts(componentType.getReferences(), resolver);
- if ( componentType instanceof PolicySetAttachPoint ) {
- resolveIntents(((PolicySetAttachPoint)componentType).getRequiredIntents(), resolver);
- resolvePolicySets(((PolicySetAttachPoint)componentType).getPolicySets(), resolver);
- }
}
public QName getArtifactType() {
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
index 652d668577..6feadbd751 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
@@ -38,7 +38,6 @@ import static org.apache.tuscany.sca.assembly.xml.Constants.LOCAL;
import static org.apache.tuscany.sca.assembly.xml.Constants.MANY;
import static org.apache.tuscany.sca.assembly.xml.Constants.MUST_SUPPLY;
import static org.apache.tuscany.sca.assembly.xml.Constants.NAME;
-import static org.apache.tuscany.sca.assembly.xml.Constants.OPERATION_QNAME;
import static org.apache.tuscany.sca.assembly.xml.Constants.PROMOTE;
import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY;
import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY_QNAME;
@@ -57,7 +56,6 @@ import static org.apache.tuscany.sca.assembly.xml.Constants.WIRED_BY_IMPL;
import static org.apache.tuscany.sca.assembly.xml.Constants.WIRE_QNAME;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
@@ -79,11 +77,9 @@ import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
@@ -103,14 +99,9 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
-import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
-import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
-import org.apache.tuscany.sca.policy.util.PolicyValidationException;
-import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.w3c.dom.Document;
/**
@@ -120,7 +111,7 @@ import org.w3c.dom.Document;
*/
public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<Composite> {
private XPathFactory xPathFactory;
- private IntentAttachPointTypeFactory intentAttachPointTypeFactory;
+ private PolicyFactory intentAttachPointTypeFactory;
private StAXAttributeProcessor<Object> extensionAttributeProcessor;
private ContributionFactory contributionFactory;
@@ -157,7 +148,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
Monitor monitor) {
super(modelFactories, extensionProcessor, monitor);
- this.intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
this.xPathFactory = modelFactories.getFactory(XPathFactory.class);
this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
this.extensionAttributeProcessor = extensionAttributeProcessor;
@@ -433,30 +424,6 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
policyProcessor.readPolicies(callback, reader);
- } else if (OPERATION_QNAME.equals(name)) {
-
- // Read an <operation>
- ConfiguredOperation operation = assemblyFactory.createConfiguredOperation();
- operation.setName(getString(reader, NAME));
- operation.setUnresolved(true);
- if (callback != null) {
- policyProcessor.readPolicies(operation, reader);
- } else {
- policyProcessor.readPolicies(operation, reader);
- }
-
- OperationsConfigurator opConfigurator = null;
- if ( compositeService != null ) {
- opConfigurator = compositeService;
- } else if ( componentService != null ) {
- opConfigurator = componentService;
- } else if ( compositeReference != null ) {
- opConfigurator = compositeReference;
- } else if ( componentReference != null ) {
- opConfigurator = componentReference;
- }
-
- opConfigurator.getConfiguredOperations().add(operation);
} else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) {
// Read an implementation.composite
@@ -489,11 +456,11 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
}
}
} else if (extension instanceof Binding) {
- if ( extension instanceof PolicySetAttachPoint ) {
- IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
- bindingType.setName(name);
+ if ( extension instanceof PolicySubject ) {
+ ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
+ bindingType.setType(name);
bindingType.setUnresolved(true);
- ((PolicySetAttachPoint)extension).setType(bindingType);
+ ((PolicySubject)extension).setType(bindingType);
}
// <service><binding> and
// <reference><binding>
@@ -513,11 +480,11 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
}
} else if (extension instanceof Implementation) {
- if ( extension instanceof PolicySetAttachPoint ) {
- IntentAttachPointType implType = intentAttachPointTypeFactory.createImplementationType();
- implType.setName(name);
+ if ( extension instanceof PolicySubject ) {
+ ExtensionType implType = intentAttachPointTypeFactory.createImplementationType();
+ implType.setType(name);
implType.setUnresolved(true);
- ((PolicySetAttachPoint)extension).setType(implType);
+ ((PolicySubject)extension).setType(implType);
}
// <component><implementation>
if (component != null) {
@@ -960,17 +927,6 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
extensionProcessor.resolve(extension, resolver);
}
}
-
- //resolve intents and policy sets
- List<Intent> compositeIntents = null;
- List<PolicySet> compositePolicySets = null;
- List<PolicySet> compositeApplicablePolicySets = null;
- resolveIntents(composite.getRequiredIntents(), resolver);
- resolvePolicySets(composite.getPolicySets(), resolver);
- resolvePolicySets(composite.getApplicablePolicySets(), resolver);
- compositeIntents = composite.getRequiredIntents();
- compositePolicySets = composite.getPolicySets();
- compositeApplicablePolicySets = composite.getApplicablePolicySets();
//Resolve composite services and references
resolveContracts(composite, composite.getServices(), resolver);
@@ -984,19 +940,6 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
component.setConstrainingType(constrainingType);
}
- //resolve intents and policy sets
- resolveIntents(component.getRequiredIntents(), resolver);
- resolvePolicySets(component.getPolicySets(), resolver);
- resolvePolicySets(component.getApplicablePolicySets(), resolver);
-
- //inherit composite intents and policysets
- PolicyComputationUtils.addDefaultPolicies(compositeIntents,
- compositePolicySets,
- component.getRequiredIntents(),
- component.getPolicySets());
-
- addInheritedPolicySets(compositeApplicablePolicySets, component.getApplicablePolicySets());
-
//resolve component services and references
resolveContracts(component, component.getServices(), resolver);
resolveContracts(component, component.getReferences(), resolver);
@@ -1015,35 +958,12 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
//resolve component implementation
Implementation implementation = component.getImplementation();
if (implementation != null) {
- try {
- //resolve intents and policysets specified on this implementation
- //before copying them over to the component. Before that, from the component
- //copy over the applicablePolicySets alone as it might have to be
- //used to validate the policysets specified on the implementation
-
- resolveImplIntentsAndPolicySets(implementation,
- component.getApplicablePolicySets(),
- resolver);
+ //now resolve the implementation so that even if there is a shared instance
+ //for this that is resolved, the specified intents and policysets are safe in the
+ //component and not lost
+ implementation = resolveImplementation(implementation, resolver);
- copyPoliciesToComponent(component, implementation, resolver, true);
-
- //now resolve the implementation so that even if there is a shared instance
- //for this that is resolved, the specified intents and policysets are safe in the
- //component and not lost
- implementation = resolveImplementation(implementation, resolver);
-
- //resolved implementation may contain intents and policysets specified at
- //componentType (either in the componentType side file or in annotations if its a
- //java implementation). This has to be consolidated in to the component.
- copyPoliciesToComponent(component, implementation, resolver, false);
-
- component.setImplementation(implementation);
- } catch ( PolicyValidationException e ) {
- error("PolicyImplValidationException", resolver, component.getName(), e.getMessage());
- //throw new ContributionResolveException("PolicyValidation exception when processing implementation of component '"
- //+ component.getName() + "' due to " + e.getMessage(), e);
- }
-
+ component.setImplementation(implementation);
}
//add model resolver to component
@@ -1062,154 +982,6 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
}
}
- private void resolveImplIntentsAndPolicySets(Implementation implementation,
- List<PolicySet> inheritedApplicablePolicySets,
- ModelResolver resolver) throws ContributionResolveException,
- PolicyValidationException
- {
- if ( implementation instanceof PolicySetAttachPoint ) {
- PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
-
- policiedImpl.getApplicablePolicySets().addAll(inheritedApplicablePolicySets);
-
- resolveIntents(policiedImpl.getRequiredIntents(), resolver);
- PolicyValidationUtils.validateIntents(policiedImpl, policiedImpl.getType());
-
- resolvePolicySets(policiedImpl.getPolicySets(), resolver);
- resolvePolicySets(policiedImpl.getApplicablePolicySets(), resolver);
-
- PolicyValidationUtils.validatePolicySets(policiedImpl);
-
- if ( implementation instanceof OperationsConfigurator ) {
- for ( ConfiguredOperation implConfOp : ((OperationsConfigurator)implementation).getConfiguredOperations() ) {
- resolveIntents(implConfOp.getRequiredIntents(), resolver);
- PolicyValidationUtils.validateIntents(implConfOp, policiedImpl.getType());
-
- resolvePolicySets(implConfOp.getPolicySets(), resolver);
- resolvePolicySets(implConfOp.getApplicablePolicySets(), resolver);
- //add the inherited applicablePolicysets
- addInheritedPolicySets(policiedImpl.getApplicablePolicySets(), implConfOp.getApplicablePolicySets());
-
- PolicyValidationUtils.validatePolicySets(implConfOp, policiedImpl.getType());
-
- PolicyComputationUtils.addDefaultPolicies(
- ((PolicySetAttachPoint)implementation).getRequiredIntents(),
- ((PolicySetAttachPoint)implementation).getPolicySets(),
- implConfOp.getRequiredIntents(),
- implConfOp.getPolicySets());
- }
- }
- }
- }
-
- private void copyPoliciesToComponent(Component component,
- Implementation implementation,
- ModelResolver resolver,
- boolean clearImplSettings) throws ContributionResolveException {
- if (implementation instanceof PolicySetAttachPoint) {
- // Add implementation policies into component, since implementation instances are
- // reused and it's likely that this implementation instance will not hold after its resolution.
- // On the first call to this method (clearImplSettings=true), we are moving policies from the
- // implementation XML element up to the component. In this case if there are mutually exclusive
- // policies we must clear the component policy so that the implementation policy "wins".
- // On the second call to this method (clearImplSettings=false), we are moving policies from the
- // componentType implementation up to the component. In this case if there are mutually
- // exclusive policies it is an error. This error will be detected later in the PolicyComputer.
- if (clearImplSettings) {
- for (Intent intent : ((PolicySetAttachPoint)implementation).getRequiredIntents()) {
- for (Intent excluded : intent.getExcludedIntents()) {
- if (component.getRequiredIntents().contains(excluded)) {
- component.getRequiredIntents().remove(excluded);
- }
- for (Iterator<PolicySet> i = component.getPolicySets().iterator(); i.hasNext(); ) {
- PolicySet cmpPolicySet = i.next();
- if (cmpPolicySet.getProvidedIntents().contains(excluded)) {
- i.remove();
- }
- }
- }
- }
- for (PolicySet policySet : ((PolicySetAttachPoint)implementation).getPolicySets()) {
- for (Intent intent : policySet.getProvidedIntents()) {
- for (Intent excluded : intent.getExcludedIntents()) {
- if (component.getRequiredIntents().contains(excluded)) {
- component.getRequiredIntents().remove(excluded);
- }
- for (Iterator<PolicySet> i = component.getPolicySets().iterator(); i.hasNext(); ) {
- PolicySet cmpPolicySet = i.next();
- if (cmpPolicySet.getProvidedIntents().contains(excluded)) {
- i.remove();
- }
- }
- }
- }
- }
- }
- component.getRequiredIntents().addAll(((PolicySetAttachPoint)implementation).getRequiredIntents());
- component.getPolicySets().addAll(((PolicySetAttachPoint)implementation).getPolicySets());
- component.getApplicablePolicySets().addAll(((PolicySetAttachPoint)implementation).getApplicablePolicySets());
-
- if ( implementation instanceof OperationsConfigurator ) {
- boolean notFound;
- List<ConfiguredOperation> opsFromImplementation = new ArrayList<ConfiguredOperation>();
- List<ConfiguredOperation> implConfOperations =
- new ArrayList<ConfiguredOperation>(((OperationsConfigurator)implementation).getConfiguredOperations());
- for ( ConfiguredOperation implConfOp : implConfOperations ) {
- notFound = true;
- for ( ConfiguredOperation compConfOp : ((OperationsConfigurator)component).getConfiguredOperations() ) {
- if ( implConfOp.getName().equals(compConfOp.getName()) ) {
- notFound = false;
-
- if (clearImplSettings) {
- for (Intent intent : implConfOp.getRequiredIntents()) {
- for (Intent excluded : intent.getExcludedIntents()) {
- if (compConfOp.getRequiredIntents().contains(excluded)) {
- compConfOp.getRequiredIntents().remove(excluded);
- }
- }
- }
- for (PolicySet policySet : implConfOp.getPolicySets()) {
- for (Intent intent : policySet.getProvidedIntents()) {
- for (Intent excluded : intent.getExcludedIntents()) {
- if (compConfOp.getRequiredIntents().contains(excluded)) {
- compConfOp.getRequiredIntents().remove(excluded);
- }
- for (Iterator<PolicySet> i = compConfOp.getPolicySets().iterator(); i.hasNext(); ) {
- PolicySet cmpPolicySet = i.next();
- if (cmpPolicySet.getProvidedIntents().contains(excluded)) {
- i.remove();
- }
- }
- }
- }
- }
- }
-
- addInheritedIntents(implConfOp.getRequiredIntents(), compConfOp.getRequiredIntents());
- addInheritedPolicySets(implConfOp.getPolicySets(), compConfOp.getPolicySets());
- addInheritedPolicySets(implConfOp.getApplicablePolicySets(), compConfOp.getApplicablePolicySets());
- }
- }
-
- if ( notFound ) {
- opsFromImplementation.add(implConfOp);
- }
-
- if ( clearImplSettings ) {
- ((OperationsConfigurator)implementation).getConfiguredOperations().remove(implConfOp);
- }
- }
- ((OperationsConfigurator)component).getConfiguredOperations().addAll(opsFromImplementation);
- }
-
- if ( clearImplSettings ) {
- ((PolicySetAttachPoint)implementation).getRequiredIntents().clear();
- ((PolicySetAttachPoint)implementation).getPolicySets().clear();
- }
- }
- }
-
-
public QName getArtifactType() {
return COMPOSITE_QNAME;
}
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java
deleted file mode 100644
index aed535cf0d..0000000000
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.assembly.xml;
-import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
-import static org.apache.tuscany.sca.assembly.xml.Constants.NAME;
-import static org.apache.tuscany.sca.assembly.xml.Constants.OPERATION;
-import static org.apache.tuscany.sca.assembly.xml.Constants.OPERATION_QNAME;
-import static org.apache.tuscany.sca.assembly.xml.Constants.SERVICE;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.PolicyFactory;
-
-/**
- * Processor for dealing with 'operation' elements from composite definitions
- *
- * @version $Rev$ $Date$
- */
-public class ConfiguredOperationProcessor implements StAXArtifactProcessor<ConfiguredOperation> {
-
- private AssemblyFactory assemblyFactory;
- private PolicyAttachPointProcessor policyProcessor;
- private PolicyFactory policyFactory;
- private Monitor monitor;
-
- public ConfiguredOperationProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
- this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
- this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
- this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
- this.monitor = monitor;
- }
-
- public ConfiguredOperation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
- ConfiguredOperation configuredOp = assemblyFactory.createConfiguredOperation();
-
- //Read an <operation>
- configuredOp.setName(reader.getAttributeValue(null, NAME));
- configuredOp.setContractName(reader.getAttributeValue(null, SERVICE));
- configuredOp.setUnresolved(true);
-
- // Read policies
- policyProcessor.readPolicies(configuredOp, reader);
-
- //Skip to end element
- while (reader.hasNext()) {
- if (reader.next() == END_ELEMENT && OPERATION_QNAME.equals(reader.getName())) {
- break;
- }
- }
-
- return configuredOp;
- }
-
- public void write(ConfiguredOperation configuredOperation, XMLStreamWriter writer)
- throws ContributionWriteException, XMLStreamException {
-
- // Write an <operation>
- policyProcessor.writePolicyPrefixes(configuredOperation, writer);
- writer.writeStartElement(Constants.SCA10_NS, OPERATION);
- policyProcessor.writePolicyAttributes(configuredOperation, writer);
-
- writer.writeAttribute(NAME, configuredOperation.getName());
- if ( configuredOperation.getContractName() != null ) {
- writer.writeAttribute(SERVICE, configuredOperation.getContractName());
- }
- writer.writeEndElement();
- }
-
- public void resolve(ConfiguredOperation configuredOperation, ModelResolver resolver)
- throws ContributionResolveException {
- }
-
- public QName getArtifactType() {
- return OPERATION_QNAME;
- }
-
- public Class<ConfiguredOperation> getModelType() {
- return ConfiguredOperation.class;
- }
-
-}
-
-
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java
index d6c1b278bb..34c4bc9909 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java
@@ -261,15 +261,6 @@ public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements
// Resolve component type services and references
resolveAbstractContracts(constrainingType.getServices(), resolver);
resolveAbstractContracts(constrainingType.getReferences(), resolver);
-
- resolveIntents(constrainingType.getRequiredIntents(), resolver);
- for ( AbstractService service : constrainingType.getServices() ) {
- resolveIntents(service.getRequiredIntents(), resolver);
- }
-
- for ( AbstractReference reference : constrainingType.getReferences() ) {
- resolveIntents(reference.getRequiredIntents(), resolver);
- }
}
public QName getArtifactType() {
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
index b29910e215..e525cc677a 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
@@ -42,7 +42,7 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Default Model Processor for beans.
@@ -220,10 +220,10 @@ public class DefaultBeanModelProcessor extends BaseAssemblyProcessor implements
implementation.getProperties().addAll(componentType.getProperties());
implementation.setConstrainingType(componentType.getConstrainingType());
- if (implementation instanceof PolicySetAttachPoint &&
- componentType instanceof PolicySetAttachPoint ) {
- PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
- PolicySetAttachPoint policiedCompType = (PolicySetAttachPoint)componentType;
+ if (implementation instanceof PolicySubject &&
+ componentType instanceof PolicySubject ) {
+ PolicySubject policiedImpl = (PolicySubject)implementation;
+ PolicySubject policiedCompType = (PolicySubject)componentType;
if ( policiedImpl.getPolicySets() != null) {
policiedImpl.getPolicySets().addAll(policiedCompType.getPolicySets());
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
index 359f87c615..d69f30aceb 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicyAttachPointProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
@@ -19,10 +19,8 @@
package org.apache.tuscany.sca.assembly.xml;
-import static org.apache.tuscany.sca.assembly.xml.Constants.APPLICABLE_POLICY_SETS;
import static org.apache.tuscany.sca.assembly.xml.Constants.POLICY_SETS;
import static org.apache.tuscany.sca.assembly.xml.Constants.REQUIRES;
-import static org.apache.tuscany.sca.assembly.xml.Constants.SCA10_TUSCANY_NS;
import java.util.ArrayList;
import java.util.List;
@@ -37,21 +35,20 @@ import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* A Policy Attach Point processor.
*
* @version $Rev$ $Date$
*/
-public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor {
+public class PolicySubjectProcessor extends BaseStAXArtifactProcessor {
private PolicyFactory policyFactory;
- public PolicyAttachPointProcessor(PolicyFactory policyFactory) {
+ public PolicySubjectProcessor(PolicyFactory policyFactory) {
this.policyFactory = policyFactory;
}
@@ -62,9 +59,9 @@ public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor {
* @param reader
*/
private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) {
- if (!(attachPoint instanceof IntentAttachPoint))
+ if (!(attachPoint instanceof PolicySubject))
return;
- IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint;
+ PolicySubject intentAttachPoint = (PolicySubject)attachPoint;
String value = reader.getAttributeValue(null, REQUIRES);
if (value != null) {
List<Intent> requiredIntents = intentAttachPoint.getRequiredIntents();
@@ -109,13 +106,13 @@ public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor {
* @param reader
*/
private void readPolicySets(Object attachPoint, Operation operation, XMLStreamReader reader) {
- if (!(attachPoint instanceof PolicySetAttachPoint)) {
+ if (!(attachPoint instanceof PolicySubject)) {
return;
}
- PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint;
+ PolicySubject policySubject = (PolicySubject)attachPoint;
String value = reader.getAttributeValue(null, POLICY_SETS);
if (value != null) {
- List<PolicySet> policySets = policySetAttachPoint.getPolicySets();
+ List<PolicySet> policySets = policySubject.getPolicySets();
for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
QName qname = getQNameValue(reader, tokens.nextToken());
PolicySet policySet = policyFactory.createPolicySet();
@@ -128,22 +125,6 @@ public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor {
policySets.add(policySet);
}
}
-
- value = reader.getAttributeValue(SCA10_TUSCANY_NS, APPLICABLE_POLICY_SETS);
- if (value != null) {
- List<PolicySet> applicablePolicySets = policySetAttachPoint.getApplicablePolicySets();
- for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
- QName qname = getQNameValue(reader, tokens.nextToken());
- PolicySet policySet = policyFactory.createPolicySet();
- policySet.setName(qname);
- if (operation != null) {
- //FIXME Don't we need to handle policySet specification
- // on an operation basis?
- //policySet.getOperations().add(operation);
- }
- applicablePolicySets.add(policySet);
- }
- }
}
/**
@@ -212,10 +193,10 @@ public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor {
* @param operation
*/
private XAttr writeIntents(Object attachPoint, Operation operation) {
- if (!(attachPoint instanceof IntentAttachPoint)) {
+ if (!(attachPoint instanceof PolicySubject)) {
return null;
}
- IntentAttachPoint intentAttachPoint = (IntentAttachPoint)attachPoint;
+ PolicySubject intentAttachPoint = (PolicySubject)attachPoint;
List<QName> qnames = new ArrayList<QName>();
for (Intent intent: intentAttachPoint.getRequiredIntents()) {
qnames.add(intent.getName());
@@ -229,10 +210,10 @@ public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor {
* @param operation
*/
private XAttr writePolicySets(Object attachPoint, Operation operation) {
- if (!(attachPoint instanceof PolicySetAttachPoint)) {
+ if (!(attachPoint instanceof PolicySubject)) {
return null;
}
- PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint;
+ PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
List<QName> qnames = new ArrayList<QName>();
for (PolicySet policySet: policySetAttachPoint.getPolicySets()) {
qnames.add(policySet.getName());
@@ -241,8 +222,8 @@ public class PolicyAttachPointProcessor extends BaseStAXArtifactProcessor {
}
public void resolvePolicies(Object attachPoint, ModelResolver resolver) {
- if ( attachPoint instanceof PolicySetAttachPoint ) {
- PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)attachPoint;
+ if ( attachPoint instanceof PolicySubject ) {
+ PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
List<Intent> requiredIntents = new ArrayList<Intent>();
Intent resolvedIntent = null;
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java
index 62318946a2..6b26c8c3af 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/BuildPolicyTestCase.java
@@ -31,7 +31,6 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.ConstrainingType;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
@@ -50,8 +49,9 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -115,35 +115,29 @@ public class BuildPolicyTestCase {
}
@Test
+ @Ignore("The inheritance will be calculated differently in OASIS SCA")
public void testPolicyIntentInheritance() throws Exception {
String namespaceUri = "http://test";
- IntentAttachPoint policiedComposite = (IntentAttachPoint)composite;
+ PolicySubject policiedComposite = (PolicySubject)composite;
assertEquals(policiedComposite.getRequiredIntents().size(), 1);
assertEquals(policiedComposite.getRequiredIntents().get(0).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
//1 defined for composite, 2 defined for the service, 1 defined and 3 inherited for the promoted service (4)
assertEquals(composite.getServices().get(0).getRequiredIntents().size(), 7);
//1 from the operation defined in this service and 2 from the operation defined in the promoted service
- assertEquals(composite.getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
assertEquals(composite.getServices().get(0).getRequiredIntents().get(3).getName(), new QName(namespaceUri, "tuscanyIntent_3"));
//bindings will have only 2 intents since duplications will be cut out
- assertEquals(((IntentAttachPoint)composite.getServices().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
- assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0)).getConfiguredOperations().size(), 1);
- assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0)).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
+ assertEquals(((PolicySubject)composite.getServices().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
assertEquals(composite.getReferences().get(0).getRequiredIntents().size(), 5);
- assertEquals(composite.getReferences().get(0).getConfiguredOperations().size(), 1);
- assertEquals(composite.getReferences().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 4);
assertEquals(composite.getReferences().get(0).getRequiredIntents().get(1).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
- assertEquals(((IntentAttachPoint)composite.getReferences().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
+ assertEquals(((PolicySubject)composite.getReferences().get(0).getBindings().get(0)).getRequiredIntents().size(), 3);
assertEquals(composite.getComponents().get(0).getRequiredIntents().size(), 3);
assertEquals(composite.getComponents().get(0).getRequiredIntents().get(2).getName(), new QName(namespaceUri, "tuscanyIntent_1"));
assertEquals(composite.getComponents().get(0).getServices().get(0).getRequiredIntents().size(), 4);
assertEquals(composite.getComponents().get(0).getServices().get(0).getCallback().getRequiredIntents().size(), 4);
- assertEquals(composite.getComponents().get(0).getServices().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
assertEquals(composite.getComponents().get(0).getReferences().get(0).getRequiredIntents().size(), 5);
- assertEquals(composite.getComponents().get(0).getReferences().get(0).getConfiguredOperations().get(0).getRequiredIntents().size(), 5);
}
}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
index 98e1cf31ef..54d8f3d260 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
@@ -41,7 +41,7 @@ import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProce
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.junit.BeforeClass;
import org.junit.Test;
import org.w3c.dom.Document;
@@ -73,9 +73,9 @@ public class ReadAllTestCase {
assertEquals(composite.getConstrainingType().getName(), new QName("http://calc", "CalculatorComponent"));
assertTrue(composite.isLocal());
assertFalse(composite.getAutowire() == Boolean.TRUE);
- assertEquals(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getName(), new QName("http://test",
+ assertEquals(((PolicySubject)composite).getRequiredIntents().get(0).getName(), new QName("http://test",
"confidentiality"));
- assertEquals(((PolicySetAttachPoint)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
+ assertEquals(((PolicySubject)composite).getPolicySets().get(0).getName(), new QName("http://test", "SecureReliablePolicy"));
Composite include = composite.getIncludes().get(0);
assertEquals(include.getName(), new QName("http://calc", "TestAllDivide"));
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
index cc5421cd84..c4519ef338 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
@@ -38,7 +38,7 @@ import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.definitions.Definitions;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -89,15 +89,17 @@ public class ResolvePolicyTestCase {
preResolvePolicyTests(composite);
documentProcessor.resolve(scaDefns, resolver);
documentProcessor.resolve(composite, resolver);
- postResolvePolicyTests(composite);
+
+ // Comment out the post resolving test
+ // postResolvePolicyTests(composite);
assertEquals(composite.getConstrainingType(), constrainingType);
assertEquals(composite.getComponents().get(0).getConstrainingType(), constrainingType);
}
private void preResolvePolicyTests(Composite composite) {
- assertNull(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getDescription());
- assertTrue(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
+ assertTrue(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
assertNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
assertTrue(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
@@ -118,9 +120,9 @@ public class ResolvePolicyTestCase {
}
private void postResolvePolicyTests(Composite composite) {
- assertNotNull(((PolicySetAttachPoint)composite).getRequiredIntents().get(0).getDescription());
- assertFalse(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
- assertNotNull(((PolicySetAttachPoint)composite).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
+ assertNotNull(((PolicySubject)composite).getRequiredIntents().get(0).getDescription());
+ assertFalse(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().isEmpty());
+ assertNotNull(((PolicySubject)composite).getPolicySets().get(0).getProvidedIntents().get(1).getDescription());
assertNotNull(composite.getServices().get(0).getRequiredIntents().get(0).getDescription());
assertFalse(composite.getServices().get(0).getPolicySets().get(0).getProvidedIntents().isEmpty());
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
index d01e304aad..e1a149494d 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
@@ -28,37 +28,46 @@ import org.apache.tuscany.sca.contribution.processor.ContributionResolveExceptio
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.policy.Policy;
+import org.apache.tuscany.sca.policy.PolicyExpression;
/**
- * A Policy Processor used for testing.
+ * A PolicyExpression Processor used for testing.
*
* @version $Rev$ $Date$
*/
-public class TestPolicyProcessor implements StAXArtifactProcessor<Policy> {
+public class TestPolicyProcessor implements StAXArtifactProcessor<PolicyExpression> {
public QName getArtifactType() {
return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
}
- public Policy read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException {
+ public PolicyExpression read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException {
return new MockPolicyImplOne();
}
- public void write(Policy arg0, XMLStreamWriter arg1) throws ContributionWriteException,
- XMLStreamException {
- }
+ public void write(PolicyExpression arg0, XMLStreamWriter arg1) throws ContributionWriteException,
+ XMLStreamException {
+ }
- public Class<Policy> getModelType() {
- return Policy.class;
+ public Class<PolicyExpression> getModelType() {
+ return PolicyExpression.class;
}
- public void resolve(Policy arg0, ModelResolver arg1) throws ContributionResolveException {
+ public void resolve(PolicyExpression arg0, ModelResolver arg1) throws ContributionResolveException {
}
-
- public class MockPolicyImplOne implements Policy {
- public QName getSchemaName() {
+ public class MockPolicyImplOne implements PolicyExpression {
+ public <T> T getPolicy() {
+ return null;
+ }
+
+ public void setName(QName name) {
+ }
+
+ public <T> void setPolicy(T policy) {
+ }
+
+ public QName getName() {
return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
}
@@ -68,6 +77,6 @@ public class TestPolicyProcessor implements StAXArtifactProcessor<Policy> {
public void setUnresolved(boolean unresolved) {
}
-
+
}
}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
index af25109de1..6d679f765f 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.assembly.xml;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import javax.xml.namespace.QName;
@@ -26,21 +27,19 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* A test cheel for the SCA binding.
*
* @version $Rev$ $Date$
*/
-public class TestSCABindingImpl implements SCABinding, OptimizableBinding, PolicySetAttachPoint, OperationsConfigurator {
+public class TestSCABindingImpl implements SCABinding, OptimizableBinding, PolicySubject {
private String name;
private String uri;
private List<Object> extensions = new ArrayList<Object>();
@@ -51,9 +50,7 @@ public class TestSCABindingImpl implements SCABinding, OptimizableBinding, Polic
private List<Intent> requiredIntents = new ArrayList<Intent>();
private List<PolicySet> policySets = new ArrayList<PolicySet>();
- private IntentAttachPointType bindingType = new TestSCABindingType();
- private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>();
- private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ private ExtensionType bindingType = new TestSCABindingType();
/**
* Constructs a new SCA binding.
@@ -148,66 +145,42 @@ public class TestSCABindingImpl implements SCABinding, OptimizableBinding, Polic
return requiredIntents;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
// TODO Auto-generated method stub
return bindingType;
}
- public void setType(IntentAttachPointType type) {
+ public void setType(ExtensionType type) {
this.bindingType = type;
}
- private class TestSCABindingType implements IntentAttachPointType {
+ private class TestSCABindingType implements ExtensionType {
private QName name = new QName("http://www.osoa.org/xmlns/sca/1.0","binding");
+ public QName getBaseType() {
+ return BINDING_BASE;
+ }
- public List<Intent> getAlwaysProvidedIntents() {
- // TODO Auto-generated method stub
- return null;
+ public QName getType() {
+ return name;
}
- public List<Intent> getMayProvideIntents() {
- // TODO Auto-generated method stub
- return null;
+ public void setType(QName type) {
}
- public QName getName() {
- return name;
+ public List<Intent> getAlwaysProvidedIntents() {
+ return Collections.emptyList();
}
- public boolean isUnresolved() {
- // TODO Auto-generated method stub
- return false;
+ public List<Intent> getMayProvidedIntents() {
+ return Collections.emptyList();
}
- public void setName(QName type) {
- // TODO Auto-generated method stub
-
+ public boolean isUnresolved() {
+ return false;
}
public void setUnresolved(boolean unresolved) {
- // TODO Auto-generated method stub
-
}
-
}
- public void setPolicySets(List<PolicySet> policySets) {
- this.policySets = policySets;
- }
-
- public void setRequiredIntents(List<Intent> intents) {
- this.requiredIntents = intents;
- }
-
- public List<ConfiguredOperation> getConfiguredOperations() {
- return configuredOperations;
- }
-
- public void setConfiguredOperations(List<ConfiguredOperation> configuredOperations) {
- this.configuredOperations = configuredOperations;
- }
-
- public List<PolicySet> getApplicablePolicySets() {
- return applicablePolicySets;
- }
}
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
index 5091ff700b..79b97e9799 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
@@ -36,13 +36,11 @@
<operation name="add" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
<binding.ws name="CalculatorWS" policySets="sns:SecureReliablePolicy" port="" requires="cns:confidentiality" uri="http://calc/ws">
- <operation name="add" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
</binding.ws>
<callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
<ext:testExtension/>
<binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="" uri="http://calc/callback/ws">
- <operation name="addCallback" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
</binding.ws>
</callback>
</service>
@@ -97,16 +95,13 @@
<reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService" policySets="sns:SecureReliablePolicy"
requires="cns:confidentiality">
<interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
- <operation name="multiply" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
<binding.ws name="MultiplyWS" port="" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" uri="http://calc/ws">
- <operation name="multiply" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
</binding.ws>
<callback policySets="sns:SecureReliablePolicy" requires="cns:confidentiality">
<binding.ws name="MultiplyCallbackWS" port="" uri="http://calc/callback/ws" policySets="sns:SecureReliablePolicy"
requires="cns:confidentiality">
- <operation name="multiplyCallback" policySets="sns:SecureReliablePolicy" requires="cns:confidentiality" />
</binding.ws>
</callback>
</reference>
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
index 7bc7ccdb83..3ac4b17117 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
@@ -49,7 +49,6 @@
<ext:testExtension/>
<service name="CalculatorService" requires="cns:tuscanyIntent_3">
<interface.java interface="calculator.CalculatorService" callbackInterface="calculator.CalculatorCallback" />
- <operation name="add" requires="cns:tuscanyIntent_6 cns:tuscanyIntent_7"/>
<binding.ws name="CalculatorCallbackWS" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
</binding.ws>
<callback>
@@ -60,7 +59,6 @@
requires="cns:tuscanyIntent_3 cns:tuscanyIntent_2.qualified" wiredByImpl="false">
<ext:testExtension/>
<interface.java interface="calculator.AddService" callbackInterface="calculator.AddCallback" />
- <operation name="add" requires="cns:tuscanyIntent_8 cns:tuscanyIntent_9"/>
<binding.ws name="addServiceWSRef" policySets="" port="" requires="cns:tuscanyIntent_4" uri="http://calc/callback/ws">
</binding.ws>
</reference>
@@ -102,7 +100,6 @@
<reference name="MultiplyService" promote="CalculatorServiceComponent/multiplyService"
requires="cns:tuscanyIntent_2">
<interface.java interface="calculator.MultiplyService" callbackInterface="calculator.MultiplyCallback" />
- <operation name="multiply" requires="cns:tuscanyIntent_6"/>
<binding.ws name="MultiplyWS" port="" requires="cns:tuscanyIntent_3" uri="http://calc/ws">
</binding.ws>
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
index bcc8c54dc8..5729038344 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
@@ -19,7 +19,7 @@
-->
<sca:definitions xmlns="http://test"
targetNamespace="http://test"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712">
<!-- simple intent -->
<sca:intent name="tuscanyIntent_1"
@@ -27,6 +27,7 @@
<sca:description>
Sample Intent
</sca:description>
+ <sca:qualifier name="qualified" default="true"/>
</sca:intent>
<sca:intent name="tuscanyIntent_2"
@@ -34,6 +35,7 @@
<sca:description>
Sample Intent
</sca:description>
+ <sca:qualifier name="qualified" default="true"/>
</sca:intent>
<sca:intent name="tuscanyIntent_3"
@@ -91,7 +93,4 @@
Sample Intent
</sca:description>
</sca:intent>
- <!-- qualified intents -->
- <sca:intent name="tuscanyIntent_1.qualified" />
- <sca:intent name="tuscanyIntent_2.qualified" />
</sca:definitions> \ No newline at end of file
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
index b79cb6b7b7..216cb29b0a 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
@@ -17,159 +17,190 @@
* specific language governing permissions and limitations
* under the License.
-->
-<sca:definitions xmlns="http://test"
- targetNamespace="http://test"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
-
- <!-- qualified intents -->
- <sca:intent name="confidentiality.transport" />
- <sca:intent name="confidentiality.message" />
- <sca:intent name="confidentiality.message.whole" />
- <sca:intent name="confidentiality.message.body" />
-
- <!-- POLICY SETS -->
- <sca:policySet name="SecureReliablePolicy"
- provides="confidentiality.transport integrity"
- appliesTo="//sca:binding.ws | //sca:binding.sca"
- xmlns="http://test"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "basic authentication" -->
- </wsp:PolicyAttachment>
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "reliability" -->
- </wsp:PolicyAttachment>
- </sca:policySet>
-
- <sca:policySet name="SecureMessagingPolicies"
- provides="confidentiality"
- appliesTo="//sca:binding.ws"
- xmlns="http://test"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <sca:intentMap provides="confidentiality" default="transport">
- <sca:qualifier name="transport">
- <wsp:Policy>
- <!-- policy expression and policy subject for "transport" alternative -->
- </wsp:Policy>
- <wsp:Policy>...</wsp:Policy>
- </sca:qualifier>
- <sca:qualifier name="message">
- <wsp:Policy>
- <!-- policy expression and policy subject for "message" alternative" -->
- </wsp:Policy>
- </sca:qualifier>
- </sca:intentMap>
-</sca:policySet>
-
-<sca:policySet name="SecurityPolicy" provides="confidentiality"
- xmlns="http://test"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" >
- <sca:intentMap provides="confidentiality" default="message">
- <sca:qualifier name="message">
- <sca:intentMap provides="message" default="whole">
- <sca:qualifier name="body">
- <wsp:Policy>
- <!-- policy attachment for body encryption -->
- </wsp:Policy>
- </sca:qualifier>
- <sca:qualifier name="whole">
- <wsp:Policy>
- <!-- policy attachment for whole message encryption -->
- </wsp:Policy>
- </sca:qualifier>
- </sca:intentMap>
- </sca:qualifier>
- <sca:qualifier name="transport">
- <wsp:Policy>
- <!-- policy attachment for transport encryption -->
- </wsp:Policy>
- </sca:qualifier>
- </sca:intentMap>
-</sca:policySet>
-
-<sca:policySet name="BasicAuthMsgProtSecurity"
- provides="authentication confidentiality"
- appliesTo="//sca:binding.ws"
- xmlns="http://test">
- <sca:policySetReference name="AuthenticationPolicies"/>
- <sca:policySetReference name="ConfidentialityPolicies"/>
-</sca:policySet>
-
-<sca:policySet name="AuthenticationPolicies"
- provides="authentication"
- appliesTo="//sca:binding.ws"
- xmlns="http://test"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "basic
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="message">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for whole message encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
authentication" -->
- </wsp:PolicyAttachment>
-</sca:policySet>
-
-<sca:policySet name="ConfidentialityPolicies"
- provides="confidentiality"
- bindings="binding.ws"
- xmlns="http://test"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <sca:intentMap provides="confidentiality" default="transport">
- <sca:qualifier name="transport">
- <wsp:Policy>
- <!-- policy expression and policy subject for "transport"
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
alternative -->
- </wsp:Policy>
- <wsp:Policy>...</wsp:Policy>
- </sca:qualifier>
- <sca:qualifier name="message">
- <wsp:Policy>
- <!-- policy expression and policy subject for "message"
- alternative" -->...
- </wsp:Policy>
- </sca:qualifier>
- </sca:intentMap>
-</sca:policySet>
-
-<!-- profile intent -->
- <sca:intent name="reliableMessageProtection"
- constrains="sca:binding"
- requires="messageProtection">
- <sca:description>
- Protect messages from unauthorized reading or modification
- </sca:description>
- </sca:intent>
-
- <sca:intent name="messageProtection"
- constrains="sca:binding"
- requires="confidentiality integrity">
- <sca:description>
- Protect messages from unauthorized reading or modification
- </sca:description>
- </sca:intent>
-
-<!-- simple intent -->
- <sca:intent name="confidentiality"
- constrains="sca:binding">
- <sca:description>
- Communitcation thro this binding must prevent
- unauthorized users from reading the messages.
- </sca:description>
- </sca:intent>
-
- <sca:intent name="integrity"
- constrains="sca:binding">
- <sca:description>
- Communitcation thro this binding must prevent
- unauthorized modification of the messages.
- </sca:description>
- </sca:intent>
-
- <sca:intent name="authentication"
- constrains="sca:binding">
- <sca:description>
- Communitcation thro this binding required
- Authentication.
- </sca:description>
- </sca:intent>
-
-</sca:definitions> \ No newline at end of file
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
index b8487d95c5..0a14b5658e 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
@@ -19,7 +19,7 @@
package org.apache.tuscany.sca.assembly;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Interface contracts define one or more business functions. These business
@@ -27,7 +27,7 @@ import org.apache.tuscany.sca.policy.IntentAttachPoint;
*
* @version $Rev$ $Date$
*/
-public interface AbstractContract extends Base, Extensible, IntentAttachPoint, OperationsConfigurator {
+public interface AbstractContract extends Base, Extensible, PolicySubject {
/**
* Returns the name of the contract.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
index 05f0e60981..fcad39d8cb 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
@@ -20,8 +20,6 @@ package org.apache.tuscany.sca.assembly;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
-
/**
* A property allows for the configuration of an implementation with externally
* set data values. An implementation can have zero or more properties. Each
@@ -30,7 +28,7 @@ import org.apache.tuscany.sca.policy.IntentAttachPoint;
*
* @version $Rev$ $Date$
*/
-public interface AbstractProperty extends Base, Extensible, IntentAttachPoint {
+public interface AbstractProperty extends Base, Extensible {
/**
* Returns the property name.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
index 8a4fc6dfda..7a972f36f9 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
@@ -144,12 +144,7 @@ public interface AssemblyFactory {
* @return a new wire
*/
Wire createWire();
-
- /**
- * Create a new configured operation.
- *
- * @return a new ConfiguredOperation
- */
- ConfiguredOperation createConfiguredOperation();
+
+ // Extension createExtension();
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
index f8b7d4d236..0423e0b128 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.assembly;
+
/**
* Represents a binding.
*
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
index f49a653aa9..d34ec7d01f 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
@@ -20,15 +20,14 @@ package org.apache.tuscany.sca.assembly;
import java.util.List;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Represents a callback object describing the bindings to use for callbacks.
*
* @version $Rev$ $Date$
*/
-public interface Callback extends Base, Extensible, IntentAttachPoint, PolicySetAttachPoint, OperationsConfigurator {
+public interface Callback extends Base, Extensible, PolicySubject {
/**
* Returns the bindings supported for callbacks.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
index 8e1943224c..7386fc8583 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
@@ -20,7 +20,7 @@ package org.apache.tuscany.sca.assembly;
import java.util.List;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Represents a component. A component is a configured instance of an
@@ -28,7 +28,7 @@ import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
*
* @version $Rev$ $Date$
*/
-public interface Component extends Base, Extensible, PolicySetAttachPoint, Cloneable {
+public interface Component extends Base, Extensible, PolicySubject, Cloneable {
/**
* Returns the URI of the component.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
index e1ea65ea39..9fb3b92102 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
@@ -20,12 +20,14 @@ package org.apache.tuscany.sca.assembly;
import java.util.List;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
/**
* Describes an implementation and represents its configurable aspects.
*
* @version $Rev$ $Date$
*/
-public interface ComponentType extends Base {
+public interface ComponentType extends Base, PolicySubject {
/**
* Returns the URI of this component type.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
index 2c7b7c6b9e..fe5cbc9484 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
@@ -22,7 +22,7 @@ import java.util.List;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
@@ -30,7 +30,7 @@ import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
*
* @version $Rev$ $Date$
*/
-public interface Composite extends Implementation, Extensible, Cloneable, PolicySetAttachPoint {
+public interface Composite extends Implementation, Extensible, Cloneable, PolicySubject {
/**
* Returns the name of the composite.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java
deleted file mode 100644
index 8832597343..0000000000
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.assembly;
-
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
-
-/**
- * Represents an Operation. Typically Operation elements are used when there is a
- * need to apply certain facets such as intents and policysets only to a specific
- * operation provided by a service or reference.
- *
- * @version $Rev$ $Date$
- */
-public interface ConfiguredOperation extends Base, PolicySetAttachPoint {
- /**
- * Returns the name of the operation.
- *
- * @return the name of the operation
- */
- String getName();
-
- /**
- * Sets the name of the operation.
- *
- * @param name the name of the operation
- */
- void setName(String name);
-
- /**
- * Returns the name of the service or reference to which this operation belongs.
- * This method is particularly useful when operation elements are specified under implementation
- * elements and it is necessary to identify which of the various services provided by the
- * implementation is referred to by the operation element in question
- *
- * @return the name of the contract to which this operation belongs
- */
- String getContractName();
-
- /**
- * Sets the name of the service or reference to which this operation belongs.
- *
- * @param contractName the name of the contract to which this operation belongs
- */
- void setContractName(String contractName);
-}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java
index 9890bfed68..74c2e70d30 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConstrainingType.java
@@ -22,7 +22,7 @@ import java.util.List;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* A constrainingType provides the "shape" for a component and its
@@ -32,7 +32,7 @@ import org.apache.tuscany.sca.policy.IntentAttachPoint;
*
* @version $Rev$ $Date$
*/
-public interface ConstrainingType extends Base, Extensible, IntentAttachPoint {
+public interface ConstrainingType extends Base, Extensible, PolicySubject {
/**
* Returns the name of the constrainingType.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
index f9a62774e6..54d6347301 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
@@ -21,14 +21,14 @@ package org.apache.tuscany.sca.assembly;
import java.util.List;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Represents a contract. A contract can be either a service or a reference.
*
* @version $Rev$ $Date$
*/
-public interface Contract extends AbstractContract, PolicySetAttachPoint, Cloneable {
+public interface Contract extends AbstractContract, PolicySubject, Cloneable {
/**
* Returns the bindings supported by this contract.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java
index 593b7de88b..90d6745f35 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java
@@ -25,7 +25,7 @@ import java.util.List;
*
* @version $Rev$ $Date$
*/
-public interface Extensible {
+public interface Extensible extends Base {
/**
* Returns a list of extension objects contained in this model object.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java
index 499c97c278..ca37c93e8a 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java
@@ -27,39 +27,39 @@ import javax.xml.namespace.QName;
*/
public interface Extension {
- /**
- * Return QName for the extension
- * @return the extension QName
- */
- QName getQName();
-
- /**
- * Set QName for the extension
- * @param qName the extension QName
- */
- void setQName(QName qName);
-
- /**
- * Return the original extension value
- * @return the extension value
- */
- Object getValue();
-
- /**
- * Set the original extension value
- * @param value the extension value
- */
- void setValue(Object value);
-
- /**
- * Return whether or not the extension is an attribute
- * @return
- */
- boolean isAttribute();
-
- /**
- * Set whether or not the extension is an attribute
- * @param value
- */
- void setIsAttribute(boolean isAttribute);
+ /**
+ * Return QName for the extension
+ * @return the extension QName
+ */
+ QName getQName();
+
+ /**
+ * Set QName for the extension
+ * @param qName the extension QName
+ */
+ void setQName(QName qName);
+
+ /**
+ * Return the original extension value
+ * @return the extension value
+ */
+ <T> T getValue();
+
+ /**
+ * Set the original extension value
+ * @param value the extension value
+ */
+ <T> void setValue(T value);
+
+ /**
+ * Return whether or not the extension is an attribute
+ * @return
+ */
+ boolean isAttribute();
+
+ /**
+ * Set whether or not the extension is an attribute
+ * @param value
+ */
+ void setIsAttribute(boolean isAttribute);
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
deleted file mode 100644
index 947fcd4c7c..0000000000
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.assembly;
-
-import java.util.List;
-
-/**
- * Interface to be implemented by SCA artifacts that support configuration of 'operation' child
- * elements for policies etc.
- *
- * @version $Rev$ $Date$
- */
-
-public interface OperationsConfigurator {
- List<ConfiguredOperation> getConfiguredOperations();
-}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
index 683920da58..986e1f12e4 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
@@ -18,7 +18,6 @@
*/
package org.apache.tuscany.sca.assembly;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
* A property allows for the configuration of an implementation with externally
@@ -28,7 +27,7 @@ import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
*
* @version $Rev$ $Date$
*/
-public interface Property extends AbstractProperty, PolicySetAttachPoint, Cloneable {
+public interface Property extends AbstractProperty, Cloneable {
/**
* Returns a clone of the property.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
index ee65e5746e..8980365bfa 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
@@ -18,15 +18,14 @@
*/
package org.apache.tuscany.sca.assembly;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Represents a wire.
*
* @version $Rev$ $Date$
*/
-public interface Wire extends Base, Extensible, IntentAttachPoint, PolicySetAttachPoint, Cloneable {
+public interface Wire extends Base, Extensible, PolicySubject, Cloneable {
/**
* Returns the source of the wire.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java
index 8197bf2552..d9b9763475 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java
@@ -65,7 +65,7 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx
/**
* Load builders declared under META-INF/services.
*/
- private void loadBuilders() {
+ private synchronized void loadBuilders() {
if (loaded)
return;
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java
index 77094da6dd..996adf7ecc 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java
@@ -45,8 +45,8 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Base class for Builder implementations
@@ -551,9 +551,9 @@ public abstract class BaseBuilderImpl implements CompositeBuilder {
}
if ( definitions != null ) {
- for ( IntentAttachPointType attachPointType : definitions.getBindingTypes() ) {
- if ( attachPointType.getName().equals(BINDING_SCA_QNAME)) {
- ((IntentAttachPoint)scaBinding).setType(attachPointType);
+ for ( ExtensionType attachPointType : definitions.getBindingTypes() ) {
+ if ( attachPointType.getType().equals(BINDING_SCA_QNAME)) {
+ ((PolicySubject)scaBinding).setType(attachPointType);
}
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
index 9846edc127..7fdad726ca 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
@@ -34,7 +34,7 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
/**
* A builder that handles the configuration of the components inside a composite
@@ -64,7 +64,7 @@ public class CompositeBuilderImpl implements CompositeBuilder {
this(factories.getFactory(AssemblyFactory.class),
factories.getFactory(EndpointFactory.class),
factories.getFactory(SCABindingFactory.class),
- factories.getFactory(IntentAttachPointTypeFactory.class),
+ factories.getFactory(PolicyFactory.class),
factories.getFactory(DocumentBuilderFactory.class),
factories.getFactory(TransformerFactory.class),
mapper);
@@ -85,7 +85,7 @@ public class CompositeBuilderImpl implements CompositeBuilder {
public CompositeBuilderImpl(AssemblyFactory assemblyFactory,
EndpointFactory endpointFactory,
SCABindingFactory scaBindingFactory,
- IntentAttachPointTypeFactory intentAttachPointTypeFactory,
+ PolicyFactory intentAttachPointTypeFactory,
InterfaceContractMapper interfaceContractMapper) {
this(assemblyFactory, endpointFactory, scaBindingFactory, intentAttachPointTypeFactory,
null, null, interfaceContractMapper);
@@ -105,7 +105,7 @@ public class CompositeBuilderImpl implements CompositeBuilder {
@Deprecated
public CompositeBuilderImpl(AssemblyFactory assemblyFactory,
SCABindingFactory scaBindingFactory,
- IntentAttachPointTypeFactory intentAttachPointTypeFactory,
+ PolicyFactory intentAttachPointTypeFactory,
InterfaceContractMapper interfaceContractMapper) {
this(assemblyFactory, null, scaBindingFactory, intentAttachPointTypeFactory,
null, null, interfaceContractMapper);
@@ -124,7 +124,7 @@ public class CompositeBuilderImpl implements CompositeBuilder {
*/
public CompositeBuilderImpl(AssemblyFactory assemblyFactory,
SCABindingFactory scaBindingFactory,
- IntentAttachPointTypeFactory intentAttachPointTypeFactory,
+ PolicyFactory intentAttachPointTypeFactory,
DocumentBuilderFactory documentBuilderFactory,
TransformerFactory transformerFactory,
InterfaceContractMapper interfaceContractMapper) {
@@ -146,7 +146,7 @@ public class CompositeBuilderImpl implements CompositeBuilder {
public CompositeBuilderImpl(AssemblyFactory assemblyFactory,
EndpointFactory endpointFactory,
SCABindingFactory scaBindingFactory,
- IntentAttachPointTypeFactory intentAttachPointTypeFactory,
+ PolicyFactory intentAttachPointTypeFactory,
DocumentBuilderFactory documentBuilderFactory,
TransformerFactory transformerFactory,
InterfaceContractMapper interfaceContractMapper) {
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java
index 76cd8256e2..a423ac5464 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java
@@ -20,9 +20,6 @@
package org.apache.tuscany.sca.assembly.builder.impl;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
@@ -30,10 +27,8 @@ import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.EndpointFactory;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
@@ -98,29 +93,9 @@ public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements Compo
PolicyComputationUtils.addInheritedIntents(service.getRequiredIntents(), componentService.getRequiredIntents());
PolicyComputationUtils.addInheritedPolicySets(service.getPolicySets(), componentService.getPolicySets(), true);
- //reconcile intents and policysets for operations
- boolean notFound;
- List<ConfiguredOperation> opsFromComponentType = new ArrayList<ConfiguredOperation>();
- for ( ConfiguredOperation ctsConfOp : service.getConfiguredOperations() ) {
- notFound = true;
- for ( ConfiguredOperation csConfOp : componentService.getConfiguredOperations() ) {
- if ( csConfOp.getName().equals(ctsConfOp.getName()) ) {
- PolicyComputationUtils.addInheritedIntents(ctsConfOp.getRequiredIntents(), csConfOp.getRequiredIntents());
- PolicyComputationUtils.addInheritedPolicySets(ctsConfOp.getPolicySets(), csConfOp.getPolicySets(), true);
- notFound = false;
- }
- }
-
- if ( notFound ) {
- opsFromComponentType.add(ctsConfOp);
- }
- }
- componentService.getConfiguredOperations().addAll(opsFromComponentType);
}
try {
- //compute the intents for operations under service element
- PolicyConfigurationUtil.computeIntentsForOperations(componentService);
//compute intents and policyset for each binding
//addInheritedOpConfOnBindings(componentService);
PolicyConfigurationUtil.computeBindingIntentsAndPolicySets(componentService);
@@ -142,8 +117,6 @@ public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements Compo
try {
- //compute the intents for operations under reference element
- PolicyConfigurationUtil.computeIntentsForOperations(componentReference);
//compute intents and policyset for each binding
//addInheritedOpConfOnBindings(componentReference);
PolicyConfigurationUtil.computeBindingIntentsAndPolicySets(componentReference);
@@ -171,8 +144,6 @@ public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements Compo
for (Service service : composite.getServices()) {
addPoliciesFromPromotedService((CompositeService)service);
try {
- //compute the intents for operations under service element
- PolicyConfigurationUtil.computeIntentsForOperations(service);
//add or merge service operations to the binding
//addInheritedOpConfOnBindings(service);
PolicyConfigurationUtil.computeBindingIntentsAndPolicySets(service);
@@ -188,10 +159,7 @@ public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements Compo
CompositeReference compReference = (CompositeReference)reference;
addPoliciesFromPromotedReference(compReference);
try {
- //compute the intents for operations under service element
- PolicyConfigurationUtil.computeIntentsForOperations(reference);
- //addInheritedOpConfOnBindings(reference);
-
+
if (compReference.getCallback() != null) {
PolicyComputationUtils.addInheritedIntents(compReference.getRequiredIntents(),
compReference.getCallback().getRequiredIntents());
@@ -215,7 +183,6 @@ public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements Compo
compositeService.getRequiredIntents());
PolicyComputationUtils.addInheritedPolicySets(compositeService.getPromotedService().getPolicySets(),
compositeService.getPolicySets(), true);
- addInheritedOperationConfigurations(compositeService.getPromotedService(), compositeService);
}
private void addPoliciesFromPromotedReference(CompositeReference compositeReference) {
@@ -225,38 +192,7 @@ public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements Compo
PolicyComputationUtils.addInheritedPolicySets(promotedReference.getPolicySets(),
compositeReference.getPolicySets(), true);
- addInheritedOperationConfigurations(promotedReference, compositeReference);
}
}
- private void addInheritedOperationConfigurations(
- OperationsConfigurator source, OperationsConfigurator target) {
- boolean found = false;
-
- List<ConfiguredOperation> additionalOperations = new ArrayList<ConfiguredOperation>();
- for (ConfiguredOperation sourceConfOp : source
- .getConfiguredOperations()) {
- for (ConfiguredOperation targetConfOp : target
- .getConfiguredOperations()) {
- if (sourceConfOp.getName().equals(targetConfOp.getName())) {
- PolicyComputationUtils.addInheritedIntents(sourceConfOp
- .getRequiredIntents(), targetConfOp
- .getRequiredIntents());
- PolicyComputationUtils.addInheritedPolicySets(sourceConfOp
- .getPolicySets(), targetConfOp.getPolicySets(),
- true);
- found = true;
- break;
- }
- }
-
- if (!found) {
- additionalOperations.add(sourceConfOp);
- }
- }
-
- if (!additionalOperations.isEmpty()) {
- target.getConfiguredOperations().addAll(additionalOperations);
- }
- }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointBuilderImpl.java
index 125112a560..a61108f3cb 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/EndpointBuilderImpl.java
@@ -34,7 +34,7 @@ import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* A factory for the Endpoint model.
@@ -131,11 +131,11 @@ public abstract class EndpointBuilderImpl implements EndpointBuilder {
private boolean hasCompatiblePolicySets(Binding refBinding, Binding svcBinding) {
boolean isCompatible = true;
- if ( refBinding instanceof PolicySetAttachPoint && svcBinding instanceof PolicySetAttachPoint ) {
+ if ( refBinding instanceof PolicySubject && svcBinding instanceof PolicySubject ) {
//TODO : need to add more compatibility checks at the policy attachment levels
- for ( PolicySet svcPolicySet : ((PolicySetAttachPoint)svcBinding).getPolicySets() ) {
+ for ( PolicySet svcPolicySet : ((PolicySubject)svcBinding).getPolicySets() ) {
isCompatible = false;
- for ( PolicySet refPolicySet : ((PolicySetAttachPoint)refBinding).getPolicySets() ) {
+ for ( PolicySet refPolicySet : ((PolicySubject)refBinding).getPolicySets() ) {
if ( svcPolicySet.equals(refPolicySet) ) {
isCompatible = true;
break;
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java
index c0bc18dfaf..a51e353ddf 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java
@@ -30,17 +30,13 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Base;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
-import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.IntentMap;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.policy.util.PolicyComputationUtils;
import org.apache.tuscany.sca.policy.util.PolicyValidationException;
import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
@@ -52,7 +48,7 @@ import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
*/
abstract class PolicyConfigurationUtil {
- private static List<Intent> computeInheritableIntents(IntentAttachPointType attachPointType,
+ private static List<Intent> computeInheritableIntents(ExtensionType attachPointType,
List<Intent> inheritableIntents) throws PolicyValidationException {
List<Intent> validInheritableIntents = new ArrayList<Intent>();
@@ -63,7 +59,7 @@ abstract class PolicyConfigurationUtil {
//only add such intents to the attachpoint (binding / implementation)
for (Intent intent : inheritableIntents) {
if ( !intent.isUnresolved() ) {
- for (QName constrained : intent.getConstrains()) {
+ for (ExtensionType constrained : intent.getConstrainedTypes()) {
if ( PolicyValidationUtils.isConstrained(constrained, attachPointType)) {
validInheritableIntents.add(intent);
break;
@@ -77,7 +73,7 @@ abstract class PolicyConfigurationUtil {
return validInheritableIntents;
}
- private static void normalizeIntents(IntentAttachPoint intentAttachPoint) {
+ private static void normalizeIntents(PolicySubject intentAttachPoint) {
//expand profile intents specified in the attachpoint (binding / implementation)
PolicyComputationUtils.expandProfileIntents(intentAttachPoint.getRequiredIntents());
@@ -86,7 +82,7 @@ abstract class PolicyConfigurationUtil {
filterDuplicatesAndQualifiableIntents(intentAttachPoint);
}
- private static void trimInherentlyProvidedIntents(IntentAttachPointType attachPointType, List<Intent>intents) {
+ private static void trimInherentlyProvidedIntents(ExtensionType attachPointType, List<Intent>intents) {
//exclude intents that are inherently supported by the
//attachpoint-type (binding-type / implementation-type)
List<Intent> requiredIntents = new ArrayList<Intent>(intents);
@@ -98,97 +94,13 @@ abstract class PolicyConfigurationUtil {
}
- static void computeIntentsForOperations(IntentAttachPoint intentAttachPoint) throws PolicyValidationException {
- if ( intentAttachPoint instanceof OperationsConfigurator ) {
- computeIntentsForOperations((OperationsConfigurator)intentAttachPoint,
- intentAttachPoint,
- intentAttachPoint.getRequiredIntents());
- }
- }
-
- private static void computeIntentsForOperations(OperationsConfigurator opConfigurator,
- IntentAttachPoint intentAttachPoint,
- List<Intent> parentIntents) throws PolicyValidationException {
- IntentAttachPointType attachPointType = intentAttachPoint.getType();
-
- boolean found = false;
- for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
- //expand profile intents specified on operations
- PolicyComputationUtils.expandProfileIntents(confOp.getRequiredIntents());
-
- //validateIntents(confOp, attachPointType);
-
- //add intents specified for parent intent attach point (binding / implementation)
- //wherever its not overridden in the operation
- Intent tempIntent = null;
- List<Intent> attachPointOpIntents = new ArrayList<Intent>();
- for (Intent anIntent : parentIntents) {
- found = false;
-
- tempIntent = anIntent;
- while ( tempIntent instanceof QualifiedIntent ) {
- tempIntent = ((QualifiedIntent)tempIntent).getQualifiableIntent();
- }
-
- for ( Intent opIntent : confOp.getRequiredIntents() ) {
- if ( opIntent.getName().getLocalPart().startsWith(tempIntent.getName().getLocalPart())) {
- found = true;
- break;
- }
- }
-
- if ( !found ) {
- boolean conflict = false;
- for (Intent excluded : anIntent.getExcludedIntents()) {
- if (confOp.getRequiredIntents().contains(excluded)) {
- conflict = true;
- break;
- }
- }
- if (!conflict) {
- attachPointOpIntents.add(anIntent);
- }
- }
- }
-
- confOp.getRequiredIntents().addAll(attachPointOpIntents);
-
- //remove duplicates and ...
- //where qualified form of intent exists retain it and remove the qualifiable intent
- filterDuplicatesAndQualifiableIntents(confOp);
-
- //exclude intents that are inherently supported by the parent
- //attachpoint-type (binding-type / implementation-type)
- if ( attachPointType != null ) {
- List<Intent> requiredIntents = new ArrayList<Intent>(confOp.getRequiredIntents());
- for ( Intent intent : requiredIntents ) {
- if ( isProvidedInherently(attachPointType, intent) ) {
- confOp.getRequiredIntents().remove(intent);
- }
- }
- }
- }
- }
-
- private static List<PolicySet> computeInheritablePolicySets(List<PolicySet> inheritablePolicySets,
- List<PolicySet> applicablePolicySets)
+ private static List<PolicySet> computeInheritablePolicySets(List<PolicySet> inheritablePolicySets)
throws PolicyValidationException {
- List<PolicySet> validInheritablePolicySets = new ArrayList<PolicySet>();
- for (PolicySet policySet : inheritablePolicySets) {
- if ( !policySet.isUnresolved() ) {
- if ( applicablePolicySets.contains(policySet) ) {
- validInheritablePolicySets.add(policySet);
- }
- } else {
- throw new PolicyValidationException("Policy Set '" + policySet.getName()
- + "' is not defined in this domain ");
- }
- }
-
- return validInheritablePolicySets;
+ // FIXME:
+ return inheritablePolicySets;
}
- private static void normalizePolicySets(PolicySetAttachPoint policySetAttachPoint ) {
+ private static void normalizePolicySets(PolicySubject policySetAttachPoint ) {
//get rid of duplicate entries
HashMap<QName, PolicySet> policySetTable = new HashMap<QName, PolicySet>();
for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
@@ -204,64 +116,6 @@ abstract class PolicyConfigurationUtil {
}
}
- private static void computePolicySetsForOperations(List<PolicySet> applicablePolicySets,
- PolicySetAttachPoint policySetAttachPoint)
- throws PolicyValidationException {
- if ( policySetAttachPoint instanceof OperationsConfigurator ) {
- computePolicySetsForOperations(applicablePolicySets,
- (OperationsConfigurator)policySetAttachPoint,
- policySetAttachPoint);
- }
-
- }
-
- private static void computePolicySetsForOperations(List<PolicySet> applicablePolicySets,
- OperationsConfigurator opConfigurator,
- PolicySetAttachPoint policySetAttachPoint)
- throws PolicyValidationException {
- //String appliesTo = null;
- //String scdlFragment = "";
- HashMap<QName, PolicySet> policySetTable = new HashMap<QName, PolicySet>();
- IntentAttachPointType attachPointType = policySetAttachPoint.getType();
-
- for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
- //validate policysets specified for the attachPoint
- for (PolicySet policySet : confOp.getPolicySets()) {
- if ( !policySet.isUnresolved() ) {
- //appliesTo = policySet.getAppliesTo();
-
- //if (!PolicyValidationUtils.isPolicySetApplicable(scdlFragment, appliesTo, attachPointType)) {
- if (!applicablePolicySets.contains(policySet)) {
- throw new PolicyValidationException("Policy Set '" + policySet.getName()
- + " specified for operation " + confOp.getName()
- + "' does not constrain extension type "
- + attachPointType.getName());
-
- }
- } else {
- throw new PolicyValidationException("Policy Set '" + policySet.getName()
- + " specified for operation " + confOp.getName()
- + "' is not defined in this domain ");
- }
- }
-
- //get rid of duplicate entries
- for ( PolicySet policySet : confOp.getPolicySets() ) {
- policySetTable.put(policySet.getName(), policySet);
- }
-
- confOp.getPolicySets().clear();
- confOp.getPolicySets().addAll(policySetTable.values());
- policySetTable.clear();
-
- //expand profile intents
- for ( PolicySet policySet : confOp.getPolicySets() ) {
- PolicyComputationUtils.expandProfileIntents(policySet.getProvidedIntents());
- }
- }
- }
-
-
private static void trimProvidedIntents(List<Intent> requiredIntents, List<PolicySet> policySets) {
for ( PolicySet policySet : policySets ) {
trimProvidedIntents(requiredIntents, policySet);
@@ -269,8 +123,8 @@ abstract class PolicyConfigurationUtil {
}
private static void determineApplicableDomainPolicySets(List<PolicySet> applicablePolicySets,
- PolicySetAttachPoint policySetAttachPoint,
- IntentAttachPointType intentAttachPointType) {
+ PolicySubject policySetAttachPoint,
+ ExtensionType intentAttachPointType) {
if (policySetAttachPoint.getRequiredIntents().size() > 0) {
@@ -308,12 +162,12 @@ abstract class PolicyConfigurationUtil {
}
}
- private static boolean isProvidedInherently(IntentAttachPointType attachPointType, Intent intent) {
+ private static boolean isProvidedInherently(ExtensionType attachPointType, Intent intent) {
return ( attachPointType != null &&
(( attachPointType.getAlwaysProvidedIntents() != null &&
attachPointType.getAlwaysProvidedIntents().contains(intent) ) ||
- ( attachPointType.getMayProvideIntents() != null &&
- attachPointType.getMayProvideIntents().contains(intent) )
+ ( attachPointType.getMayProvidedIntents() != null &&
+ attachPointType.getMayProvidedIntents().contains(intent) )
) );
}
@@ -324,14 +178,14 @@ abstract class PolicyConfigurationUtil {
}
}
- for ( Intent mappedIntent : policySet.getMappedPolicies().keySet() ) {
- if ( requiredIntents.contains(mappedIntent) ) {
- requiredIntents.remove(mappedIntent);
+ for ( IntentMap intentMap : policySet.getIntentMaps() ) {
+ if ( requiredIntents.contains(intentMap.getProvidedIntent()) ) {
+ requiredIntents.remove(intentMap.getProvidedIntent());
}
}
}
- private static void filterDuplicatesAndQualifiableIntents(IntentAttachPoint intentAttachPoint) {
+ private static void filterDuplicatesAndQualifiableIntents(PolicySubject intentAttachPoint) {
//remove duplicates
Map<QName, Intent> intentsTable = new HashMap<QName, Intent>();
for ( Intent intent : intentAttachPoint.getRequiredIntents() ) {
@@ -342,55 +196,22 @@ abstract class PolicyConfigurationUtil {
Map<QName, Intent> intentsTableCopy = new HashMap<QName, Intent>(intentsTable);
//if qualified form of intent exists remove the unqualified form
for ( Intent intent : intentsTableCopy.values() ) {
- if ( intent instanceof QualifiedIntent ) {
- QualifiedIntent qualifiedIntent = (QualifiedIntent)intent;
- if ( intentsTable.get(qualifiedIntent.getQualifiableIntent().getName()) != null ) {
- intentsTable.remove(qualifiedIntent.getQualifiableIntent().getName());
+ if ( intent.getParent()!=null ) {
+ if ( intentsTable.get(intent.getParent().getName()) != null ) {
+ intentsTable.remove(intent.getParent().getName());
}
}
}
intentAttachPoint.getRequiredIntents().clear();
intentAttachPoint.getRequiredIntents().addAll(intentsTable.values());
}
-
- private static void validateIntents(ConfiguredOperation confOp, IntentAttachPointType attachPointType) throws PolicyValidationException {
- boolean found = false;
- if ( attachPointType != null ) {
- //validate intents specified against the parent (binding / implementation)
- found = false;
- for (Intent intent : confOp.getRequiredIntents()) {
- if ( !intent.isUnresolved() ) {
- for (QName constrained : intent.getConstrains()) {
- if (PolicyValidationUtils.isConstrained(constrained, attachPointType)) {
- found = true;
- break;
- }
- }
-
- if (!found) {
- throw new PolicyValidationException("Policy Intent '" + intent.getName()
- + " specified for operation " + confOp.getName()
- + "' does not constrain extension type "
- + attachPointType.getName());
- }
- } else {
- throw new PolicyValidationException("Policy Intent '" + intent.getName()
- + " specified for operation " + confOp.getName()
- + "' is not defined in this domain ");
- }
- }
- }
- }
static void computeBindingIntentsAndPolicySets(Contract contract) throws PolicyValidationException {
for (Binding binding : contract.getBindings()) {
- if (binding instanceof PolicySetAttachPoint) {
- PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
- computeIntents((IntentAttachPoint)binding, contract.getRequiredIntents());
+ if (binding instanceof PolicySubject) {
+ PolicySubject policiedBinding = (PolicySubject)binding;
+ computeIntents((PolicySubject)binding, contract.getRequiredIntents());
- aggregateAndPruneApplicablePolicySets(contract.getApplicablePolicySets(),
- policiedBinding.getApplicablePolicySets());
-
computePolicySets(policiedBinding, contract.getPolicySets());
PolicyComputationUtils.checkForMutuallyExclusiveIntents(
@@ -398,39 +219,15 @@ abstract class PolicyConfigurationUtil {
policiedBinding.getPolicySets(),
policiedBinding.getType(),
contract.getName());
-
- if ( binding instanceof OperationsConfigurator &&
- contract instanceof OperationsConfigurator ) {
- //add or merge service operations to the binding
- addInheritedOpConfOnBindings((OperationsConfigurator)contract,
- (OperationsConfigurator)binding,
- (PolicySetAttachPoint)binding);
-
- computeIntentsForOperations((IntentAttachPoint)binding);
- computePolicySetsForOperations(contract.getApplicablePolicySets(),
- policiedBinding);
-
- for ( ConfiguredOperation confOp : ((OperationsConfigurator)binding).getConfiguredOperations() ) {
- PolicyComputationUtils.checkForMutuallyExclusiveIntents(
- confOp.getRequiredIntents(),
- confOp.getPolicySets(),
- policiedBinding.getType(),
- contract.getName() + "." + confOp.getName());
- }
-
- }
}
}
if ( contract.getCallback() != null ) {
for (Binding binding : contract.getCallback().getBindings()) {
- if (binding instanceof PolicySetAttachPoint) {
- PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
- computeIntents((IntentAttachPoint)binding, contract.getCallback().getRequiredIntents());
+ if (binding instanceof PolicySubject) {
+ PolicySubject policiedBinding = (PolicySubject)binding;
+ computeIntents((PolicySubject)binding, contract.getCallback().getRequiredIntents());
- aggregateAndPruneApplicablePolicySets(contract.getApplicablePolicySets(),
- policiedBinding.getApplicablePolicySets());
-
computePolicySets(policiedBinding, contract.getCallback().getPolicySets());
PolicyComputationUtils.checkForMutuallyExclusiveIntents(
@@ -444,7 +241,7 @@ abstract class PolicyConfigurationUtil {
}
}
- private static void computeIntents(IntentAttachPoint policiedBinding, List<Intent> inheritedIntents)
+ private static void computeIntents(PolicySubject policiedBinding, List<Intent> inheritedIntents)
throws PolicyValidationException {
//since the parent component could also contain intents that apply to implementation
//and binding elements within, we filter out only those that apply to this binding type
@@ -455,11 +252,10 @@ abstract class PolicyConfigurationUtil {
normalizeIntents(policiedBinding);
}
- private static void computePolicySets(PolicySetAttachPoint policiedBinding,
+ private static void computePolicySets(PolicySubject policiedBinding,
List<PolicySet> inheritedPolicySets) throws PolicyValidationException {
- List<PolicySet> prunedPolicySets = computeInheritablePolicySets(inheritedPolicySets,
- policiedBinding.getApplicablePolicySets());
+ List<PolicySet> prunedPolicySets = computeInheritablePolicySets(inheritedPolicySets);
policiedBinding.getPolicySets().addAll(prunedPolicySets);
normalizePolicySets(policiedBinding);
}
@@ -467,9 +263,9 @@ abstract class PolicyConfigurationUtil {
static void determineApplicableBindingPolicySets(Contract source, Contract target) throws PolicyConfigurationException {
List<Intent> intentsCopy = null;
for (Binding aBinding : source.getBindings()) {
- if (aBinding instanceof PolicySetAttachPoint) {
- PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)aBinding;
- IntentAttachPointType bindingType = policiedBinding.getType();
+ if (aBinding instanceof PolicySubject) {
+ PolicySubject policiedBinding = (PolicySubject)aBinding;
+ ExtensionType bindingType = policiedBinding.getType();
intentsCopy = new ArrayList<Intent>(policiedBinding.getRequiredIntents());
@@ -477,11 +273,11 @@ abstract class PolicyConfigurationUtil {
if (target != null) {
for (Intent intent : target.getRequiredIntents()) {
if (!policiedBinding.getRequiredIntents().contains(intent)) {
- for (QName constrained : intent.getConstrains()) {
- if (bindingType != null && bindingType.getName().getNamespaceURI()
- .equals(constrained.getNamespaceURI())
- && bindingType.getName().getLocalPart().startsWith(constrained
- .getLocalPart())) {
+ for (ExtensionType constrained : intent.getConstrainedTypes()) {
+ if (bindingType != null && bindingType.getType().getNamespaceURI()
+ .equals(constrained.getType().getNamespaceURI())
+ && bindingType.getType().getLocalPart().startsWith(constrained
+ .getType().getLocalPart())) {
policiedBinding.getRequiredIntents().add(intent);
break;
}
@@ -489,37 +285,6 @@ abstract class PolicyConfigurationUtil {
}
}
}
-
- //trim intents specified in operations. First check for policysets specified on the operation
- //and then in the parent implementation
- if ( aBinding instanceof OperationsConfigurator ) {
- OperationsConfigurator opConfigurator = (OperationsConfigurator)aBinding;
-
- for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
- List<Intent> opsIntentsCopy = new ArrayList<Intent>(confOp.getRequiredIntents());
-
- trimInherentlyProvidedIntents(policiedBinding.getType(),
- confOp.getRequiredIntents());
- trimProvidedIntents(confOp.getRequiredIntents(), confOp.getPolicySets());
- trimProvidedIntents(confOp.getRequiredIntents(), policiedBinding.getPolicySets());
-
- determineApplicableDomainPolicySets(policiedBinding.getApplicablePolicySets(),
- confOp,
- policiedBinding.getType());
-
- if (confOp.getRequiredIntents().size() > 0) {
- throw new PolicyConfigurationException("The following are unfulfilled intents for operations configured in "
- + "binding - " + aBinding.getName() + "\nUnfulfilled Intents = " +
- confOp.getRequiredIntents());
- }
-
- //the intents list could have been trimmed when matching for policysets
- //since the bindings may need the original set of intents we copy that back
- confOp.getRequiredIntents().clear();
- confOp.getRequiredIntents().addAll(opsIntentsCopy);
-
- }
- }
trimInherentlyProvidedIntents(policiedBinding.getType(),
policiedBinding.getRequiredIntents());
@@ -544,8 +309,10 @@ abstract class PolicyConfigurationUtil {
}
private static void determineApplicableDomainPolicySets(Contract contract,
- PolicySetAttachPoint policiedBinding)
+ PolicySubject policiedBinding)
throws PolicyConfigurationException {
+ // FIXME:
+ /*
//if ( domainPolicySets != null) {
determineApplicableDomainPolicySets(policiedBinding.getApplicablePolicySets(),
policiedBinding,
@@ -563,38 +330,7 @@ abstract class PolicyConfigurationUtil {
}
}
//}
- }
-
- private static void addInheritedOpConfOnBindings(OperationsConfigurator source,
- OperationsConfigurator target,
- PolicySetAttachPoint attachPoint) throws PolicyValidationException {
- boolean found = false;
-
- List<ConfiguredOperation> additionalOperations = new ArrayList<ConfiguredOperation>();
- for ( ConfiguredOperation sourceConfOp : source.getConfiguredOperations() ) {
- for ( ConfiguredOperation targetConfOp : target.getConfiguredOperations() ) {
- if ( sourceConfOp.getName().equals(targetConfOp.getName())) {
- List<Intent> prunedIntents = computeInheritableIntents(attachPoint.getType(),
- sourceConfOp.getRequiredIntents());
- PolicyComputationUtils.addInheritedIntents(prunedIntents,
- targetConfOp.getRequiredIntents());
-
- List<PolicySet> prunedPolicySets = computeInheritablePolicySets(sourceConfOp.getPolicySets(),
- attachPoint.getApplicablePolicySets());
- PolicyComputationUtils.addInheritedPolicySets(prunedPolicySets, targetConfOp.getPolicySets(), true);
- found = true;
- break;
- }
- }
-
- if ( !found ) {
- additionalOperations.add(sourceConfOp);
- }
- }
-
- if ( !additionalOperations.isEmpty() ) {
- target.getConfiguredOperations().addAll(additionalOperations);
- }
+ */
}
private static void aggregateAndPruneApplicablePolicySets(List<PolicySet> source, List<PolicySet> target) {
@@ -614,23 +350,14 @@ abstract class PolicyConfigurationUtil {
for (Contract contract : contracts) {
// The contract inherits default policies from the parent composite/component.
- if ( parent instanceof PolicySetAttachPoint ) {
+ if ( parent instanceof PolicySubject ) {
PolicyComputationUtils.addDefaultPolicies(
- ((PolicySetAttachPoint)parent).getRequiredIntents(),
- ((PolicySetAttachPoint)parent).getPolicySets(),
+ ((PolicySubject)parent).getRequiredIntents(),
+ ((PolicySubject)parent).getPolicySets(),
contract.getRequiredIntents(),
contract.getPolicySets());
}
- // The contract's configured operations inherit default policies from the contract.
- for ( ConfiguredOperation confOp : contract.getConfiguredOperations() ) {
- PolicyComputationUtils.addDefaultPolicies(
- contract.getRequiredIntents(),
- contract.getPolicySets(),
- confOp.getRequiredIntents(),
- confOp.getPolicySets());
- }
-
// The contract's callback inherits default policies from the contract.
if (contract.getCallback() != null) {
PolicyComputationUtils.addDefaultPolicies(
@@ -645,8 +372,8 @@ abstract class PolicyConfigurationUtil {
static void computeImplementationIntentsAndPolicySets(Implementation implementation, Component parent)
throws PolicyValidationException, PolicyConfigurationException {
- if ( implementation instanceof PolicySetAttachPoint ) {
- PolicySetAttachPoint policiedImplementation = (PolicySetAttachPoint)implementation;
+ if ( implementation instanceof PolicySubject ) {
+ PolicySubject policiedImplementation = (PolicySubject)implementation;
//since for an implementation the component has its policy intents and policysets its possible
//that there are some intents there that does not constrain the implementation.. so prune
List<Intent> prunedIntents = computeInheritableIntents(policiedImplementation.getType(),
@@ -655,13 +382,7 @@ abstract class PolicyConfigurationUtil {
parent.getRequiredIntents().addAll(prunedIntents);
normalizeIntents(parent);
- computeIntentsForOperations((OperationsConfigurator)parent,
- (IntentAttachPoint)implementation,
- parent.getRequiredIntents());
-
-
- List<PolicySet> prunedPolicySets = computeInheritablePolicySets(parent.getPolicySets(),
- parent.getApplicablePolicySets());
+ List<PolicySet> prunedPolicySets = computeInheritablePolicySets(parent.getPolicySets());
parent.getPolicySets().clear();
parent.getPolicySets().addAll(prunedPolicySets);
normalizePolicySets(parent);
@@ -672,18 +393,6 @@ abstract class PolicyConfigurationUtil {
policiedImplementation.getType(),
parent.getName());
- computePolicySetsForOperations(parent.getApplicablePolicySets(),
- (OperationsConfigurator)parent,
- (PolicySetAttachPoint)implementation);
-
- for ( ConfiguredOperation confOp : ((OperationsConfigurator)parent).getConfiguredOperations() ) {
- PolicyComputationUtils.checkForMutuallyExclusiveIntents(
- confOp.getRequiredIntents(),
- confOp.getPolicySets(),
- policiedImplementation.getType(),
- parent.getName() + "." + confOp.getName());
- }
-
determineApplicableImplementationPolicySets(parent);
}
@@ -691,37 +400,8 @@ abstract class PolicyConfigurationUtil {
private static void determineApplicableImplementationPolicySets(Component component) throws PolicyConfigurationException {
List<Intent> intentsCopy = null;
- if ( component.getImplementation() instanceof PolicySetAttachPoint ) {
- PolicySetAttachPoint policiedImplementation = (PolicySetAttachPoint)component.getImplementation();
-
- //trim intents specified in operations. First check for policysets specified on the operation
- //and then in the parent implementation
- if ( component instanceof OperationsConfigurator ) {
- OperationsConfigurator opConfigurator = (OperationsConfigurator)component;
-
- for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
- intentsCopy = new ArrayList<Intent>(confOp.getRequiredIntents());
- trimInherentlyProvidedIntents(policiedImplementation.getType(),
- confOp.getRequiredIntents());
- trimProvidedIntents(confOp.getRequiredIntents(), confOp.getPolicySets());
- trimProvidedIntents(confOp.getRequiredIntents(), component.getPolicySets());
-
- determineApplicableDomainPolicySets(component.getApplicablePolicySets(),
- confOp,
- policiedImplementation.getType());
-
- if (confOp.getRequiredIntents().size() > 0) {
- throw new PolicyConfigurationException("The following are unfulfilled intents for operations configured in "
- + "component implementation - " + component.getName() + "\nUnfulfilled Intents = " +
- confOp.getRequiredIntents());
- }
-
- //the intents list could have been trimmed when matching for policysets
- //since the implementation may need the original set of intents we copy that back
- confOp.getRequiredIntents().clear();
- confOp.getRequiredIntents().addAll(intentsCopy);
- }
- }
+ if ( component.getImplementation() instanceof PolicySubject ) {
+ PolicySubject policiedImplementation = (PolicySubject)component.getImplementation();
intentsCopy = new ArrayList<Intent>(component.getRequiredIntents());
trimInherentlyProvidedIntents(policiedImplementation.getType(),
@@ -733,9 +413,6 @@ abstract class PolicyConfigurationUtil {
//TODO: resolved to domain policy registry and attach suitable policy sets to the implementation
//...for now using the SCA Definitions instead of registry
//if ( domainPolicySets != null) {
- determineApplicableDomainPolicySets(component.getApplicablePolicySets(),
- component,
- policiedImplementation.getType());
if (component.getRequiredIntents().size() > 0) {
throw new PolicyConfigurationException("The following are unfulfilled intents for component implementation - " + component
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
index b7c63dc2b4..db4bcb0060 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
@@ -19,14 +19,9 @@
package org.apache.tuscany.sca.assembly.impl;
-import java.util.ArrayList;
-import java.util.List;
-
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.AbstractProperty;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
/**
* Represents an abstract property.
@@ -40,12 +35,6 @@ public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProp
private QName xsdElement;
private boolean many;
private boolean mustSupply;
- private List<Intent> requiredIntents = new ArrayList<Intent>();
-
-
- public List<Intent> getRequiredIntents() {
- return requiredIntents;
- }
/**
* Constructs a new abstract property.
@@ -101,14 +90,4 @@ public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProp
this.xsdType = type;
}
- public IntentAttachPointType getType() {
- return null;
- }
-
- public void setType(IntentAttachPointType type) {
- }
-
- public void setRequiredIntents(List<Intent> intents) {
- this.requiredIntents = intents;
- }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
index 016a9a5b05..003f5fa323 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
@@ -32,7 +32,6 @@ import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
@@ -113,9 +112,5 @@ public abstract class AssemblyFactoryImpl implements AssemblyFactory {
public Wire createWire() {
return new WireImpl();
}
-
- public ConfiguredOperation createConfiguredOperation() {
- return new ConfiguredOperationImpl();
- }
-
+
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java
index 1373ce511b..1e69dfcc87 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java
@@ -1,93 +1,77 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.assembly.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
-import org.apache.tuscany.sca.policy.PolicySet;
-
-/**
- * Represents an Operation.
- *
- * @version $Rev$ $Date$
- */
-public class ConfiguredOperationImpl extends BaseImpl implements ConfiguredOperation {
- private List<PolicySet> policySets = new ArrayList<PolicySet>();
- private List<Intent> requiredIntents = new ArrayList<Intent>();
- private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
-
- private String name;
- private String contractName;
-
- /**
- * Constructs a new Operation.
- */
- protected ConfiguredOperationImpl() {
- }
-
- public List<PolicySet> getPolicySets() {
- return policySets;
- }
-
- public void setPolicySets(List<PolicySet> policySets) {
- this.policySets = policySets;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<Intent> getRequiredIntents() {
- return requiredIntents;
- }
-
- public void setRequiredIntents(List<Intent> intents) {
- this.requiredIntents = intents;
- }
-
- public String getContractName() {
- return contractName;
- }
-
- public void setContractName(String contractName) {
- this.contractName = contractName;
- }
-
- public IntentAttachPointType getType() {
- return null;
- }
-
- public void setType(IntentAttachPointType type) {
- }
-
- public List<PolicySet> getApplicablePolicySets() {
- return applicablePolicySets;
- }
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ *
+ */
+public abstract class BindingImpl extends ExtensibleImpl implements Binding {
+ private String name;
+ private ExtensionType type;
+ private String uri;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ExtensionType getType() {
+ return type;
+ }
+
+ public void setType(ExtensionType type) {
+ this.type = type;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
index 4082d81fdb..f8f856f1b4 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
@@ -24,9 +24,8 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Callback;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -38,8 +37,6 @@ public class CallbackImpl extends ExtensibleImpl implements Callback {
private List<Binding> bindings = new ArrayList<Binding>();
private List<Intent> requiredIntents = new ArrayList<Intent>();
private List<PolicySet> policySets = new ArrayList<PolicySet>();
- private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>();
- private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
public List<PolicySet> getPolicySets() {
return policySets;
@@ -56,27 +53,15 @@ public class CallbackImpl extends ExtensibleImpl implements Callback {
return bindings;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return null;
}
- public void setType(IntentAttachPointType type) {
+ public void setType(ExtensionType type) {
}
- public void setPolicySets(List<PolicySet> policySets) {
- this.policySets = policySets;
- }
-
public void setRequiredIntents(List<Intent> intents) {
this.requiredIntents = intents;
}
- public List<ConfiguredOperation> getConfiguredOperations() {
- return configuredOperations;
- }
-
- public List<PolicySet> getApplicablePolicySets() {
- return applicablePolicySets;
- }
-
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
index 34429a6703..d751d59f83 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
@@ -25,12 +25,10 @@ import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentProperty;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -38,7 +36,7 @@ import org.apache.tuscany.sca.policy.PolicySet;
*
* @version $Rev$ $Date$
*/
-public class ComponentImpl extends ExtensibleImpl implements Component, Cloneable, OperationsConfigurator {
+public class ComponentImpl extends ExtensibleImpl implements Component, Cloneable {
private ConstrainingType constrainingType;
private Implementation implementation;
private String name;
@@ -49,9 +47,7 @@ public class ComponentImpl extends ExtensibleImpl implements Component, Cloneabl
private List<Intent> requiredIntents = new ArrayList<Intent>();
private List<PolicySet> policySets = new ArrayList<PolicySet>();
private Boolean autowire;
- private IntentAttachPointType type;
- private List<ConfiguredOperation> configuredImplOperations = new ArrayList<ConfiguredOperation>();
- private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ private ExtensionType type;
/**
* Constructs a new component.
*/
@@ -141,34 +137,12 @@ public class ComponentImpl extends ExtensibleImpl implements Component, Cloneabl
return autowire;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return type;
}
- public void setType(IntentAttachPointType type) {
+ public void setType(ExtensionType type) {
this.type = type;
}
- public void setPolicySets(List<PolicySet> policySets) {
- this.policySets = policySets;
-
- }
-
- public void setRequiredIntents(List<Intent> intents) {
- this.requiredIntents = intents;
-
- }
-
- public List<ConfiguredOperation> getConfiguredOperations() {
- return configuredImplOperations;
- }
-
- public void setConfiguredOperations(List<ConfiguredOperation> configuredOperations) {
- this.configuredImplOperations = configuredOperations;
- }
-
- public List<PolicySet> getApplicablePolicySets() {
- return applicablePolicySets;
- }
-
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
index bbe665d52f..c79aaf6b2e 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
@@ -26,6 +26,9 @@ import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
/**
* Represents a component type.
@@ -38,6 +41,8 @@ public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType,
private List<Property> properties = new ArrayList<Property>();
private List<Reference> references = new ArrayList<Reference>();
private List<Service> services = new ArrayList<Service>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
/**
* Constructs a new component type.
*/
@@ -112,4 +117,19 @@ public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType,
}
}
}
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public ExtensionType getType() {
+ return null;
+ }
+
+ public void setType(ExtensionType type) {
+ }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java
index d5701df74e..641e0f17df 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java
@@ -27,8 +27,9 @@ import org.apache.tuscany.sca.assembly.AbstractProperty;
import org.apache.tuscany.sca.assembly.AbstractReference;
import org.apache.tuscany.sca.assembly.AbstractService;
import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
/**
* Represents a constraining type.
@@ -41,6 +42,7 @@ public class ConstrainingTypeImpl extends ExtensibleImpl implements Constraining
private List<AbstractReference> references = new ArrayList<AbstractReference>();
private List<AbstractService> services = new ArrayList<AbstractService>();
private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
/**
* Constructs a new ConstrainingType
@@ -71,6 +73,10 @@ public class ConstrainingTypeImpl extends ExtensibleImpl implements Constraining
public List<Intent> getRequiredIntents() {
return requiredIntents;
}
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
@Override
public int hashCode() {
@@ -92,14 +98,11 @@ public class ConstrainingTypeImpl extends ExtensibleImpl implements Constraining
}
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return null;
}
- public void setType(IntentAttachPointType type) {
+ public void setType(ExtensionType type) {
}
- public void setRequiredIntents(List<Intent> intents) {
- this.requiredIntents = intents;
- }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
index 491c835246..a121635323 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
@@ -22,10 +22,10 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.tuscany.sca.assembly.AbstractContract;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
/**
* Implementation of a Contract.
@@ -36,7 +36,7 @@ public class ContractImpl extends ExtensibleImpl implements AbstractContract {
private InterfaceContract interfaceContract;
private String name;
private List<Intent> requiredIntents = new ArrayList<Intent>();
- private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
private boolean isCallback = false;
@@ -74,23 +74,15 @@ public class ContractImpl extends ExtensibleImpl implements AbstractContract {
this.isCallback = isCallback;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return null;
}
- public void setType(IntentAttachPointType type) {
+ public void setType(ExtensionType type) {
}
-
- public void setRequiredIntents(List<Intent> intents) {
- this.requiredIntents = intents;
- }
-
- public List<ConfiguredOperation> getConfiguredOperations() {
- return configuredOperations;
- }
-
- public void setConfiguredOperations(List<ConfiguredOperation> configuredOperations) {
- this.configuredOperations = configuredOperations;
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java
index 2753bcc091..3aad253a03 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java
@@ -23,41 +23,40 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Extension;
public class ExtensionImpl implements Extension {
- private QName qName;
- private Object value;
- boolean isAttribute = false;
-
- public ExtensionImpl() {
-
- }
-
- public ExtensionImpl(QName qName, Object value, boolean isAttribute) {
- this.qName = qName;
- this.value = value;
- this.isAttribute = isAttribute;
- }
-
- public QName getQName() {
- return qName;
- }
-
- public void setQName(QName qName) {
- this.qName = qName;
- }
-
- public Object getValue() {
- return value;
- }
-
- public void setValue(Object value) {
- this.value = value;
- }
-
- public boolean isAttribute() {
- return isAttribute;
- }
-
- public void setIsAttribute(boolean isAttribute) {
- this.isAttribute = isAttribute;
- }
+ private QName qName;
+ private Object value;
+ boolean isAttribute = false;
+
+ public ExtensionImpl() {
+ }
+
+ public ExtensionImpl(QName qName, Object value, boolean isAttribute) {
+ this.qName = qName;
+ this.value = value;
+ this.isAttribute = isAttribute;
+ }
+
+ public QName getQName() {
+ return qName;
+ }
+
+ public void setQName(QName qName) {
+ this.qName = qName;
+ }
+
+ public <T> T getValue() {
+ return (T) value;
+ }
+
+ public <T> void setValue(T value) {
+ this.value = value;
+ }
+
+ public boolean isAttribute() {
+ return isAttribute;
+ }
+
+ public void setIsAttribute(boolean isAttribute) {
+ this.isAttribute = isAttribute;
+ }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
index aa75922489..1c28192b3a 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
@@ -22,25 +22,19 @@ package org.apache.tuscany.sca.assembly.impl;
import java.util.ArrayList;
import java.util.List;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Base implementation class of Implementation model interface
*
* @version $Rev$ $Date$
*/
-public abstract class ImplementationImpl extends ComponentTypeImpl implements Implementation, PolicySetAttachPoint,
- OperationsConfigurator {
-
- private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
- private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>();
- private IntentAttachPointType type;
+public abstract class ImplementationImpl extends ComponentTypeImpl implements Implementation, PolicySubject {
+ private ExtensionType type;
private List<PolicySet> policySets = new ArrayList<PolicySet>();
private List<Intent> requiredIntents = new ArrayList<Intent>();
@@ -48,14 +42,6 @@ public abstract class ImplementationImpl extends ComponentTypeImpl implements Im
super();
}
- public List<PolicySet> getApplicablePolicySets() {
- return applicablePolicySets;
- }
-
- public List<ConfiguredOperation> getConfiguredOperations() {
- return configuredOperations;
- }
-
public List<PolicySet> getPolicySets() {
return policySets;
}
@@ -64,12 +50,11 @@ public abstract class ImplementationImpl extends ComponentTypeImpl implements Im
return requiredIntents;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return type;
}
- public void setType(IntentAttachPointType type) {
+ public void setType(ExtensionType type) {
this.type = type;
}
-
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
index 1a7abc8564..99ed9b6d10 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
@@ -25,7 +25,7 @@ import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Wire;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -79,11 +79,11 @@ public class WireImpl extends ExtensibleImpl implements Wire, Cloneable {
return policySets;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return null;
}
- public void setType(IntentAttachPointType type) {
+ public void setType(ExtensionType type) {
}
public void setPolicySets(List<PolicySet> policySets) {
diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
index 5e0a2335d1..3a75bbcc36 100644
--- a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
+++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
@@ -18,13 +18,15 @@
*/
package org.apache.tuscany.sca.assembly;
+import org.apache.tuscany.sca.assembly.impl.BindingImpl;
+
/**
* A test interface model.
*
* @version $Rev$ $Date$
*/
-public class TestBinding implements Binding {
+public class TestBinding extends BindingImpl implements Binding {
public TestBinding(AssemblyFactory factory) {
}
@@ -35,22 +37,9 @@ public class TestBinding implements Binding {
public String getURI() {
return "http://test";
}
-
- public void setName(String name) {
- }
-
- public void setURI(String uri) {
- }
-
- public void setUnresolved(boolean unresolved) {
- }
public boolean isUnresolved() {
return false;
}
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
}
diff --git a/java/sca/modules/binding-sca-xml/src/main/java/org/apache/tuscany/sca/binding/sca/xml/SCABindingProcessor.java b/java/sca/modules/binding-sca-xml/src/main/java/org/apache/tuscany/sca/binding/sca/xml/SCABindingProcessor.java
index 56468c8204..474fb0ce38 100644
--- a/java/sca/modules/binding-sca-xml/src/main/java/org/apache/tuscany/sca/binding/sca/xml/SCABindingProcessor.java
+++ b/java/sca/modules/binding-sca-xml/src/main/java/org/apache/tuscany/sca/binding/sca/xml/SCABindingProcessor.java
@@ -29,17 +29,16 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.assembly.xml.Constants;
-import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* A processor to read the XML that describes the SCA binding.
@@ -51,8 +50,8 @@ public class SCABindingProcessor implements StAXArtifactProcessor<SCABinding>, C
private PolicyFactory policyFactory;
private SCABindingFactory scaBindingFactory;
- private PolicyAttachPointProcessor policyProcessor;
- private IntentAttachPointTypeFactory intentAttachPointTypeFactory;
+ private PolicySubjectProcessor policyProcessor;
+ private PolicyFactory intentAttachPointTypeFactory;
protected static final String BINDING_SCA = "binding.sca";
protected static final QName BINDING_SCA_QNAME = new QName(Constants.SCA10_NS, BINDING_SCA);
@@ -60,8 +59,8 @@ public class SCABindingProcessor implements StAXArtifactProcessor<SCABinding>, C
public SCABindingProcessor(FactoryExtensionPoint modelFactories) {
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
- policyProcessor = new PolicyAttachPointProcessor(policyFactory);
- this.intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
+ policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
}
public QName getArtifactType() {
@@ -74,10 +73,10 @@ public class SCABindingProcessor implements StAXArtifactProcessor<SCABinding>, C
public SCABinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
SCABinding scaBinding = scaBindingFactory.createSCABinding();
- IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
- bindingType.setName(getArtifactType());
+ ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
+ bindingType.setType(getArtifactType());
bindingType.setUnresolved(true);
- ((PolicySetAttachPoint)scaBinding).setType(bindingType);
+ ((PolicySubject)scaBinding).setType(bindingType);
// Read policies
policyProcessor.readPolicies(scaBinding, reader);
diff --git a/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java b/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
index fb8ab4104c..ec49035c78 100644
--- a/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
+++ b/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
@@ -30,23 +30,23 @@ import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.assembly.builder.AutomaticBinding;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* The assembly mode object for an SCA binding.
*
* @version $Rev$ $Date$
*/
-public class SCABindingImpl implements SCABinding, Extensible, PolicySetAttachPoint, OptimizableBinding, AutomaticBinding {
+public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, OptimizableBinding, AutomaticBinding {
private String name;
private String uri;
private List<Object> extensions = new ArrayList<Object>();
private List<Extension> attributeExtensions = new ArrayList<Extension>();
private List<Intent> requiredIntents = new ArrayList<Intent>();
private List<PolicySet> policySets = new ArrayList<PolicySet>();
- private IntentAttachPointType intentAttachPointType;
+ private ExtensionType intentAttachPointType;
private Component targetComponent;
private ComponentService targetComponentService;
@@ -154,11 +154,11 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySetAttachPo
return requiredIntents;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return intentAttachPointType;
}
- public void setType(IntentAttachPointType intentAttachPointType) {
+ public void setType(ExtensionType intentAttachPointType) {
this.intentAttachPointType = intentAttachPointType;
}
diff --git a/java/sca/modules/binding-sca/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml b/java/sca/modules/binding-sca/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
index 8bac9e01c9..f3c5cd0aa1 100644
--- a/java/sca/modules/binding-sca/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
+++ b/java/sca/modules/binding-sca/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
@@ -17,9 +17,9 @@
* specific language governing permissions and limitations
* under the License.
-->
-<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
- targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
<sca:bindingType type="sca:binding.sca" mayProvide="" alwaysProvides=""/>
diff --git a/java/sca/modules/binding-sca/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java b/java/sca/modules/binding-sca/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java
index 1b4b770f66..8a3b664fac 100644
--- a/java/sca/modules/binding-sca/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java
+++ b/java/sca/modules/binding-sca/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java
@@ -36,7 +36,7 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -66,7 +66,7 @@ public class SCABindingTestCase {
FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
SCABindingFactory scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
- IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
+ PolicyFactory attachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
compositeBuilder = extensionPoints.getExtensionPoint(CompositeBuilderExtensionPoint.class).getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeBuilder");
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java
index 004d52be9c..b44d30002b 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java
@@ -20,15 +20,13 @@ package org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.Policy;
-
/**
* Implementation for policies that could be injected as parameter
* into the axis2config.
*
* @version $Rev: 695374 $ $Date: 2008-09-15 09:07:58 +0100 (Mon, 15 Sep 2008) $
*/
-public class Axis2TokenAuthenticationPolicy implements Policy {
+public class Axis2TokenAuthenticationPolicy {
private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
public static final QName AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME = new QName(SCA10_TUSCANY_NS, "axis2TokenAuthentication");
public static final String AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME = "tokenName";
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java
index 2226c691ee..4753012de4 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java
@@ -26,7 +26,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -49,8 +49,8 @@ public class Axis2TokenAuthenticationReferencePolicyProvider implements PolicyPr
}
private PolicySet findPolicySet() {
- if (binding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
+ if (binding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)binding).getPolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) {
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java
index 8a18e4f4af..d1be46d1ce 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java
@@ -26,7 +26,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -47,8 +47,8 @@ public class Axis2TokenAuthenticationServicePolicyProvider implements PolicyProv
}
private PolicySet findPolicySet() {
- if (binding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
+ if (binding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)binding).getPolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) {
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
index fa26fedc9e..43b6162bd0 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
@@ -24,7 +24,6 @@ import java.util.Map;
import javax.xml.namespace.QName;
import org.apache.axiom.om.OMElement;
-import org.apache.tuscany.sca.policy.Policy;
/**
* Implementation for policies that could be injected as parameter
@@ -32,7 +31,7 @@ import org.apache.tuscany.sca.policy.Policy;
*
* @version $Rev$ $Date$
*/
-public class Axis2ConfigParamPolicy implements Policy {
+public class Axis2ConfigParamPolicy {
private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
public static final QName NAME = new QName(SCA10_TUSCANY_NS, "wsConfigParam");
private Map<String, OMElement> paramElements = new Hashtable<String, OMElement>();
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java
index 5ac4e3f5fd..dfedaf97a5 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java
@@ -23,7 +23,6 @@ import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.Parameter;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.util.PolicyHandler;
/**
@@ -31,7 +30,7 @@ import org.apache.tuscany.sca.policy.util.PolicyHandler;
*
* @version $Rev$ $Date$
*/
-public class Axis2ConfigParamPolicyHandler implements PolicyHandler {
+public class Axis2ConfigParamPolicyHandler {
private PolicySet applicablePolicySet = null;
public void setUp(Object... context) {
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java
index 0c9cf76a29..50388aef28 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java
@@ -20,15 +20,13 @@ package org.apache.tuscany.sca.binding.ws.axis2.policy.header;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.Policy;
-
/**
* Implementation for policies that could be injected as parameter
* into the axis2config.
*
* @version $Rev$ $Date$
*/
-public class Axis2HeaderPolicy implements Policy {
+public class Axis2HeaderPolicy {
private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
public static final QName AXIS2_HEADER_POLICY_QNAME = new QName(SCA10_TUSCANY_NS, "axis2Header");
public static final String AXIS2_HEADER_NAME = "headerName";
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java
index 0176fee05d..d0fc58cd33 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java
@@ -26,7 +26,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -48,9 +48,10 @@ public class Axis2HeaderReferencePolicyProvider implements PolicyProvider {
this.binding = binding;
}
+ // FIXME: Need to use the endpoint with effective policies
private PolicySet findPolicySet() {
- if (binding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
+ if (binding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)binding).getPolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
if (Axis2HeaderPolicy.class.isInstance(p)) {
diff --git a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java
index 7a3ff2a48e..3cb6d8007b 100644
--- a/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java
+++ b/java/sca/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java
@@ -26,7 +26,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -47,8 +47,8 @@ public class Axis2HeaderServicePolicyProvider implements PolicyProvider {
}
private PolicySet findPolicySet() {
- if (binding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
+ if (binding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)binding).getPolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
if (Axis2HeaderPolicy.class.isInstance(p)) {
diff --git a/java/sca/modules/binding-ws-axis2/pom.xml b/java/sca/modules/binding-ws-axis2/pom.xml
index ad3e0a35de..0b092563d9 100644
--- a/java/sca/modules/binding-ws-axis2/pom.xml
+++ b/java/sca/modules/binding-ws-axis2/pom.xml
@@ -66,6 +66,13 @@
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-xml</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-ws</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
index cfa2b2678f..85fb8dd20c 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
@@ -48,12 +48,10 @@ import org.apache.tuscany.sca.interfacedef.util.FaultException;
import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
-import org.apache.tuscany.sca.policy.util.PolicyHandler;
import org.apache.tuscany.sca.runtime.ReferenceParameters;
+
/**
* Axis2BindingInvoker uses an Axis2 OperationClient to invoke a remote web service
*
@@ -75,7 +73,6 @@ public class Axis2BindingInvoker implements Invoker, DataExchangeSemantics {
private QName wsdlOperationName;
private Options options;
private SOAPFactory soapFactory;
- private List<PolicyHandler> policyHandlerList = null;
private WebServiceBinding wsBinding;
private BasicAuthenticationPolicy basicAuthenticationPolicy = null;
@@ -86,18 +83,17 @@ public class Axis2BindingInvoker implements Invoker, DataExchangeSemantics {
QName wsdlOperationName,
Options options,
SOAPFactory soapFactory,
- List<PolicyHandler> policyHandlerList,
WebServiceBinding wsBinding) {
this.serviceClient = serviceClient;
this.wsdlOperationName = wsdlOperationName;
this.options = options;
this.soapFactory = soapFactory;
- this.policyHandlerList = policyHandlerList;
this.wsBinding = wsBinding;
// find out which policies are active
- if (wsBinding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)wsBinding).getApplicablePolicySets();
+ /*
+ if (wsBinding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)wsBinding).getPolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
if (BasicAuthenticationPolicy.class.isInstance(p)) {
@@ -112,6 +108,7 @@ public class Axis2BindingInvoker implements Invoker, DataExchangeSemantics {
}
}
}
+ */
}
private static final QName EXCEPTION = new QName("", "Exception");
@@ -144,9 +141,11 @@ public class Axis2BindingInvoker implements Invoker, DataExchangeSemantics {
requestMC.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
requestMC.getOptions().setTimeOutInMilliSeconds(240000L);
+ /*
for ( PolicyHandler policyHandler : policyHandlerList ) {
policyHandler.beforeInvoke(msg, requestMC, operationClient);
}
+ */
// set policy specified headers
for (Axis2HeaderPolicy policy : axis2HeaderPolicies){
@@ -177,9 +176,11 @@ public class Axis2BindingInvoker implements Invoker, DataExchangeSemantics {
MessageContext responseMC = operationClient.getMessageContext("In");
+ /*
for ( PolicyHandler policyHandler : policyHandlerList ) {
policyHandler.afterInvoke(msg, responseMC, operationClient);
}
+ */
OMElement response = responseMC.getEnvelope().getBody().getFirstElement();
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java
index a532f899bc..cc65988553 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java
@@ -26,15 +26,12 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerDefinitionsLoader;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.provider.BindingProviderFactory;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
-import org.oasisopen.sca.ServiceRuntimeException;
/**
* Axis2BindingProviderFactory
@@ -46,7 +43,6 @@ public class Axis2BindingProviderFactory implements BindingProviderFactory<WebSe
private FactoryExtensionPoint modelFactories;
private ServletHost servletHost;
- private List<PolicyHandlerTuple> policyHandlerClassnames = null;
private DataBindingExtensionPoint dataBindings;
public Axis2BindingProviderFactory(ExtensionPointRegistry extensionPoints) {
@@ -56,7 +52,6 @@ public class Axis2BindingProviderFactory implements BindingProviderFactory<WebSe
this.servletHost = hosts.get(0);
}
modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
- policyHandlerClassnames = PolicyHandlerDefinitionsLoader.loadPolicyHandlerClassnames();
dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class);
}
@@ -64,7 +59,7 @@ public class Axis2BindingProviderFactory implements BindingProviderFactory<WebSe
RuntimeComponentReference reference,
WebServiceBinding binding) {
return new Axis2ReferenceBindingProvider(component, reference, binding,
- modelFactories, policyHandlerClassnames, dataBindings);
+ modelFactories, dataBindings);
}
public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
@@ -72,7 +67,7 @@ public class Axis2BindingProviderFactory implements BindingProviderFactory<WebSe
WebServiceBinding binding) {
return new Axis2ServiceBindingProvider(component, service, binding,
servletHost, modelFactories,
- policyHandlerClassnames, dataBindings);
+ dataBindings);
}
public Class<WebServiceBinding> getModelType() {
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java
index 97eb3949af..abf5f4008d 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java
@@ -18,8 +18,6 @@
*/
package org.apache.tuscany.sca.binding.ws.axis2;
-import java.util.List;
-
import javax.xml.namespace.QName;
import org.apache.axiom.soap.SOAPFactory;
@@ -30,7 +28,6 @@ import org.apache.axis2.context.MessageContext;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.policy.util.PolicyHandler;
/**
* Axis2OneWayBindingInvoker uses an Axis2 OperationClient to invoke a OneWay remote web service.
@@ -43,10 +40,9 @@ public class Axis2OneWayBindingInvoker extends Axis2BindingInvoker {
QName wsdlOperationName,
Options options,
SOAPFactory soapFactory,
- List<PolicyHandler> policyHandlerList,
WebServiceBinding wsBinding) {
- super(serviceClient, wsdlOperationName, options, soapFactory, policyHandlerList, wsBinding);
+ super(serviceClient, wsdlOperationName, options, soapFactory, wsBinding);
}
@Override
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java
index 83f1f3219e..184d02642e 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java
@@ -18,8 +18,6 @@
*/
package org.apache.tuscany.sca.binding.ws.axis2;
-import java.util.List;
-
import org.apache.axiom.om.OMElement;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
@@ -28,7 +26,6 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -43,7 +40,6 @@ public class Axis2ReferenceBindingProvider implements ReferenceBindingProvider {
RuntimeComponentReference reference,
WebServiceBinding wsBinding,
FactoryExtensionPoint modelFactories,
- List<PolicyHandlerTuple> policyHandlerClassnames,
DataBindingExtensionPoint dataBindings) {
MessageFactory messageFactory = modelFactories.getFactory(MessageFactory.class);
@@ -60,7 +56,7 @@ public class Axis2ReferenceBindingProvider implements ReferenceBindingProvider {
contract.getInterface().resetDataBinding(OMElement.class.getName());
}
- axisClient = new Axis2ServiceClient(component, reference, wsBinding, messageFactory, policyHandlerClassnames);
+ axisClient = new Axis2ServiceClient(component, reference, wsBinding, messageFactory);
}
public void start() {
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java
index d7f8096ff2..8aa2181c22 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java
@@ -18,8 +18,6 @@
*/
package org.apache.tuscany.sca.binding.ws.axis2;
-import java.util.List;
-
import org.apache.axiom.om.OMElement;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
@@ -27,7 +25,6 @@ import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
import org.apache.tuscany.sca.host.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -43,7 +40,6 @@ public class Axis2ServiceBindingProvider implements ServiceBindingProvider {
WebServiceBinding wsBinding,
ServletHost servletHost,
FactoryExtensionPoint modelFactories,
- List<PolicyHandlerTuple> policyHandlerClassnames,
DataBindingExtensionPoint dataBindings) {
if (servletHost == null) {
@@ -62,7 +58,7 @@ public class Axis2ServiceBindingProvider implements ServiceBindingProvider {
InterfaceContract contract = wsBinding.getBindingInterfaceContract();
contract.getInterface().resetDataBinding(OMElement.class.getName());
- axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost, messageFactory, policyHandlerClassnames);
+ axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost, messageFactory);
}
public void start() {
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
index c4bb3e9342..d2ba46a7e2 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
@@ -27,7 +27,6 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -74,10 +73,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
-import org.apache.tuscany.sca.policy.util.PolicyHandler;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerUtils;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.xsd.xml.XMLDocumentHelper;
import org.apache.ws.commons.schema.resolver.URIResolver;
@@ -89,19 +85,15 @@ public class Axis2ServiceClient {
private AbstractContract contract;
private WebServiceBinding wsBinding;
private ServiceClient serviceClient;
- List<PolicyHandlerTuple> policyHandlerClassnames = null;
- private List<PolicyHandler> policyHandlerList = new ArrayList<PolicyHandler>();
public Axis2ServiceClient(RuntimeComponent component,
AbstractContract contract,
WebServiceBinding wsBinding,
- MessageFactory messageFactory,
- List<PolicyHandlerTuple> policyHandlerClassnames) {
+ MessageFactory messageFactory) {
this.component = component;
this.contract = contract;
this.wsBinding = wsBinding;
- this.policyHandlerClassnames = policyHandlerClassnames;
}
protected void start() {
@@ -156,7 +148,6 @@ public class Axis2ServiceClient {
}
createPolicyHandlers();
- setupPolicyHandlers(policyHandlerList, configContext);
Definition definition = wsBinding.getWSDLDocument();
QName serviceQName = wsBinding.getService().getQName();
@@ -374,9 +365,9 @@ public class Axis2ServiceClient {
}
Axis2BindingInvoker invoker;
if (operation.isNonBlocking()) {
- invoker = new Axis2OneWayBindingInvoker(this, wsdlOperationQName, options, soapFactory, policyHandlerList, wsBinding);
+ invoker = new Axis2OneWayBindingInvoker(this, wsdlOperationQName, options, soapFactory, wsBinding);
} else {
- invoker = new Axis2BindingInvoker(this, wsdlOperationQName, options, soapFactory, policyHandlerList, wsBinding);
+ invoker = new Axis2BindingInvoker(this, wsdlOperationQName, options, soapFactory, wsBinding);
}
return invoker;
@@ -465,16 +456,7 @@ public class Axis2ServiceClient {
}
private void createPolicyHandlers() throws IllegalAccessException, InstantiationException, ClassNotFoundException {
- if (wsBinding instanceof PolicySetAttachPoint) {
- PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding;
- PolicyHandler policyHandler = null;
- for (PolicySet policySet : policiedBinding.getPolicySets()) {
- policyHandler = PolicyHandlerUtils.findPolicyHandler(policySet, policyHandlerClassnames);
- if (policyHandler != null) {
- policyHandler.setApplicablePolicySet(policySet);
- policyHandlerList.add(policyHandler);
- }
- }
+ if (wsBinding instanceof PolicySubject) {
// code to create policy handlers using the new policy SPI based
// on policy providers
@@ -491,10 +473,5 @@ public class Axis2ServiceClient {
}
}
- private void setupPolicyHandlers(List<PolicyHandler> policyHandlers, ConfigurationContext configContext) {
- for (PolicyHandler aHandler : policyHandlers) {
- aHandler.setUp(configContext);
- }
- }
}
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java
index a0cfab9154..795b3b256f 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java
@@ -19,14 +19,12 @@
package org.apache.tuscany.sca.binding.ws.axis2;
import java.lang.reflect.InvocationTargetException;
-import java.util.List;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.receivers.AbstractInMessageReceiver;
import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.policy.util.PolicyHandler;
public class Axis2ServiceInMessageReceiver extends AbstractInMessageReceiver {
@@ -34,12 +32,9 @@ public class Axis2ServiceInMessageReceiver extends AbstractInMessageReceiver {
private Axis2ServiceProvider provider;
- private List<PolicyHandler> policyHandlerList = null;
-
- public Axis2ServiceInMessageReceiver(Axis2ServiceProvider provider, Operation operation, List<PolicyHandler> policyHandlerList) {
+ public Axis2ServiceInMessageReceiver(Axis2ServiceProvider provider, Operation operation) {
this.provider = provider;
this.operation = operation;
- this.policyHandlerList = policyHandlerList;
}
public Axis2ServiceInMessageReceiver() {
@@ -51,20 +46,8 @@ public class Axis2ServiceInMessageReceiver extends AbstractInMessageReceiver {
OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
Object[] args = new Object[] {requestOM};
- /*
- for ( PolicyHandler policyHandler : policyHandlerList ) {
- policyHandler.beforeInvoke(operation, args, inMC);
- }
- */
-
provider.invokeTarget(operation, args, inMC);
- /*
- for ( PolicyHandler policyHandler : policyHandlerList ) {
- policyHandler.afterInvoke(operation, args, inMC);
- }
- */
-
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
if (t instanceof Exception) {
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java
index 64e49e0b0d..2cd176aae0 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.binding.ws.axis2;
import java.lang.reflect.InvocationTargetException;
-import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -31,21 +30,18 @@ import org.apache.axis2.context.MessageContext;
import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.FaultException;
-import org.apache.tuscany.sca.policy.util.PolicyHandler;
import org.oasisopen.sca.ServiceRuntimeException;
public class Axis2ServiceInOutSyncMessageReceiver extends AbstractInOutSyncMessageReceiver {
private static final Logger logger = Logger.getLogger(Axis2ServiceInOutSyncMessageReceiver.class.getName());
protected Operation operation;
- private List<PolicyHandler> policyHandlerList = null;
private Axis2ServiceProvider provider;
- public Axis2ServiceInOutSyncMessageReceiver(Axis2ServiceProvider provider, Operation operation, List<PolicyHandler> policyHandlerList) {
+ public Axis2ServiceInOutSyncMessageReceiver(Axis2ServiceProvider provider, Operation operation) {
this.provider = provider;
this.operation = operation;
- this.policyHandlerList = policyHandlerList;
}
public Axis2ServiceInOutSyncMessageReceiver() {
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
index e5b64b99cc..ae67fa8a80 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
@@ -91,11 +91,8 @@ import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
-import org.apache.tuscany.sca.policy.util.PolicyHandler;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerUtils;
import org.apache.tuscany.sca.runtime.EndpointReference;
import org.apache.tuscany.sca.runtime.ReferenceParameters;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -128,8 +125,6 @@ public class Axis2ServiceProvider {
private ConfigurationContext configContext;
private JMSSender jmsSender;
private JMSListener jmsListener;
- private List<PolicyHandlerTuple> policyHandlerClassnames = null;
- private List<PolicyHandler> policyHandlerList = new ArrayList<PolicyHandler>();
private Map<String, Port> urlMap = new HashMap<String, Port>();
private BasicAuthenticationPolicy basicAuthenticationPolicy = null;
@@ -166,15 +161,13 @@ public class Axis2ServiceProvider {
AbstractContract contract,
WebServiceBinding wsBinding,
ServletHost servletHost,
- MessageFactory messageFactory,
- List<PolicyHandlerTuple> policyHandlerClassnames) {
+ MessageFactory messageFactory) {
this.component = component;
this.contract = contract;
this.wsBinding = wsBinding;
this.servletHost = servletHost;
this.messageFactory = messageFactory;
- this.policyHandlerClassnames = policyHandlerClassnames;
final boolean isRampartRequired = AxisPolicyHelper.isRampartRequired(wsBinding);
try {
@@ -214,9 +207,10 @@ public class Axis2ServiceProvider {
urlMap.put(endpointURI, (Port)port);
}
+ /*
// find out which policies are active
- if (wsBinding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)wsBinding).getApplicablePolicySets();
+ if (wsBinding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)wsBinding).getApplicablePolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
if (BasicAuthenticationPolicy.class.isInstance(p)) {
@@ -230,7 +224,8 @@ public class Axis2ServiceProvider {
}
}
}
- }
+ }
+ */
}
static String getPortAddress(Port port) {
@@ -319,7 +314,6 @@ public class Axis2ServiceProvider {
AxisService axisService = createAxisService(entry.getKey(), entry.getValue());
configContext.getAxisConfiguration().addService(axisService);
}
- setupPolicyHandlers(policyHandlerList, configContext);
Axis2ServiceServlet servlet = null;
for (String endpointURL : urlMap.keySet()) {
@@ -640,9 +634,9 @@ public class Axis2ServiceProvider {
MessageReceiver msgrec = null;
if (op.isNonBlocking()) {
- msgrec = new Axis2ServiceInMessageReceiver(this, op, policyHandlerList);
+ msgrec = new Axis2ServiceInMessageReceiver(this, op);
} else {
- msgrec = new Axis2ServiceInOutSyncMessageReceiver(this, op, policyHandlerList);
+ msgrec = new Axis2ServiceInOutSyncMessageReceiver(this, op);
}
axisOp.setMessageReceiver(msgrec);
}
@@ -739,10 +733,6 @@ public class Axis2ServiceProvider {
parameters.setConversationID(conversationID);
}
- for ( PolicyHandler policyHandler : policyHandlerList ) {
- policyHandler.beforeInvoke(msg, inMC);
- }
-
if (basicAuthenticationPolicy != null) {
Axis2BindingBasicAuthenticationConfigurator.parseHTTPHeader(inMC, msg, basicAuthenticationPolicy);
}
@@ -751,10 +741,6 @@ public class Axis2ServiceProvider {
RuntimeWire wire = ((RuntimeComponentService)contract).getRuntimeWire(getBinding());
Object response = wire.invoke(op, msg);
- for ( PolicyHandler policyHandler : policyHandlerList ) {
- policyHandler.afterInvoke(response, inMC);
- }
-
return response;
}
@@ -772,28 +758,10 @@ public class Axis2ServiceProvider {
return wsBinding;
}
- private void setupPolicyHandlers(List<PolicyHandler> policyHandlers, ConfigurationContext configContext) {
- for ( PolicyHandler aHandler : policyHandlers ) {
- aHandler.setUp(configContext);
- }
- }
-
private void createPolicyHandlers() throws IllegalAccessException,
InstantiationException,
ClassNotFoundException {
- if (wsBinding instanceof PolicySetAttachPoint) {
- PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding;
- PolicyHandler policyHandler = null;
-
- for (PolicySet policySet : policiedBinding.getPolicySets()) {
- policyHandler =
- PolicyHandlerUtils.findPolicyHandler(policySet, policyHandlerClassnames);
-
- if (policyHandler != null) {
- policyHandler.setApplicablePolicySet(policySet);
- policyHandlerList.add(policyHandler);
- }
- }
+ if (wsBinding instanceof PolicySubject) {
// code to create policy handlers using a policy SPI based
// on policy providers
diff --git a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java
index 1f389b422f..13e32b0bfd 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java
+++ b/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java
@@ -25,9 +25,9 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* @version $Rev$ $Date$
@@ -44,8 +44,8 @@ public class AxisPolicyHelper {
public static PolicySet getPolicySet(Binding wsBinding, QName intentName) {
PolicySet returnPolicySet = null;
- if (wsBinding instanceof PolicySetAttachPoint) {
- PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding;
+ if (wsBinding instanceof PolicySubject) {
+ PolicySubject policiedBinding = (PolicySubject)wsBinding;
for (PolicySet policySet : policiedBinding.getPolicySets()) {
for (Intent intent : policySet.getProvidedIntents()) {
if (intent.getName().equals(intentName)) {
@@ -60,8 +60,8 @@ public class AxisPolicyHelper {
}
public static boolean isIntentRequired(Binding wsBinding, QName intent) {
- if (wsBinding instanceof IntentAttachPoint) {
- List<Intent> intents = ((IntentAttachPoint)wsBinding).getRequiredIntents();
+ if (wsBinding instanceof PolicySubject) {
+ List<Intent> intents = ((PolicySubject)wsBinding).getRequiredIntents();
for (Intent i : intents) {
if (intent.equals(i.getName())) {
return true;
diff --git a/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml b/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml
index 6bff613a7c..88c0ef14d1 100644
--- a/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml
+++ b/java/sca/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml
@@ -20,9 +20,9 @@
<!-- $Rev$ $Date$ -->
-<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
- targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
<sca:bindingType type="sca:binding.ws" mayProvide="SOAP SOAP.1_1 SOAP.1_2 MTOM" alwaysProvides=""/>
diff --git a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml
index 8fa2d3b8c0..063cd0b3e6 100644
--- a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml
+++ b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml
@@ -17,9 +17,9 @@
* specific language governing permissions and limitations
* under the License.
-->
-<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
<!-- WS Security POLICY SETS -->
diff --git a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml
index 65f8cb67d8..21ab1d8a47 100644
--- a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml
+++ b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml
@@ -17,9 +17,9 @@
* specific language governing permissions and limitations
* under the License.
-->
-<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
<sca:intent name="wsAuthentication"
diff --git a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml
index 871e889835..3239d855b6 100644
--- a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml
+++ b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml
@@ -17,9 +17,9 @@
* specific language governing permissions and limitations
* under the License.
-->
-<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
<!-- WS Security POLICY SETS -->
diff --git a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml
index d7f40ccf0e..2f43f6f484 100644
--- a/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml
+++ b/java/sca/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml
@@ -17,9 +17,9 @@
* specific language governing permissions and limitations
* under the License.
-->
-<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
<!-- WS Security POLICY SETS -->
diff --git a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
index 79213a1ce7..fa078d59e9 100644
--- a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
+++ b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
@@ -51,7 +51,7 @@ import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.xsd.XSDFactory;
/**
@@ -269,8 +269,8 @@ public class BindingWSDLGenerator {
}
protected static boolean requiresSOAP12(WebServiceBinding wsBinding) {
- if (wsBinding instanceof IntentAttachPoint) {
- List<Intent> intents = ((IntentAttachPoint)wsBinding).getRequiredIntents();
+ if (wsBinding instanceof PolicySubject) {
+ List<Intent> intents = ((PolicySubject)wsBinding).getRequiredIntents();
for (Intent intent : intents) {
if (SOAP12_INTENT.equals(intent.getName())) {
return true;
diff --git a/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
index 23322e822e..f2a1d5a15d 100644
--- a/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
+++ b/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
@@ -33,11 +33,8 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
-import org.apache.tuscany.sca.assembly.xml.ConfiguredOperationProcessor;
import org.apache.tuscany.sca.assembly.xml.Constants;
-import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
import org.apache.tuscany.sca.binding.ws.DefaultWebServiceBindingFactory;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
@@ -59,7 +56,6 @@ import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
import org.apache.tuscany.sca.policy.PolicyFactory;
/**
@@ -73,9 +69,8 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
private WSDLFactory wsdlFactory;
private WebServiceBindingFactory wsFactory;
private PolicyFactory policyFactory;
- private PolicyAttachPointProcessor policyProcessor;
- private IntentAttachPointTypeFactory intentAttachPointTypeFactory;
- private ConfiguredOperationProcessor configuredOperationProcessor;
+ private PolicySubjectProcessor policyProcessor;
+ private PolicyFactory intentAttachPointTypeFactory;
private Monitor monitor;
public WebServiceBindingProcessor(ExtensionPointRegistry extensionPoints) {
@@ -84,14 +79,13 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.wsFactory = new DefaultWebServiceBindingFactory();
this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
- this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
- this.intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
if (monitorFactory != null) {
this.monitor = monitorFactory.createMonitor();
}
- this.configuredOperationProcessor = new ConfiguredOperationProcessor(modelFactories, this.monitor);
}
/**
@@ -126,10 +120,10 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
// Read a <binding.ws>
WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
- /*IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
+ /*ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
bindingType.setName(getArtifactType());
bindingType.setUnresolved(true);
- ((PolicySetAttachPoint)wsBinding).setType(bindingType);*/
+ ((PolicySubject)wsBinding).setType(bindingType);*/
wsBinding.setUnresolved(true);
wsBinding.setBuilder(new BindingBuilderImpl(extensionPoints));
@@ -209,7 +203,6 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
// Read wsdlLocation
wsBinding.setLocation(reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION));
- ConfiguredOperation confOp = null;
// Skip to end element
while (reader.hasNext()) {
int event = reader.next();
@@ -221,12 +214,7 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
throw new ContributionReadException(wsdlElement + " must use wsdl.binding when using wsa:EndpointReference");
}
wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader));
- } else if (Constants.OPERATION_QNAME.equals(reader.getName())) {
- confOp = configuredOperationProcessor.read(reader);
- if (confOp != null) {
- ((OperationsConfigurator)wsBinding).getConfiguredOperations().add(confOp);
- }
- }
+ }
}
break;
@@ -373,11 +361,6 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
model.setBindingInterfaceContract(interfaceContract);
}
}
- policyProcessor.resolvePolicies(model, resolver);
- OperationsConfigurator opCongigurator = (OperationsConfigurator)model;
- for (ConfiguredOperation confOp : opCongigurator.getConfiguredOperations()) {
- policyProcessor.resolvePolicies(confOp, resolver);
- }
}
private PortType getPortType(WebServiceBinding model) {
diff --git a/java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java b/java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java
index 550593f515..72d0236e46 100644
--- a/java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java
+++ b/java/sca/modules/binding-ws-xml/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.binding.ws.xml;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.fail;
@@ -31,7 +30,6 @@ import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
@@ -90,8 +88,6 @@ public class ReadTestCase {
compositeBuilder.build(composite, null, null);
- assertEquals(((OperationsConfigurator)composite.getServices().get(0).getBindings().get(0))
- .getConfiguredOperations().get(0).getRequiredIntents().size(), 2);
}
/**
diff --git a/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java b/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
index bfc3765f4b..4ea8fb41a1 100644
--- a/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
+++ b/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
@@ -28,20 +28,18 @@ import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.Extensible;
import org.apache.tuscany.sca.assembly.Extension;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.w3c.dom.Element;
/**
@@ -49,7 +47,7 @@ import org.w3c.dom.Element;
*
* @version $Rev$ $Date$
*/
-class WebServiceBindingImpl implements WebServiceBinding, PolicySetAttachPoint, Extensible, OperationsConfigurator {
+class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensible {
private String name;
private String uri;
private boolean unresolved;
@@ -57,9 +55,7 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySetAttachPoint,
private List<Extension> attributeExtensions = new ArrayList<Extension>();
private List<Intent> requiredIntents = new ArrayList<Intent>();
private List<PolicySet> policySets = new ArrayList<PolicySet>();
- private IntentAttachPointType intentAttachPointType;
- private List<ConfiguredOperation> configuredOperations = new ArrayList<ConfiguredOperation>();
- private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ private ExtensionType intentAttachPointType;
private String location;
private Binding binding;
private Service service;
@@ -268,11 +264,11 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySetAttachPoint,
return requiredIntents;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return intentAttachPointType;
}
- public void setType(IntentAttachPointType intentAttachPointType) {
+ public void setType(ExtensionType intentAttachPointType) {
this.intentAttachPointType = intentAttachPointType;
}
@@ -299,24 +295,4 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySetAttachPoint,
public void setBuilder(BindingBuilder builder) {
this.builder = builder;
}
-
- public void setPolicySets(List<PolicySet> policySets) {
- this.policySets = policySets;
- }
-
- public void setRequiredIntents(List<Intent> intents) {
- this.requiredIntents = intents;
- }
-
- public List<ConfiguredOperation> getConfiguredOperations() {
- return configuredOperations;
- }
-
- public void setConfiguredOperations(List<ConfiguredOperation> configuredOperations) {
- this.configuredOperations = configuredOperations;
- }
-
- public List<PolicySet> getApplicablePolicySets() {
- return applicablePolicySets;
- }
}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
index ef23778ea3..a531eb9ddd 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
@@ -148,7 +148,7 @@ public class DefaultStAXArtifactProcessorExtensionPoint extends
/**
* Lazily load artifact processors registered in the extension point.
*/
- private void loadArtifactProcessors() {
+ private synchronized void loadArtifactProcessors() {
if (loaded)
return;
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
index bd38a609a6..3cdcddc976 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
@@ -144,7 +144,7 @@ public class DefaultStAXAttributeProcessorExtensionPoint extends
/**
* Lazily load artifact processors registered in the extension point.
*/
- private void loadArtifactProcessors() {
+ private synchronized void loadArtifactProcessors() {
if (loaded)
return;
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
index 402d4aa151..86206d4ab2 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
@@ -117,7 +117,7 @@ public class DefaultURLArtifactProcessorExtensionPoint
/**
* Lazily load artifact processors registered in the extension point.
*/
- private void loadProcessors() {
+ private synchronized void loadProcessors() {
if (loaded)
return;
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java
index a6631f498e..9f4094aa12 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java
@@ -51,7 +51,7 @@ public class DefaultValidationSchemaExtensionPoint implements ValidationSchemaEx
* Load schema declarations from META-INF/services/
* org.apache.tuscany.sca.contribution.processor.ValidationSchema files
*/
- private void loadSchemas() {
+ private synchronized void loadSchemas() {
if (loaded)
return;
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
index 878a2efdab..33e252830a 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
@@ -89,7 +89,7 @@ public class DefaultModelResolverExtensionPoint implements ModelResolverExtensio
/**
* Dynamically load model resolvers declared under META-INF/services
*/
- private void loadModelResolvers() {
+ private synchronized void loadModelResolvers() {
if (loadedResolvers != null)
return;
loadedResolvers = new HashMap<String, ServiceDeclaration>();
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
index cf3c77d5eb..163f887bbc 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
@@ -57,7 +57,7 @@ public class DefaultContributionScannerExtensionPoint implements ContributionSca
return scanners.get(contentType);
}
- private void loadScanners() {
+ private synchronized void loadScanners() {
if (loaded)
return;
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java
index 2aea4baa67..b2d0639a16 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/endpointresolver/DefaultEndpointResolverFactoryExtensionPoint.java
@@ -92,7 +92,7 @@ public class DefaultEndpointResolverFactoryExtensionPoint implements EndpointRes
* Load provider factories declared under META-INF/services.
* @param registry
*/
- private void loadProviderFactories() {
+ private synchronized void loadProviderFactories() {
if (loaded)
return;
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultDefinitionsProviderExtensionPoint.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultDefinitionsProviderExtensionPoint.java
index 47757bee24..fc1c2ed5af 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultDefinitionsProviderExtensionPoint.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultDefinitionsProviderExtensionPoint.java
@@ -38,6 +38,7 @@ public class DefaultDefinitionsProviderExtensionPoint implements
private ExtensionPointRegistry extensionPointRegistry = null;
+ private boolean loaded;
private List<DefinitionsProvider> scaDefnsProviders = new ArrayList<DefinitionsProvider>();
public DefaultDefinitionsProviderExtensionPoint(ExtensionPointRegistry extnPtReg) {
@@ -53,13 +54,14 @@ public class DefaultDefinitionsProviderExtensionPoint implements
}
public List<DefinitionsProvider> getDefinitionsProviders() {
- if (scaDefnsProviders.isEmpty()) {
- loadProviders();
- }
+ loadProviders();
return scaDefnsProviders;
}
- private void loadProviders() {
+ private synchronized void loadProviders() {
+ if(loaded) {
+ return;
+ }
// Get the provider service declarations
Set<ServiceDeclaration> defnProviderDecls;
DefinitionsProvider aProvider = null;
@@ -86,6 +88,6 @@ public class DefaultDefinitionsProviderExtensionPoint implements
} catch (Exception e) {
throw new RuntimeException(e);
}
-
+ loaded = true;
}
}
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
index 5e17737d58..518927939f 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
@@ -106,7 +106,7 @@ public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExte
* Load provider factories declared under META-INF/services.
* @param registry
*/
- private void loadProviderFactories() {
+ private synchronized void loadProviderFactories() {
if (loaded)
return;
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java
index b60a14d2da..d9ac4d16b0 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java
@@ -21,7 +21,6 @@ package org.apache.tuscany.sca.provider;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.policy.Policy;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -29,7 +28,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
/**
* @version $Rev$ $Date$
*/
-public interface PolicyProviderFactory<M extends Policy> extends ProviderFactory<M> {
+public interface PolicyProviderFactory<M> extends ProviderFactory<M> {
/**
* Create policy provider for a given reference binding
* @param component
diff --git a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
index 3bd729b472..2583270b3d 100644
--- a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
+++ b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
@@ -109,7 +109,7 @@ public class DefaultTransformerExtensionPoint implements TransformerExtensionPoi
*
* @param transformerClass
*/
- private void loadTransformers(Class<?> transformerClass) {
+ private synchronized void loadTransformers(Class<?> transformerClass) {
// Get the transformer service declarations
Set<ServiceDeclaration> transformerDeclarations;
diff --git a/java/sca/modules/definitions-xml/pom.xml b/java/sca/modules/definitions-xml/pom.xml
index f44236e304..9ba6587631 100644
--- a/java/sca/modules/definitions-xml/pom.xml
+++ b/java/sca/modules/definitions-xml/pom.xml
@@ -39,6 +39,7 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-policy-xml</artifactId>
<version>2.0-SNAPSHOT</version>
+ <scope>runtime</scope>
</dependency>
<dependency>
diff --git a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java b/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
index 6c3dca7bab..2f9c5d3379 100644
--- a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
+++ b/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
@@ -27,8 +27,8 @@ import java.net.URLConnection;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.HashSet;
+import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
@@ -48,8 +48,9 @@ import org.apache.tuscany.sca.definitions.util.DefinitionsUtil;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -73,9 +74,9 @@ public class DefinitionsDocumentProcessor implements URLArtifactProcessor<Defini
* @param staxProcessor
*/
public DefinitionsDocumentProcessor(StAXArtifactProcessor<Object> staxProcessor,
- XMLInputFactory inputFactory,
- DefinitionsFactory definitionsFactory,
- Monitor monitor) {
+ XMLInputFactory inputFactory,
+ DefinitionsFactory definitionsFactory,
+ Monitor monitor) {
this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
this.inputFactory = inputFactory;
this.definitionsFactory = definitionsFactory;
@@ -89,8 +90,8 @@ public class DefinitionsDocumentProcessor implements URLArtifactProcessor<Defini
* @param staxProcessor
*/
public DefinitionsDocumentProcessor(FactoryExtensionPoint modelFactories,
- StAXArtifactProcessor<Object> staxProcessor,
- Monitor monitor) {
+ StAXArtifactProcessor<Object> staxProcessor,
+ Monitor monitor) {
this.extensionProcessor = (StAXArtifactProcessor<Object>)staxProcessor;
this.inputFactory = modelFactories.getFactory(XMLInputFactory.class);
this.definitionsFactory = modelFactories.getFactory(DefinitionsFactory.class);
@@ -198,36 +199,22 @@ public class DefinitionsDocumentProcessor implements URLArtifactProcessor<Defini
}
}
}
-
+
private static void stripDuplicates(Definitions scaDefns) {
- Map<QName, Intent> definedIntents = new HashMap<QName, Intent>();
- for (Intent intent : scaDefns.getIntents()) {
- definedIntents.put(intent.getName(), intent);
- }
+ Set<Intent> definedIntents = new HashSet<Intent>(scaDefns.getIntents());
+ Set<PolicySet> definedPolicySets = new HashSet<PolicySet>(scaDefns.getPolicySets());
+
+ Set<BindingType> definedBindingTypes = new HashSet<BindingType>(scaDefns.getBindingTypes());
+ Set<ImplementationType> definedImplTypes = new HashSet<ImplementationType>(scaDefns.getImplementationTypes());
- Map<QName, PolicySet> definedPolicySets = new HashMap<QName, PolicySet>();
- for (PolicySet policySet : scaDefns.getPolicySets()) {
- definedPolicySets.put(policySet.getName(), policySet);
- }
-
- Map<QName, IntentAttachPointType> definedBindingTypes = new HashMap<QName, IntentAttachPointType>();
- for (IntentAttachPointType bindingType : scaDefns.getBindingTypes()) {
- definedBindingTypes.put(bindingType.getName(), bindingType);
- }
-
- Map<QName, IntentAttachPointType> definedImplTypes = new HashMap<QName, IntentAttachPointType>();
- for (IntentAttachPointType implType : scaDefns.getImplementationTypes()) {
- definedImplTypes.put(implType.getName(), implType);
- }
-
scaDefns.getIntents().clear();
- scaDefns.getIntents().addAll(definedIntents.values());
+ scaDefns.getIntents().addAll(definedIntents);
scaDefns.getPolicySets().clear();
- scaDefns.getPolicySets().addAll(definedPolicySets.values());
+ scaDefns.getPolicySets().addAll(definedPolicySets);
scaDefns.getBindingTypes().clear();
- scaDefns.getBindingTypes().addAll(definedBindingTypes.values());
+ scaDefns.getBindingTypes().addAll(definedBindingTypes);
scaDefns.getImplementationTypes().clear();
- scaDefns.getImplementationTypes().addAll(definedImplTypes.values());
+ scaDefns.getImplementationTypes().addAll(definedImplTypes);
}
public void resolve(Definitions scaDefinitions, ModelResolver resolver) throws ContributionResolveException {
@@ -236,7 +223,7 @@ public class DefinitionsDocumentProcessor implements URLArtifactProcessor<Defini
}
public String getArtifactType() {
- return "definitions.xml";
+ return "META-INF/definitions.xml";
}
public Class<Definitions> getModelType() {
diff --git a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java b/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
index c65a9626ab..701d80711c 100644
--- a/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
+++ b/java/sca/modules/definitions-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
@@ -39,14 +39,13 @@ import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.definitions.DefinitionsFactory;
import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.definitions.DefinitionsFactory;
import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
/**
* Processor for SCA Definitions
@@ -59,17 +58,17 @@ public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements S
private DefinitionsFactory definitionsFactory;
private Monitor monitor;
+ public static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200712";
public static final String BINDING = "binding";
public static final String IMPLEMENTATION = "implementation";
- public static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
- public static final String SCA_DEFINITIONS = "definitions";
- public static final QName SCA_DEFINITIONS_QNAME = new QName(SCA10_NS, SCA_DEFINITIONS);
+ public static final String DEFINITIONS = "definitions";
+ public static final QName DEFINITIONS_QNAME = new QName(SCA11_NS, DEFINITIONS);
public static final String TARGET_NAMESPACE = "targetNamespace";
public static final String NAME = "name";
public DefinitionsProcessor(FactoryExtensionPoint factoryExtensionPoint,
- StAXArtifactProcessor<Object> extensionProcessor,
- Monitor monitor) {
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
this.extensionProcessor = extensionProcessor;
this.monitor = monitor;
this.definitionsFactory = factoryExtensionPoint.getFactory(DefinitionsFactory.class);
@@ -85,7 +84,7 @@ public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements S
switch (event) {
case START_ELEMENT: {
name = reader.getName();
- if (SCA_DEFINITIONS_QNAME.equals(name)) {
+ if (DEFINITIONS_QNAME.equals(name)) {
definitions = definitionsFactory.createDefinitions();
targetNamespace = reader.getAttributeValue(null, TARGET_NAMESPACE);
definitions.setTargetNamespace(targetNamespace);
@@ -95,17 +94,10 @@ public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements S
if (extension instanceof Intent) {
Intent intent = (Intent)extension;
intent.setName(new QName(targetNamespace, intent.getName().getLocalPart()));
- if (intent instanceof QualifiedIntent) {
- QualifiedIntent qualifiedIntent = (QualifiedIntent)intent;
- qualifiedIntent.getQualifiableIntent()
- .setName(new QName(targetNamespace, qualifiedIntent.getQualifiableIntent()
- .getName().getLocalPart()));
- }
-
- // FIXME: Workaround for TUSCANY-2499
- intent.setUnresolved(false);
-
definitions.getIntents().add(intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ i.setName(new QName(targetNamespace, i.getName().getLocalPart()));
+ }
} else if (extension instanceof PolicySet) {
PolicySet policySet = (PolicySet)extension;
policySet.setName(new QName(targetNamespace, policySet.getName().getLocalPart()));
@@ -113,13 +105,10 @@ public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements S
} else if (extension instanceof Binding) {
Binding binding = (Binding)extension;
definitions.getBindings().add(binding);
- } else if (extension instanceof IntentAttachPointType) {
- IntentAttachPointType type = (IntentAttachPointType)extension;
- if (type.getName().getLocalPart().startsWith(BINDING)) {
- definitions.getBindingTypes().add((IntentAttachPointType)extension);
- } else if (type.getName().getLocalPart().startsWith(IMPLEMENTATION)) {
- definitions.getImplementationTypes().add((IntentAttachPointType)extension);
- }
+ } else if (extension instanceof BindingType) {
+ definitions.getBindingTypes().add((BindingType)extension);
+ } else if (extension instanceof ImplementationType) {
+ definitions.getImplementationTypes().add((ImplementationType)extension);
}
}
break;
@@ -131,7 +120,7 @@ public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements S
case END_ELEMENT:
name = reader.getName();
- if (SCA_DEFINITIONS_QNAME.equals(name)) {
+ if (DEFINITIONS_QNAME.equals(name)) {
return definitions;
}
break;
@@ -148,8 +137,7 @@ public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements S
public void write(Definitions definitions, XMLStreamWriter writer) throws ContributionWriteException,
XMLStreamException {
- writeStartDocument(writer, SCA10_NS, SCA_DEFINITIONS, new XAttr(TARGET_NAMESPACE, definitions
- .getTargetNamespace()));
+ writeStartDocument(writer, SCA11_NS, DEFINITIONS, new XAttr(TARGET_NAMESPACE, definitions.getTargetNamespace()));
for (Intent policyIntent : definitions.getIntents()) {
extensionProcessor.write(policyIntent, writer);
@@ -159,11 +147,11 @@ public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements S
extensionProcessor.write(policySet, writer);
}
- for (IntentAttachPointType bindingType : definitions.getBindingTypes()) {
+ for (BindingType bindingType : definitions.getBindingTypes()) {
extensionProcessor.write(bindingType, writer);
}
- for (IntentAttachPointType implType : definitions.getImplementationTypes()) {
+ for (ImplementationType implType : definitions.getImplementationTypes()) {
extensionProcessor.write(implType, writer);
}
@@ -175,71 +163,60 @@ public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements S
// are many cross artifact references in a definitions file and we don't want
// to be dependent on the order things appear
- List<Intent> simpleIntents = new ArrayList<Intent>();
- List<ProfileIntent> profileIntents = new ArrayList<ProfileIntent>();
- List<QualifiedIntent> qualifiedIntents = new ArrayList<QualifiedIntent>();
- List<PolicySet> simplePolicySets = new ArrayList<PolicySet>();
+ List<Intent> intents = new ArrayList<Intent>();
+ List<PolicySet> policySets = new ArrayList<PolicySet>();
List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
- for (Intent policyIntent : scaDefns.getIntents()) {
- if (policyIntent instanceof ProfileIntent)
- profileIntents.add((ProfileIntent)policyIntent);
- else if (policyIntent instanceof QualifiedIntent)
- qualifiedIntents.add((QualifiedIntent)policyIntent);
- else
- simpleIntents.add(policyIntent);
-
- resolver.addModel(policyIntent);
+ for (Intent intent : scaDefns.getIntents()) {
+ intents.add(intent);
+ resolver.addModel(intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ intents.add(i);
+ resolver.addModel(i);
+ }
}
for (PolicySet policySet : scaDefns.getPolicySets()) {
- if (policySet.getReferencedPolicySets().isEmpty())
- simplePolicySets.add(policySet);
- else
+ if (policySet.getReferencedPolicySets().isEmpty()) {
+ policySets.add(policySet);
+ } else {
referredPolicySets.add(policySet);
+ }
resolver.addModel(policySet);
}
- for (IntentAttachPointType bindingType : scaDefns.getBindingTypes()) {
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
resolver.addModel(bindingType);
}
- for (IntentAttachPointType implType : scaDefns.getImplementationTypes()) {
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
resolver.addModel(implType);
}
// now resolve everything to ensure that any references between
// artifacts are satisfied
- for (Intent policyIntent : simpleIntents)
- extensionProcessor.resolve(policyIntent, resolver);
-
- for (ProfileIntent policyIntent : profileIntents)
- extensionProcessor.resolve(policyIntent, resolver);
-
- for (QualifiedIntent policyIntent : qualifiedIntents)
+ for (Intent policyIntent : intents)
extensionProcessor.resolve(policyIntent, resolver);
- for (PolicySet policySet : simplePolicySets)
+ for (PolicySet policySet : policySets)
extensionProcessor.resolve(policySet, resolver);
for (PolicySet policySet : referredPolicySets)
extensionProcessor.resolve(policySet, resolver);
- for (int count = 0, size = scaDefns.getBindingTypes().size(); count < size; count++) {
- IntentAttachPointType bindingType = scaDefns.getBindingTypes().get(count);
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
extensionProcessor.resolve(bindingType, resolver);
}
- for (int count = 0, size = scaDefns.getImplementationTypes().size(); count < size; count++) {
- IntentAttachPointType implType = scaDefns.getImplementationTypes().get(count);
- extensionProcessor.resolve(implType, resolver);
+ for (ImplementationType implementationType : scaDefns.getImplementationTypes()) {
+ extensionProcessor.resolve(implementationType, resolver);
}
}
public QName getArtifactType() {
- return SCA_DEFINITIONS_QNAME;
+ return DEFINITIONS_QNAME;
}
public Class<Definitions> getModelType() {
diff --git a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
index fa33150e87..7768f11565 100644
--- a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ b/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -16,4 +16,4 @@
# under the License.
# Implementation class for the artifact processor extension
-org.apache.tuscany.sca.definitions.xml.DefinitionsProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#definitions,model=org.apache.tuscany.sca.definitions.Definitions
+org.apache.tuscany.sca.definitions.xml.DefinitionsProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200712#definitions,model=org.apache.tuscany.sca.definitions.Definitions
diff --git a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
index 677aff9918..78cba6e6ab 100644
--- a/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
+++ b/java/sca/modules/definitions-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
@@ -16,4 +16,4 @@
# under the License.
# Implementation class for the artifact processor extension
-org.apache.tuscany.sca.definitions.xml.DefinitionsDocumentProcessor;type=definitions.xml,model=org.apache.tuscany.sca.definitions.Definitions
+org.apache.tuscany.sca.definitions.xml.DefinitionsDocumentProcessor;type=META-INF/definitions.xml,model=org.apache.tuscany.sca.definitions.Definitions
diff --git a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/ReadDocumentTestCase.java b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/ReadDocumentTestCase.java
index 2614bbacb4..69dedd2076 100644
--- a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/ReadDocumentTestCase.java
+++ b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/ReadDocumentTestCase.java
@@ -38,11 +38,12 @@ import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensi
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.IntentMap;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
+import org.apache.tuscany.sca.policy.Qualifier;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -57,16 +58,16 @@ public class ReadDocumentTestCase {
private static Definitions definitions;
private static Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
private static Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
- private static Map<QName, IntentAttachPointType> bindingTypesTable = new Hashtable<QName, IntentAttachPointType>();
- private static Map<QName, IntentAttachPointType> implTypesTable = new Hashtable<QName, IntentAttachPointType>();
- public static final String scaNamespace = "http://www.osoa.org/xmlns/sca/1.0";
+ private static Map<QName, BindingType> bindingTypesTable = new Hashtable<QName, BindingType>();
+ private static Map<QName, ImplementationType> implTypesTable = new Hashtable<QName, ImplementationType>();
+ public static final String scaNamespace = "http://docs.oasis-open.org/ns/opencsa/sca/200712";
public static final String namespace = "http://test";
-
+
private static final QName secureWsPolicy = new QName(namespace, "SecureWSPolicy");
private static final QName confidentiality = new QName(namespace, "confidentiality");
private static final QName integrity = new QName(namespace, "integrity");
private static final QName messageProtection = new QName(namespace, "messageProtection");
- private static final QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ private static final QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
private static final QName confidentiality_message = new QName(namespace, "confidentiality.message");
private static final QName secureReliablePolicy = new QName(namespace, "SecureReliablePolicy");
private static final QName secureMessagingPolicies = new QName(namespace, "SecureMessagingPolicies");
@@ -74,125 +75,152 @@ public class ReadDocumentTestCase {
private static final QName basicAuthMsgProtSecurity = new QName(namespace, "BasicAuthMsgProtSecurity");
private static final QName wsBinding = new QName(scaNamespace, "binding.ws");
private static final QName javaImpl = new QName(scaNamespace, "implementation.java");
-
@BeforeClass
public static void setUp() throws Exception {
DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
-
+
// Create StAX processors
- StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
-
- URLArtifactProcessorExtensionPoint documentProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
- policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
-
+
+ URLArtifactProcessorExtensionPoint documentProcessors =
+ extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
+ policyDefinitionsProcessor = documentProcessors.getProcessor(Definitions.class);
+
URL url = ReadDocumentTestCase.class.getResource("test_definitions.xml");
URI uri = URI.create("test_definitions.xml");
definitions = policyDefinitionsProcessor.read(null, uri, url);
-
- for ( Intent intent : definitions.getIntents() ) {
+
+ for (Intent intent : definitions.getIntents()) {
intentTable.put(intent.getName(), intent);
+ for (Intent i : intent.getQualifiedIntents()) {
+ intentTable.put(i.getName(), i);
+ }
}
-
- for ( PolicySet policySet : definitions.getPolicySets() ) {
+
+ for (PolicySet policySet : definitions.getPolicySets()) {
policySetTable.put(policySet.getName(), policySet);
}
-
- for ( IntentAttachPointType bindingType : definitions.getBindingTypes() ) {
- bindingTypesTable.put(bindingType.getName(), bindingType);
+
+ for (BindingType bindingType : definitions.getBindingTypes()) {
+ bindingTypesTable.put(bindingType.getType(), bindingType);
}
-
- for ( IntentAttachPointType implType : definitions.getImplementationTypes() ) {
- implTypesTable.put(implType.getName(), implType);
+
+ for (ImplementationType implType : definitions.getImplementationTypes()) {
+ implTypesTable.put(implType.getType(), implType);
}
}
@Test
public void testReadSCADefinitions() throws Exception {
assertNotNull(definitions);
-
+
assertNotNull(intentTable.get(confidentiality));
assertNotNull(intentTable.get(messageProtection));
assertNotNull(intentTable.get(confidentiality_transport));
- assertTrue(intentTable.get(confidentiality).getDescription().length() > 0 );
-
+ assertTrue(intentTable.get(confidentiality).getDescription().length() > 0);
+
assertNotNull(policySetTable.get(secureReliablePolicy));
assertTrue(policySetTable.get(secureReliablePolicy).getProvidedIntents().size() == 2);
assertTrue(policySetTable.get(secureReliablePolicy).getPolicies().size() == 2);
-
+
assertNotNull(policySetTable.get(secureMessagingPolicies));
- assertEquals(policySetTable.get(secureMessagingPolicies).getMappedPolicies().size(), 3);
+ assertEquals(2, policySetTable.get(secureMessagingPolicies).getIntentMaps().get(0).getQualifiers().size());
//assertTrue(policySetTable.get(secureWsPolicy).getPolicies().get(0) instanceof org.apache.neethi.Policy);
-
+
assertEquals(bindingTypesTable.size(), 1);
assertNotNull(bindingTypesTable.get(wsBinding));
assertEquals(implTypesTable.size(), 1);
assertNotNull(implTypesTable.get(javaImpl));
}
+
+ private boolean isRealizedBy(PolicySet policySet, Intent intent) {
+ if (intent.getName().getLocalPart().indexOf('.') == -1) {
+ return policySet.getProvidedIntents().contains(intent);
+ }
+ for (IntentMap map : policySet.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (q.getIntent().equals(intent)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ private int getNumberOfQualifiedPolicies(PolicySet policySet) {
+ int count = 0;
+ for(IntentMap intentMap: policySet.getIntentMaps()) {
+ for(Qualifier q: intentMap.getQualifiers()) {
+ count += q.getPolicies().size();
+ }
+ }
+ return count;
+ }
+
@Test
public void testResolveSCADefinitions() throws Exception {
- assertTrue(intentTable.get(messageProtection) instanceof ProfileIntent);
- ProfileIntent profileIntent = (ProfileIntent)intentTable.get(new QName(namespace, "messageProtection"));
- assertNull(profileIntent.getRequiredIntents().get(0).getDescription());
-
- QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
- assertTrue(intentTable.get(confidentiality_transport) instanceof QualifiedIntent);
- QualifiedIntent qualifiedIntent = (QualifiedIntent)intentTable.get(new QName(namespace, "confidentiality.transport"));
- assertNull(qualifiedIntent.getQualifiableIntent().getDescription());
-
+ Intent i1 = intentTable.get(messageProtection);
+ assertTrue(!i1.getRequiredIntents().isEmpty());
+ assertNull(i1.getRequiredIntents().get(0).getDescription());
+
+ QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ Intent i2 = intentTable.get(confidentiality_transport);
+ assertNotNull(i2.getParent());
+
PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
PolicySet securityPolicySet = policySetTable.get(securityPolicy);
-
+
assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
assertNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
assertTrue(secureMessagingPolicySet.isUnresolved());
- assertEquals(securityPolicySet.getMappedPolicies().size(), 5);
-
+ assertEquals(3, getNumberOfQualifiedPolicies(securityPolicySet));
+
//testing to ensure that inclusion of referred policy sets has not happened
PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
- assertTrue(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
-
- IntentAttachPointType wsBindingType = bindingTypesTable.get(wsBinding);
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+
+ BindingType wsBindingType = bindingTypesTable.get(wsBinding);
assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
- assertNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
-
- IntentAttachPointType javaImplType = implTypesTable.get(javaImpl);
+ assertNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
+ ImplementationType javaImplType = implTypesTable.get(javaImpl);
assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
- assertNull(javaImplType.getMayProvideIntents().get(0).getDescription());
-
+ assertNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+
ModelResolver resolver = new DefaultModelResolver();
policyDefinitionsProcessor.resolve(definitions, resolver);
//builder.build(scaDefinitions);
-
+
//testing if policy intents have been linked have property been linked up
- assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());
- assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
+ assertNotNull(i1.getRequiredIntents().get(0).getDescription());
+ // assertNotNull(i2.getQualifiableIntent().getDescription());
assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
-
+
//testing if policysets have been properly linked up with intents
assertFalse(secureMessagingPolicySet.isUnresolved());
- assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
- assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
-
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality_transport)));
+
//testing if intent maps have been properly mapped to policies
assertFalse(securityPolicySet.isUnresolved());
- assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
- assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_message)));
-
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality_message)));
+
//testing for inclusion of referred policysets
assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
- assertFalse(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
- assertNotNull(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
-
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getIntentMaps().get(0).getQualifiers().isEmpty());
+ assertTrue(isRealizedBy(basicAuthMsgProtSecurityPolicySet, intentTable.get(confidentiality_transport)));
+
assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
- assertNotNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
-
+ assertNotNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
+
assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
- assertNotNull(javaImplType.getMayProvideIntents().get(0).getDescription());
+ assertNotNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
}
}
diff --git a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/TestPolicyProcessor.java b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/TestPolicyProcessor.java
index 3ff8f294f8..270aed0f90 100644
--- a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/TestPolicyProcessor.java
+++ b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/TestPolicyProcessor.java
@@ -28,7 +28,6 @@ import org.apache.tuscany.sca.contribution.processor.ContributionResolveExceptio
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.policy.Policy;
/**
* A PolicyProcessor used for testing.
diff --git a/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml b/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml
index f60047e769..216cb29b0a 100644
--- a/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml
+++ b/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml
@@ -17,239 +17,190 @@
* specific language governing permissions and limitations
* under the License.
-->
-<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
- targetNamespace="http://test"
- xmlns:test="http://test"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
-
-<!-- Extension Types Metadata -->
-<implementationType type="sca:implementation.java" alwaysProvides="test:logging"
- mayProvide="test:tracing"/>
-<bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality"
- mayProvide="test:integrity"/>
-
-<!-- Intents and Policysets to assume targetnamespace -->
-<intent name="TestIntentOne"
- constrains="sca:binding">
- <description>
- Test Intent
- </description>
- </intent>
-
- <intent name="TestIntentTwo"
- constrains="sca:binding"
- requires="test:TestIntentOne">
- <description>
- Protect messages from unauthorized reading or modification
- </description>
- </intent>
-
- <policySet name="TestPolicySetOne"
- provides="test:TestIntentOne"
- appliesTo="sca:binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "basic authentication" -->
- </wsp:PolicyAttachment>
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "reliability" -->
- </wsp:PolicyAttachment>
- </policySet>
-
-
- <!-- qualified intents -->
- <intent name="confidentiality.transport" />
- <intent name="confidentiality.message" />
- <intent name="confidentiality.message.whole" />
- <intent name="confidentiality.message.body" />
-
- <!-- POLICY SETS -->
- <policySet name="SecureReliablePolicy"
- provides="test:confidentiality.transport test:integrity"
- appliesTo="sca:binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "basic authentication" -->
- </wsp:PolicyAttachment>
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "reliability" -->
- </wsp:PolicyAttachment>
- </policySet>
-
- <policySet name="SecureMessagingPolicies"
- provides="test:confidentiality"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <intentMap provides="test:confidentiality" default="transport">
- <qualifier name="transport">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "transport" alternative -->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
</wsp:PolicyAttachment>
- <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
- </qualifier>
- <qualifier name="message">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "message" alternative" -->
- </wsp:PolicyAttachment>
- </qualifier>
- </intentMap>
-</policySet>
-
-<policySet name="SecurityPolicy"
- provides="test:confidentiality"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" >
- <intentMap provides="test:confidentiality" default="message">
- <qualifier name="message">
- <intentMap provides="message" default="whole">
- <qualifier name="body">
- <wsp:PolicyAttachment>
- <!-- policy attachment for body encryption -->
- </wsp:PolicyAttachment>
- </qualifier>
- <qualifier name="whole">
- <wsp:PolicyAttachment>
- <!-- policy attachment for whole message encryption -->
- </wsp:PolicyAttachment>
- </qualifier>
- </intentMap>
- </qualifier>
- <qualifier name="transport">
- <wsp:PolicyAttachment>
- <!-- policy attachment for transport encryption -->
- </wsp:PolicyAttachment>
- </qualifier>
- </intentMap>
-</policySet>
-
-<policySet name="BasicAuthMsgProtSecurity"
- provides="test:authentication test:confidentiality"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0">
- <policySetReference name="test:AuthenticationPolicies"/>
- <policySetReference name="test:ConfidentialityPolicies"/>
-</policySet>
-
-<policySet name="AuthenticationPolicies"
- provides="test:authentication"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "basic
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="message">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for whole message encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
authentication" -->
- </wsp:PolicyAttachment>
-</policySet>
-
-<policySet name="ConfidentialityPolicies"
- provides="test:confidentiality"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <intentMap provides="test:confidentiality" default="transport">
- <qualifier name="transport">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "transport"
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
alternative -->
- </wsp:PolicyAttachment>
- <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
- </qualifier>
- <qualifier name="message">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "message"
- alternative" -->...
- </wsp:PolicyAttachment>
- </qualifier>
- </intentMap>
-</policySet>
-
-<policySet name="SecureWSPolicy"
- provides="test:confidentiality"
- appliesTo="sca:binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:Policy>
- <wsp:ExactlyOne>
- <wsp:All>
- <sp:SecurityToken>
- <sp:TokenType>sp:X509v3</sp:TokenType>
- </sp:SecurityToken>
- <sp:UsernameToken />
- <sp:SignedParts />
- <sp:EncryptedParts>
- <sp:Body />
- </sp:EncryptedParts>
- <sp:TransportBinding>
- <sp:IncludeTimeStamp />
- </sp:TransportBinding>
- </wsp:All>
- </wsp:ExactlyOne>
- </wsp:Policy>
- </policySet>
-
-<!-- profile intent -->
- <intent name="reliableMessageProtection"
- constrains="sca:binding"
- requires="test:messageProtection">
- <description>
- Protect messages from unauthorized reading or modification
- </description>
- </intent>
-
- <intent name="messageProtection"
- constrains="sca:binding"
- requires="test:confidentiality test:integrity">
- <description>
- Protect messages from unauthorized reading or modification
- </description>
- </intent>
-
-<!-- simple intent -->
- <intent name="confidentiality"
- constrains="sca:binding">
- <description>
- Communitcation thro this binding must prevent
- unauthorized users from reading the messages.
- </description>
- </intent>
-
- <intent name="integrity"
- constrains="sca:binding">
- <description>
- Communitcation thro this binding must prevent
- unauthorized modification of the messages.
- </description>
- </intent>
-
- <intent name="authentication"
- constrains="sca:binding">
- <description>
- Communitcation thro this binding required
- Authentication.
- </description>
- </intent>
-
- <intent name="logging"
- constrains="sca:implementation">
- <description>
- All messages to and from this implementation must be logged
- </description>
- </intent>
-
- <intent name="tracing"
- constrains="sca:implementation.java">
- <description>
- Need to figure out some description for this
- </description>
- </intent>
-
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
</definitions> \ No newline at end of file
diff --git a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
index d3373215a2..812ed9fa02 100644
--- a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
+++ b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
@@ -20,8 +20,9 @@ package org.apache.tuscany.sca.definitions;
import java.util.List;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -63,7 +64,7 @@ public interface Definitions {
*
* @return a list of domain wide Binding Types
*/
- List<IntentAttachPointType> getBindingTypes();
+ List<BindingType> getBindingTypes();
/**
@@ -71,7 +72,7 @@ public interface Definitions {
*
* @return a list of domain wide Implementation Types
*/
- List<IntentAttachPointType> getImplementationTypes();
+ List<ImplementationType> getImplementationTypes();
/**
* Returns a list of domain wide binding definition objects
diff --git a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java
index e75cd40adc..3ef7a2f4ae 100644
--- a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java
+++ b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java
@@ -20,7 +20,6 @@ package org.apache.tuscany.sca.definitions.impl;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
@@ -29,11 +28,13 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.definitions.DefinitionsBuilder;
import org.apache.tuscany.sca.definitions.DefinitionsBuilderException;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.IntentMap;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
+import org.apache.tuscany.sca.policy.Qualifier;
/**
* Provides a concrete implementation for a SCADefinitionsBuilder
@@ -52,64 +53,63 @@ public class DefinitionsBuilderImpl implements DefinitionsBuilder {
for (PolicySet policySet : scaDefns.getPolicySets()) {
definedPolicySets.put(policySet.getName(), policySet);
}
-
- Map<QName, IntentAttachPointType> definedBindingTypes = new HashMap<QName, IntentAttachPointType>();
- for (IntentAttachPointType bindingType : scaDefns.getBindingTypes()) {
- definedBindingTypes.put(bindingType.getName(), bindingType);
+
+ Map<QName, BindingType> definedBindingTypes = new HashMap<QName, BindingType>();
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ definedBindingTypes.put(bindingType.getType(), bindingType);
}
-
- Map<QName, IntentAttachPointType> definedImplTypes = new HashMap<QName, IntentAttachPointType>();
- for (IntentAttachPointType implType : scaDefns.getImplementationTypes()) {
- definedImplTypes.put(implType.getName(), implType);
+
+ Map<QName, ImplementationType> definedImplTypes = new HashMap<QName, ImplementationType>();
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
+ definedImplTypes.put(implType.getType(), implType);
}
-
+
//filling up the maps removes all duplicate entries... so fill this unique lists
//into the scaDefns.
scaDefns.getIntents().clear();
scaDefns.getPolicySets().clear();
scaDefns.getBindingTypes().clear();
scaDefns.getImplementationTypes().clear();
-
+
scaDefns.getIntents().addAll(definedIntents.values());
scaDefns.getPolicySets().addAll(definedPolicySets.values());
scaDefns.getBindingTypes().addAll(definedBindingTypes.values());
scaDefns.getImplementationTypes().addAll(definedImplTypes.values());
-
+
buildPolicyIntents(scaDefns, definedIntents);
buildPolicySets(scaDefns, definedPolicySets, definedIntents);
buildBindingTypes(scaDefns, definedBindingTypes, definedIntents);
buildImplementationTypes(scaDefns, definedImplTypes, definedIntents);
}
-
- private void buildBindingTypes(Definitions scaDefns,
- Map<QName, IntentAttachPointType> definedBindingTypes,
+
+ private void buildBindingTypes(Definitions scaDefns,
+ Map<QName, BindingType> definedBindingTypes,
Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
- for (IntentAttachPointType bindingType : scaDefns.getBindingTypes()) {
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
buildAlwaysProvidedIntents(bindingType, definedIntents);
buildMayProvideIntents(bindingType, definedIntents);
}
}
-
- private void buildImplementationTypes(Definitions scaDefns,
- Map<QName, IntentAttachPointType> definedImplTypes,
- Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
- for (IntentAttachPointType implType : scaDefns.getImplementationTypes()) {
+
+ private void buildImplementationTypes(Definitions scaDefns,
+ Map<QName, ImplementationType> definedImplTypes,
+ Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
buildAlwaysProvidedIntents(implType, definedIntents);
buildMayProvideIntents(implType, definedIntents);
}
}
-
private void buildPolicyIntents(Definitions scaDefns, Map<QName, Intent> definedIntents)
throws DefinitionsBuilderException {
for (Intent policyIntent : scaDefns.getIntents()) {
- if (policyIntent instanceof ProfileIntent) {
- buildProfileIntent((ProfileIntent)policyIntent, definedIntents);
+ if (!policyIntent.getRequiredIntents().isEmpty()) {
+ buildProfileIntent(policyIntent, definedIntents);
}
- if (policyIntent instanceof QualifiedIntent) {
- buildQualifiedIntent((QualifiedIntent)policyIntent, definedIntents);
+ if (!policyIntent.getQualifiedIntents().isEmpty()) {
+ buildQualifiedIntent(policyIntent, definedIntents);
}
}
}
@@ -130,8 +130,8 @@ public class DefinitionsBuilderImpl implements DefinitionsBuilder {
}
}
}
-
- private void buildProfileIntent(ProfileIntent policyIntent, Map<QName, Intent> definedIntents)
+
+ private void buildProfileIntent(Intent policyIntent, Map<QName, Intent> definedIntents)
throws DefinitionsBuilderException {
//FIXME: Need to check for cyclic references first i.e an A requiring B and then B requiring A...
if (policyIntent != null) {
@@ -157,8 +157,9 @@ public class DefinitionsBuilderImpl implements DefinitionsBuilder {
}
}
- private void buildQualifiedIntent(QualifiedIntent policyIntent, Map<QName, Intent> definedIntents)
+ private void buildQualifiedIntent(Intent policyIntent, Map<QName, Intent> definedIntents)
throws DefinitionsBuilderException {
+ /*
if (policyIntent != null) {
//resolve the qualifiable intent
Intent qualifiableIntent = policyIntent.getQualifiableIntent();
@@ -175,11 +176,11 @@ public class DefinitionsBuilderImpl implements DefinitionsBuilder {
}
}
+ */
}
-
-
- private void buildAlwaysProvidedIntents(IntentAttachPointType extensionType,
- Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
+
+ private void buildAlwaysProvidedIntents(ExtensionType extensionType, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
if (extensionType != null) {
// resolve all provided intents
List<Intent> alwaysProvided = new ArrayList<Intent>();
@@ -189,10 +190,9 @@ public class DefinitionsBuilderImpl implements DefinitionsBuilder {
if (resolvedProvidedIntent != null) {
alwaysProvided.add(resolvedProvidedIntent);
} else {
- throw new DefinitionsBuilderException(
- "Always Provided Intent - " + providedIntent
- + " not found for ExtensionType "
- + extensionType);
+ throw new DefinitionsBuilderException("Always Provided Intent - " + providedIntent
+ + " not found for ExtensionType "
+ + extensionType);
}
} else {
@@ -203,30 +203,29 @@ public class DefinitionsBuilderImpl implements DefinitionsBuilder {
extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
}
}
-
- private void buildMayProvideIntents(IntentAttachPointType extensionType,
- Map<QName, Intent> definedIntents) throws DefinitionsBuilderException {
+
+ private void buildMayProvideIntents(ExtensionType extensionType, Map<QName, Intent> definedIntents)
+ throws DefinitionsBuilderException {
if (extensionType != null) {
// resolve all provided intents
List<Intent> mayProvide = new ArrayList<Intent>();
- for (Intent providedIntent : extensionType.getMayProvideIntents()) {
+ for (Intent providedIntent : extensionType.getMayProvidedIntents()) {
if (providedIntent.isUnresolved()) {
Intent resolvedProvidedIntent = definedIntents.get(providedIntent.getName());
if (resolvedProvidedIntent != null) {
mayProvide.add(resolvedProvidedIntent);
} else {
- throw new DefinitionsBuilderException(
- "May Provide Intent - " + providedIntent
- + " not found for ExtensionType "
- + extensionType);
+ throw new DefinitionsBuilderException("May Provide Intent - " + providedIntent
+ + " not found for ExtensionType "
+ + extensionType);
}
} else {
mayProvide.add(providedIntent);
}
}
- extensionType.getMayProvideIntents().clear();
- extensionType.getMayProvideIntents().addAll(mayProvide);
+ extensionType.getMayProvidedIntents().clear();
+ extensionType.getMayProvidedIntents().addAll(mayProvide);
}
}
@@ -257,27 +256,23 @@ public class DefinitionsBuilderImpl implements DefinitionsBuilder {
private void buildIntentsInMappedPolicies(PolicySet policySet, Map<QName, Intent> definedIntents)
throws DefinitionsBuilderException {
- Map<Intent, List<Object>> mappedPolicies = new Hashtable<Intent, List<Object>>();
- for (Map.Entry<Intent, List<Object>> entry : policySet.getMappedPolicies().entrySet()) {
- Intent mappedIntent = entry.getKey();
- if (mappedIntent.isUnresolved()) {
- Intent resolvedMappedIntent = definedIntents.get(mappedIntent.getName());
-
- if (resolvedMappedIntent != null) {
- mappedPolicies.put(resolvedMappedIntent, entry.getValue());
- } else {
- throw new DefinitionsBuilderException("Mapped Intent - " + mappedIntent
- + " not found for PolicySet "
- + policySet);
+ for (IntentMap intentMap : policySet.getIntentMaps()) {
+ for (Qualifier qualifier : intentMap.getQualifiers()) {
+ Intent mappedIntent = qualifier.getIntent();
+ if (mappedIntent.isUnresolved()) {
+ Intent resolvedMappedIntent = definedIntents.get(mappedIntent.getName());
+ if (resolvedMappedIntent != null) {
+ qualifier.setIntent(resolvedMappedIntent);
+ } else {
+ throw new DefinitionsBuilderException("Mapped Intent - " + mappedIntent
+ + " not found for PolicySet "
+ + policySet);
+
+ }
}
- } else {
- mappedPolicies.put(mappedIntent, entry.getValue());
}
}
-
- policySet.getMappedPolicies().clear();
- policySet.getMappedPolicies().putAll(mappedPolicies);
}
private void buildReferredPolicySets(PolicySet policySet, Map<QName, PolicySet> definedPolicySets)
@@ -307,6 +302,6 @@ public class DefinitionsBuilderImpl implements DefinitionsBuilder {
includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet);
}
policySet.getPolicies().addAll(referredPolicySet.getPolicies());
- policySet.getMappedPolicies().putAll(referredPolicySet.getMappedPolicies());
+ policySet.getIntentMaps().addAll(referredPolicySet.getIntentMaps());
}
}
diff --git a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
index fdce0060f9..31cb68b9a9 100644
--- a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
+++ b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
@@ -23,8 +23,9 @@ import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.tuscany.sca.definitions.Definitions;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -36,16 +37,16 @@ public class DefinitionsImpl implements Definitions {
private String targetNamespace = null;
private List<Intent> intents = new CopyOnWriteArrayList<Intent>();
private List<PolicySet> policySets = new CopyOnWriteArrayList<PolicySet>();
- private List<IntentAttachPointType> bindingTypes = new CopyOnWriteArrayList<IntentAttachPointType>();
- private List<IntentAttachPointType> implementationTypes = new CopyOnWriteArrayList<IntentAttachPointType>();
+ private List<BindingType> bindingTypes = new CopyOnWriteArrayList<BindingType>();
+ private List<ImplementationType> implementationTypes = new CopyOnWriteArrayList<ImplementationType>();
private List<Object> bindings = new CopyOnWriteArrayList<Object>();
- public List<IntentAttachPointType> getBindingTypes() {
+ public List<BindingType> getBindingTypes() {
return bindingTypes;
}
- public List<IntentAttachPointType> getImplementationTypes() {
+ public List<ImplementationType> getImplementationTypes() {
return implementationTypes;
}
diff --git a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
index cd408125d2..0ff2f81a9a 100644
--- a/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
+++ b/java/sca/modules/definitions/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
@@ -28,8 +28,6 @@ import org.apache.tuscany.sca.definitions.Definitions;
*/
public class DefinitionsUtil {
-
-
public static void aggregate(Definitions source, Definitions target) {
target.getIntents().addAll(source.getIntents());
target.getPolicySets().addAll(source.getPolicySets());
diff --git a/java/sca/modules/endpoint/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml b/java/sca/modules/endpoint/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
index 8bac9e01c9..f3c5cd0aa1 100644
--- a/java/sca/modules/endpoint/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
+++ b/java/sca/modules/endpoint/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
@@ -17,9 +17,9 @@
* specific language governing permissions and limitations
* under the License.
-->
-<sca:definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
- targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
<sca:bindingType type="sca:binding.sca" mayProvide="" alwaysProvides=""/>
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
index d84f28f11e..f5aced9b50 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
@@ -58,7 +58,7 @@ public class DefaultModuleActivatorExtensionPoint implements ModuleActivatorExte
/**
* Dynamically load module activators declared under META-INF/services
*/
- private void loadModuleActivators() {
+ private synchronized void loadModuleActivators() {
if (loadedActivators)
return;
diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
index e5deab4b9e..0b560e8c88 100644
--- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
+++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
@@ -20,7 +20,6 @@
package org.apache.tuscany.sca.implementation.java.invocation;
import java.lang.reflect.Method;
-import java.util.List;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.context.ComponentContextFactory;
@@ -42,7 +41,6 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.oasisopen.sca.ComponentContext;
@@ -62,12 +60,10 @@ public class JavaImplementationProvider implements ScopedImplementationProvider
DataBindingExtensionPoint dataBindingRegistry,
JavaPropertyValueObjectFactory propertyValueObjectFactory,
ComponentContextFactory componentContextFactory,
- RequestContextFactory requestContextFactory,
- List<PolicyHandlerTuple> policyHandlerClassNames) {
+ RequestContextFactory requestContextFactory) {
super();
this.implementation = implementation;
this.requestContextFactory = requestContextFactory;
- this.implementation.setPolicyHandlerClassNames(policyHandlerClassNames);
try {
JavaInstanceFactoryProvider configuration = new JavaInstanceFactoryProvider(implementation);
diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
index 9b78439012..77e0e44065 100644
--- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
+++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
@@ -19,15 +19,12 @@
package org.apache.tuscany.sca.implementation.java.invocation;
-import java.util.List;
-
import org.apache.tuscany.sca.context.ComponentContextFactory;
import org.apache.tuscany.sca.context.RequestContextFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.provider.ImplementationProvider;
import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -41,21 +38,18 @@ public class JavaImplementationProviderFactory implements ImplementationProvider
private ProxyFactory proxyService;
private ComponentContextFactory componentContextFactory;
private RequestContextFactory requestContextFactory;
- private List<PolicyHandlerTuple> policyHandlerClassNames = null;
public JavaImplementationProviderFactory(ProxyFactory proxyService,
DataBindingExtensionPoint dataBindingRegistry,
JavaPropertyValueObjectFactory propertyValueObjectFactory,
ComponentContextFactory componentContextFactory,
- RequestContextFactory requestContextFactory,
- List<PolicyHandlerTuple> policyHandlerClassNames) {
+ RequestContextFactory requestContextFactory) {
super();
this.proxyService = proxyService;
this.dataBindingRegistry = dataBindingRegistry;
this.propertyValueObjectFactory = propertyValueObjectFactory;
this.componentContextFactory = componentContextFactory;
this.requestContextFactory = requestContextFactory;
- this.policyHandlerClassNames = policyHandlerClassNames;
}
public ImplementationProvider createImplementationProvider(RuntimeComponent component,
@@ -66,8 +60,7 @@ public class JavaImplementationProviderFactory implements ImplementationProvider
dataBindingRegistry,
propertyValueObjectFactory,
componentContextFactory,
- requestContextFactory,
- policyHandlerClassNames);
+ requestContextFactory);
}
public Class<JavaImplementation> getModelType() {
diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PolicyHandlingInterceptor.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PolicyHandlingInterceptor.java
deleted file mode 100644
index 8c85b46c65..0000000000
--- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PolicyHandlingInterceptor.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.invocation;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.interfacedef.Operation;
-import org.apache.tuscany.sca.invocation.Interceptor;
-import org.apache.tuscany.sca.invocation.Invoker;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.policy.util.PolicyHandler;
-
-/**
- * An interceptor to invoke policy handlers before and after the invocation of operations on
- * an implementation.
- *
- * @version $Rev$ $Date$
- */
-public class PolicyHandlingInterceptor implements Interceptor {
- private Invoker next;
- private List<PolicyHandler> policyHandlers = null;
- private Operation targetOperation = null;
-
- public PolicyHandlingInterceptor(Operation targetOperation, List<PolicyHandler> policyHandlers) {
- this.policyHandlers = policyHandlers;
- this.targetOperation = targetOperation;
- }
-
- public Message invoke(Message msg) {
- try {
- applyPreInvocationPolicies(targetOperation, msg);
- msg = next.invoke(msg);
- } finally {
- applyPostInvocationPolices(targetOperation, msg);
- }
- return msg;
- }
-
- public void setNext(Invoker next) {
- this.next = next;
- }
-
- public Invoker getNext() {
- return next;
- }
-
- private void applyPreInvocationPolicies(Object... context) {
- for (PolicyHandler policyHandler : policyHandlers) {
- policyHandler.beforeInvoke(context);
- }
- }
-
- private void applyPostInvocationPolices(Object... context) {
- for ( int count = policyHandlers.size() - 1 ; count >= 0 ; --count) {
- policyHandlers.get(count).afterInvoke(context);
- }
- }
-}
diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
index 1ea3546adb..b3a3210285 100644
--- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
+++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.implementation.java.module;
-import java.util.List;
import java.util.logging.Logger;
import org.apache.tuscany.sca.context.ComponentContextFactory;
@@ -42,8 +41,6 @@ import org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationP
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerDefinitionsLoader;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
@@ -85,14 +82,11 @@ public class JavaRuntimeModuleActivator implements ModuleActivator {
ComponentContextFactory componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class);
RequestContextFactory requestContextFactory = contextFactories.getFactory(RequestContextFactory.class);
- List<PolicyHandlerTuple> policyHandlerClassNames = null;
- policyHandlerClassNames = PolicyHandlerDefinitionsLoader.loadPolicyHandlerClassnames();
-
ProxyFactory proxyFactory = new ExtensibleProxyFactory(proxyFactories);
JavaImplementationProviderFactory javaImplementationProviderFactory =
new JavaImplementationProviderFactory(proxyFactory, dataBindings, factory, componentContextFactory,
- requestContextFactory, policyHandlerClassNames);
+ requestContextFactory);
ProviderFactoryExtensionPoint providerFactories =
registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
diff --git a/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java b/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
index 143bb094a3..1745e10894 100644
--- a/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
+++ b/java/sca/modules/implementation-java-xml/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
@@ -20,11 +20,9 @@
package org.apache.tuscany.sca.implementation.java.xml;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
-import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.CLASS;
import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.IMPLEMENTATION_JAVA;
import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.IMPLEMENTATION_JAVA_QNAME;
-import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.OPERATION_QNAME;
import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.SCA10_NS;
import java.lang.reflect.Field;
@@ -40,13 +38,10 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.ComponentType;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.xml.ConfiguredOperationProcessor;
-import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
+import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
@@ -64,7 +59,6 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
import org.apache.tuscany.sca.policy.PolicyFactory;
/**
@@ -76,19 +70,17 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm
private JavaImplementationFactory javaFactory;
private AssemblyFactory assemblyFactory;
private PolicyFactory policyFactory;
- private PolicyAttachPointProcessor policyProcessor;
- private IntentAttachPointTypeFactory intentAttachPointTypeFactory;
- private ConfiguredOperationProcessor configuredOperationProcessor;
+ private PolicySubjectProcessor policyProcessor;
+ private PolicyFactory intentAttachPointTypeFactory;
private Monitor monitor;
public JavaImplementationProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.javaFactory = modelFactories.getFactory(JavaImplementationFactory.class);
- this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
- this.intentAttachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class);
this.monitor = monitor;
- this.configuredOperationProcessor = new ConfiguredOperationProcessor(modelFactories, this.monitor);
}
/**
@@ -124,11 +116,11 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm
// Read an <implementation.java>
JavaImplementation javaImplementation = javaFactory.createJavaImplementation();
- /*if ( javaImplementation instanceof PolicySetAttachPoint ) {
- IntentAttachPointType implType = intentAttachPointTypeFactory.createImplementationType();
+ /*if ( javaImplementation instanceof PolicySubject ) {
+ ExtensionType implType = intentAttachPointTypeFactory.createImplementationType();
implType.setName(getArtifactType());
implType.setUnresolved(true);
- ((PolicySetAttachPoint)javaImplementation).setType(implType);
+ ((PolicySubject)javaImplementation).setType(implType);
}*/
javaImplementation.setUnresolved(true);
@@ -139,21 +131,8 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm
// read operation elements if exists or skip unto end element
int event;
- ConfiguredOperation confOp = null;
while (reader.hasNext()) {
event = reader.next();
- switch ( event ) {
- case START_ELEMENT : {
- if ( OPERATION_QNAME.equals(reader.getName()) ) {
- confOp = configuredOperationProcessor.read(reader);
- if ( confOp != null ) {
- ((OperationsConfigurator)javaImplementation).getConfiguredOperations().add(confOp);
- }
- }
- }
- break;
- }
-
if (event == END_ELEMENT && IMPLEMENTATION_JAVA_QNAME.equals(reader.getName())) {
break;
}
diff --git a/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java b/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
index d0d5caaa3a..18435e205c 100644
--- a/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
+++ b/java/sca/modules/implementation-java-xml/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
@@ -32,7 +32,6 @@ import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
@@ -45,7 +44,7 @@ import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -106,15 +105,15 @@ public class ReadTestCase {
compositeBuilder.build(composite, null, null);
//intents are computed and aggregate intents from ancestor elements
- assertEquals(((PolicySetAttachPoint)composite.getComponents().get(0)).getRequiredIntents().size(), 3);
- assertEquals(((PolicySetAttachPoint)composite.getComponents().get(5)).getRequiredIntents().size(), 3);
+ assertEquals(((PolicySubject)composite.getComponents().get(0)).getRequiredIntents().size(), 3);
+ assertEquals(((PolicySubject)composite.getComponents().get(5)).getRequiredIntents().size(), 3);
//assertEquals(((OperationsConfigurator)composite.getComponents().get(0)).getConfiguredOperations().isEmpty(), true);
//assertEquals(((OperationsConfigurator)composite.getComponents().get(5)).getConfiguredOperations().isEmpty(), false);
//test for proper aggregation of policy intents on implementation elements
- for ( Intent intent : ((PolicySetAttachPoint)composite.getComponents().get(0).getImplementation()).getRequiredIntents() ) {
+ for ( Intent intent : ((PolicySubject)composite.getComponents().get(0).getImplementation()).getRequiredIntents() ) {
String intentName = intent.getName().getLocalPart();
if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_2") ||
intentName.equals("tuscanyIntent_3")) ) {
@@ -122,7 +121,7 @@ public class ReadTestCase {
}
}
- for ( Intent intent : ((PolicySetAttachPoint)composite.getComponents().get(5)).getRequiredIntents() ) {
+ for ( Intent intent : ((PolicySubject)composite.getComponents().get(5)).getRequiredIntents() ) {
String intentName = intent.getName().getLocalPart();
if ( !(intentName.equals("tuscanyIntent_1") || intentName.equals("tuscanyIntent_4") ||
intentName.equals("tuscanyIntent_5")) ) {
@@ -130,6 +129,7 @@ public class ReadTestCase {
}
}
+ /*
//test for proper aggregation of policy intents and policysets on operations of implementation
OperationsConfigurator opConf = (OperationsConfigurator)composite.getComponents().get(5);
assertEquals(opConf.getConfiguredOperations().get(0).getRequiredIntents().size(), 4);
@@ -150,6 +150,7 @@ public class ReadTestCase {
fail();
}
}
+ */
}
@Test
@@ -168,7 +169,7 @@ public class ReadTestCase {
for ( Component component : composite.getComponents() ) {
for ( PolicySet policySet : policyDefinitions.getPolicySets() ) {
- component.getApplicablePolicySets().add(policySet);
+ component.getPolicySets().add(policySet);
}
}
@@ -178,22 +179,23 @@ public class ReadTestCase {
compositeBuilder.build(composite, null, null);
//test for determination of policysets for implementation
- assertEquals(((PolicySetAttachPoint)composite.getComponents().get(0)).getPolicySets().size(), 1);
- for ( PolicySet policySet : ((PolicySetAttachPoint)composite.getComponents().get(0).getImplementation()).getPolicySets() ) {
+ assertEquals(((PolicySubject)composite.getComponents().get(0)).getPolicySets().size(), 1);
+ for ( PolicySet policySet : ((PolicySubject)composite.getComponents().get(0).getImplementation()).getPolicySets() ) {
String policySetName = policySet.getName().getLocalPart();
if ( !(policySetName.equals("tuscanyPolicySet_1")) ) {
fail();
}
}
- assertEquals(((PolicySetAttachPoint)composite.getComponents().get(5)).getPolicySets().size(), 2);
- for ( PolicySet policySet : ((PolicySetAttachPoint)composite.getComponents().get(5).getImplementation()).getPolicySets() ) {
+ assertEquals(((PolicySubject)composite.getComponents().get(5)).getPolicySets().size(), 2);
+ for ( PolicySet policySet : ((PolicySubject)composite.getComponents().get(5).getImplementation()).getPolicySets() ) {
String policySetName = policySet.getName().getLocalPart();
if ( !(policySetName.equals("tuscanyPolicySet_1") || policySetName.equals("tuscanyPolicySet_2")) ) {
fail();
}
}
+ /*
//test for computation of policysets on operations of implementation
OperationsConfigurator opConf = (OperationsConfigurator)composite.getComponents().get(5);
assertEquals(opConf.getConfiguredOperations().get(0).getPolicySets().size(), 3);
@@ -215,6 +217,8 @@ public class ReadTestCase {
fail();
}
}
+ */
+
//new PrintUtil(System.out).print(composite);
}
diff --git a/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml b/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
index cddc134c2c..7af59d8eb9 100644
--- a/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
+++ b/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
@@ -19,7 +19,7 @@
-->
<sca:definitions xmlns="http://test"
targetNamespace="http://test"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712">
<!-- simple intent -->
<sca:intent name="tuscanyIntent_1"
diff --git a/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml b/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml
index 9147133d5d..781afe1241 100644
--- a/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml
+++ b/java/sca/modules/implementation-java-xml/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml
@@ -17,117 +17,97 @@
* specific language governing permissions and limitations
* under the License.
-->
-<sca:definitions xmlns="http://test"
- targetNamespace="http://test"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+<sca:definitions xmlns="http://test" targetNamespace="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712">
-<!-- simple intent -->
- <sca:intent name="tuscanyIntent_1"
- constrains="sca:binding sca:implementation.java">
- <sca:description>
- Sample Intent
+ <!-- simple intent -->
+ <sca:intent name="tuscanyIntent_1" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
</sca:description>
- </sca:intent>
-
- <sca:intent name="tuscanyIntent_2"
- constrains="sca:binding sca:implementation.java">
- <sca:description>
- Sample Intent
+ <!-- qualified intents -->
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_2" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
</sca:description>
- </sca:intent>
-
- <sca:intent name="tuscanyIntent_3"
- constrains="sca:binding sca:implementation.java">
- <sca:description>
- Sample Intent
+ <sca:qualifier name="qualified" default="true"/>
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_3" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
</sca:description>
- </sca:intent>
-
- <sca:intent name="tuscanyIntent_4"
- constrains="sca:binding sca:implementation.java">
- <sca:description>
- Sample Intent
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_4" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
</sca:description>
- </sca:intent>
-
-<sca:intent name="tuscanyIntent_5"
- constrains="sca:binding sca:implementation.java">
- <sca:description>
- Sample Intent
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_5" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
</sca:description>
- </sca:intent>
-
- <sca:intent name="tuscanyIntent_6"
- constrains="sca:binding sca:implementation.java">
- <sca:description>
- Sample Intent
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_6" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
</sca:description>
- </sca:intent>
-
- <sca:intent name="tuscanyIntent_7"
- constrains="sca:binding sca:implementation.java">
- <sca:description>
- Sample Intent
+ <sca:qualifier name="qualified1" default="true"/>
+ <sca:qualifier name="qualified2" />
+
+
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_7" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
</sca:description>
- </sca:intent>
-
- <sca:intent name="tuscanyIntent_8"
- constrains="sca:binding sca:implementation.java">
- <sca:description>
- Sample Intent
+ </sca:intent>
+
+ <sca:intent name="tuscanyIntent_8" constrains="sca:binding sca:implementation.java">
+ <sca:description>
+ Sample Intent
</sca:description>
- </sca:intent>
-
- <sca:policySet name="tuscanyPolicySet_1"
- provides="tuscanyIntent_1 tuscanyIntent_2 tuscanyIntent_3"
- appliesTo="/sca:composite/sca:component"
- xmlns="http://test"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- </sca:policySet>
-
- <sca:policySet name="tuscanyPolicySet_2"
- provides="tuscanyIntent_4 tuscanyIntent_5"
- appliesTo="/sca:composite/sca:component"
- xmlns="http://test"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- </sca:policySet>
-
- <sca:policySet name="tuscanyPolicySet_3"
- provides="tuscanyIntent_6"
- appliesTo="/sca:composite/sca:component"
- xmlns="http://test"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <sca:intentMap provides="tuscanyIntent_6" default="qualified1">
- <sca:qualifier name="qualified1">
- <wsp:Policy>
- <!-- policy expression and policy subject for "qualified1" alternative -->
- </wsp:Policy>
- </sca:qualifier>
- <sca:qualifier name="qualifed2">
- <wsp:Policy>
- <!-- policy expression and policy subject for "qualified2" alternative" -->
- </wsp:Policy>
- </sca:qualifier>
- </sca:intentMap>
- </sca:policySet>
-
- <sca:policySet name="tuscanyPolicySet_4"
- provides="tuscanyIntent_6"
- appliesTo="/sca:composite/sca:component"
- xmlns="http://test"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <sca:intentMap provides="tuscanyIntent_6" default="qualified2">
- <sca:qualifier name="qualified2">
- <wsp:Policy>
- <!-- policy expression and policy subject for "qualified2" alternative" -->
- </wsp:Policy>
- </sca:qualifier>
- </sca:intentMap>
- </sca:policySet>
-
- <!-- qualified intents -->
- <sca:intent name="tuscanyIntent_1.qualified" />
- <sca:intent name="tuscanyIntent_2.qualified" />
- <sca:intent name="tuscanyIntent_6.qualified1" />
- <sca:intent name="tuscanyIntent_6.qualified2" />
+ </sca:intent>
+
+ <sca:policySet name="tuscanyPolicySet_1" provides="tuscanyIntent_1 tuscanyIntent_2 tuscanyIntent_3"
+ appliesTo="/sca:composite/sca:component" xmlns="http://test" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ </sca:policySet>
+
+ <sca:policySet name="tuscanyPolicySet_2" provides="tuscanyIntent_4 tuscanyIntent_5" appliesTo="/sca:composite/sca:component"
+ xmlns="http://test" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ </sca:policySet>
+
+ <sca:policySet name="tuscanyPolicySet_3" provides="tuscanyIntent_6" appliesTo="/sca:composite/sca:component"
+ xmlns="http://test" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <sca:intentMap provides="tuscanyIntent_6" default="qualified1">
+ <sca:qualifier name="qualified1">
+ <wsp:Policy>
+ <!-- policy expression and policy subject for "qualified1" alternative -->
+ </wsp:Policy>
+ </sca:qualifier>
+ <sca:qualifier name="qualifed2">
+ <wsp:Policy>
+ <!-- policy expression and policy subject for "qualified2" alternative" -->
+ </wsp:Policy>
+ </sca:qualifier>
+ </sca:intentMap>
+ </sca:policySet>
+
+ <sca:policySet name="tuscanyPolicySet_4" provides="tuscanyIntent_6" appliesTo="/sca:composite/sca:component"
+ xmlns="http://test" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <sca:intentMap provides="tuscanyIntent_6" default="qualified2">
+ <sca:qualifier name="qualified2">
+ <wsp:Policy>
+ <!-- policy expression and policy subject for "qualified2" alternative" -->
+ </wsp:Policy>
+ </sca:qualifier>
+ </sca:intentMap>
+ </sca:policySet>
+
</sca:definitions> \ No newline at end of file
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
index cfb8aed338..db2d3efe56 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
@@ -26,8 +26,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
-
/**
* Represents a Java implementation.
*
@@ -181,14 +179,4 @@ public interface JavaImplementation extends BaseJavaImplementation {
*/
void setMaxIdleTime(long maxIdleTime);
- /**
- * @return the map of a policy handler class names
- */
- List<PolicyHandlerTuple> getPolicyHandlerClassNames();
-
- /**
- * @param policyHandlerClassNames Map of policyhandler class names
- */
- void setPolicyHandlerClassNames(List<PolicyHandlerTuple> policyHandlerClassNames);
-
}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
index a0b8b1dba0..43a074e0ec 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
@@ -32,7 +32,6 @@ import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.JavaResourceImpl;
import org.apache.tuscany.sca.implementation.java.JavaScopeImpl;
-import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
/**
* A component type specialization for POJO implementations
@@ -55,7 +54,6 @@ public class JavaImplementationImpl extends BaseJavaImplementationImpl implement
private long maxAge = -1;
private long maxIdleTime = -1;
private JavaScopeImpl scope = JavaScopeImpl.STATELESS;
- private List<PolicyHandlerTuple> policyHandlerClassNames = null;
protected JavaImplementationImpl() {
super();
@@ -161,12 +159,4 @@ public class JavaImplementationImpl extends BaseJavaImplementationImpl implement
this.maxIdleTime = maxIdleTime;
}
- public List<PolicyHandlerTuple> getPolicyHandlerClassNames() {
- return policyHandlerClassNames;
- }
-
- public void setPolicyHandlerClassNames(List<PolicyHandlerTuple> policyHandlerClassNames) {
- this.policyHandlerClassNames = policyHandlerClassNames;
- }
-
}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
index a85a66e8c7..f48358eddf 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
@@ -26,8 +26,6 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Callback;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
@@ -40,7 +38,7 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.oasisopen.sca.annotation.PolicySets;
import org.oasisopen.sca.annotation.Requires;
@@ -85,11 +83,12 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
readIntents(method.getAnnotation(Requires.class), reference.getRequiredIntents());
readPolicySets(method.getAnnotation(PolicySets.class), reference.getPolicySets());
} else {
+ /*
if ( type instanceof OperationsConfigurator ) {
//Read the intents specified on the given implementation method
if ( (method.getAnnotation(Requires.class) != null ||
method.getAnnotation(PolicySets.class) != null ) &&
- (type instanceof PolicySetAttachPoint )) {
+ (type instanceof PolicySubject )) {
ConfiguredOperation confOp = assemblyFactory.createConfiguredOperation();
confOp.setName(method.getName());
((OperationsConfigurator)type).getConfiguredOperations().add(confOp);
@@ -99,6 +98,7 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
readPolicySets(method.getAnnotation(PolicySets.class), confOp.getPolicySets());
}
}
+ */
}
}
@@ -106,10 +106,10 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
// Read intents on the Java implementation class
- if ( type instanceof PolicySetAttachPoint ) {
+ if ( type instanceof PolicySubject ) {
readIntentsAndPolicySets(clazz,
- ((PolicySetAttachPoint)type).getRequiredIntents(),
- ((PolicySetAttachPoint)type).getPolicySets());
+ ((PolicySubject)type).getRequiredIntents(),
+ ((PolicySubject)type).getPolicySets());
}
// Process annotations on the service interfaces
@@ -127,6 +127,7 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
service.getRequiredIntents(),
service.getPolicySets());
+ /*
// Read intents on the service interface methods
Method[] methods = javaInterface.getJavaClass().getMethods();
ConfiguredOperation confOp = null;
@@ -142,6 +143,7 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
readPolicySets(method.getAnnotation(PolicySets.class), confOp.getPolicySets());
}
}
+ */
}
}
@@ -159,6 +161,7 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
callback.getRequiredIntents(),
callback.getPolicySets());
+ /*
// Read intents on the callback interface methods
Method[] methods = javaCallbackInterface.getJavaClass().getMethods();
ConfiguredOperation confOp = null;
@@ -169,6 +172,7 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
readIntents(method.getAnnotation(Requires.class), confOp.getRequiredIntents());
readPolicySets(method.getAnnotation(PolicySets.class), confOp.getPolicySets());
}
+ */
}
}
}
diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
index e6a29b0e13..6c9ffc7975 100644
--- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
+++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
@@ -26,9 +26,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
@@ -37,7 +35,7 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.impl.PolicyJavaInterfaceVisitor;
import org.apache.tuscany.sca.policy.DefaultPolicyFactory;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.junit.Before;
import org.junit.Test;
import org.oasisopen.sca.annotation.Requires;
@@ -102,13 +100,13 @@ public class PolicyProcessorTestCase {
}
private void verifyIntents(Class<?> serviceImplClass, JavaImplementation type) {
- if ( !(type instanceof PolicySetAttachPoint) ) {
+ if ( !(type instanceof PolicySubject) ) {
fail("No Intents on the service ");
}
Requires serviceImplIntentAnnotation = (Requires)serviceImplClass.getAnnotation(Requires.class);
if (serviceImplIntentAnnotation != null) {
String[] serviceImplIntents = serviceImplIntentAnnotation.value();
- List<Intent> requiredIntents = ((PolicySetAttachPoint)type).getRequiredIntents();
+ List<Intent> requiredIntents = ((PolicySubject)type).getRequiredIntents();
if (serviceImplIntents.length > 0) {
if (requiredIntents == null || requiredIntents.size() == 0) {
fail("No Intents on the service ");
@@ -162,6 +160,7 @@ public class PolicyProcessorTestCase {
}
}
+ /*
for (Method method : interfaceClass.getDeclaredMethods()) {
Requires methodIntentAnnotation = method.getAnnotation(Requires.class);
@@ -232,6 +231,7 @@ public class PolicyProcessorTestCase {
}
}
}
+ */
}
}
diff --git a/java/sca/modules/implementation-node/META-INF/MANIFEST.MF b/java/sca/modules/implementation-node/META-INF/MANIFEST.MF
index f89a513dc5..7c43865563 100644
--- a/java/sca/modules/implementation-node/META-INF/MANIFEST.MF
+++ b/java/sca/modules/implementation-node/META-INF/MANIFEST.MF
@@ -19,6 +19,7 @@ Import-Package: javax.xml.namespace,
javax.xml.transform,
org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
org.apache.tuscany.sca.contribution;version="2.0.0",
org.apache.tuscany.sca.contribution.processor;version="2.0.0",
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/ConfiguredNodeImplementationImpl.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/ConfiguredNodeImplementationImpl.java
index 1d183513b4..706a657654 100644
--- a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/ConfiguredNodeImplementationImpl.java
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/ConfiguredNodeImplementationImpl.java
@@ -27,6 +27,7 @@ import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.implementation.node.ConfiguredNodeImplementation;
@@ -36,7 +37,7 @@ import org.apache.tuscany.sca.implementation.node.ConfiguredNodeImplementation;
*
* @version $Rev$ $Date$
*/
-class ConfiguredNodeImplementationImpl implements ConfiguredNodeImplementation {
+class ConfiguredNodeImplementationImpl extends ImplementationImpl implements ConfiguredNodeImplementation {
private String uri;
private boolean unresolved;
diff --git a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/NodeImplementationImpl.java b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/NodeImplementationImpl.java
index 8f6315d969..daa1e54333 100644
--- a/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/NodeImplementationImpl.java
+++ b/java/sca/modules/implementation-node/src/main/java/org/apache/tuscany/sca/implementation/node/impl/NodeImplementationImpl.java
@@ -26,6 +26,7 @@ import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
import org.apache.tuscany.sca.implementation.node.NodeImplementation;
@@ -34,7 +35,7 @@ import org.apache.tuscany.sca.implementation.node.NodeImplementation;
*
* @version $Rev$ $Date$
*/
-class NodeImplementationImpl implements NodeImplementation {
+class NodeImplementationImpl extends ImplementationImpl implements NodeImplementation {
private String uri;
private boolean unresolved;
diff --git a/java/sca/modules/implementation-web/META-INF/MANIFEST.MF b/java/sca/modules/implementation-web/META-INF/MANIFEST.MF
index 4fed82e56e..bf2948e958 100644
--- a/java/sca/modules/implementation-web/META-INF/MANIFEST.MF
+++ b/java/sca/modules/implementation-web/META-INF/MANIFEST.MF
@@ -13,15 +13,16 @@ Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Implementation Web Model
Import-Package: org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.assembly.builder;version="2.0.0",
+ org.apache.tuscany.sca.assembly.impl;version="2.0.0",
org.apache.tuscany.sca.assembly.xml;version="2.0.0",
org.apache.tuscany.sca.contribution;version="2.0.0",
org.apache.tuscany.sca.contribution.processor;version="2.0.0",
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.implementation.web;version="2.0.0",
org.apache.tuscany.sca.policy;version="2.0.0",
org.apache.tuscany.sca.runtime;version="2.0.0",
- org.apache.tuscany.sca.xsd;version="2.0.0",
- org.apache.tuscany.sca.implementation.web;version="2.0.0"
+ org.apache.tuscany.sca.xsd;version="2.0.0"
Bundle-SymbolicName: org.apache.tuscany.sca.implementation.web
Bundle-DocURL: http://www.apache.org/
diff --git a/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java b/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
index b255dd2d0e..0495ccb600 100644
--- a/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
+++ b/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
@@ -28,6 +28,7 @@ import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor;
+import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
import org.apache.tuscany.sca.implementation.web.WebImplementation;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -35,7 +36,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent;
/**
* The model representing an Web implementation in an SCA assembly model.
*/
-class WebImplementationImpl implements WebImplementation, ComponentPreProcessor {
+class WebImplementationImpl extends ImplementationImpl implements WebImplementation, ComponentPreProcessor {
private List<Property> properties = new ArrayList<Property>();
private List<Reference> references = new ArrayList<Reference>();
diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
index 67a9c8f2c6..97513fefd9 100644
--- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
+++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
@@ -56,7 +56,7 @@ public class DefaultJavaInterfaceFactory extends JavaInterfaceFactoryImpl implem
* Load visitors declared under META-INF/services
*/
@SuppressWarnings("unchecked")
- private void loadVisitors() {
+ private synchronized void loadVisitors() {
if (loadedVisitors)
return;
diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java
index f9de645a6e..1ad7a8f370 100644
--- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java
+++ b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java
@@ -20,7 +20,7 @@ package org.apache.tuscany.sca.interfacedef;
import java.util.List;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Represents a service interface. This interface will typically be extended to
@@ -29,7 +29,7 @@ import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
*
* @version $Rev$ $Date$
*/
-public interface Interface extends Cloneable, PolicySetAttachPoint {
+public interface Interface extends Cloneable, PolicySubject {
/**
* Returns true if the interface is a remotable interface..
diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
index 4676e35f80..e278fe1457 100644
--- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
+++ b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
@@ -25,14 +25,14 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* Represents an operation on a service interface.
*
* @version $Rev$ $Date$
*/
-public interface Operation extends Cloneable, PolicySetAttachPoint {
+public interface Operation extends Cloneable, PolicySubject {
/**
* Returns the name of the operation.
*
diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
index e2a524c5e0..0890ca1664 100644
--- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
+++ b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
@@ -27,7 +27,7 @@ import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -43,7 +43,7 @@ public class InterfaceImpl implements Interface {
private boolean unresolved;
private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
- private IntentAttachPointType type;
+ private ExtensionType type;
private List<PolicySet> policySets = new ArrayList<PolicySet>();
private List<Intent> requiredIntents = new ArrayList<Intent>();
@@ -234,11 +234,11 @@ public class InterfaceImpl implements Interface {
return requiredIntents;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return type;
}
- public void setType(IntentAttachPointType type) {
+ public void setType(ExtensionType type) {
this.type = type;
}
diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
index 00a5dc3065..2e0902e1bb 100644
--- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
+++ b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
@@ -32,7 +32,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.util.WrapperInfo;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -58,7 +58,7 @@ public class OperationImpl implements Operation {
private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
private List<PolicySet> policySets = new ArrayList<PolicySet>();
private List<Intent> requiredIntents = new ArrayList<Intent>();
- private IntentAttachPointType type;
+ private ExtensionType type;
/**
* @param name
@@ -328,11 +328,11 @@ public class OperationImpl implements Operation {
return requiredIntents;
}
- public IntentAttachPointType getType() {
+ public ExtensionType getType() {
return type;
}
- public void setType(IntentAttachPointType type) {
+ public void setType(ExtensionType type) {
this.type = type;
}
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index f9be2039e0..786bf6840e 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -413,10 +413,10 @@ public class NodeImpl implements Node, Client {
// for (PolicySet policySet : systemDefinitions.getPolicySets()) {
// definitionsResolver.addModel(policySet);
// }
-// for (IntentAttachPointType bindingType : systemDefinitions.getBindingTypes()) {
+// for (ExtensionType bindingType : systemDefinitions.getBindingTypes()) {
// definitionsResolver.addModel(bindingType);
// }
-// for (IntentAttachPointType implementationType : systemDefinitions.getImplementationTypes()) {
+// for (ExtensionType implementationType : systemDefinitions.getImplementationTypes()) {
// definitionsResolver.addModel(implementationType);
// }
//
diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
index 45870dd183..2a14657d21 100644
--- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
+++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
@@ -931,9 +931,22 @@ final class NodeLauncherUtil {
static Set<URL> manifestClassPath(URL jarFile) throws Exception {
Set<URL> urls = new HashSet<URL>();
if (jarFile != null) {
- JarInputStream jar = new JarInputStream(jarFile.openStream());
- Manifest mf = jar.getManifest();
- jar.close();
+ Manifest mf = null;
+ if ("file".equals(jarFile.getProtocol())) {
+ File f = file(jarFile);
+ if (f.isDirectory()) {
+ File mfFile = new File(f, "META-INF/MANIFEST.MF");
+ if (mfFile.isFile()) {
+ FileInputStream is = new FileInputStream(mfFile);
+ mf = new Manifest(is);
+ is.close();
+ }
+ } else if (f.isFile()) {
+ JarInputStream jar = new JarInputStream(jarFile.openStream());
+ mf = jar.getManifest();
+ jar.close();
+ }
+ }
if (mf != null) {
String cp = mf.getMainAttributes().getValue("Class-Path");
if (cp != null) {
diff --git a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java
index 152a8de6cc..7e86e996bf 100644
--- a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java
+++ b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java
@@ -20,15 +20,13 @@ package org.apache.tuscany.sca.policy.authentication.basic;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.Policy;
-
/**
* Implementation for policies that could be injected as parameter
* into the axis2config.
*
* @version $Rev$ $Date$
*/
-public class BasicAuthenticationPolicy implements Policy {
+public class BasicAuthenticationPolicy {
private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
public static final QName BASIC_AUTHENTICATION_POLICY_QNAME = new QName(SCA10_TUSCANY_NS, "basicAuthentication");
diff --git a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java
index 5aa36ecc89..c5352e1f57 100644
--- a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java
+++ b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java
@@ -26,7 +26,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -49,8 +49,8 @@ public class BasicAuthenticationReferencePolicyProvider implements PolicyProvide
}
private PolicySet findPolicySet() {
- if (binding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
+ if (binding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)binding).getPolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
if (BasicAuthenticationPolicy.class.isInstance(p)) {
diff --git a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java
index aae0386589..b8684e29c0 100644
--- a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java
+++ b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java
@@ -26,7 +26,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
import org.apache.tuscany.sca.provider.PolicyProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
@@ -47,8 +47,8 @@ public class BasicAuthenticationServicePolicyProvider implements PolicyProvider
}
private PolicySet findPolicySet() {
- if (binding instanceof PolicySetAttachPoint) {
- List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
+ if (binding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)binding).getPolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
if (BasicAuthenticationPolicy.class.isInstance(p)) {
diff --git a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java
index dfb6fee180..89b8ed29d8 100644
--- a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java
+++ b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java
@@ -24,14 +24,12 @@ import java.util.List;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.Policy;
-
/**
* Models the SCA Implementation Security Policy Assertion for Authorization.
*
* @version $Rev$ $Date$
*/
-public class AuthorizationPolicy implements Policy {
+public class AuthorizationPolicy {
private final static String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
// private final static String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
public static final QName NAME = new QName(SCA10_NS, "authorization");
diff --git a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java
index aa52e0bc41..38feea21b5 100644
--- a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java
+++ b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java
@@ -21,9 +21,7 @@ package org.apache.tuscany.sca.policy.identity;
import java.util.ArrayList;
import java.util.List;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
@@ -46,6 +44,7 @@ public class SecurityIdentityImplementationPolicyProvider implements PolicyProvi
private List<SecurityIdentityPolicy> findPolicies(Operation op) {
List<SecurityIdentityPolicy> polices = new ArrayList<SecurityIdentityPolicy>();
+ /*
// FIXME: How do we get a list of effective policySets for a given operation?
if (implementation instanceof OperationsConfigurator) {
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)implementation;
@@ -61,6 +60,7 @@ public class SecurityIdentityImplementationPolicyProvider implements PolicyProvi
}
}
}
+ */
List<PolicySet> policySets = component.getPolicySets();
for (PolicySet ps : policySets) {
diff --git a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java
index e4c4794c52..9d0094ee4b 100644
--- a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java
+++ b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java
@@ -21,14 +21,12 @@ package org.apache.tuscany.sca.policy.identity;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.Policy;
-
/**
* Models the SCA Implementation Security Policy Assertion for Security Identity.
*
* @version $Rev$ $Date$
*/
-public class SecurityIdentityPolicy implements Policy {
+public class SecurityIdentityPolicy {
private final static String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
public static final QName NAME = new QName(SCA10_NS, "securityIdentity");
diff --git a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java
index 185982a749..203d9ca0ab 100644
--- a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java
+++ b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java
@@ -21,9 +21,7 @@ package org.apache.tuscany.sca.policy.security.jaas;
import java.util.ArrayList;
import java.util.List;
-import org.apache.tuscany.sca.assembly.ConfiguredOperation;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.OperationsConfigurator;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Phase;
@@ -48,6 +46,7 @@ public class JaasAuthenticationImplementationPolicyProvider implements PolicyPro
private List<JaasAuthenticationPolicy> findPolicies(Operation op) {
List<JaasAuthenticationPolicy> polices = new ArrayList<JaasAuthenticationPolicy>();
+ /*
// FIXME: How do we get a list of effective policySets for a given operation?
if (implementation instanceof OperationsConfigurator) {
OperationsConfigurator operationsConfigurator = (OperationsConfigurator)implementation;
@@ -63,6 +62,7 @@ public class JaasAuthenticationImplementationPolicyProvider implements PolicyPro
}
}
}
+ */
List<PolicySet> policySets = component.getPolicySets();
for (PolicySet ps : policySets) {
diff --git a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java
index e1ef32f36c..20f9e38f11 100644
--- a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java
+++ b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java
@@ -21,13 +21,11 @@ package org.apache.tuscany.sca.policy.security.jaas;
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.Policy;
-
/**
*
* @version $Rev$ $Date$
*/
-public class JaasAuthenticationPolicy implements Policy {
+public class JaasAuthenticationPolicy {
private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
public static final QName NAME = new QName(SCA10_TUSCANY_NS, "jaasAuthentication");
diff --git a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java
index edff316700..5bd19e5c69 100644
--- a/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java
+++ b/java/sca/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java
@@ -24,14 +24,13 @@ import javax.security.auth.login.LoginContext;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.util.PolicyHandler;
/**
* Policy handler to handle PolicySet containing JaasAuthenticationPolicy instances
*
* @version $Rev$ $Date$
*/
-public class JaasAuthenticationPolicyHandler implements PolicyHandler {
+public class JaasAuthenticationPolicyHandler {
private static final String jaasPolicy = "JaasPolicy";
private static final String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
public static final QName policySetQName = new QName(SCA10_TUSCANY_NS, jaasPolicy);
diff --git a/java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml b/java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml
index f8f0634a9a..0e9e050bd4 100644
--- a/java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml
+++ b/java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml
@@ -17,9 +17,9 @@
* specific language governing permissions and limitations
* under the License.
-->
-<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
- targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712"
xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
<!-- POLICY SETS -->
@@ -31,7 +31,7 @@
<!-- Policy Intents Defined by the SCA Runtime -->
<intent name="authentication"
- constrains="sca:binding tuscany:binding">
+ constrains="sca:binding">
<description>
Specifying this intent on references requires necessary authentication information
to be sent along with outgoing messages. Specifying this intent on service requires
@@ -40,14 +40,14 @@
</intent>
<intent name="confidentiality"
- constrains="sca:binding tuscany:binding">
+ constrains="sca:binding">
<description>
Specifying this intent requires message exchanged to be encrypted
</description>
</intent>
<intent name="integrity"
- constrains="sca:binding tuscany:binding">
+ constrains="sca:binding">
<description>
Specifying this intent requires message exchanged to be signed
</description>
diff --git a/java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml b/java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml
index 91383eaf6a..0ae105c755 100644
--- a/java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml
+++ b/java/sca/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml
@@ -17,8 +17,8 @@
* specific language governing permissions and limitations
* under the License.
-->
-<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0">
<intent name="identity" constrains="sca:implementation.java
sca:implementation.spring">
diff --git a/java/sca/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.java b/java/sca/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.java
index cb5db57c15..12a90f5c37 100644
--- a/java/sca/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.java
+++ b/java/sca/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.java
@@ -28,37 +28,36 @@ import org.apache.tuscany.sca.contribution.processor.ContributionResolveExceptio
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.policy.Policy;
/**
*
* @version $Rev$ $Date$
*/
-public class TestPolicyProcessor implements StAXArtifactProcessor<Policy> {
+public class TestPolicyProcessor implements StAXArtifactProcessor<Object> {
public QName getArtifactType() {
return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
}
- public Policy read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException {
+ public Object read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException {
return new MockPolicyImplOne();
}
- public void write(Policy arg0, XMLStreamWriter arg1) throws ContributionWriteException,
+ public void write(Object arg0, XMLStreamWriter arg1) throws ContributionWriteException,
XMLStreamException {
}
- public Class<Policy> getModelType() {
+ public Class<Object> getModelType() {
// TODO Auto-generated method stub
- return Policy.class;
+ return Object.class;
}
- public void resolve(Policy arg0, ModelResolver arg1) throws ContributionResolveException {
+ public void resolve(Object arg0, ModelResolver arg1) throws ContributionResolveException {
}
- public class MockPolicyImplOne implements Policy {
+ public class MockPolicyImplOne {
public QName getSchemaName() {
return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
}
diff --git a/java/sca/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/java/sca/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
index 814476b4f9..c3db1d50ae 100644
--- a/java/sca/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
+++ b/java/sca/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
@@ -17,15 +17,15 @@
* specific language governing permissions and limitations
* under the License.
-->
-<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
targetNamespace="http://test"
xmlns:test="http://test"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712">
<policySet name="SecureWSPolicy"
provides="test:confidentiality"
appliesTo="sca:binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:Policy>
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
index ae6805c832..38c7b57f12 100644
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
+++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
@@ -26,30 +26,27 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.apache.tuscany.sca.policy.impl.BindingTypeImpl;
/**
* Processor for handling XML models of BindingType meta data definitions
*
* @version $Rev$ $Date$
*/
-public class BindingTypeProcessor extends IntentAttachPointTypeProcessor {
+public class BindingTypeProcessor extends ExtensionTypeProcessor {
public BindingTypeProcessor(PolicyFactory policyFactory,
- IntentAttachPointTypeFactory intentAttachPointTypeFactory,
StAXArtifactProcessor<Object> extensionProcessor,
Monitor monitor) {
- super(policyFactory, intentAttachPointTypeFactory, extensionProcessor, monitor);
+ super(policyFactory, extensionProcessor, monitor);
}
public BindingTypeProcessor(FactoryExtensionPoint modelFactories,
StAXArtifactProcessor<Object> extensionProcessor,
Monitor monitor) {
- super(modelFactories.getFactory(PolicyFactory.class), modelFactories
- .getFactory(IntentAttachPointTypeFactory.class), extensionProcessor, monitor);
+ super(modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor);
}
public QName getArtifactType() {
@@ -57,11 +54,11 @@ public class BindingTypeProcessor extends IntentAttachPointTypeProcessor {
}
@Override
- protected IntentAttachPointType resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver)
+ protected ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver)
throws ContributionResolveException {
- if (extnType instanceof BindingTypeImpl) {
- BindingTypeImpl bindingType = (BindingTypeImpl)extnType;
- return resolver.resolveModel(BindingTypeImpl.class, bindingType);
+ if (extnType instanceof BindingType) {
+ BindingType bindingType = (BindingType)extnType;
+ return resolver.resolveModel(BindingType.class, bindingType);
} else {
return extnType;
}
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
index a85ef28572..f437b5d599 100644
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java
+++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
@@ -37,34 +37,30 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.apache.tuscany.sca.policy.impl.BindingTypeImpl;
-import org.apache.tuscany.sca.policy.impl.ImplementationTypeImpl;
/**
* Processor for handling XML models of ExtensionType meta data definitions
*
* @version $Rev$ $Date$
*/
-abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor implements
- StAXArtifactProcessor<IntentAttachPointType>, PolicyConstants {
+abstract class ExtensionTypeProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<ExtensionType>, PolicyConstants {
- private IntentAttachPointTypeFactory attachPointTypeFactory;
private PolicyFactory policyFactory;
private Monitor monitor;
- protected abstract IntentAttachPointType resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver)
+ protected abstract ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver)
throws ContributionResolveException;
- public IntentAttachPointTypeProcessor(PolicyFactory policyFactory,
- IntentAttachPointTypeFactory attachPointTypeFactory,
- StAXArtifactProcessor<Object> extensionProcessor,
- Monitor monitor) {
+ public ExtensionTypeProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
this.policyFactory = policyFactory;
- this.attachPointTypeFactory = attachPointTypeFactory;
this.monitor = monitor;
}
@@ -88,39 +84,37 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
}
}
- public IntentAttachPointType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
- QName type = getQName(reader, TYPE);
+ public ExtensionType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ QName extType = getArtifactType();
+ QName type = getQName(reader, "type");
if (type != null) {
- if (type.getLocalPart().startsWith(BINDING)) {
- IntentAttachPointType bindingType = attachPointTypeFactory.createBindingType();
- bindingType.setName(type);
- bindingType.setUnresolved(true);
-
- readAlwaysProvidedIntents(bindingType, reader);
- readMayProvideIntents(bindingType, reader);
- return bindingType;
- } else if (type.getLocalPart().startsWith(IMPLEMENTATION)) {
- IntentAttachPointType implType = attachPointTypeFactory.createImplementationType();
- implType.setName(type);
- implType.setUnresolved(true);
-
- readAlwaysProvidedIntents(implType, reader);
- readMayProvideIntents(implType, reader);
- return implType;
+ ExtensionType extensionType = null;
+ if (BINDING_TYPE_QNAME.equals(extType)) {
+ extensionType = policyFactory.createBindingType();
+ } else if (IMPLEMENTATION_TYPE_QNAME.equals(extType)) {
+ extensionType = policyFactory.createImplementationType();
} else {
- error("UnrecognizedIntentAttachPointType", reader, type);
- //throw new ContributionReadException("Unrecognized IntentAttachPointType - " + type);
+ error("UnrecognizedExtensionType", reader, type);
+ return null;
+ //throw new ContributionReadException("Unrecognized ExtensionType - " + type);
}
+ extensionType.setType(type);
+ extensionType.setUnresolved(true);
+
+ readAlwaysProvidedIntents(extensionType, reader);
+ readMayProvideIntents(extensionType, reader);
+ return extensionType;
+
} else {
- error("RequiredAttributeMissing", reader, TYPE);
+ error("RequiredAttributeMissing", reader, extType);
//throw new ContributionReadException("Required attribute '" + TYPE +
//"' missing from BindingType Definition");
}
return null;
}
- private void readAlwaysProvidedIntents(IntentAttachPointType extnType, XMLStreamReader reader) {
+ private void readAlwaysProvidedIntents(ExtensionType extnType, XMLStreamReader reader) {
String value = reader.getAttributeValue(null, ALWAYS_PROVIDES);
if (value != null) {
List<Intent> alwaysProvided = extnType.getAlwaysProvidedIntents();
@@ -133,10 +127,10 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
}
}
- private void readMayProvideIntents(IntentAttachPointType extnType, XMLStreamReader reader) {
+ private void readMayProvideIntents(ExtensionType extnType, XMLStreamReader reader) {
String value = reader.getAttributeValue(null, MAY_PROVIDE);
if (value != null) {
- List<Intent> mayProvide = extnType.getMayProvideIntents();
+ List<Intent> mayProvide = extnType.getMayProvidedIntents();
for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
QName qname = getQNameValue(reader, tokens.nextToken());
Intent intent = policyFactory.createIntent();
@@ -146,14 +140,14 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
}
}
- public void write(IntentAttachPointType extnType, XMLStreamWriter writer) throws ContributionWriteException,
+ public void write(ExtensionType extnType, XMLStreamWriter writer) throws ContributionWriteException,
XMLStreamException {
// Write an <sca:bindingType or sca:implementationType>
- if (extnType instanceof BindingTypeImpl) {
- writer.writeStartElement(SCA10_NS, BINDING_TYPE);
- } else if (extnType instanceof ImplementationTypeImpl) {
- writer.writeStartElement(SCA10_NS, IMPLEMENTATION_TYPE);
+ if (extnType instanceof BindingType) {
+ writer.writeStartElement(SCA11_NS, BINDING_TYPE);
+ } else if (extnType instanceof ImplementationType) {
+ writer.writeStartElement(SCA11_NS, IMPLEMENTATION_TYPE);
}
writeAlwaysProvidesIntentsAttribute(extnType, writer);
@@ -162,10 +156,10 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
writer.writeEndElement();
}
- private void writeMayProvideIntentsAttribute(IntentAttachPointType extnType, XMLStreamWriter writer)
+ private void writeMayProvideIntentsAttribute(ExtensionType extnType, XMLStreamWriter writer)
throws XMLStreamException {
StringBuffer sb = new StringBuffer();
- for (Intent intent : extnType.getMayProvideIntents()) {
+ for (Intent intent : extnType.getMayProvidedIntents()) {
writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
sb.append(intent.getName().getPrefix() + COLON + intent.getName().getLocalPart());
sb.append(WHITE_SPACE);
@@ -176,7 +170,7 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
}
}
- private void writeAlwaysProvidesIntentsAttribute(IntentAttachPointType extnType, XMLStreamWriter writer)
+ private void writeAlwaysProvidesIntentsAttribute(ExtensionType extnType, XMLStreamWriter writer)
throws XMLStreamException {
StringBuffer sb = new StringBuffer();
for (Intent intent : extnType.getAlwaysProvidedIntents()) {
@@ -191,7 +185,7 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
}
}
- public void resolve(IntentAttachPointType extnType, ModelResolver resolver) throws ContributionResolveException {
+ public void resolve(ExtensionType extnType, ModelResolver resolver) throws ContributionResolveException {
if (extnType != null && extnType.isUnresolved()) {
resolveAlwaysProvidedIntents(extnType, resolver);
@@ -201,7 +195,7 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
}
}
- private void resolveAlwaysProvidedIntents(IntentAttachPointType extensionType, ModelResolver resolver)
+ private void resolveAlwaysProvidedIntents(ExtensionType extensionType, ModelResolver resolver)
throws ContributionResolveException {
if (extensionType != null) {
// resolve all provided intents
@@ -226,12 +220,12 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
}
}
- private void resolveMayProvideIntents(IntentAttachPointType extensionType, ModelResolver resolver)
+ private void resolveMayProvideIntents(ExtensionType extensionType, ModelResolver resolver)
throws ContributionResolveException {
if (extensionType != null) {
// resolve all provided intents
List<Intent> mayProvide = new ArrayList<Intent>();
- for (Intent providedIntent : extensionType.getMayProvideIntents()) {
+ for (Intent providedIntent : extensionType.getMayProvidedIntents()) {
if (providedIntent.isUnresolved()) {
providedIntent = resolver.resolveModel(Intent.class, providedIntent);
if (!providedIntent.isUnresolved()) {
@@ -246,12 +240,12 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
mayProvide.add(providedIntent);
}
}
- extensionType.getMayProvideIntents().clear();
- extensionType.getMayProvideIntents().addAll(mayProvide);
+ extensionType.getMayProvidedIntents().clear();
+ extensionType.getMayProvidedIntents().addAll(mayProvide);
}
}
- public Class<IntentAttachPointType> getModelType() {
- return IntentAttachPointType.class;
+ public Class<ExtensionType> getModelType() {
+ return ExtensionType.class;
}
}
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
index e405da21c7..41e2af3809 100644
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
+++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
@@ -26,30 +26,27 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.apache.tuscany.sca.policy.impl.ImplementationTypeImpl;
/**
* Processor for handling XML models of ImplementationType meta data definitions
*
* @version $Rev$ $Date$
*/
-public class ImplementationTypeProcessor extends IntentAttachPointTypeProcessor {
+public class ImplementationTypeProcessor extends ExtensionTypeProcessor {
public ImplementationTypeProcessor(PolicyFactory policyFactory,
- IntentAttachPointTypeFactory intentAttachPointTypeFactory,
StAXArtifactProcessor<Object> extensionProcessor,
Monitor monitor) {
- super(policyFactory, intentAttachPointTypeFactory, extensionProcessor, monitor);
+ super(policyFactory, extensionProcessor, monitor);
}
public ImplementationTypeProcessor(FactoryExtensionPoint modelFactories,
StAXArtifactProcessor<Object> extensionProcessor,
Monitor monitor) {
- super(modelFactories.getFactory(PolicyFactory.class), modelFactories
- .getFactory(IntentAttachPointTypeFactory.class), extensionProcessor, monitor);
+ super(modelFactories.getFactory(PolicyFactory.class), extensionProcessor, monitor);
}
public QName getArtifactType() {
@@ -57,11 +54,11 @@ public class ImplementationTypeProcessor extends IntentAttachPointTypeProcessor
}
@Override
- protected IntentAttachPointType resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver)
+ protected ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver)
throws ContributionResolveException {
- if (extnType instanceof ImplementationTypeImpl) {
- ImplementationTypeImpl implType = (ImplementationTypeImpl)extnType;
- return resolver.resolveModel(ImplementationTypeImpl.class, implType);
+ if (extnType instanceof ImplementationType) {
+ ImplementationType implType = (ImplementationType)extnType;
+ return resolver.resolveModel(ImplementationType.class, implType);
} else {
return extnType;
}
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
new file mode 100644
index 0000000000..ffbceeaa12
--- /dev/null
+++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
@@ -0,0 +1,383 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.Intent.Type;
+
+/**
+ * Processor for handling XML models of PolicyIntent definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntentProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Intent>,
+ PolicyConstants {
+
+ private PolicyFactory policyFactory;
+ private Monitor monitor;
+
+ public IntentProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.monitor = monitor;
+ }
+
+ public IntentProcessor(PolicyFactory policyFactory, Monitor monitor) {
+ this.policyFactory = policyFactory;
+ this.monitor = monitor;
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ private void warn(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.WARNING,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ public Intent read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+ Intent intent = null;
+ String intentLocalName = reader.getAttributeValue(null, NAME);
+ if (intentLocalName == null) {
+ error("IntentNameMissing", reader);
+ return null;
+ }
+
+ String intentType = reader.getAttributeValue(null, INTENT_TYPE);
+ if (intentType == null) {
+ intentType = Intent.Type.interaction.name();
+ }
+
+ intent = policyFactory.createIntent();
+
+ // [rfeng] the target namespace is not available, set the local part for now
+ // This will be changed in the definitions processor
+ intent.setName(new QName(intentLocalName));
+ intent.setType(Type.valueOf(intentType));
+
+ readRequiredIntents(intent, reader);
+ readExcludedIntents(intent, reader);
+
+ readConstrainedTypes(intent, reader);
+
+ Intent current = intent;
+ int event = reader.getEventType();
+ QName name = null;
+ while (reader.hasNext()) {
+ event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+ if (DESCRIPTION_QNAME.equals(name)) {
+ current.setDescription(reader.getElementText());
+ } else if (INTENT_QUALIFIER_QNAME.equals(name)) {
+ String qualifierName = reader.getAttributeValue(null, NAME);
+ String defaultQ = reader.getAttributeValue(null, DEFAULT);
+ boolean isDefault = defaultQ == null ? false : Boolean.parseBoolean(defaultQ);
+ String qualifiedIntentName = intentLocalName + QUALIFIER + qualifierName;
+ Intent qualified = policyFactory.createIntent();
+ qualified.setType(intent.getType());
+ qualified.setName(new QName(qualifiedIntentName));
+ if (isDefault) {
+ intent.setDefaultQualifiedIntent(qualified);
+ }
+ intent.getQualifiedIntents().add(qualified);
+ qualified.setParent(intent);
+ current = qualified;
+ }
+ break;
+ }
+ case END_ELEMENT: {
+ name = reader.getName();
+ if (INTENT_QUALIFIER_QNAME.equals(name)) {
+ current = intent;
+ }
+ break;
+ }
+ }
+ if (event == END_ELEMENT && POLICY_INTENT_QNAME.equals(reader.getName())) {
+ break;
+ }
+
+ //Read the next element
+ if (reader.hasNext()) {
+ reader.next();
+ }
+ }
+ return intent;
+ }
+
+ public void write(Intent intent, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+ // Write an <sca:intent>
+ writer.writeStartElement(PolicyConstants.SCA11_NS, INTENT);
+ writer.writeNamespace(intent.getName().getPrefix(), intent.getName().getNamespaceURI());
+ writer.writeAttribute(PolicyConstants.NAME, intent.getName().getPrefix() + COLON
+ + intent.getName().getLocalPart());
+ if (intent.getRequiredIntents() != null && intent.getRequiredIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent requiredIntents : intent.getRequiredIntents()) {
+ sb.append(requiredIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(PolicyConstants.REQUIRES, sb.toString());
+ }
+
+ if (intent.getExcludedIntents() != null && intent.getExcludedIntents().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (Intent excludedIntents : intent.getExcludedIntents()) {
+ sb.append(excludedIntents.getName());
+ sb.append(" ");
+ }
+ writer.writeAttribute(PolicyConstants.EXCLUDES, sb.toString());
+ }
+
+ if (intent.getConstrainedTypes() != null && intent.getConstrainedTypes().size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ for (ExtensionType contrainedArtifact : intent.getConstrainedTypes()) {
+ sb.append(contrainedArtifact.getType().getPrefix());
+ sb.append(':').append(contrainedArtifact.getType().getLocalPart());
+ sb.append(" ");
+ }
+ writer.writeAttribute(CONSTRAINS, sb.toString());
+ }
+
+ if (intent.getDescription() != null && intent.getDescription().length() > 0) {
+ writer.writeStartElement(PolicyConstants.SCA11_NS, DESCRIPTION);
+ writer.writeCData(intent.getDescription());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ private void resolveContrainedTypes(Intent intent, ModelResolver resolver) throws ContributionResolveException {
+ Collection<ExtensionType> resolvedTypes = new HashSet<ExtensionType>();
+ for (ExtensionType extensionType : intent.getConstrainedTypes()) {
+ if (ExtensionType.BINDING_BASE.equals(extensionType.getType()) || ExtensionType.IMPLEMENTATION_BASE
+ .equals(extensionType.getType())) {
+ // HACK: Mark sca:binding and sca:implementation as resolved
+ extensionType.setUnresolved(false);
+ resolvedTypes.add(extensionType);
+ } else {
+ ExtensionType resolved = resolver.resolveModel(ExtensionType.class, extensionType);
+ if (!resolved.isUnresolved() || resolved != extensionType) {
+ resolvedTypes.add(resolved);
+ } else {
+ warn("ConstrainedTypeNotFound", intent, extensionType, intent);
+ }
+ }
+ }
+ intent.getConstrainedTypes().clear();
+ intent.getConstrainedTypes().addAll(resolvedTypes);
+ }
+
+ private void resolveProfileIntent(Intent intent, ModelResolver resolver) throws ContributionResolveException {
+ // FIXME: Need to check for cyclic references first i.e an A requiring B
+ // and then B requiring A...
+ if (intent != null && !intent.getRequiredIntents().isEmpty()) {
+ // resolve all required intents
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ for (Intent required : intent.getRequiredIntents()) {
+ if (required.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, required);
+ // At this point, when the required intent is not resolved, it does not mean
+ // its undeclared, chances are that their dependency are not resolved yet.
+ // Lets try to resolve them first.
+ if (resolved.isUnresolved()) {
+ if (((resolved).getRequiredIntents()).contains(intent)) {
+ error("CyclicReferenceFound", resolver, required, intent);
+ return;
+ }
+ }
+
+ if (!resolved.isUnresolved() || resolved != required) {
+ requiredIntents.add(resolved);
+ } else {
+ error("RequiredIntentNotFound", resolver, required, intent);
+ return;
+ //throw new ContributionResolveException("Required Intent - " + requiredIntent
+ //+ " not found for Intent " + policyIntent);
+ }
+ } else {
+ requiredIntents.add(required);
+ }
+ }
+ intent.getRequiredIntents().clear();
+ intent.getRequiredIntents().addAll(requiredIntents);
+ }
+ }
+
+ private void resolveQualifiedIntent(Intent qualifed, ModelResolver resolver) throws ContributionResolveException {
+ if (qualifed != null) {
+ //resolve the qualifiable intent
+ Intent parent = qualifed.getParent();
+ if (parent == null) {
+ return;
+ }
+ if (parent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, parent);
+ // At this point, when the qualifiable intent is not resolved, it does not mean
+ // its undeclared, chances are that their dependency are not resolved yet.
+ // Lets try to resolve them first.
+
+ if (!resolved.isUnresolved() || resolved != qualifed) {
+ qualifed.setParent(resolved);
+ } else {
+ error("QualifiableIntentNotFound", resolver, parent, qualifed);
+ //throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
+ //+ " not found for Intent " + policyIntent);
+ }
+ }
+ }
+ }
+
+ public void resolve(Intent intent, ModelResolver resolver) throws ContributionResolveException {
+ resolveProfileIntent(intent, resolver);
+ resolveExcludedIntents(intent, resolver);
+ resolveQualifiedIntent(intent, resolver);
+ resolveContrainedTypes(intent, resolver);
+ intent.setUnresolved(false);
+ }
+
+ public QName getArtifactType() {
+ return POLICY_INTENT_QNAME;
+ }
+
+ private void readConstrainedTypes(Intent policyIntent, XMLStreamReader reader) throws ContributionReadException {
+ String value = reader.getAttributeValue(null, CONSTRAINS);
+ if (value != null) {
+ List<ExtensionType> constrainedTypes = policyIntent.getConstrainedTypes();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ ExtensionType extensionType = policyFactory.createExtensionType();
+ extensionType.setType(qname);
+ constrainedTypes.add(extensionType);
+ }
+ }
+ }
+
+ private void readRequiredIntents(Intent intent, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, REQUIRES);
+ if (value != null) {
+ List<Intent> requiredIntents = intent.getRequiredIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent required = policyFactory.createIntent();
+ required.setName(qname);
+ required.setUnresolved(true);
+ requiredIntents.add(required);
+ }
+ }
+ }
+
+ private void readExcludedIntents(Intent intent, XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, EXCLUDES);
+ if (value != null) {
+ List<Intent> excludedIntents = intent.getExcludedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent excluded = policyFactory.createIntent();
+ excluded.setName(qname);
+ excluded.setUnresolved(true);
+ excludedIntents.add(excluded);
+ }
+ }
+ }
+
+ private void resolveExcludedIntents(Intent policyIntent, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (policyIntent != null) {
+ // resolve all excluded intents
+ List<Intent> excludedIntents = new ArrayList<Intent>();
+ for (Intent excludedIntent : policyIntent.getExcludedIntents()) {
+ if (excludedIntent.isUnresolved()) {
+ Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent);
+ if (!resolvedExcludedIntent.isUnresolved()) {
+ excludedIntents.add(resolvedExcludedIntent);
+ } else {
+ error("ExcludedIntentNotFound", resolver, excludedIntent, policyIntent);
+ return;
+ //throw new ContributionResolveException("Excluded Intent " + excludedIntent
+ //+ " not found for intent " + policyIntent);
+ }
+ } else {
+ excludedIntents.add(excludedIntent);
+ }
+ }
+ policyIntent.getExcludedIntents().clear();
+ policyIntent.getExcludedIntents().addAll(excludedIntents);
+ }
+ }
+
+ public Class<Intent> getModelType() {
+ return Intent.class;
+ }
+
+}
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
index 3f69df05d8..15a5546430 100644
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
+++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
@@ -28,7 +28,7 @@ import javax.xml.namespace.QName;
public interface PolicyConstants {
String WHITE_SPACE = " ";
String COLON = ":";
- String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200712";
String TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
String INTENT = "intent";
String POLICY_SET = "policySet";
@@ -41,8 +41,10 @@ public interface PolicyConstants {
String DESCRIPTION = "description";
String PROVIDES = "provides";
String APPLIES_TO = "appliesTo";
+ String ATTACH_TO = "attachTo";
String ALWAYS_APPLIES_TO = "alwaysAppliesTo";
String QUALIFIER = ".";
+ String INTENT_QUALIFIER = "qualifier";
String INTENT_MAP_QUALIFIER = "qualifier";
String REQUIRES = "requires";
String EXCLUDES = "excludes";
@@ -50,21 +52,22 @@ public interface PolicyConstants {
String ALWAYS_PROVIDES = "alwaysProvides";
String MAY_PROVIDE = "mayProvide";
- String TYPE = "type";
+ String INTENT_TYPE = "intentType";
String IMPLEMENTATION_TYPE = "implementationType";
String BINDING_TYPE = "bindingType";
- QName IMPLEMENTATION_TYPE_QNAME = new QName(SCA10_NS, IMPLEMENTATION_TYPE);
- QName BINDING_TYPE_QNAME = new QName(SCA10_NS, BINDING_TYPE);
+ QName IMPLEMENTATION_TYPE_QNAME = new QName(SCA11_NS, IMPLEMENTATION_TYPE);
+ QName BINDING_TYPE_QNAME = new QName(SCA11_NS, BINDING_TYPE);
String BINDING = "binding";
String IMPLEMENTATION = "implementation";
- QName POLICY_INTENT_QNAME = new QName(SCA10_NS, INTENT);
- QName POLICY_SET_QNAME = new QName(SCA10_NS, POLICY_SET);
- QName POLICY_INTENT_MAP_QNAME = new QName(SCA10_NS, INTENT_MAP);
- QName SCA_DEFINITIONS_QNAME = new QName(SCA10_NS, SCA_DEFINITIONS);
- QName DESCRIPTION_QNAME = new QName(SCA10_NS, DESCRIPTION);
- QName POLICY_INTENT_MAP_QUALIFIER_QNAME = new QName(SCA10_NS, INTENT_MAP_QUALIFIER);
- QName POLICY_SET_REFERENCE_QNAME = new QName(SCA10_NS, POLICY_SET_REFERENCE);
+ QName POLICY_INTENT_QNAME = new QName(SCA11_NS, INTENT);
+ QName POLICY_SET_QNAME = new QName(SCA11_NS, POLICY_SET);
+ QName POLICY_INTENT_MAP_QNAME = new QName(SCA11_NS, INTENT_MAP);
+ QName SCA_DEFINITIONS_QNAME = new QName(SCA11_NS, SCA_DEFINITIONS);
+ QName DESCRIPTION_QNAME = new QName(SCA11_NS, DESCRIPTION);
+ QName POLICY_INTENT_MAP_QUALIFIER_QNAME = new QName(SCA11_NS, INTENT_MAP_QUALIFIER);
+ QName POLICY_SET_REFERENCE_QNAME = new QName(SCA11_NS, POLICY_SET_REFERENCE);
+ QName INTENT_QUALIFIER_QNAME = new QName(SCA11_NS, INTENT_QUALIFIER);
String QUALIFIED_INTENT_CONSTRAINS_ERROR = " - Qualified Intents must not specify 'constrains' attribute";
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
deleted file mode 100644
index 03cd635596..0000000000
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.xml;
-
-import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
-import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
-import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.Problem;
-import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
-
-/**
- * Processor for handling XML models of PolicyIntent definitions
- *
- * @version $Rev$ $Date$
- */
-abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactProcessor implements
- StAXArtifactProcessor<T>, PolicyConstants {
-
- private PolicyFactory policyFactory;
- private Monitor monitor;
-
- public PolicyIntentProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
- this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
- this.monitor = monitor;
- }
-
- public PolicyIntentProcessor(PolicyFactory policyFactory, Monitor monitor) {
- this.policyFactory = policyFactory;
- this.monitor = monitor;
- }
-
- /**
- * Report a error.
- *
- * @param problems
- * @param message
- * @param model
- */
- private void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem =
- monitor.createProblem(this.getClass().getName(),
- "policy-xml-validation-messages",
- Severity.ERROR,
- model,
- message,
- (Object[])messageParameters);
- monitor.problem(problem);
- }
- }
-
- public T read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
- Intent policyIntent = null;
- String policyIntentName = reader.getAttributeValue(null, NAME);
- if (policyIntentName == null) {
- error("IntentNameMissing", reader);
- return (T)policyIntent;
- }
-
- // Read an <sca:intent>
- if (reader.getAttributeValue(null, REQUIRES) != null) {
- policyIntent = policyFactory.createProfileIntent();
- } else if (policyIntentName != null && policyIntentName.indexOf(QUALIFIER) != -1) {
- policyIntent = policyFactory.createQualifiedIntent();
-
- int qualifierIndex = policyIntentName.lastIndexOf(QUALIFIER);
- Intent qualifiableIntent = policyFactory.createIntent();
- qualifiableIntent.setUnresolved(true);
- qualifiableIntent.setName(new QName(policyIntentName.substring(0, qualifierIndex)));
-
- ((QualifiedIntent)policyIntent).setQualifiableIntent(qualifiableIntent);
- } else {
- policyIntent = policyFactory.createIntent();
- }
- policyIntent.setName(new QName(policyIntentName));
-
- if (policyIntent instanceof ProfileIntent) {
- readRequiredIntents((ProfileIntent)policyIntent, reader);
- } else {
- readExcludedIntents(policyIntent, reader);
- }
-
- readConstrainedArtifacts(policyIntent, reader);
-
- int event = reader.getEventType();
- QName name = null;
- while (reader.hasNext()) {
- event = reader.getEventType();
- switch (event) {
- case START_ELEMENT: {
- name = reader.getName();
- if (DESCRIPTION_QNAME.equals(name)) {
- policyIntent.setDescription(reader.getElementText());
- }
- break;
- }
- }
- if (event == END_ELEMENT && POLICY_INTENT_QNAME.equals(reader.getName())) {
- break;
- }
-
- //Read the next element
- if (reader.hasNext()) {
- reader.next();
- }
- }
- return (T)policyIntent;
- }
-
- public void write(T policyIntent, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
- // Write an <sca:intent>
- writer.writeStartElement(PolicyConstants.SCA10_NS, INTENT);
- writer.writeNamespace(policyIntent.getName().getPrefix(), policyIntent.getName().getNamespaceURI());
- writer.writeAttribute(PolicyConstants.NAME, policyIntent.getName().getPrefix() + COLON
- + policyIntent.getName().getLocalPart());
- if (policyIntent instanceof ProfileIntent) {
- ProfileIntent profileIntent = (ProfileIntent)policyIntent;
- if (profileIntent.getRequiredIntents() != null && profileIntent.getRequiredIntents().size() > 0) {
- StringBuffer sb = new StringBuffer();
- for (Intent requiredIntents : profileIntent.getRequiredIntents()) {
- sb.append(requiredIntents.getName());
- sb.append(" ");
- }
- writer.writeAttribute(PolicyConstants.REQUIRES, sb.toString());
- }
- } else {
- if (policyIntent.getExcludedIntents() != null && policyIntent.getExcludedIntents().size() > 0) {
- StringBuffer sb = new StringBuffer();
- for (Intent excludedIntents : policyIntent.getExcludedIntents()) {
- sb.append(excludedIntents.getName());
- sb.append(" ");
- }
- writer.writeAttribute(PolicyConstants.EXCLUDES, sb.toString());
- }
- }
-
- if (!(policyIntent instanceof QualifiedIntent)) {
- if (policyIntent.getConstrains() != null && policyIntent.getConstrains().size() > 0) {
- StringBuffer sb = new StringBuffer();
- for (QName contrainedArtifact : policyIntent.getConstrains()) {
- sb.append(contrainedArtifact.toString());
- sb.append(" ");
- }
- writer.writeAttribute(CONSTRAINS, sb.toString());
- } else {
- error("ContrainsAttributeMissing", policyIntent, policyIntent.getName());
- //throw new ContributionWriteException("Contrains attribute missing from " +
- //"Policy Intent Definition" + policyIntent.getName());
- }
- }
-
- if (policyIntent.getDescription() != null && policyIntent.getDescription().length() > 0) {
- writer.writeStartElement(PolicyConstants.SCA10_NS, DESCRIPTION);
- writer.writeCData(policyIntent.getDescription());
- writer.writeEndElement();
- }
-
- writer.writeEndElement();
- }
-
- //FIXME This method is never used
- // private Intent resolveRequiredIntents(ProfileIntent policyIntent, ModelResolver resolver) throws ContributionResolveException {
- // boolean isUnresolved = false;
- // //FIXME: Need to check for cyclic references first i.e an A requiring B and then B requiring A...
- // if (policyIntent != null && policyIntent.isUnresolved()) {
- //
- // //resolve all required intents
- // List<Intent> requiredIntents = new ArrayList<Intent>();
- // for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
- // if ( requiredIntent.isUnresolved() ) {
- // //policyIntent.getRequiredIntents().remove(requiredIntent);
- // requiredIntent = resolver.resolveModel(Intent.class, requiredIntent);
- // requiredIntents.add(requiredIntent);
- // if (requiredIntent.isUnresolved()) {
- // isUnresolved = true;
- // }
- // }
- // }
- // policyIntent.getRequiredIntents().clear();
- // policyIntent.getRequiredIntents().addAll(requiredIntents);
- // }
- // policyIntent.setUnresolved(isUnresolved);
- //
- // return policyIntent;
- // }
-
- //FIXME This method is never used
- // private Intent resolveQualifiableIntent(QualifiedIntent policyIntent, ModelResolver resolver) throws ContributionResolveException {
- // boolean isUnresolved = false;
- //
- // if (policyIntent != null && policyIntent.isUnresolved()) {
- // //resolve the qualifiable intent
- // Intent qualifiableIntent =
- // resolver.resolveModel(Intent.class, policyIntent.getQualifiableIntent());
- // policyIntent.setQualifiableIntent(qualifiableIntent);
- // isUnresolved = qualifiableIntent.isUnresolved();
- // }
- // policyIntent.setUnresolved(isUnresolved);
- //
- // return policyIntent;
- // }
-
- private void resolveContrainedArtifacts(Intent policyIntent, ModelResolver resolver) {
- //FIXME : need to figure out this resolution.
- policyIntent.setUnresolved(false);
- }
-
- private void resolveProfileIntent(ProfileIntent policyIntent, ModelResolver resolver)
- throws ContributionResolveException {
- // FIXME: Need to check for cyclic references first i.e an A requiring B
- // and then B requiring A...
- if (policyIntent != null) {
- // resolve all required intents
- List<Intent> requiredIntents = new ArrayList<Intent>();
- for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
- if (requiredIntent.isUnresolved()) {
- Intent resolvedRequiredIntent = resolver.resolveModel(Intent.class, requiredIntent);
- // At this point, when the required intent is not resolved, it does not mean
- // its undeclared, chances are that their dependency are not resolved yet.
- // Lets try to resolve them first.
- if (resolvedRequiredIntent.isUnresolved()) {
- if (resolvedRequiredIntent instanceof ProfileIntent) {
- if ((((ProfileIntent)resolvedRequiredIntent).getRequiredIntents()).contains(policyIntent)) {
- error("CyclicReferenceFound", resolver, requiredIntent, policyIntent);
- return;
- }
- resolveDependent(resolvedRequiredIntent, resolver);
- }
- }
-
- if (!resolvedRequiredIntent.isUnresolved()) {
- requiredIntents.add(resolvedRequiredIntent);
- } else {
- error("RequiredIntentNotFound", resolver, requiredIntent, policyIntent);
- return;
- //throw new ContributionResolveException("Required Intent - " + requiredIntent
- //+ " not found for ProfileIntent " + policyIntent);
- }
- } else {
- requiredIntents.add(requiredIntent);
- }
- }
- policyIntent.getRequiredIntents().clear();
- policyIntent.getRequiredIntents().addAll(requiredIntents);
- }
- }
-
- private void resolveQualifiedIntent(QualifiedIntent policyIntent, ModelResolver resolver)
- throws ContributionResolveException {
- if (policyIntent != null) {
- //resolve the qualifiable intent
- Intent qualifiableIntent = policyIntent.getQualifiableIntent();
- if (qualifiableIntent.isUnresolved()) {
- Intent resolvedQualifiableIntent = resolver.resolveModel(Intent.class, qualifiableIntent);
- // At this point, when the qualifiable intent is not resolved, it does not mean
- // its undeclared, chances are that their dependency are not resolved yet.
- // Lets try to resolve them first.
- if (resolvedQualifiableIntent.isUnresolved()) {
- if (resolvedQualifiableIntent instanceof QualifiedIntent) {
- resolveDependent(resolvedQualifiableIntent, resolver);
- }
- }
-
- if (!resolvedQualifiableIntent.isUnresolved()) {
- policyIntent.setQualifiableIntent(resolvedQualifiableIntent);
- } else {
- error("QualifiableIntentNotFound", resolver, qualifiableIntent, policyIntent);
- //throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
- //+ " not found for QualifiedIntent " + policyIntent);
- }
- }
- }
- }
-
- public void resolveDependent(Intent policyIntent, ModelResolver resolver) throws ContributionResolveException {
- if (policyIntent instanceof ProfileIntent)
- resolveProfileIntent((ProfileIntent)policyIntent, resolver);
-
- if (policyIntent instanceof QualifiedIntent)
- resolveQualifiedIntent((QualifiedIntent)policyIntent, resolver);
-
- resolveContrainedArtifacts(policyIntent, resolver);
- }
-
- public void resolve(T policyIntent, ModelResolver resolver) throws ContributionResolveException {
- if (policyIntent instanceof ProfileIntent) {
- resolveProfileIntent((ProfileIntent)policyIntent, resolver);
- } else {
- resolveExcludedIntents(policyIntent, resolver);
- }
-
- if (policyIntent instanceof QualifiedIntent) {
- resolveQualifiedIntent((QualifiedIntent)policyIntent, resolver);
- }
-
- resolveContrainedArtifacts(policyIntent, resolver);
-
- /* This is too late in the processing
- if ( !policyIntent.isUnresolved() ) {
- resolver.addModel(policyIntent);
- }
- */
- }
-
- public QName getArtifactType() {
- return POLICY_INTENT_QNAME;
- }
-
- private void readConstrainedArtifacts(Intent policyIntent, XMLStreamReader reader) throws ContributionReadException {
- String value = reader.getAttributeValue(null, CONSTRAINS);
- if (policyIntent instanceof QualifiedIntent && value != null) {
- error("ErrorInPolicyIntentDefinition",
- policyIntent,
- policyIntent.getName(),
- QUALIFIED_INTENT_CONSTRAINS_ERROR);
- //String errorMsg = "Error in PolicyIntent Definition - " + policyIntent.getName() + QUALIFIED_INTENT_CONSTRAINS_ERROR;
- //throw new ContributionReadException(errorMsg);
- } else {
- if (value != null) {
- List<QName> constrainedArtifacts = policyIntent.getConstrains();
- for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
- QName qname = getQNameValue(reader, tokens.nextToken());
- constrainedArtifacts.add(qname);
- }
- }
- }
- }
-
- private void readRequiredIntents(ProfileIntent policyIntent, XMLStreamReader reader) {
- String value = reader.getAttributeValue(null, REQUIRES);
- if (value != null) {
- List<Intent> requiredIntents = policyIntent.getRequiredIntents();
- for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
- QName qname = getQNameValue(reader, tokens.nextToken());
- Intent intent = policyFactory.createIntent();
- intent.setName(qname);
- intent.setUnresolved(true);
- requiredIntents.add(intent);
- }
- }
- }
-
- private void readExcludedIntents(Intent policyIntent, XMLStreamReader reader) {
- String value = reader.getAttributeValue(null, "excludes");
- if (value != null) {
- List<Intent> excludedIntents = policyIntent.getExcludedIntents();
- for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
- QName qname = getQNameValue(reader, tokens.nextToken());
- Intent intent = policyFactory.createIntent();
- intent.setName(qname);
- intent.setUnresolved(true);
- excludedIntents.add(intent);
- }
- }
- }
-
- private void resolveExcludedIntents(Intent policyIntent, ModelResolver resolver)
- throws ContributionResolveException {
- if (policyIntent != null) {
- // resolve all excluded intents
- List<Intent> excludedIntents = new ArrayList<Intent>();
- for (Intent excludedIntent : policyIntent.getExcludedIntents()) {
- if (excludedIntent.isUnresolved()) {
- Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent);
- if (!resolvedExcludedIntent.isUnresolved()) {
- excludedIntents.add(resolvedExcludedIntent);
- } else {
- error("ExcludedIntentNotFound", resolver, excludedIntent, policyIntent);
- return;
- //throw new ContributionResolveException("Excluded Intent " + excludedIntent
- //+ " not found for intent " + policyIntent);
- }
- } else {
- excludedIntents.add(excludedIntent);
- }
- }
- policyIntent.getExcludedIntents().clear();
- policyIntent.getExcludedIntents().addAll(excludedIntents);
- }
- }
-
-}
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
index 93a8433d65..955788ce8f 100644
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
+++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
@@ -23,9 +23,7 @@ import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
import java.util.ArrayList;
-import java.util.Hashtable;
import java.util.List;
-import java.util.Map;
import java.util.StringTokenizer;
import javax.xml.namespace.QName;
@@ -47,8 +45,11 @@ import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.Qualifier;
/**
* Processor for handling XML models of PolicySet definitions
@@ -134,7 +135,6 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
policySet = policyFactory.createPolicySet();
policySet.setName(new QName(policySetName));
- String alwaysAppliesTo = reader.getAttributeValue(TUSCANY_NS, ALWAYS_APPLIES_TO);
//TODO: with 1.0 version of specs the applies to xpath is given related to the immediate
//parent whereas the runtime evaluates the xpath aginst the composite element. What the runtime
@@ -144,12 +144,7 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
appliesTo = "//" + appliesTo;
}
- if (alwaysAppliesTo != null && !alwaysAppliesTo.startsWith("/")) {
- alwaysAppliesTo = "//" + alwaysAppliesTo;
- }
-
policySet.setAppliesTo(appliesTo);
- policySet.setAlwaysAppliesTo(alwaysAppliesTo);
XPath path = xpathFactory.newXPath();
path.setNamespaceContext(reader.getNamespaceContext());
@@ -157,9 +152,6 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
if (appliesTo != null) {
policySet.setAppliesToXPathExpression(path.compile(appliesTo));
}
- if (alwaysAppliesTo != null) {
- policySet.setAlwaysAppliesToXPathExpression(path.compile(alwaysAppliesTo));
- }
} catch (XPathExpressionException e) {
ContributionReadException ce = new ContributionReadException(e);
error("ContributionReadException", policySet, ce);
@@ -200,13 +192,16 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
error("PolicySetReferenceNameMissing", reader, policySetName);
}
} /*else if ( WS_POLICY_QNAME.equals(name) ) {
- OMElement policyElement = loadElement(reader);
- org.apache.neethi.Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
- policySet.getPolicies().add(wsPolicy);
- } */else {
+ OMElement policyElement = loadElement(reader);
+ org.apache.neethi.Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
+ policySet.getPolicies().add(wsPolicy);
+ } */else {
Object extension = extensionProcessor.read(reader);
if (extension != null) {
- policySet.getPolicies().add(extension);
+ PolicyExpression exp = policyFactory.createPolicyExpression();
+ exp.setName(name);
+ exp.setPolicy(extension);
+ policySet.getPolicies().add(exp);
}
}
break;
@@ -229,16 +224,20 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
public void readIntentMap(XMLStreamReader reader, PolicySet policySet, Intent mappedIntent)
throws ContributionReadException {
QName name = reader.getName();
- Map<Intent, List<Object>> mappedPolicies = policySet.getMappedPolicies();
if (POLICY_INTENT_MAP_QNAME.equals(name)) {
- //Intent mappedIntent = policyFactory.createIntent();
- //mappedIntent.setName(getQName(reader, PROVIDES));
- String defaultQualifier = getString(reader, DEFAULT);
+
+ IntentMap intentMap = policyFactory.createIntentMap();
+ QName intentName = getQName(reader, INTENT_MAP);
+ intentMap.setProvidedIntent(mappedIntent);
+
+ policySet.getIntentMaps().add(intentMap);
String qualifierName = null;
String qualfiedIntentName = null;
Intent qualifiedIntent = null;
+ Qualifier qualifier = null;
+
int event = reader.getEventType();
try {
reader.next();
@@ -255,6 +254,10 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
qualifiedIntent = policyFactory.createIntent();
qualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(),
qualfiedIntentName));
+ qualifier = policyFactory.createQualifier();
+ qualifier.setIntent(qualifiedIntent);
+ intentMap.getQualifiers().add(qualifier);
+
} else {
error("QualifierNameMissing", reader, policySet.getName());
}
@@ -272,55 +275,13 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
//providedIntent + " does not match parent qualifier " + qualifierName +
//" in policyset - " + policySet);
}
- }/* else if ( WS_POLICY_QNAME.equals(name) ) {
- OMElement policyElement = loadElement(reader);
- Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
- policySet.getPolicies().add(wsPolicy);
-
- List<Object> policyList = mappedPolicies.get(qualifiedIntent);
- if ( policyList == null ) {
- policyList = new ArrayList<Object>();
- mappedPolicies.put(qualifiedIntent, policyList);
-
- if (qualifierName.equals(defaultQualifier)) {
- mappedPolicies.put(mappedIntent, policyList);
- }
- }
- policyList.add((Policy)wsPolicy);
- }*/else {
+ } else {
Object extension = extensionProcessor.read(reader);
- if (extension != null && qualifiedIntent != null) {
- List<Object> policyList = mappedPolicies.get(qualifiedIntent);
- if (policyList == null) {
- policyList = new ArrayList<Object>();
- mappedPolicies.put(qualifiedIntent, policyList);
-
- if (qualifierName.equals(defaultQualifier)) {
- mappedPolicies.put(mappedIntent, policyList);
- }
- }
- policyList.add(extension);
- }
- }
- break;
- }
- case END_ELEMENT: {
- if (POLICY_INTENT_MAP_QNAME.equals(reader.getName())) {
- if (defaultQualifier != null) {
- String qualifiedIntentName =
- mappedIntent.getName().getLocalPart() + QUALIFIER + defaultQualifier;
- Intent defaultQualifiedIntent = policyFactory.createIntent();
- defaultQualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(),
- qualifiedIntentName));
- List<Object> policyList = mappedPolicies.get(defaultQualifiedIntent);
- if (policyList != null) {
- mappedPolicies.put(mappedIntent, policyList);
- } else {
- error("UnableToMapPolicies", mappedPolicies, mappedIntent, policySet);
- //throw new ContributionReadException("Unable to map policies for default qualifier in IntentMap for - " +
- //mappedIntent + " in policy set - " + policySet);
- }
- defaultQualifier = null;
+ if (extension != null && qualifier != null) {
+ PolicyExpression exp = policyFactory.createPolicyExpression();
+ exp.setName(name);
+ exp.setPolicy(extension);
+ qualifier.getPolicies().add(exp);
}
}
break;
@@ -346,11 +307,11 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
XMLStreamException {
// Write an <sca:policySet>
- writer.writeStartElement(SCA10_NS, POLICY_SET);
+ writer.writeStartElement(SCA11_NS, POLICY_SET);
writer.writeNamespace(policySet.getName().getPrefix(), policySet.getName().getNamespaceURI());
writer.writeAttribute(NAME, policySet.getName().getPrefix() + COLON + policySet.getName().getLocalPart());
writer.writeAttribute(APPLIES_TO, policySet.getAppliesTo());
- writer.writeAttribute(TUSCANY_NS, ALWAYS_APPLIES_TO, policySet.getAlwaysAppliesTo());
+ writer.writeAttribute(ATTACH_TO, policySet.getAttachTo());
writeProvidedIntents(policySet, writer);
@@ -371,16 +332,28 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
}
private void writeProvidedIntents(PolicySet policySet, XMLStreamWriter writer) throws XMLStreamException {
- if (policySet.getProvidedIntents() != null && policySet.getProvidedIntents().size() > 0) {
+ if (!policySet.getProvidedIntents().isEmpty()) {
StringBuffer sb = new StringBuffer();
for (Intent providedIntents : policySet.getProvidedIntents()) {
- sb.append(providedIntents.getName());
+ sb.append(getQualifiedName(providedIntents.getName(), writer));
sb.append(" ");
}
+ // Remove the last space
+ sb.deleteCharAt(sb.length() - 1);
writer.writeAttribute(PolicyConstants.PROVIDES, sb.toString());
}
}
+ private String getQualifiedName(QName name, XMLStreamWriter writer) throws XMLStreamException {
+ String local = name.getLocalPart();
+ String prefix = writer.getPrefix(name.getNamespaceURI());
+ if (prefix != null && prefix.length() > 0) {
+ return prefix + ':' + local;
+ } else {
+ return local;
+ }
+ }
+
private void resolvePolicies(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
boolean unresolved = false;
if (policySet != null) {
@@ -409,9 +382,9 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
List<Intent> providedIntents = new ArrayList<Intent>();
for (Intent providedIntent : policySet.getProvidedIntents()) {
if (providedIntent.isUnresolved()) {
- Intent resolvedProvidedIntent = resolver.resolveModel(Intent.class, providedIntent);
- if (!resolvedProvidedIntent.isUnresolved()) {
- providedIntents.add(resolvedProvidedIntent);
+ Intent resolved = resolver.resolveModel(Intent.class, providedIntent);
+ if (!resolved.isUnresolved() || resolved != providedIntent) {
+ providedIntents.add(resolved);
} else {
error("ProvidedIntentNotFound", policySet, providedIntent, policySet);
return;
@@ -429,26 +402,38 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
private void resolveIntentsInMappedPolicies(PolicySet policySet, ModelResolver resolver)
throws ContributionResolveException {
- Map<Intent, List<Object>> mappedPolicies = new Hashtable<Intent, List<Object>>();
- for (Map.Entry<Intent, List<Object>> entry : policySet.getMappedPolicies().entrySet()) {
- Intent mappedIntent = entry.getKey();
- if (mappedIntent.isUnresolved()) {
- Intent resolvedMappedIntent = resolver.resolveModel(Intent.class, mappedIntent);
- if (!resolvedMappedIntent.isUnresolved()) {
- mappedPolicies.put(resolvedMappedIntent, entry.getValue());
+ for (IntentMap intentMap : policySet.getIntentMaps()) {
+ Intent intent = intentMap.getProvidedIntent();
+ if (intent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, intent);
+ if (!resolved.isUnresolved() || resolved != intent) {
+ intentMap.setProvidedIntent(resolved);
} else {
- error("MappedIntentNotFound", policySet, mappedIntent, policySet);
+ error("MappedIntentNotFound", policySet, intent, policySet);
return;
//throw new ContributionResolveException("Mapped Intent - " + mappedIntent
//+ " not found for PolicySet " + policySet);
}
- } else {
- mappedPolicies.put(mappedIntent, entry.getValue());
+ }
+ for (Qualifier qualifier : intentMap.getQualifiers()) {
+ intent = qualifier.getIntent();
+ if (intent.isUnresolved()) {
+ Intent resolved = resolver.resolveModel(Intent.class, intent);
+ if (!resolved.isUnresolved() || resolved != intent) {
+ qualifier.setIntent(resolved);
+ } else {
+ error("MappedIntentNotFound", policySet, intent, policySet);
+ return;
+ //throw new ContributionResolveException("Mapped Intent - " + mappedIntent
+ //+ " not found for PolicySet " + policySet);
+ }
+ }
+ for (PolicyExpression exp : qualifier.getPolicies()) {
+ // FIXME: How to resolve the policies?
+ }
}
}
- policySet.getMappedPolicies().clear();
- policySet.getMappedPolicies().putAll(mappedPolicies);
}
private void resolveReferredPolicySets(PolicySet policySet, ModelResolver resolver)
@@ -457,9 +442,9 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
if (referredPolicySet.isUnresolved()) {
- PolicySet resolvedReferredPolicySet = resolver.resolveModel(PolicySet.class, referredPolicySet);
- if (!resolvedReferredPolicySet.isUnresolved()) {
- referredPolicySets.add(resolvedReferredPolicySet);
+ PolicySet resolved = resolver.resolveModel(PolicySet.class, referredPolicySet);
+ if (!resolved.isUnresolved() || resolved != referredPolicySet) {
+ referredPolicySets.add(resolved);
} else {
error("ReferredPolicySetNotFound", policySet, referredPolicySet, policySet);
return;
@@ -479,7 +464,7 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet);
}
policySet.getPolicies().addAll(referredPolicySet.getPolicies());
- policySet.getMappedPolicies().putAll(referredPolicySet.getMappedPolicies());
+ policySet.getIntentMaps().addAll(referredPolicySet.getIntentMaps());
}
public void resolve(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
@@ -499,5 +484,7 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
resolver.addModel(policySet);
}*/
}
+
+ policySet.setUnresolved(false);
}
}
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ProfileIntentProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ProfileIntentProcessor.java
deleted file mode 100644
index d0b19af129..0000000000
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ProfileIntentProcessor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.xml;
-
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-
-/**
- * Processor for handling XML models of PolicyIntent definitions that are ProfileIntents
- *
- * @version $Rev$ $Date$
- */
-public class ProfileIntentProcessor extends PolicyIntentProcessor<ProfileIntent> {
-
- public ProfileIntentProcessor(PolicyFactory policyFactory, Monitor monitor) {
- super(policyFactory, monitor);
- }
-
- public ProfileIntentProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
- super(modelFactories, monitor);
- }
-
- public Class<ProfileIntent> getModelType() {
- return ProfileIntent.class;
- }
-}
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/QualifiedIntentProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/QualifiedIntentProcessor.java
deleted file mode 100644
index 50d8cb06e2..0000000000
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/QualifiedIntentProcessor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.xml;
-
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.PolicyFactory;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
-
-/**
- * Processor for handling XML models of PolicyIntent definitions that are QualifiedIntents
- *
- * @version $Rev$ $Date$
- */
-public class QualifiedIntentProcessor extends PolicyIntentProcessor<QualifiedIntent> {
-
- public QualifiedIntentProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
- super(modelFactories, monitor);
- }
-
- public QualifiedIntentProcessor(PolicyFactory policyFactory, Monitor monitor) {
- super(policyFactory, monitor);
- }
-
- public Class<QualifiedIntent> getModelType() {
- return QualifiedIntent.class;
- }
-}
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SimpleIntentProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SimpleIntentProcessor.java
deleted file mode 100644
index e928ead4c6..0000000000
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SimpleIntentProcessor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.xml;
-
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicyFactory;
-
-/**
- * Processor for handling XML models of PolicyIntent definitions
- *
- * @version $Rev$ $Date$
- */
-public class SimpleIntentProcessor extends PolicyIntentProcessor<Intent> {
-
- public SimpleIntentProcessor(PolicyFactory policyFactory, Monitor monitor) {
- super(policyFactory, monitor);
- }
-
- public SimpleIntentProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
- super(modelFactories, monitor);
- }
-
- public Class<Intent> getModelType() {
- return Intent.class;
- }
-}
diff --git a/java/sca/modules/policy-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/java/sca/modules/policy-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
index c41a0cd01f..21d50ec544 100644
--- a/java/sca/modules/policy-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
+++ b/java/sca/modules/policy-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -16,9 +16,7 @@
# under the License.
# Implementation class for the artifact processor extension
-org.apache.tuscany.sca.policy.xml.BindingTypeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#bindingType,model=org.apache.tuscany.sca.policy.IntentAttachPointType
-org.apache.tuscany.sca.policy.xml.ImplementationTypeProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#implementationType,model=org.apache.tuscany.sca.policy.IntentAttachPointType
-org.apache.tuscany.sca.policy.xml.SimpleIntentProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#intent,model=org.apache.tuscany.sca.policy.Intent
-org.apache.tuscany.sca.policy.xml.PolicySetProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#policySet,model=org.apache.tuscany.sca.policy.PolicySet
-org.apache.tuscany.sca.policy.xml.ProfileIntentProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#intent,model=org.apache.tuscany.sca.policy.ProfileIntent
-org.apache.tuscany.sca.policy.xml.QualifiedIntentProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#intent,model=org.apache.tuscany.sca.policy.QualifiedIntent
+org.apache.tuscany.sca.policy.xml.BindingTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200712#bindingType,model=org.apache.tuscany.sca.policy.BindingType
+org.apache.tuscany.sca.policy.xml.ImplementationTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200712#implementationType,model=org.apache.tuscany.sca.policy.ImplementationType
+org.apache.tuscany.sca.policy.xml.IntentProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200712#intent,model=org.apache.tuscany.sca.policy.Intent
+org.apache.tuscany.sca.policy.xml.PolicySetProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200712#policySet,model=org.apache.tuscany.sca.policy.PolicySet
diff --git a/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties b/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties
index 40107bb11e..d092b5959a 100644
--- a/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties
+++ b/java/sca/modules/policy-xml/src/main/resources/policy-xml-validation-messages.properties
@@ -30,7 +30,7 @@ QualifiableIntentNotFound = Qualifiable Intent - {0} not found for QualifiedInte
ErrorInPolicyIntentDefinition = Error in PolicyIntent Definition - {0} {1}
ExcludedIntentNotFound = Excluded Intent {0} not found for intent {1}
UnrecognizedIntentAttachPointType = Unrecognized IntentAttachPointType - {0}
-RequiredAttributeMissing = Required attribute {0} missing from BindingType Definition
+RequiredAttributeMissing = Required attribute {0} missing from extension type definition
AlwaysProvidedIntentNotFound = Always Provided Intent - {0} not found for ExtensionType {1}
MayProvideIntentNotFound = May Provide Intent - {0} not found for ExtensionType {1}
ContributionReadException = ContributionReadException occurred due to: {0}
@@ -41,4 +41,5 @@ PolicySetNameMissing = Required attribute "name" missing for PolicySet Definitio
PolicySetAppliesToMissing = Required attribute "appliesTo" missing for PolicySet Definition
IntentMapProvidesMissing = Required attribute "provides" missing for IntentMap in PolicySet : {0}
QualifierNameMissing = Required attribute "name" missing for qualifier definition in PolicySet : {0}
+ConstrainedTypeNotFound = Unable to find the extension type {0} constrained by intent: {1}
diff --git a/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java b/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
index 72235812a1..0e35d31f00 100644
--- a/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
+++ b/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
@@ -47,12 +47,13 @@ import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.IntentMap;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
-import org.apache.tuscany.sca.policy.impl.BindingTypeImpl;
+import org.apache.tuscany.sca.policy.Qualifier;
import org.apache.tuscany.sca.policy.impl.ImplementationTypeImpl;
import org.junit.Before;
import org.junit.Test;
@@ -68,13 +69,14 @@ public class ReadDocumentTestCase {
private StAXArtifactProcessor<Object> staxProcessor;
private Monitor monitor;
- private static final QName elementToProcess = new QName("http://www.osoa.org/xmlns/sca/1.0", "implementationType");
+ private static final QName elementToProcess =
+ new QName("http://docs.oasis-open.org/ns/opencsa/sca/200712", "implementationType");
private Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
private Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
- private Map<QName, IntentAttachPointType> bindingTypesTable = new Hashtable<QName, IntentAttachPointType>();
- private Map<QName, IntentAttachPointType> implTypesTable = new Hashtable<QName, IntentAttachPointType>();
- private static final String scaNamespace = "http://www.osoa.org/xmlns/sca/1.0";
+ private Map<QName, BindingType> bindingTypesTable = new Hashtable<QName, BindingType>();
+ private Map<QName, ImplementationType> implTypesTable = new Hashtable<QName, ImplementationType>();
+ private static final String scaNamespace = "http://docs.oasis-open.org/ns/opencsa/sca/200712";
private static final String namespace = "http://test";
private static final QName confidentiality = new QName(namespace, "confidentiality");
@@ -131,18 +133,18 @@ public class ReadDocumentTestCase {
} else if (artifact instanceof Intent) {
Intent intent = (Intent)artifact;
intent.setName(new QName(namespace, intent.getName().getLocalPart()));
- if (intent instanceof QualifiedIntent) {
- ((QualifiedIntent)intent).getQualifiableIntent()
- .setName(new QName(namespace, ((QualifiedIntent)intent).getQualifiableIntent()
- .getName().getLocalPart()));
- }
intentTable.put(intent.getName(), intent);
- } else if (artifact instanceof BindingTypeImpl) {
- IntentAttachPointType bindingType = (IntentAttachPointType)artifact;
- bindingTypesTable.put(bindingType.getName(), bindingType);
+ for (Intent i : intent.getQualifiedIntents()) {
+ i.setName(new QName(namespace, i.getName().getLocalPart()));
+ intentTable.put(i.getName(), i);
+ resolver.addModel(i);
+ }
+ } else if (artifact instanceof BindingType) {
+ BindingType bindingType = (BindingType)artifact;
+ bindingTypesTable.put(bindingType.getType(), bindingType);
} else if (artifact instanceof ImplementationTypeImpl) {
- IntentAttachPointType implType = (IntentAttachPointType)artifact;
- implTypesTable.put(implType.getName(), implType);
+ ImplementationType implType = (ImplementationType)artifact;
+ implTypesTable.put(implType.getType(), implType);
}
if (artifact != null) {
@@ -173,25 +175,35 @@ public class ReadDocumentTestCase {
assertTrue(policySetTable.get(secureReliablePolicy).getPolicies().size() == 2);
assertNotNull(policySetTable.get(secureMessagingPolicies));
- assertEquals(policySetTable.get(secureMessagingPolicies).getMappedPolicies().size(), 3);
+ assertEquals(2, policySetTable.get(secureMessagingPolicies).getIntentMaps().get(0).getQualifiers().get(0).getPolicies().size());
assertEquals(bindingTypesTable.size(), 1);
assertNotNull(bindingTypesTable.get(wsBinding));
assertEquals(implTypesTable.size(), 1);
assertNotNull(implTypesTable.get(javaImpl));
}
+
+ private int getNumberOfQualifiedPolicies(PolicySet policySet) {
+ int count = 0;
+ for(IntentMap intentMap: policySet.getIntentMaps()) {
+ for(Qualifier q: intentMap.getQualifiers()) {
+ count += q.getPolicies().size();
+ }
+ }
+ return count;
+ }
@Test
public void testResolution() throws Exception {
- assertTrue(intentTable.get(messageProtection) instanceof ProfileIntent);
- ProfileIntent profileIntent = (ProfileIntent)intentTable.get(new QName(namespace, "messageProtection"));
+ assertTrue(!intentTable.get(messageProtection).getRequiredIntents().isEmpty());
+ Intent profileIntent = intentTable.get(new QName(namespace, "messageProtection"));
assertNull(profileIntent.getRequiredIntents().get(0).getDescription());
QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
- assertTrue(intentTable.get(confidentiality_transport) instanceof QualifiedIntent);
- QualifiedIntent qualifiedIntent =
- (QualifiedIntent)intentTable.get(new QName(namespace, "confidentiality.transport"));
- assertNull(qualifiedIntent.getQualifiableIntent().getDescription());
+ assertTrue(intentTable.get(confidentiality_transport) instanceof Intent);
+ Intent qualifiedIntent = (Intent)intentTable.get(new QName(namespace, "confidentiality.transport"));
+ assertNull(qualifiedIntent.getDescription());
+ assertNotNull(qualifiedIntent.getParent().getDescription());
PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
@@ -200,42 +212,26 @@ public class ReadDocumentTestCase {
assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
assertNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
assertTrue(secureMessagingPolicySet.isUnresolved());
- assertEquals(securityPolicySet.getMappedPolicies().size(), 5);
+ assertEquals(2, getNumberOfQualifiedPolicies(securityPolicySet));
//testing to ensure that inclusion of referred policy sets has not happened
PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
- assertTrue(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
+ assertTrue(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
- IntentAttachPointType wsBindingType = bindingTypesTable.get(wsBinding);
+ ExtensionType wsBindingType = bindingTypesTable.get(wsBinding);
assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
- assertNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
+ assertNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
- IntentAttachPointType javaImplType = implTypesTable.get(javaImpl);
+ ExtensionType javaImplType = implTypesTable.get(javaImpl);
assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
- assertNull(javaImplType.getMayProvideIntents().get(0).getDescription());
-
- List<Intent> simpleIntents = new ArrayList<Intent>();
- List<ProfileIntent> profileIntents = new ArrayList<ProfileIntent>();
- List<QualifiedIntent> qualifiedIntents = new ArrayList<QualifiedIntent>();
-
- for (Intent intent : intentTable.values()) {
- if (intent instanceof ProfileIntent)
- profileIntents.add((ProfileIntent)intent);
- else if (intent instanceof QualifiedIntent)
- qualifiedIntents.add((QualifiedIntent)intent);
- else
- simpleIntents.add(intent);
- }
-
- for (Intent intent : simpleIntents)
- staxProcessor.resolve(intent, resolver);
+ assertNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
- for (ProfileIntent intent : profileIntents)
- staxProcessor.resolve(intent, resolver);
+ List<Intent> intents = new ArrayList<Intent>(intentTable.values());
- for (QualifiedIntent intent : qualifiedIntents)
+ for (Intent intent : intents) {
staxProcessor.resolve(intent, resolver);
+ }
for (PolicySet policySet : policySetTable.values()) {
if (policySet.getReferencedPolicySets().isEmpty())
@@ -247,40 +243,53 @@ public class ReadDocumentTestCase {
staxProcessor.resolve(policySet, resolver);
}
- for (IntentAttachPointType bindingType : bindingTypesTable.values()) {
+ for (ExtensionType bindingType : bindingTypesTable.values()) {
staxProcessor.resolve(bindingType, resolver);
}
- for (IntentAttachPointType implType : implTypesTable.values()) {
+ for (ExtensionType implType : implTypesTable.values()) {
staxProcessor.resolve(implType, resolver);
}
//testing if policy intents have been linked have property been linked up
assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());
- assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
+ assertNotNull(qualifiedIntent.getParent().getDescription());
assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
//testing if policysets have been properly linked up with intents
assertFalse(secureMessagingPolicySet.isUnresolved());
- assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
- assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(secureMessagingPolicySet, intentTable.get(confidentiality_transport)));
//testing if intent maps have been properly mapped to policies
assertFalse(securityPolicySet.isUnresolved());
- assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
- assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_message)));
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality)));
+ assertTrue(isRealizedBy(securityPolicySet, intentTable.get(confidentiality_message)));
//testing for inclusion of referred policysets
assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
- assertFalse(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
- assertNotNull(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().get(intentTable
- .get(confidentiality_transport)));
+ assertFalse(basicAuthMsgProtSecurityPolicySet.getIntentMaps().isEmpty());
+ assertTrue(isRealizedBy(basicAuthMsgProtSecurityPolicySet, intentTable.get(confidentiality_transport)));
assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
- assertNotNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
+ assertNotNull(wsBindingType.getMayProvidedIntents().get(0).getDescription());
assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
- assertNotNull(javaImplType.getMayProvideIntents().get(0).getDescription());
+ assertNotNull(javaImplType.getMayProvidedIntents().get(0).getDescription());
+ }
+
+ private boolean isRealizedBy(PolicySet policySet, Intent intent) {
+ if (intent.getName().getLocalPart().indexOf('.') == -1) {
+ return policySet.getProvidedIntents().contains(intent);
+ }
+ for (IntentMap map : policySet.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (q.getIntent().equals(intent)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
}
diff --git a/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java b/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
index 2dc8a1cdc7..6887cd1b42 100644
--- a/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
+++ b/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
@@ -28,36 +28,46 @@ import org.apache.tuscany.sca.contribution.processor.ContributionResolveExceptio
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.policy.Policy;
+import org.apache.tuscany.sca.policy.PolicyExpression;
/**
*
* @version $Rev$ $Date$
*/
-public class TestPolicyProcessor implements StAXArtifactProcessor<Policy> {
+public class TestPolicyProcessor implements StAXArtifactProcessor<PolicyExpression> {
public QName getArtifactType() {
return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
}
- public Policy read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException {
+ public PolicyExpression read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException {
return new MockPolicyImplOne();
}
- public void write(Policy arg0, XMLStreamWriter arg1) throws ContributionWriteException, XMLStreamException {
+ public void write(PolicyExpression arg0, XMLStreamWriter arg1) throws ContributionWriteException, XMLStreamException {
}
- public Class<Policy> getModelType() {
+ public Class<PolicyExpression> getModelType() {
// TODO Auto-generated method stub
- return Policy.class;
+ return PolicyExpression.class;
}
- public void resolve(Policy arg0, ModelResolver arg1) throws ContributionResolveException {
+ public void resolve(PolicyExpression arg0, ModelResolver arg1) throws ContributionResolveException {
}
- public class MockPolicyImplOne implements Policy {
- public QName getSchemaName() {
+ public class MockPolicyImplOne implements PolicyExpression {
+ public <T> T getPolicy() {
+ return null;
+ }
+
+ public void setName(QName name) {
+ }
+
+ public <T> void setPolicy(T policy) {
+ }
+
+ public QName getName() {
return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
}
diff --git a/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
index b51a6fba98..b46ac57e5f 100644
--- a/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
+++ b/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
@@ -17,239 +17,187 @@
* specific language governing permissions and limitations
* under the License.
-->
-<definitions xmlns="http://www.osoa.org/xmlns/sca/1.0"
- targetNamespace="http://test"
- xmlns:test="http://test"
- xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
-
-<!-- Extension Types Metadata -->
-<implementationType type="sca:implementation.java" alwaysProvides="test:logging"
- mayProvide="test:tracing"/>
-<bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality"
- mayProvide="test:integrity"/>
-
-<!-- Intents and Policysets to assume targetnamespace -->
-<intent name="TestIntentOne"
- constrains="sca:binding">
- <description>
- Test Intent
- </description>
- </intent>
-
- <intent name="TestIntentTwo"
- constrains="sca:binding"
- requires="test:TestIntentOne">
- <description>
- Protect messages from unauthorized reading or modification
- </description>
- </intent>
-
- <policySet name="TestPolicySetOne"
- provides="test:TestIntentOne"
- appliesTo="sca:binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "basic authentication" -->
- </wsp:PolicyAttachment>
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "reliability" -->
- </wsp:PolicyAttachment>
- </policySet>
-
-
- <!-- qualified intents -->
- <intent name="confidentiality.transport" />
- <intent name="confidentiality.message" />
- <intent name="confidentiality.message.whole" />
- <intent name="confidentiality.message.body" />
-
- <!-- POLICY SETS -->
- <policySet name="SecureReliablePolicy"
- provides="test:confidentiality.transport test:integrity"
- appliesTo="sca:binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "basic authentication" -->
- </wsp:PolicyAttachment>
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for
- "reliability" -->
- </wsp:PolicyAttachment>
- </policySet>
-
- <policySet name="SecureMessagingPolicies"
- provides="test:confidentiality"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <intentMap provides="test:confidentiality" default="transport">
- <qualifier name="transport">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "transport" alternative -->
+<definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200712">
+
+ <!-- Extension Types Metadata -->
+ <implementationType type="sca:implementation.java" alwaysProvides="test:logging" mayProvide="test:tracing" />
+ <bindingType type="sca:binding.ws" alwaysProvides="test:confidentiality" mayProvide="test:integrity" />
+
+ <!-- Intents and Policysets to assume targetnamespace -->
+ <intent name="TestIntentOne" constrains="sca:binding">
+ <description>
+ Test Intent
+ </description>
+ </intent>
+
+ <intent name="TestIntentTwo" constrains="sca:binding" requires="test:TestIntentOne">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="SecureReliablePolicy" provides="test:confidentiality.transport test:integrity" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "basic authentication" -->
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for
+ "reliability" -->
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="SecureMessagingPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport" alternative -->
</wsp:PolicyAttachment>
- <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
- </qualifier>
- <qualifier name="message">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "message" alternative" -->
- </wsp:PolicyAttachment>
- </qualifier>
- </intentMap>
-</policySet>
-
-<policySet name="SecurityPolicy"
- provides="test:confidentiality"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" >
- <intentMap provides="test:confidentiality" default="message">
- <qualifier name="message">
- <intentMap provides="message" default="whole">
- <qualifier name="body">
- <wsp:PolicyAttachment>
- <!-- policy attachment for body encryption -->
- </wsp:PolicyAttachment>
- </qualifier>
- <qualifier name="whole">
- <wsp:PolicyAttachment>
- <!-- policy attachment for whole message encryption -->
- </wsp:PolicyAttachment>
- </qualifier>
- </intentMap>
- </qualifier>
- <qualifier name="transport">
- <wsp:PolicyAttachment>
- <!-- policy attachment for transport encryption -->
- </wsp:PolicyAttachment>
- </qualifier>
- </intentMap>
-</policySet>
-
-<policySet name="BasicAuthMsgProtSecurity"
- provides="test:authentication test:confidentiality"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0">
- <policySetReference name="test:AuthenticationPolicies"/>
- <policySetReference name="test:ConfidentialityPolicies"/>
-</policySet>
-
-<policySet name="AuthenticationPolicies"
- provides="test:authentication"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "basic
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message" alternative" -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecurityPolicy" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="message">
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for body encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy attachment for transport encryption -->
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="BasicAuthMsgProtSecurity" provides="test:authentication test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712">
+ <policySetReference name="test:AuthenticationPolicies" />
+ <policySetReference name="test:ConfidentialityPolicies" />
+ </policySet>
+
+ <policySet name="AuthenticationPolicies" provides="test:authentication" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "basic
authentication" -->
- </wsp:PolicyAttachment>
-</policySet>
-
-<policySet name="ConfidentialityPolicies"
- provides="test:confidentiality"
- appliesTo="binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <intentMap provides="test:confidentiality" default="transport">
- <qualifier name="transport">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "transport"
+ </wsp:PolicyAttachment>
+ </policySet>
+
+ <policySet name="ConfidentialityPolicies" provides="test:confidentiality" appliesTo="binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <intentMap provides="test:confidentiality" default="transport">
+ <qualifier name="transport">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "transport"
alternative -->
- </wsp:PolicyAttachment>
- <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
- </qualifier>
- <qualifier name="message">
- <wsp:PolicyAttachment>
- <!-- policy expression and policy subject for "message"
- alternative" -->...
- </wsp:PolicyAttachment>
- </qualifier>
- </intentMap>
-</policySet>
-
-<policySet name="SecureWSPolicy"
- provides="test:confidentiality"
- appliesTo="sca:binding.ws"
- xmlns="http://www.osoa.org/xmlns/sca/1.0"
- xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
- xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
- <wsp:Policy>
- <wsp:ExactlyOne>
- <wsp:All>
- <sp:SecurityToken>
- <sp:TokenType>sp:X509v3</sp:TokenType>
- </sp:SecurityToken>
- <sp:UsernameToken />
- <sp:SignedParts />
- <sp:EncryptedParts>
- <sp:Body />
- </sp:EncryptedParts>
- <sp:TransportBinding>
- <sp:IncludeTimeStamp />
- </sp:TransportBinding>
- </wsp:All>
- </wsp:ExactlyOne>
- </wsp:Policy>
- </policySet>
-
-<!-- profile intent -->
- <intent name="reliableMessageProtection"
- constrains="sca:binding"
- requires="test:messageProtection">
- <description>
- Protect messages from unauthorized reading or modification
- </description>
- </intent>
-
- <intent name="messageProtection"
- constrains="sca:binding"
- requires="test:confidentiality test:integrity">
- <description>
- Protect messages from unauthorized reading or modification
- </description>
- </intent>
-
-<!-- simple intent -->
- <intent name="confidentiality"
- constrains="sca:binding">
- <description>
- Communitcation thro this binding must prevent
- unauthorized users from reading the messages.
- </description>
- </intent>
-
- <intent name="integrity"
- constrains="sca:binding">
- <description>
- Communitcation thro this binding must prevent
- unauthorized modification of the messages.
- </description>
- </intent>
-
- <intent name="authentication"
- constrains="sca:binding">
- <description>
- Communitcation thro this binding required
- Authentication.
- </description>
- </intent>
-
- <intent name="logging"
- constrains="sca:implementation">
- <description>
- All messages to and from this implementation must be logged
- </description>
- </intent>
-
- <intent name="tracing"
- constrains="sca:implementation.java">
- <description>
- Need to figure out some description for this
- </description>
- </intent>
-
+ </wsp:PolicyAttachment>
+ <wsp:PolicyAttachment>...</wsp:PolicyAttachment>
+ </qualifier>
+ <qualifier name="message">
+ <wsp:PolicyAttachment>
+ <!-- policy expression and policy subject for "message"
+ alternative" -->
+ ...
+ </wsp:PolicyAttachment>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+ <policySet name="SecureWSPolicy" provides="test:confidentiality" appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712" xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy>
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SecurityToken>
+ <sp:TokenType>sp:X509v3</sp:TokenType>
+ </sp:SecurityToken>
+ <sp:UsernameToken />
+ <sp:SignedParts />
+ <sp:EncryptedParts>
+ <sp:Body />
+ </sp:EncryptedParts>
+ <sp:TransportBinding>
+ <sp:IncludeTimeStamp />
+ </sp:TransportBinding>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </policySet>
+
+ <!-- profile intent -->
+ <intent name="reliableMessageProtection" constrains="sca:binding" requires="test:messageProtection">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <intent name="messageProtection" constrains="sca:binding" requires="test:confidentiality test:integrity">
+ <description>
+ Protect messages from unauthorized reading or modification
+ </description>
+ </intent>
+
+ <!-- simple intent -->
+ <intent name="confidentiality" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized users from reading the messages.
+ </description>
+ <qualifier name="transport" />
+ <qualifier name="message" default="true" />
+ </intent>
+
+ <intent name="integrity" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding must prevent
+ unauthorized modification of the messages.
+ </description>
+ </intent>
+
+ <intent name="authentication" constrains="sca:binding">
+ <description>
+ Communitcation thro this binding required
+ Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging" constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing" constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
+ </description>
+ </intent>
+
</definitions> \ No newline at end of file
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/DefaultIntentAttachPointTypeFactory.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
index 6ca4fe72ec..f43c428563 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/DefaultIntentAttachPointTypeFactory.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
@@ -1,29 +1,27 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy;
-
-import org.apache.tuscany.sca.policy.impl.IntentAttachPointTypeFactoryImpl;
-
-/**
- * Default implementation for IntentAttachPointTypeFactory
- *
- * @version $Rev$ $Date$
- */
-public class DefaultIntentAttachPointTypeFactory extends IntentAttachPointTypeFactoryImpl implements IntentAttachPointTypeFactory{
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+
+/**
+ * Definition of binding type which extends from sca:binding
+ */
+public interface BindingType extends ExtensionType {
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointType.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
index 6db529c7f0..828d0a9966 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointType.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
@@ -1,71 +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.sca.policy;
-
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-/**
- * Base interface for representing the model type of assembly model objects that can be have policy intents
- * attached to them.
- *
- * @version $Rev$ $Date$
- */
-public interface IntentAttachPointType {
-
- /**
- * Returns the name of the extension type defined by this instance e.g. implementation.java, binding.ws
- * @return the extension type QName
- */
- QName getName();
-
- /**
- * Sets the name of the extension type
- * @param type the name of the extension type
- */
- void setName(QName type);
-
- /**
- * Returns the list of names of policy intents that will always be provided by this Extension Type
- * @return list of Policy Intent names
- */
- List<Intent> getAlwaysProvidedIntents();
-
- /**
- * Returns the list of names of policy intents that may be provided by this Extension Type thro
- * appropriate configuration
- * @return list of Policy Intent names
- */
- List<Intent> getMayProvideIntents();
-
- /**
- * Returns true if the model element is unresolved.
- *
- * @return true if the model element is unresolved.
- */
- boolean isUnresolved();
-
- /**
- * Sets whether the model element is unresolved.
- *
- * @param unresolved whether the model element is unresolved
- */
- void setUnresolved(boolean unresolved);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Definition of extension type: binding or implementation
+ */
+public interface ExtensionType {
+ QName BINDING_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200712", "binding");
+ QName IMPLEMENTATION_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200712", "implementation");
+
+ /**
+ * The name of the extension type (binding or implementation). The extension type name
+ * attribute MUST be the QName of an XSD global element definition used for
+ * binding/implementation elements of that type
+ *
+ * @return The QName of this type
+ */
+ QName getType();
+
+ /**
+ * Set the QName for this type
+ * @param type The QName of this type
+ */
+ void setType(QName type);
+
+ QName getBaseType();
+
+ /**
+ * A set of intents. The intents in the alwaysProvides set are always
+ * provided by this extension type, whether the intents are attached
+ * to the using component or not.
+ *
+ * @return A list of intents that are always provided by this type
+ */
+ List<Intent> getAlwaysProvidedIntents();
+
+ /**
+ * a set of intents. The intents in the mayProvide set are provided by this
+ * extension type if the intent in question is attached to the using
+ * component.
+ *
+ * @return A list of intents that may be provided by this type
+ */
+ List<Intent> getMayProvidedIntents();
+ /**
+ * Returns true if the model element is unresolved.
+ *
+ * @return true if the model element is unresolved.
+ */
+ boolean isUnresolved();
+
+ /**
+ * Sets whether the model element is unresolved.
+ *
+ * @param unresolved whether the model element is unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Policy.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
index c6393e2ada..d142015f57 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Policy.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
@@ -1,33 +1,27 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy;
-
-import javax.xml.namespace.QName;
-
-/**
- * Interface that will abstract various types of policy specifications
- * and attachments for example WS-Policy
- *
- * @version $Rev$ $Date$
- */
-public interface Policy {
- QName getSchemaName();
- void setUnresolved(boolean unresolved);
- boolean isUnresolved();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+
+/**
+ * Definition of an implementation type which extends from sca:implementation
+ */
+public interface ImplementationType extends ExtensionType {
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
index 22f328f643..78ce04e9c9 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
@@ -29,6 +29,9 @@ import javax.xml.namespace.QName;
* @version $Rev$ $Date$
*/
public interface Intent {
+ enum Type {
+ interaction, implementation
+ };
/**
* Returns the intent name.
@@ -45,45 +48,72 @@ public interface Intent {
void setName(QName name);
/**
- * Get the intent domain (the root intent name before any qualifiers)
- * @return the domain
+ * Returns the list of SCA constructs that this intent is meant to
+ * configure.
+ *
+ * @return the list of SCA constructs that this intent is meant to configure
*/
- String getDomain();
+ List<ExtensionType> getConstrainedTypes();
/**
- * Get the intent qualifiers
- * @return the domain
+ * Return a list of required intents
+ * @return The list of required intents
*/
- String[] getQualifiedNames();
+ List<Intent> getRequiredIntents();
/**
- * Returns the list of operations that this intent applies to.
+ * Returns the list of intents which are mutually exclusive with this intent.
*
- * @return
+ * @return the list of mutually exclusive intents.
*/
- //List<Operation> getOperations();
+ List<Intent> getExcludedIntents();
/**
- * Returns the list of SCA constructs that this intent is meant to
- * configure.
+ * Returns the list of qualified intents.
*
- * @return the list of SCA constructs that this intent is meant to configure
+ * @return the list of qualified intents.
*/
- List<QName> getConstrains();
+ List<Intent> getQualifiedIntents();
/**
- * Returns the list of intents which are mutually exclusive with this intent.
+ * Get the default qualified intent
*
- * @return the list of mutually exclusive intents.
+ * @return
*/
- List<Intent> getExcludedIntents();
+ Intent getDefaultQualifiedIntent();
/**
- * Returns the list of children qualified intents.
+ * Set the default qualified intent
*
- * @return the list of children qualified intents.
+ * @param qualifiedIntent
*/
- List<Intent> getQualifiedIntents();
+ void setDefaultQualifiedIntent(Intent qualifiedIntent);
+
+ /**
+ * Get the intent type: Interaction or Implementation
+ * @return
+ */
+ Type getType();
+
+ /**
+ * Set the intent type
+ * @param type: Interaction or Implementation
+ */
+ void setType(Type type);
+
+ /**
+ * If this attribute is present and has a value of true it indicates that
+ * the qualified intents defined for this intent are mutually exclusive
+ *
+ * @return
+ */
+ boolean isMutuallyExclusive();
+
+ /**
+ * Set the value of mutuallyExclusive
+ * @param mutuallyExclusive
+ */
+ void setMutuallyExclusive(boolean mutuallyExclusive);
/**
* Returns the intent description.
@@ -104,6 +134,20 @@ public interface Intent {
*
* @return true if the model element is unresolved.
*/
+
+ /**
+ * Get the parent intent for a qualified intent. If an intent is not qualified,
+ * return null.
+ * @return The parent intent or null if this intent is not qualified
+ */
+ Intent getParent();
+
+ /**
+ * Set the parent intent for a qualified intent
+ * @param intent
+ */
+ void setParent(Intent intent);
+
boolean isUnresolved();
/**
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointTypeFactory.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointTypeFactory.java
deleted file mode 100644
index ee67006875..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPointTypeFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy;
-
-/**
- * Factory interface for creating extension types meta data
- *
- * @version $Rev$ $Date$
- */
-public interface IntentAttachPointTypeFactory {
-
- /**
- * Creates an ImplementationTypeImpl instance to hold metadata related to
- * a particular implementation extension in the SCA Domain
- *
- * @return an instance of IntentAttachPointType
- */
- IntentAttachPointType createImplementationType();
-
- /**
- * Creates an BindingTypeImpl instance to hold metadata related to
- * a particular binding extension in the SCA Domain
- *
- * @return an instance of IntentAttachPointType
- */
- IntentAttachPointType createBindingType();
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
index 1b225bc918..efed4bfdb1 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
@@ -16,18 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.tuscany.sca.policy;
import java.util.List;
+import org.apache.tuscany.sca.policy.Intent;
+
+
/**
- * Represents a policy intent map. See the Policy Framework specification for a
- * description of this element.
- *
- * @version $Rev$ $Date$
+ * Map policies to the qualified intents
*/
public interface IntentMap {
-
/**
* Returns the intent realized by this intent map.
*
@@ -41,49 +41,11 @@ public interface IntentMap {
* @param providedIntent the intent realized by this intent map
*/
void setProvidedIntent(Intent providedIntent);
-
- /**
- * Returns the default qualified intent map.
- *
- * @return the default qualified intent map
- */
- IntentMap getDefaultQualifiedIntentMap();
-
- /**
- * Sets the default qualified intent map.
- *
- * @param defaultQualifiedIntentMap the default qualified intent map
- */
- void setDefaultQualifiedIntentMap(IntentMap defaultQualifiedIntentMap);
-
+
/**
- * Returns the list of children qualified intent maps.
+ * Get a list of qualifiers
*
- * @return
+ * @return A list of qualifiers
*/
- List<IntentMap> getQualifiedIntentMaps();
-
- /**
- * Returns the list of concrete policies, either WS-Policy policy
- * attachments, policy references, or policies expressed in another policy
- * language.
- *
- * @return the list of concrete policies
- */
- List<Object> getPolicies();
-
- /**
- * Returns true if the model element is unresolved.
- *
- * @return true if the model element is unresolved.
- */
- boolean isUnresolved();
-
- /**
- * Sets whether the model element is unresolved.
- *
- * @param unresolved whether the model element is unresolved
- */
- void setUnresolved(boolean unresolved);
-
+ List<Qualifier> getQualifiers();
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ProfileIntent.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java
index 28ff9d09d3..ee4f5b5236 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/ProfileIntent.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java
@@ -1,36 +1,31 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy;
-
-import java.util.List;
-
-/**
- * Interface that abstracts a profile intent
- *
- * @version $Rev$ $Date$
- */
-public interface ProfileIntent extends Intent {
- /**
- * Returns the list of required intents.
- *
- * @return the list of required intents
- */
- List<Intent> getRequiredIntents();
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+/**
+ * Attach a policySet to a collection of policy subjects
+ */
+public interface PolicyAttachment {
+ PolicySet getPolicySet();
+ void setPolicySet(PolicySet policySet);
+ List<PolicySubject> getPolicySubjects();
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyContext.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyContext.java
deleted file mode 100644
index 65c39803d2..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyContext.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy;
-
-import java.util.List;
-
-/**
- * A context container for policies.
- *
- * @version $Rev$ $Date$
- */
-public interface PolicyContext {
- List<Intent> getIntents(Object key);
- List<PolicySet> getPolicySets(Object key);
- void addIntents(Object key, List<Intent> intents);
- void addPolicySets(Object key, List<PolicySet> policySets);
- void addIntent(Object key, Intent intent);
- void addPolicySet(Object key, PolicySet policySet);
- void clearIntents(Object key);
- void clearPolicySets(Object key);
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetReference.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java
index caa0d04fe3..a29f214f98 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetReference.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java
@@ -1,43 +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.sca.policy;
-
-import javax.xml.namespace.QName;
-
-/**
- * Interface that abstracts a PolicySet Reference
- *
- * @version $Rev$ $Date$
- */
-public interface PolicySetReference {
-
- /**
- * Returns the name of the policyset being referred to
- *
- * @return the QName of the referred policyset
- */
- QName getReferredPolicySetName();
-
- /**
- * @param refPolicySetName the name of the policyset being referred to
- *
- */
- void setReferredPolicySetName(QName refPolicySetName);
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Interface that will abstract various types of policy specifications
+ * and attachments for example WS-Policy
+ *
+ * @version $Rev$ $Date$
+ */
+public interface PolicyExpression {
+ /**
+ * Get the QName of the policy expression
+ * @return the QName of the policy expression
+ */
+ QName getName();
+
+ /**
+ * Set the QName of the policy expression
+ * @param name
+ */
+ void setName(QName name);
+
+ /**
+ * Get the policy definition in the type of the specific domain
+ * @return
+ */
+ <T> T getPolicy();
+
+ /**
+ * Set the policy definition
+ * @param expression
+ */
+ <T> void setPolicy(T policy);
+
+ /**
+ *
+ * @param unresolved
+ */
+ void setUnresolved(boolean unresolved);
+
+ /**
+ *
+ * @return
+ */
+ boolean isUnresolved();
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
index 49bcbae1ae..9e7de2f6da 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
@@ -47,23 +47,20 @@ public interface PolicyFactory {
IntentMap createIntentMap();
/**
- * create a new Profile Intent
+ * create a new Qualifier
*
- * @return a ProfileIntent instance
+ * @return a Qualifier
*/
- ProfileIntent createProfileIntent();
+ Qualifier createQualifier();
/**
- * create a new QualifiedIntent
- *
- * @return a QualifiedIntent instance
+ * Create a new PolicyExpression
+ * @return
*/
- QualifiedIntent createQualifiedIntent();
+ PolicyExpression createPolicyExpression();
- /**
- * create a new PolicySetReference
- *
- * @return a PolicySetReference instance
- */
- PolicySetReference createPolicySetReference();
+ ExtensionType createExtensionType();
+ BindingType createBindingType();
+ ImplementationType createImplementationType();
+
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetAttachPoint.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyResolver.java
index f4156fc2e6..b04641bdf5 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySetAttachPoint.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicyResolver.java
@@ -16,33 +16,38 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.tuscany.sca.policy;
import java.util.List;
/**
- * Base interface for all assembly model objects that can have policy sets
- * attached to them.
- *
- * @version $Rev$ $Date$
+ *
*/
-public interface PolicySetAttachPoint extends IntentAttachPoint {
+public interface PolicyResolver {
+ /**
+ * Attach a policySet to a given policy subject
+ * @param policySet
+ * @param policySubject
+ * @return
+ */
+ PolicyAttachment attach(PolicySet policySet, PolicySubject policySubject);
/**
- * Returns a list of policy sets. See the Policy Framework specification for
- * a description of this attribute.
- *
- * @return a list of policy sets.
+ * Apply the policySet against the SCA domain composite to
+ * @param policySet
+ * @param domainComposite
+ * @return
*/
- List<PolicySet> getPolicySets();
-
-
+ List<PolicyAttachment> apply(PolicySet policySet, PolicySubject domainComposite);
+
/**
- * Returns a list of policy sets defined in the domain, that are applicable to this
- * PolicySetAttachPoint. An applicable PolicySet is one that include this PolicySetAttachPoint
- * as part of its 'appliesTo' XPath attribute.
- *
- * @return a list of policy sets applicable to this PolicySetAttachPoint
+ * Calculate a list of effective policies for a given policy subject
+ * @param policySubject
+ * @return
*/
- List<PolicySet> getApplicablePolicySets();
+ List<PolicyExpression> getEffectivePolicies(PolicySubject policySubject);
+
+ boolean isIntentProvidedBy(PolicySet policySet, Intent intent);
+ List<PolicyExpression> getPolicies(Intent intent);
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
index b16072c214..2b5b8458d5 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.policy;
import java.util.List;
-import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.xpath.XPathExpression;
@@ -47,12 +46,6 @@ public interface PolicySet {
void setName(QName name);
/**
- * Returns the list of operations that this policy set applies to.
- *
- * @return
- */
- //List<Operation> getOperations();
- /**
* Returns the list of
*
* @return
@@ -73,7 +66,7 @@ public interface PolicySet {
*
* @return the list of concrete policies
*/
- List<Object> getPolicies();
+ List<PolicyExpression> getPolicies();
/**
* Returns true if the model element is unresolved.
@@ -91,7 +84,7 @@ public interface PolicySet {
/**
* Returns the XPath expression that is to be used to evaluate
- * if this PolicySet applies to specific attachment point
+ * if this PolicySet applies to specific policy subject
*
* @return the XPath expression
*/
@@ -99,35 +92,45 @@ public interface PolicySet {
/**
* Sets the XPath expression that is to be used to evaluate
- * if this PolicySet applies to specific attachment point
+ * if this PolicySet applies to specific policy subject
*
*/
void setAppliesTo(String xpath);
-
+
/**
- * Returns the policies / policy attachments provided thro intent maps
+ * A string which is an XPath 1.0 expression identifying one or more
+ * elements (policy subject) in the Domain. It is used to declare which
+ * set of elements the policySet is actually attached to.
*
+ * @return The attachTo XPath
+ */
+ String getAttachTo();
+
+ /**
+ * Set the attachTo XPath
+ * @param xpath
+ */
+ void setAttachTo(String xpath);
+
+ /**
+ * Get the resolved XPathExpression for attachTo
* @return
*/
- Map<Intent, List<Object>> getMappedPolicies();
-
+ XPathExpression getAttachToXPathExpression();
+
/**
- * Gets the XPath expression that is to be used to evaluate
- * the SCA Artifacts that this policyset will always apply to
- * immaterial of an intent declared on the SCA Artifact
- *
- * @return the XPath expression
+ * Set the resolved XPathExpression for attachTo
+ * @param expression
*/
- String getAlwaysAppliesTo();
+ void setAttachToXPathExpression(XPathExpression expression);
/**
- * Sets the XPath expression that is to be used to evaluate
- * the SCA Artifacts that this policyset will always apply to
- * immaterial of an intent declared on the SCA Artifact
+ * Returns the policies / policy attachments provided thro intent maps
*
+ * @return
*/
- void setAlwaysAppliesTo(String xpath);
-
+ List<IntentMap> getIntentMaps();
+
/**
* Get the XPath expression for the appliesTo attribute
* @return the XPath expression for the appliesTo attribute
@@ -140,16 +143,4 @@ public interface PolicySet {
*/
void setAppliesToXPathExpression(XPathExpression xpathExpression);
- /**
- * Get the XPath expression for the alwaysAppliesTo attribute
- * @return the XPath expression for the alwaysAppliesTo attribute
- */
- XPathExpression getAlwaysAppliesToXPathExpression();
-
- /**
- * Set the XPath expression for the alwaysAppliesTo attribute
- * @param xpathExpression the XPath expression for the alwaysAppliesTo attribute
- */
- void setAlwaysAppliesToXPathExpression(XPathExpression xpathExpression);
-
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPoint.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java
index bf2cfca924..41847bad79 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/IntentAttachPoint.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java
@@ -16,37 +16,41 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.tuscany.sca.policy;
import java.util.List;
/**
- * Base interface for all assembly model objects that can be have policy intents
- * attached to them.
- *
- * @version $Rev$ $Date$
+ * A policy subject is an entity in the assembly with which a policy can be
+ * associated.
+ *
+ * For example, a policy subject can be one of the following:
+ * <ul>
+ * <li>composite
+ * <li>component
+ * <li>implementation
+ * <li>service
+ * <li>reference
+ * <li>binding
+ * <li>interface
+ * </ul>
*/
-public interface IntentAttachPoint {
-
+public interface PolicySubject {
/**
- * Returns a list of policy intents. See the Policy Framework specification
- * for a description of this attribute.
+ * Get a list of required intents
*
- * @return a list of policy intents.
- */
- List<Intent> getRequiredIntents();
-
-
- /**
- * Returns the type of the attach point such as a BindingType or an ImplementationType and so on
* @return
*/
- IntentAttachPointType getType();
-
+ List<Intent> getRequiredIntents();
+
/**
+ * Get a list of attached policySets
*
- * Sets the type of the attach point such as a BindingType or an ImplementationType and so on
- * @param type
+ * @return A list of policySets
*/
- void setType(IntentAttachPointType type);
+ List<PolicySet> getPolicySets();
+
+ ExtensionType getType();
+ void setType(ExtensionType type);
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/QualifiedIntent.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java
index 0f43221dd6..c1862283c7 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/QualifiedIntent.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java
@@ -1,41 +1,44 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy;
-
-/**
- * Abstracts a qualified policy intent
- *
- * @version $Rev$ $Date$
- */
-public interface QualifiedIntent extends Intent {
-
- /**
- * Returns the intent qualified by this intent
- *
- * @return
- */
- Intent getQualifiableIntent();
-
- /**
- * sets the qualifiable intent for this Qualified intent instance
- *
- * @param qualifiableIntent
- */
- void setQualifiableIntent(Intent qualifiableIntent);
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy;
+
+import java.util.List;
+
+/**
+ * A qualifier provides a list of policies for a qualified intent within the IntentMap
+ */
+public interface Qualifier {
+ /**
+ * Get the qualified intent for this qualifier
+ * @return The intent
+ */
+ Intent getIntent();
+
+ /**
+ * Set the qualified intent for this qualifier
+ */
+ void setIntent(Intent intent);
+
+ /**
+ * Get the list of policies provided by this qualifier
+ * @return A list of policies
+ */
+ List<PolicyExpression> getPolicies();
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
index 0f8b1ae00a..53c6684d11 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
@@ -18,73 +18,21 @@
*/
package org.apache.tuscany.sca.policy.impl;
-import java.util.ArrayList;
-import java.util.List;
-
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.BindingType;
/**
* Concrete implementation for a BindingType
*
* @version $Rev$ $Date$
*/
-public class BindingTypeImpl implements IntentAttachPointType {
-
- private List<Intent> alwaysProvides = new ArrayList<Intent>();
- private List<Intent> mayProvides = new ArrayList<Intent>();
- private QName typeName;
- private boolean unResolved = true;
-
- public List<Intent> getAlwaysProvidedIntents() {
- return alwaysProvides;
- }
-
- public List<Intent> getMayProvideIntents() {
- return mayProvides;
- }
-
- public QName getName() {
- return typeName;
+public class BindingTypeImpl extends ExtensionTypeImpl implements BindingType {
+ protected BindingTypeImpl() {
+ super();
}
- public void setName(QName type) {
- this.typeName = type;
- }
-
- public boolean isUnresolved() {
- return unResolved;
- }
-
- public void setUnresolved(boolean unresolved) {
- this.unResolved = unresolved;
- }
-
- @Override
- public int hashCode() {
- return String.valueOf(getName()).hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- } else if (obj instanceof BindingTypeImpl ) {
- if (getName() != null) {
- return getName().equals(((BindingTypeImpl)obj).getName());
- } else {
- return ((BindingTypeImpl)obj).getName() == null;
- }
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- return ( this.typeName != null ) ? getName().toString() : "null";
+ public QName getBaseType() {
+ return BINDING_BASE;
}
}
-; \ No newline at end of file
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
new file mode 100644
index 0000000000..97fbc19ced
--- /dev/null
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.Intent;
+
+/**
+ * Concrete implementation for a BindingType
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensionTypeImpl implements ExtensionType {
+
+ private List<Intent> alwaysProvides = new ArrayList<Intent>();
+ private List<Intent> mayProvide = new ArrayList<Intent>();
+ private QName typeName;
+ private boolean unResolved = true;
+
+ protected ExtensionTypeImpl() {
+
+ }
+
+ public List<Intent> getAlwaysProvidedIntents() {
+ return alwaysProvides;
+ }
+
+ public List<Intent> getMayProvidedIntents() {
+ return mayProvide;
+ }
+
+ public QName getType() {
+ return typeName;
+ }
+
+ public void setType(QName type) {
+ this.typeName = type;
+ }
+
+ public boolean isUnresolved() {
+ return unResolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unResolved = unresolved;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getType()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else if (obj instanceof ExtensionTypeImpl) {
+ if (getType() != null) {
+ return getType().equals(((ExtensionTypeImpl)obj).getType());
+ } else {
+ return ((ExtensionTypeImpl)obj).getType() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return (this.typeName != null) ? getType().toString() : "null";
+ }
+
+ public QName getBaseType() {
+ return null;
+ }
+};
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
index 7861fd79f9..169ca29833 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
@@ -18,71 +18,22 @@
*/
package org.apache.tuscany.sca.policy.impl;
-import java.util.ArrayList;
-import java.util.List;
-
import javax.xml.namespace.QName;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.ImplementationType;
/**
* Concrete implementation for a Implementation Type
*
* @version $Rev$ $Date$
*/
-public class ImplementationTypeImpl implements IntentAttachPointType {
- private List<Intent> alwaysProvides = new ArrayList<Intent>();
- private List<Intent> mayProvides = new ArrayList<Intent>();
- private QName typeName;
- private boolean unResolved = true;
-
- public List<Intent> getAlwaysProvidedIntents() {
- return alwaysProvides;
- }
-
- public List<Intent> getMayProvideIntents() {
- return mayProvides;
- }
-
- public QName getName() {
- return typeName;
+public class ImplementationTypeImpl extends ExtensionTypeImpl implements ImplementationType {
+ protected ImplementationTypeImpl() {
+ super();
}
- public void setName(QName type) {
- this.typeName = type;
- }
-
- public boolean isUnresolved() {
- return unResolved;
+ public QName getBaseType() {
+ return IMPLEMENTATION_BASE;
}
- public void setUnresolved(boolean unresolved) {
- this.unResolved = unresolved;
- }
-
- @Override
- public int hashCode() {
- return String.valueOf(getName()).hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- } else if (obj instanceof ImplementationTypeImpl ) {
- if (getName() != null) {
- return getName().equals(((ImplementationTypeImpl)obj).getName());
- } else {
- return ((ImplementationTypeImpl)obj).getName() == null;
- }
- } else {
- return false;
- }
- }
-
- @Override
- public String toString() {
- return ( this.typeName != null ) ? getName().toString() : "null";
- }
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentAttachPointTypeFactoryImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentAttachPointTypeFactoryImpl.java
deleted file mode 100644
index aa6e27c240..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentAttachPointTypeFactoryImpl.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy.impl;
-
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
-import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
-
-/**
- * Default implementation for IntentAttachPointTypeFactory
- *
- * @version $Rev$ $Date$
- */
-public class IntentAttachPointTypeFactoryImpl implements IntentAttachPointTypeFactory {
-
- public IntentAttachPointType createBindingType() {
- return new BindingTypeImpl();
- }
-
- public IntentAttachPointType createImplementationType() {
- return new ImplementationTypeImpl();
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
index 2d6bd0eb6f..3c87c78af9 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
@@ -23,6 +23,7 @@ import java.util.List;
import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
/**
@@ -32,18 +33,17 @@ import org.apache.tuscany.sca.policy.Intent;
*/
public class IntentImpl implements Intent {
- private static final String QUALIFIED_SEPARATOR = ".";
- private static final String DOMAIN_SEPARATOR = ".";
private QName name;
- //private List<Operation> operations = new ArrayList<Operation>();
- private List<QName> constrains = new ArrayList<QName>();
+ private Type type;
+ private List<ExtensionType> constrainedTypes = new ArrayList<ExtensionType>();
private String description;
private List<Intent> qualifiedIntents = new ArrayList<Intent>();
- // private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private Intent defaultQualifiedIntent;
+ private Intent parent;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
private List<Intent> excludedIntents = new ArrayList<Intent>();
+ private boolean mutuallyExclusive;
private boolean unresolved = true;
- private String domain;
- private String[] qualifiedNames;
protected IntentImpl() {
}
@@ -54,33 +54,14 @@ public class IntentImpl implements Intent {
public void setName(QName name) {
this.name = name;
- String iname = name.getLocalPart();
- int domainIdx = iname.indexOf(DOMAIN_SEPARATOR);
- if (domainIdx > -1) {
- domain = iname.substring(0, domainIdx);
- String qualifNamesStr = iname.substring(domainIdx + 1);
- String pattern = "\\" + QUALIFIED_SEPARATOR;
- qualifiedNames = qualifNamesStr.split(pattern);
- } else
- domain = iname;
}
- public String getDomain() {
- return domain;
+ public List<ExtensionType> getConstrainedTypes() {
+ return constrainedTypes;
}
- public String[] getQualifiedNames() {
- String[] results = new String[qualifiedNames.length];
- System.arraycopy(qualifiedNames, 0, results, 0, qualifiedNames.length);
- return results;
- }
-
- /*public List<Operation> getOperations() {
- return operations;
- }*/
-
- public List<QName> getConstrains() {
- return constrains;
+ public void setConstrainedTypes(List<ExtensionType> constrainedTypes) {
+ this.constrainedTypes = constrainedTypes;
}
public String getDescription() {
@@ -91,14 +72,38 @@ public class IntentImpl implements Intent {
this.description = description;
}
+ public Intent getParent() {
+ return parent;
+ }
+
+ public void setParent(Intent parent) {
+ this.parent = parent;
+ }
+
public List<Intent> getQualifiedIntents() {
return qualifiedIntents;
}
+ public void setQualifiedIntents(List<Intent> qualifiedIntents) {
+ this.qualifiedIntents = qualifiedIntents;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public void setRequiredIntents(List<Intent> requiredIntents) {
+ this.requiredIntents = requiredIntents;
+ }
+
public List<Intent> getExcludedIntents() {
return excludedIntents;
}
+ public void setExcludedIntents(List<Intent> excludedIntents) {
+ this.excludedIntents = excludedIntents;
+ }
+
public boolean isUnresolved() {
return unresolved;
}
@@ -107,45 +112,57 @@ public class IntentImpl implements Intent {
this.unresolved = unresolved;
}
- /**
- * @see java.lang.Object#hashCode()
- */
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public boolean isMutuallyExclusive() {
+ return mutuallyExclusive;
+ }
+
+ public void setMutuallyExclusive(boolean mutuallyExclusive) {
+ this.mutuallyExclusive = mutuallyExclusive;
+ }
+
+ public Intent getDefaultQualifiedIntent() {
+ return defaultQualifiedIntent;
+ }
+
+ public void setDefaultQualifiedIntent(Intent defaultQualifiedIntent) {
+ this.defaultQualifiedIntent = defaultQualifiedIntent;
+ }
+
+
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- QName intentName = getName();
- result = prime * result + ((intentName == null) ? 0 : intentName.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
- /**
- * @see java.lang.Object#equals(java.lang.Object)
- */
@Override
public boolean equals(Object obj) {
- if (this == obj) {
+ if (this == obj)
return true;
- }
- if (obj == null) {
+ if (obj == null)
return false;
- }
- if (!(obj instanceof IntentImpl)) {
+ if (getClass() != obj.getClass())
return false;
- }
- final IntentImpl other = (IntentImpl)obj;
- if (getName() == null) {
- if (other.getName() != null) {
+ IntentImpl other = (IntentImpl)obj;
+ if (name == null) {
+ if (other.name != null)
return false;
- }
- } else if (!getName().equals(other.getName())) {
+ } else if (!name.equals(other.name))
return false;
- }
return true;
}
-
- @Override
+
public String toString() {
- return String.valueOf(getName());
+ return String.valueOf(name);
}
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
index aab03281ba..6e2941ff5c 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
@@ -18,10 +18,12 @@
*/
package org.apache.tuscany.sca.policy.impl;
+import java.util.ArrayList;
import java.util.List;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.Qualifier;
/**
* Represents an intent map.
@@ -31,43 +33,29 @@ import org.apache.tuscany.sca.policy.IntentMap;
public class IntentMapImpl implements IntentMap {
private boolean unresolved;
- private IntentMap defaultQualifiedIntentMap;
- private List<Object> policies;
private Intent providedIntent;
- private List<IntentMap> qualifiedIntentMaps;
+ private List<Qualifier> qualifiers = new ArrayList<Qualifier>();
protected IntentMapImpl() {
}
- public IntentMap getDefaultQualifiedIntentMap() {
- return defaultQualifiedIntentMap;
+ public boolean isUnresolved() {
+ return unresolved;
}
- public List<Object> getPolicies() {
- return policies;
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
}
public Intent getProvidedIntent() {
return providedIntent;
}
- public List<IntentMap> getQualifiedIntentMaps() {
- return qualifiedIntentMaps;
- }
-
- public void setDefaultQualifiedIntentMap(IntentMap defaultQualifiedIntentMap) {
- this.defaultQualifiedIntentMap = defaultQualifiedIntentMap;
- }
-
public void setProvidedIntent(Intent providedIntent) {
this.providedIntent = providedIntent;
}
- public boolean isUnresolved() {
- return unresolved;
- }
-
- public void setUnresolved(boolean unresolved) {
- this.unresolved = unresolved;
+ public List<Qualifier> getQualifiers() {
+ return qualifiers;
}
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyContextImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyContextImpl.java
deleted file mode 100644
index a0e2f10f56..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyContextImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.impl;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicyContext;
-import org.apache.tuscany.sca.policy.PolicySet;
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class PolicyContextImpl implements PolicyContext {
- private Map<Object, List<Intent>> intents = new Hashtable<Object , List<Intent>>();
- private Map<Object, List<PolicySet>> policySets = new Hashtable<Object, List<PolicySet>>();
-
- public void addIntent(Object key, Intent intent) {
- if ( intents.get(key) == null ) {
- intents.put(key, new ArrayList<Intent>());
- }
- intents.get(key).add(intent);
- }
-
- public void addIntents(Object key, List<Intent> intents) {
- if ( this.intents.get(key) == null ) {
- this.intents.put(key, new ArrayList<Intent>());
- }
- this.intents.get(key).addAll(intents);
- }
-
- public void addPolicySet(Object key, PolicySet policySet) {
- if ( policySets.get(key) == null ) {
- policySets.put(key, new ArrayList<PolicySet>());
- }
- policySets.get(key).add(policySet);
- }
-
- public void addPolicySets(Object key, List<PolicySet> policySets) {
- if ( this.policySets.get(key) == null ) {
- this.policySets.put(key, new ArrayList<PolicySet>());
- }
- this.policySets.get(key).addAll(policySets);
- }
-
- public List<Intent> getIntents(Object key) {
- if ( intents.get(key) == null ) {
- intents.put(key, new ArrayList<Intent>());
- }
- return intents.get(key);
- }
-
- public List<PolicySet> getPolicySets(Object key) {
- if ( policySets.get(key) == null ) {
- policySets.put(key, new ArrayList<PolicySet>());
- }
- return policySets.get(key);
- }
-
- public void clearIntents(Object key) {
- if ( intents.get(key) != null ) {
- intents.clear();
- }
- }
-
- public void clearPolicySets(Object key) {
- if ( policySets.get(key) != null ) {
- policySets.clear();
- }
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java
new file mode 100644
index 0000000000..71e5eef6a7
--- /dev/null
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.policy.PolicyExpression;
+
+public class PolicyExpressionImpl implements PolicyExpression {
+ private QName name;
+ private Object policy;
+ private boolean unresolved = true;
+
+ protected PolicyExpressionImpl() {
+ }
+
+ public QName getName() {
+ return name;
+ }
+
+ public <T> T getPolicy() {
+ return (T)policy;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public <T> void setPolicy(T policy) {
+ this.policy = policy;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PolicyExpressionImpl other = (PolicyExpressionImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
index 1db29b835e..c67ff1eab8 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
@@ -18,13 +18,15 @@
*/
package org.apache.tuscany.sca.policy.impl;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetReference;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
+import org.apache.tuscany.sca.policy.Qualifier;
/**
* A factory for the policy model.
@@ -37,10 +39,6 @@ public abstract class PolicyFactoryImpl implements PolicyFactory {
return new IntentImpl();
}
- public PolicySetReference createPolicySetReference() {
- return new PolicySetReferenceImpl();
- }
-
public PolicySet createPolicySet() {
return new PolicySetImpl();
}
@@ -49,12 +47,24 @@ public abstract class PolicyFactoryImpl implements PolicyFactory {
return new IntentMapImpl();
}
- public ProfileIntent createProfileIntent() {
- return new ProfileIntentImpl();
+ public Qualifier createQualifier() {
+ return new QualifierImpl();
+ }
+
+ public PolicyExpression createPolicyExpression() {
+ return new PolicyExpressionImpl();
+ }
+
+ public BindingType createBindingType() {
+ return new BindingTypeImpl();
+ }
+
+ public ImplementationType createImplementationType() {
+ return new ImplementationTypeImpl();
}
- public QualifiedIntent createQualifiedIntent() {
- return new QualifiedIntentImpl();
+ public ExtensionType createExtensionType() {
+ return new ExtensionTypeImpl();
}
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
index 179a10cc1a..75d1229cd8 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
@@ -19,14 +19,14 @@
package org.apache.tuscany.sca.policy.impl;
import java.util.ArrayList;
-import java.util.Hashtable;
import java.util.List;
-import java.util.Map;
import javax.xml.namespace.QName;
import javax.xml.xpath.XPathExpression;
import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentMap;
+import org.apache.tuscany.sca.policy.PolicyExpression;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -37,29 +37,17 @@ import org.apache.tuscany.sca.policy.PolicySet;
public class PolicySetImpl implements PolicySet {
private QName name;
- //private List<Operation> operations = new ArrayList<Operation>();
- //private List<QName> appliesTo;
private String appliesTo;
+ private String attachTo;
private List<Intent> providedIntents = new ArrayList<Intent>();
private List<PolicySet> referencedPolicySets = new ArrayList<PolicySet>();
- private List<Object> policies = new ArrayList<Object>();
- Map<Intent, List<Object>> mappedPolicies = new Hashtable<Intent, List<Object>>();
private boolean unresolved = true;
- private String alwaysAppliesTo;
-
- private XPathExpression appliesToXPathExpression;
- private XPathExpression alwaysAppliesToXPathExpression;
-
- public String getAlwaysAppliesTo() {
- return alwaysAppliesTo;
- }
- public void setAlwaysAppliesTo(String alwaysAppliesTo) {
- this.alwaysAppliesTo = alwaysAppliesTo;
- }
+ private XPathExpression appliesToXPathExpression;
+ private XPathExpression attachToXPathExpression;
- protected PolicySetImpl() {
- }
+ private List<IntentMap> intentMaps = new ArrayList<IntentMap>();
+ private List<PolicyExpression> policies = new ArrayList<PolicyExpression>();
public QName getName() {
return name;
@@ -69,10 +57,6 @@ public class PolicySetImpl implements PolicySet {
this.name = name;
}
- /*public List<Operation> getOperations() {
- return operations;
- }*/
-
public String getAppliesTo() {
return appliesTo;
}
@@ -81,16 +65,12 @@ public class PolicySetImpl implements PolicySet {
this.appliesTo = appliesTo;
}
- public List<Intent> getProvidedIntents() {
- return providedIntents;
- }
-
- public List<PolicySet> getReferencedPolicySets() {
- return referencedPolicySets;
+ public String getAttachTo() {
+ return attachTo;
}
- public List<Object> getPolicies() {
- return policies;
+ public void setAttachTo(String attachTo) {
+ this.attachTo = attachTo;
}
public boolean isUnresolved() {
@@ -101,49 +81,65 @@ public class PolicySetImpl implements PolicySet {
this.unresolved = unresolved;
}
- public Map<Intent, List<Object>> getMappedPolicies() {
- return mappedPolicies;
+ public XPathExpression getAppliesToXPathExpression() {
+ return appliesToXPathExpression;
}
-
- @Override
- public int hashCode() {
- return String.valueOf(getName()).hashCode();
+
+ public void setAppliesToXPathExpression(XPathExpression appliesToXPathExpression) {
+ this.appliesToXPathExpression = appliesToXPathExpression;
}
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- } else if (obj instanceof PolicySet) {
- if (getName() != null) {
- return getName().equals(((PolicySet)obj).getName());
- } else {
- return ((PolicySet)obj).getName() == null;
- }
- } else {
- return false;
- }
+
+ public XPathExpression getAttachToXPathExpression() {
+ return attachToXPathExpression;
}
-
- @Override
- public String toString() {
- return ( this.name != null ) ? getName().toString() : "null";
+
+ public void setAttachToXPathExpression(XPathExpression attachToXPathExpression) {
+ this.attachToXPathExpression = attachToXPathExpression;
}
- public XPathExpression getAppliesToXPathExpression() {
- return appliesToXPathExpression;
+ public List<IntentMap> getIntentMaps() {
+ return intentMaps;
}
- public void setAppliesToXPathExpression(XPathExpression appliesToXPathExpression) {
- this.appliesToXPathExpression = appliesToXPathExpression;
+ public List<Intent> getProvidedIntents() {
+ return providedIntents;
+ }
+
+ public List<PolicySet> getReferencedPolicySets() {
+ return referencedPolicySets;
}
- public XPathExpression getAlwaysAppliesToXPathExpression() {
- return alwaysAppliesToXPathExpression;
+ public List<PolicyExpression> getPolicies() {
+ return policies;
+ }
+
+ public String toString() {
+ return String.valueOf(name);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
}
- public void setAlwaysAppliesToXPathExpression(XPathExpression alwaysAppliesToXPathExpression) {
- this.alwaysAppliesToXPathExpression = alwaysAppliesToXPathExpression;
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PolicySetImpl other = (PolicySetImpl)obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
}
}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetReferenceImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetReferenceImpl.java
deleted file mode 100644
index 98a116fe7b..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetReferenceImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy.impl;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.policy.PolicySetReference;
-
-/**
- * Concrete implementation for a PolicySetReference
- *
- * @version $Rev$ $Date$
- */
-public class PolicySetReferenceImpl implements PolicySetReference {
-
- private QName referredPolicySetName = null;
-
- /*
- * @see org.apache.tuscany.sca.policy.PolicySetReference#getReferredPolicySetName()
- */
- public QName getReferredPolicySetName() {
- return referredPolicySetName;
- }
-
- /*
- * @see org.apache.tuscany.sca.policy.PolicySetReference#setReferredPolicySetName(javax.xml.namespace.QName)
- */
- public void setReferredPolicySetName(QName refPolicySetName) {
- referredPolicySetName = refPolicySetName;
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifiedIntentImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifiedIntentImpl.java
deleted file mode 100644
index d6f65b1788..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifiedIntentImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy.impl;
-
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.QualifiedIntent;
-
-/**
- * Models a concrete implementation of a Qualified Intent
- *
- * @version $Rev$ $Date$
- */
-public class QualifiedIntentImpl extends IntentImpl implements QualifiedIntent {
- private Intent qualifiableIntent = null;
-
- public Intent getQualifiableIntent() {
- return qualifiableIntent;
- }
-
- public void setQualifiableIntent(Intent qualifiableIntent) {
- this.qualifiableIntent = qualifiableIntent;
- }
-
- @Override
- public List<QName> getConstrains() {
- return getQualifiableIntent().getConstrains();
- }
-
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ProfileIntentImpl.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java
index e5002d2cdc..102bea8d41 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/ProfileIntentImpl.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java
@@ -1,39 +1,48 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.policy.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.ProfileIntent;
-
-/**
- * Concrete implementation for Profile Intent
- *
- * @version $Rev$ $Date$
- */
-public class ProfileIntentImpl extends IntentImpl implements ProfileIntent {
- private List<Intent> requiredIntents = new ArrayList<Intent>();
-
- public List<Intent> getRequiredIntents() {
- return requiredIntents;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.Qualifier;
+
+public class QualifierImpl implements Qualifier {
+ private Intent intent;
+ private List<PolicyExpression> policies = new ArrayList<PolicyExpression>();
+
+ protected QualifierImpl() {
+ }
+
+ public Intent getIntent() {
+ return intent;
+ }
+
+ public List<PolicyExpression> getPolicies() {
+ return policies;
+ }
+
+ public void setIntent(Intent intent) {
+ this.intent = intent;
+ }
+
+}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
index 2e4c6a9d78..077b71009f 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java
@@ -48,10 +48,9 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.ProfileIntent;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -66,9 +65,9 @@ public class PolicyComputationUtils {
private static final String POLICYSET_PREFIX = "tp_";
private static final String APPLICABLE_POLICYSET_ATTR_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
private static final String APPLICABLE_POLICYSET_ATTR = "applicablePolicySets";
- private static final String POLICY_SETS_ATTR = "policySets";
+ private static final String POLICY_SETS_ATTR = "policySets";
private static final String APPLICABLE_POLICYSET_ATTR_PREFIX = "tuscany";
- private static final String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200712";
/**
* This method unconditionally adds intents from the source list to the target list.
@@ -125,8 +124,7 @@ public class PolicyComputationUtils {
public static void addDefaultPolicies(List<Intent> sourceIntents,
List<PolicySet> sourcePolicySets,
List<Intent> targetIntents,
- List<PolicySet> targetPolicySets)
- {
+ List<PolicySet> targetPolicySets) {
// form a list of all intents required by the target
List<Intent> combinedTargetIntents = new ArrayList<Intent>();
combinedTargetIntents.addAll(findAndExpandProfileIntents(targetIntents));
@@ -167,14 +165,12 @@ public class PolicyComputationUtils {
}
- public static void checkForMutuallyExclusiveIntents(
- List<Intent> intents,
- List<PolicySet> policySets,
- IntentAttachPointType intentAttachPointType,
- String id) throws PolicyValidationException
- {
+ public static void checkForMutuallyExclusiveIntents(List<Intent> intents,
+ List<PolicySet> policySets,
+ ExtensionType intentAttachPointType,
+ String id) throws PolicyValidationException {
// gather all intents (keeping track of where they come from)
- Map<Intent, PolicySet> combinedIntents = new HashMap<Intent,PolicySet>();
+ Map<Intent, PolicySet> combinedIntents = new HashMap<Intent, PolicySet>();
for (PolicySet policySet : policySets) {
for (Intent providedIntent : findAndExpandProfileIntents(policySet.getProvidedIntents())) {
combinedIntents.put(providedIntent, policySet);
@@ -192,14 +188,21 @@ public class PolicyComputationUtils {
if (combinedIntents.get(intent) == null)
sIntent1 = intent.getName().toString();
else
- sIntent1 = intent.getName().toString() + " in policy set " + combinedIntents.get(intent).getName().toString();
+ sIntent1 =
+ intent.getName().toString() + " in policy set "
+ + combinedIntents.get(intent).getName().toString();
if (combinedIntents.get(excluded) == null)
sIntent2 = excluded.getName().toString();
else
- sIntent2 = excluded.getName().toString() + " in policy set " + combinedIntents.get(excluded).getName().toString();
- throw new PolicyValidationException(
- intentAttachPointType.getName() + " for " + id +
- " uses mutually-exclusive intents " + sIntent1 + " and " + sIntent2);
+ sIntent2 =
+ excluded.getName().toString() + " in policy set "
+ + combinedIntents.get(excluded).getName().toString();
+ throw new PolicyValidationException(intentAttachPointType.getType() + " for "
+ + id
+ + " uses mutually-exclusive intents "
+ + sIntent1
+ + " and "
+ + sIntent2);
}
}
}
@@ -207,7 +210,7 @@ public class PolicyComputationUtils {
public static void expandProfileIntents(List<Intent> intents) {
List<Intent> expandedIntents = null;
- if ( intents.size() > 0 ) {
+ if (intents.size() > 0) {
expandedIntents = findAndExpandProfileIntents(intents);
intents.clear();
intents.addAll(expandedIntents);
@@ -216,10 +219,9 @@ public class PolicyComputationUtils {
public static List<Intent> findAndExpandProfileIntents(List<Intent> intents) {
List<Intent> expandedIntents = new ArrayList<Intent>();
- for ( Intent intent : intents ) {
- if ( intent instanceof ProfileIntent ) {
- ProfileIntent profileIntent = (ProfileIntent)intent;
- List<Intent> requiredIntents = profileIntent.getRequiredIntents();
+ for (Intent intent : intents) {
+ if (!intent.getRequiredIntents().isEmpty()) {
+ List<Intent> requiredIntents = intent.getRequiredIntents();
expandedIntents.addAll(findAndExpandProfileIntents(requiredIntents));
} else {
expandedIntents.add(intent);
@@ -230,15 +232,11 @@ public class PolicyComputationUtils {
private static byte[] addApplicablePolicySets(Document doc, Collection<PolicySet> policySets)
throws XPathExpressionException, TransformerConfigurationException, TransformerException {
-
+
for (PolicySet policySet : policySets) {
if (policySet.getAppliesTo() != null) {
addApplicablePolicySets(policySet, doc);
}
-
- if (policySet.getAlwaysAppliesTo() != null) {
- addAlwaysApplicablePolicySets(policySet, doc);
- }
}
StringWriter sw = new StringWriter();
@@ -258,48 +256,11 @@ public class PolicyComputationUtils {
} catch (PrivilegedActionException e) {
throw (TransformerException)e.getException();
}
-
- return sw.toString().getBytes();
- }
-
- private static void addAlwaysApplicablePolicySets(PolicySet policySet,
- Document doc) throws XPathExpressionException {
- XPathExpression expression = policySet.getAlwaysAppliesToXPathExpression();
- NodeList result = (NodeList)expression.evaluate(doc, XPathConstants.NODESET);
-
- if (result != null) {
- for (int counter = 0; counter < result.getLength(); ++counter) {
- Node aResultNode = result.item(counter);
- String alwaysApplicablePolicySets = null;
-
- String policySetPrefix =
- declareNamespace((Element)aResultNode, policySet.getName().getNamespaceURI());
- String policySetsAttrPrefix =
- declareNamespace((Element)aResultNode, SCA10_NS);
- if (aResultNode.getAttributes().getNamedItem(POLICY_SETS_ATTR) != null) {
- alwaysApplicablePolicySets =
- aResultNode.getAttributes().getNamedItem(POLICY_SETS_ATTR).getNodeValue();
- }
-
- if (alwaysApplicablePolicySets != null && alwaysApplicablePolicySets.length() > 0) {
- alwaysApplicablePolicySets =
- alwaysApplicablePolicySets + " "
- + policySetPrefix
- + ":"
- + policySet.getName().getLocalPart();
- } else {
- alwaysApplicablePolicySets =
- policySetPrefix + ":" + policySet.getName().getLocalPart();
- }
-
- ((Element)aResultNode).setAttribute(POLICY_SETS_ATTR, alwaysApplicablePolicySets);
- }
- }
+ return sw.toString().getBytes();
}
- private static void addApplicablePolicySets(PolicySet policySet,
- Document doc) throws XPathExpressionException {
+ private static void addApplicablePolicySets(PolicySet policySet, Document doc) throws XPathExpressionException {
XPathExpression expression = policySet.getAppliesToXPathExpression();
NodeList result = (NodeList)expression.evaluate(doc, XPathConstants.NODESET);
@@ -309,46 +270,37 @@ public class PolicyComputationUtils {
String applicablePolicySets = null;
- String policySetPrefix =
- declareNamespace((Element)aResultNode, policySet.getName().getNamespaceURI());
- String appPolicyAttrPrefix =
- declareNamespace((Element)aResultNode,
- APPLICABLE_POLICYSET_ATTR_NS);
- if (aResultNode.getAttributes().getNamedItemNS(APPLICABLE_POLICYSET_ATTR_NS,
- APPLICABLE_POLICYSET_ATTR) != null) {
+ String policySetPrefix = declareNamespace((Element)aResultNode, policySet.getName().getNamespaceURI());
+ String appPolicyAttrPrefix = declareNamespace((Element)aResultNode, APPLICABLE_POLICYSET_ATTR_NS);
+ if (aResultNode.getAttributes().getNamedItemNS(APPLICABLE_POLICYSET_ATTR_NS, APPLICABLE_POLICYSET_ATTR) != null) {
applicablePolicySets =
aResultNode.getAttributes().getNamedItemNS(APPLICABLE_POLICYSET_ATTR_NS,
- APPLICABLE_POLICYSET_ATTR)
- .getNodeValue();
+ APPLICABLE_POLICYSET_ATTR).getNodeValue();
}
if (applicablePolicySets != null && applicablePolicySets.length() > 0) {
applicablePolicySets =
- applicablePolicySets + " "
- + policySetPrefix
- + ":"
- + policySet.getName().getLocalPart();
+ applicablePolicySets + " " + policySetPrefix + ":" + policySet.getName().getLocalPart();
} else {
- applicablePolicySets =
- policySetPrefix + ":" + policySet.getName().getLocalPart();
+ applicablePolicySets = policySetPrefix + ":" + policySet.getName().getLocalPart();
}
- ((Element)aResultNode).setAttributeNS(APPLICABLE_POLICYSET_ATTR_NS,
- appPolicyAttrPrefix + ":"
- + APPLICABLE_POLICYSET_ATTR,
- applicablePolicySets);
+ ((Element)aResultNode).setAttributeNS(APPLICABLE_POLICYSET_ATTR_NS, appPolicyAttrPrefix + ":"
+ + APPLICABLE_POLICYSET_ATTR, applicablePolicySets);
}
}
}
- public static byte[] addApplicablePolicySets(InputStream is, Collection<PolicySet> domainPolicySets, DocumentBuilderFactory documentBuilderFactory) throws Exception {
+ public static byte[] addApplicablePolicySets(InputStream is,
+ Collection<PolicySet> domainPolicySets,
+ DocumentBuilderFactory documentBuilderFactory) throws Exception {
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder db = documentBuilderFactory.newDocumentBuilder();
Document doc = db.parse(is);
is.close();
return addApplicablePolicySets(doc, domainPolicySets);
}
-
+
private static class DOMNamespaceContext implements NamespaceContext {
private Node node;
@@ -373,7 +325,7 @@ public class PolicyComputationUtils {
}
}
-
+
private static String declareNamespace(Element element, String ns) {
if (ns == null) {
ns = "";
@@ -382,7 +334,7 @@ public class PolicyComputationUtils {
String prefix = "";
boolean declared = false;
while (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
- if ( node.lookupPrefix(ns) != null ) {
+ if (node.lookupPrefix(ns) != null) {
prefix = node.lookupPrefix(ns);
declared = true;
break;
@@ -401,7 +353,7 @@ public class PolicyComputationUtils {
}
if (!declared) {
// Find an available prefix
- for (int i=1; ; i++) {
+ for (int i = 1;; i++) {
prefix = POLICYSET_PREFIX + i;
if (element.lookupNamespaceURI(prefix) == null) {
break;
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandler.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandler.java
deleted file mode 100644
index 1f91710f95..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandler.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.util;
-
-import org.apache.tuscany.sca.policy.PolicySet;
-
-/**
- * @deprecated This interface is replaced by PolicyProviderFactory/PolicyProvider SPIs
- * Handler interface for handling policies defined in policysets
- *
- * @version $Rev$ $Date$
- */
-@Deprecated
-public interface PolicyHandler {
- PolicySet getApplicablePolicySet();
- void setApplicablePolicySet(PolicySet policySet);
- void setUp(Object... context);
- void cleanUp(Object... context);
- void beforeInvoke(Object... context);
- void afterInvoke(Object... context);
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java
deleted file mode 100644
index e9af4912a3..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerDefinitionsLoader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.util;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
-
-/**
- * Utility class for loading policy handler definitions from META-INF/services directories
- *
- * @version $Rev$ $Date$
- */
-public class PolicyHandlerDefinitionsLoader {
-
- public static List<PolicyHandlerTuple> loadPolicyHandlerClassnames() {
- // Get the processor service declarations
- Set<ServiceDeclaration> sds;
- try {
- sds = ServiceDiscovery.getInstance().getServiceDeclarations(PolicyHandler.class.getName());
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
-
- List<PolicyHandlerTuple> handlerTupleList = new ArrayList<PolicyHandlerTuple>();
-
- Map<Object, List<PolicyHandlerTuple>> handlerTuples = new Hashtable<Object, List<PolicyHandlerTuple>>();
- for (ServiceDeclaration sd : sds) {
- Map<String, String> attributes = sd.getAttributes();
- String intentName = attributes.get("intent");
- QName intentQName = getQName(intentName);
- String policyModelClassName = attributes.get("model");
- String appliesTo = attributes.get("appliesTo");
- if ( appliesTo != null && !appliesTo.startsWith("/") ) {
- appliesTo = "//" + appliesTo;
- }
- handlerTupleList.add(new PolicyHandlerTuple(sd, sd.getClassName(), intentQName, policyModelClassName, appliesTo));
- }
-
- return handlerTupleList;
- }
-
- private static QName getQName(String qname) {
- if (qname == null) {
- return null;
- }
- qname = qname.trim();
- if (qname.startsWith("{")) {
- int h = qname.indexOf('}');
- if (h != -1) {
- return new QName(qname.substring(1, h), qname.substring(h + 1));
- }
- } else {
- int h = qname.indexOf('#');
- if (h != -1) {
- return new QName(qname.substring(0, h), qname.substring(h + 1));
- }
- }
- throw new IllegalArgumentException("Invalid qname: " + qname);
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java
deleted file mode 100644
index c80e68a0be..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerTuple.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.util;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-
-/**
- * PolicyHanlder tuples stored in policy handler services files
- *
- * @version $Rev$ $Date$
- */
-public class PolicyHandlerTuple {
- private ServiceDeclaration declaration;
- private String policyHandlerClassName;
- private QName providedIntentName;
- private String policyModelClassName;
- private String appliesTo;
-
- public PolicyHandlerTuple(ServiceDeclaration declaration,
- String handlerClassName,
- QName providedIntentName,
- String policyModelClassName,
- String appliesTo) {
- this.declaration = declaration;
- this.policyHandlerClassName = handlerClassName;
- this.providedIntentName = providedIntentName;
- this.policyModelClassName = policyModelClassName;
- this.appliesTo = appliesTo;
- }
-
- public ServiceDeclaration getDeclaration() {
- return declaration;
- }
-
- public void setDeclaration(ServiceDeclaration declaration) {
- this.declaration = declaration;
- }
-
- public String getAppliesTo() {
- return appliesTo;
- }
-
- public void setAppliesTo(String appliesTo) {
- this.appliesTo = appliesTo;
- }
-
-
- public String getPolicyHandlerClassName() {
- return policyHandlerClassName;
- }
- public void setPolicyHandlerClassName(String policyHandlerClassName) {
- this.policyHandlerClassName = policyHandlerClassName;
- }
- public String getPolicyModelClassName() {
- return policyModelClassName;
- }
- public void setPolicyModelClassName(String policyModelClassName) {
- this.policyModelClassName = policyModelClassName;
- }
- public QName getProvidedIntentName() {
- return providedIntentName;
- }
- public void setProvidedIntentName(QName providedIntentName) {
- this.providedIntentName = providedIntentName;
- }
-
- @Override
- public String toString() {
- return policyHandlerClassName + ", " + providedIntentName + ", " + policyModelClassName + ", " + appliesTo;
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerUtils.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerUtils.java
deleted file mode 100644
index 6d6420017f..0000000000
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHandlerUtils.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.policy.util;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicySet;
-
-/**
- * Utility methods to deal with PolicyHandlers
- *
- * @version $Rev$ $Date$
- */
-public class PolicyHandlerUtils {
- public static PolicyHandler findPolicyHandler(PolicySet policySet, List<PolicyHandlerTuple> policyHandlerClassNames)
- throws IllegalAccessException, ClassNotFoundException, InstantiationException {
-
- PolicyHandler handler = null;
-
- for (PolicyHandlerTuple handlerTuple : policyHandlerClassNames) {
- //System.out.println(handlerTuple);
- for (Intent intent : policySet.getProvidedIntents()) {
- if (intent.getName().equals(handlerTuple.getProvidedIntentName())) {
- for (Object policy : policySet.getPolicies()) {
- if (policy.getClass().getName().equals(handlerTuple.getPolicyModelClassName())) {
- if (handlerTuple.getAppliesTo() != null) {
- if (handlerTuple.getAppliesTo().equals(policySet.getAppliesTo())) {
- handler = (PolicyHandler)handlerTuple.getDeclaration().loadClass().newInstance();
- handler.setApplicablePolicySet(policySet);
- return handler;
- }
- } else {
- handler = (PolicyHandler)handlerTuple.getDeclaration().loadClass().newInstance();
- handler.setApplicablePolicySet(policySet);
- return handler;
- }
- }
- }
- }
- }
- }
-
- return handler;
- }
-
-}
diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
index afb3c035ae..c8fe89f364 100644
--- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
+++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java
@@ -21,27 +21,22 @@ package org.apache.tuscany.sca.policy.util;
import java.util.List;
-import javax.xml.namespace.QName;
-
+import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.IntentAttachPoint;
-import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
-import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.PolicySubject;
/**
* @version $Rev$ $Date$
*/
public class PolicyValidationUtils {
- public static boolean isConstrained(QName constrained, IntentAttachPointType attachPointType) {
- return (attachPointType != null && attachPointType.getName().getNamespaceURI()
- .equals(constrained.getNamespaceURI()) && attachPointType.getName().getLocalPart()
- .startsWith(constrained.getLocalPart()));
+ public static boolean isConstrained(ExtensionType constrained, ExtensionType attachPointType) {
+ return (attachPointType != null
+ && (attachPointType.equals(constrained)) || (attachPointType.getBaseType().equals(constrained)));
}
- public static void validateIntents(IntentAttachPoint attachPoint,
- IntentAttachPointType attachPointType)
+ public static void validateIntents(PolicySubject attachPoint, ExtensionType attachPointType)
throws PolicyValidationException {
boolean found = false;
if (attachPointType != null) {
@@ -50,7 +45,7 @@ public class PolicyValidationUtils {
found = false;
for (Intent intent : attachPoint.getRequiredIntents()) {
if (!intent.isUnresolved()) {
- for (QName constrained : intent.getConstrains()) {
+ for (ExtensionType constrained : intent.getConstrainedTypes()) {
if (isConstrained(constrained, attachPointType)) {
found = true;
break;
@@ -60,7 +55,7 @@ public class PolicyValidationUtils {
if (!found) {
throw new PolicyValidationException("Policy Intent '" + intent.getName()
+ "' does not constrain extension type "
- + attachPointType.getName());
+ + attachPointType.getType());
}
} else {
throw new PolicyValidationException("Policy Intent '" + intent.getName()
@@ -70,36 +65,28 @@ public class PolicyValidationUtils {
}
}
- public static void validatePolicySets(PolicySetAttachPoint policySetAttachPoint)
- throws PolicyValidationException {
- validatePolicySets(policySetAttachPoint,
- policySetAttachPoint.getType(),
- policySetAttachPoint.getApplicablePolicySets());
+ public static void validatePolicySets(PolicySubject subject) throws PolicyValidationException {
+ // validatePolicySets(subject, subject.getType(), subject.getAttachedPolicySets());
}
-
- public static void validatePolicySets(PolicySetAttachPoint policySetAttachPoint,
- IntentAttachPointType attachPointType)
+
+ public static void validatePolicySets(PolicySubject subject, ExtensionType attachPointType)
throws PolicyValidationException {
- validatePolicySets(policySetAttachPoint,
- attachPointType,
- policySetAttachPoint.getApplicablePolicySets());
+ validatePolicySets(subject, attachPointType, subject.getPolicySets());
}
- public static void validatePolicySets(PolicySetAttachPoint policySetAttachPoint,
- IntentAttachPointType attachPointType,
- List<PolicySet> applicablePolicySets)
- throws PolicyValidationException {
- // Since the applicablePolicySets in a policySetAttachPoint will already
+ public static void validatePolicySets(PolicySubject subject,
+ ExtensionType attachPointType,
+ List<PolicySet> applicablePolicySets) throws PolicyValidationException {
+ // Since the applicablePolicySets in a subject will already
// have the list of policysets that might ever be applicable to this attachPoint,
// just check if the defined policysets feature in the list of applicable
// policysets
- for (PolicySet definedPolicySet : policySetAttachPoint.getPolicySets()) {
+ for (PolicySet definedPolicySet : subject.getPolicySets()) {
if (!definedPolicySet.isUnresolved()) {
if (!applicablePolicySets.contains(definedPolicySet)) {
- throw new PolicyValidationException("Policy Set '" + definedPolicySet
- .getName()
+ throw new PolicyValidationException("Policy Set '" + definedPolicySet.getName()
+ "' does not apply to extension type "
- + attachPointType.getName());
+ + attachPointType.getType());
}
} else {
throw new PolicyValidationException("Policy Set '" + definedPolicySet.getName()
diff --git a/java/sca/modules/policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory b/java/sca/modules/policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory
deleted file mode 100644
index a0e56c1822..0000000000
--- a/java/sca/modules/policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.tuscany.sca.policy.DefaultIntentAttachPointTypeFactory \ No newline at end of file
diff --git a/java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/builder/DefaultContributionBuilderExtensionPoint.java b/java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/builder/DefaultContributionBuilderExtensionPoint.java
index 490eae9dad..8ce6f53f20 100644
--- a/java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/builder/DefaultContributionBuilderExtensionPoint.java
+++ b/java/sca/modules/workspace/src/main/java/org/apache/tuscany/sca/workspace/builder/DefaultContributionBuilderExtensionPoint.java
@@ -63,7 +63,7 @@ public class DefaultContributionBuilderExtensionPoint implements ContributionBui
/**
* Load builders declared under META-INF/services.
*/
- private void loadBuilders() {
+ private synchronized void loadBuilders() {
if (loaded)
return;