From cf9fccdc66de888137a8d33c3ca9c6f206dcc633 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 11 Sep 2009 06:26:33 +0000 Subject: Merge modules to assembly module as discussed on ML git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@813673 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/features/core/pom.xml | 5 - java/sca/modules/assembly-xml/pom.xml | 12 - java/sca/modules/assembly/META-INF/MANIFEST.MF | 46 ++- java/sca/modules/assembly/pom.xml | 19 +- .../sca/definitions/DefaultDefinitionsFactory.java | 32 ++ .../tuscany/sca/definitions/Definitions.java | 83 +++++ .../sca/definitions/DefinitionsBuilder.java | 34 ++ .../definitions/DefinitionsBuilderException.java | 43 +++ .../sca/definitions/DefinitionsFactory.java | 31 ++ .../definitions/impl/DefinitionsBuilderImpl.java | 307 ++++++++++++++++ .../sca/definitions/impl/DefinitionsImpl.java | 72 ++++ .../sca/definitions/util/DefinitionsUtil.java | 102 ++++++ .../sca/interfacedef/ConversationSequence.java | 29 ++ .../apache/tuscany/sca/interfacedef/DataType.java | 119 +++++++ .../sca/interfacedef/FaultExceptionMapper.java | 62 ++++ .../IncompatibleInterfaceContractException.java | 69 ++++ .../apache/tuscany/sca/interfacedef/Interface.java | 102 ++++++ .../sca/interfacedef/InterfaceContract.java | 81 +++++ .../sca/interfacedef/InterfaceContractMapper.java | 139 ++++++++ .../sca/interfacedef/InvalidCallbackException.java | 34 ++ .../interfacedef/InvalidInterfaceException.java | 41 +++ .../interfacedef/InvalidOperationException.java | 42 +++ .../apache/tuscany/sca/interfacedef/Operation.java | 209 +++++++++++ .../interfacedef/OverloadedOperationException.java | 45 +++ .../sca/interfacedef/impl/DataTypeImpl.java | 219 ++++++++++++ .../interfacedef/impl/InterfaceContractImpl.java | 128 +++++++ .../impl/InterfaceContractMapperImpl.java | 390 ++++++++++++++++++++ .../sca/interfacedef/impl/InterfaceImpl.java | 259 ++++++++++++++ .../sca/interfacedef/impl/OperationImpl.java | 284 +++++++++++++++ .../tuscany/sca/interfacedef/util/ElementInfo.java | 114 ++++++ .../sca/interfacedef/util/FaultException.java | 82 +++++ .../sca/interfacedef/util/JavaXMLMapper.java | 143 ++++++++ .../tuscany/sca/interfacedef/util/TypeInfo.java | 100 ++++++ .../tuscany/sca/interfacedef/util/WrapperInfo.java | 190 ++++++++++ .../tuscany/sca/interfacedef/util/XMLType.java | 152 ++++++++ .../org/apache/tuscany/sca/policy/BindingType.java | 27 ++ .../tuscany/sca/policy/DefaultPolicyFactory.java | 30 ++ .../apache/tuscany/sca/policy/ExtensionType.java | 81 +++++ .../tuscany/sca/policy/ImplementationType.java | 27 ++ .../java/org/apache/tuscany/sca/policy/Intent.java | 160 +++++++++ .../org/apache/tuscany/sca/policy/IntentMap.java | 51 +++ .../tuscany/sca/policy/PolicyAttachment.java | 31 ++ .../tuscany/sca/policy/PolicyExpression.java | 65 ++++ .../apache/tuscany/sca/policy/PolicyFactory.java | 66 ++++ .../org/apache/tuscany/sca/policy/PolicySet.java | 146 ++++++++ .../apache/tuscany/sca/policy/PolicySubject.java | 56 +++ .../org/apache/tuscany/sca/policy/Qualifier.java | 44 +++ .../tuscany/sca/policy/impl/BindingTypeImpl.java | 38 ++ .../tuscany/sca/policy/impl/ExtensionTypeImpl.java | 97 +++++ .../sca/policy/impl/ImplementationTypeImpl.java | 39 ++ .../apache/tuscany/sca/policy/impl/IntentImpl.java | 168 +++++++++ .../tuscany/sca/policy/impl/IntentMapImpl.java | 61 ++++ .../sca/policy/impl/PolicyExpressionImpl.java | 86 +++++ .../tuscany/sca/policy/impl/PolicyFactoryImpl.java | 70 ++++ .../tuscany/sca/policy/impl/PolicySetImpl.java | 145 ++++++++ .../tuscany/sca/policy/impl/QualifierImpl.java | 48 +++ .../sca/policy/util/PolicyComputationUtils.java | 370 +++++++++++++++++++ .../sca/policy/util/PolicyValidationException.java | 38 ++ .../sca/policy/util/PolicyValidationUtils.java | 98 +++++ ...ache.tuscany.sca.definitions.DefinitionsFactory | 17 + ...uscany.sca.interfacedef.InterfaceContractMapper | 18 + .../org.apache.tuscany.sca.policy.PolicyFactory | 18 + .../definitions-validation-messages.properties | 25 ++ .../impl/ContractCompatibilityTestCase.java | 395 +++++++++++++++++++++ .../impl/InterfaceContractTestCase.java | 70 ++++ .../tuscany/sca/policy/PolicyFactoryTestCase.java | 55 +++ java/sca/modules/binding-ejb/pom.xml | 6 - java/sca/modules/core-spi/pom.xml | 19 - java/sca/modules/databinding/pom.xml | 2 +- java/sca/modules/definitions-xml/pom.xml | 13 +- java/sca/modules/endpoint-wrapper/pom.xml | 6 - .../modules/implementation-bpel-runtime/pom.xml | 5 - java/sca/modules/implementation-bpel/pom.xml | 6 - java/sca/modules/implementation-spring/pom.xml | 5 - java/sca/modules/implementation-web/pom.xml | 13 - java/sca/modules/interface-java/pom.xml | 6 - java/sca/modules/interface-wsdl/pom.xml | 12 - java/sca/modules/interface/LICENSE | 205 ----------- java/sca/modules/interface/META-INF/MANIFEST.MF | 27 -- java/sca/modules/interface/NOTICE | 6 - java/sca/modules/interface/pom.xml | 39 -- .../sca/interfacedef/ConversationSequence.java | 29 -- .../apache/tuscany/sca/interfacedef/DataType.java | 119 ------- .../sca/interfacedef/FaultExceptionMapper.java | 62 ---- .../IncompatibleInterfaceContractException.java | 69 ---- .../apache/tuscany/sca/interfacedef/Interface.java | 102 ------ .../sca/interfacedef/InterfaceContract.java | 81 ----- .../sca/interfacedef/InterfaceContractMapper.java | 139 -------- .../sca/interfacedef/InvalidCallbackException.java | 34 -- .../interfacedef/InvalidInterfaceException.java | 41 --- .../interfacedef/InvalidOperationException.java | 42 --- .../apache/tuscany/sca/interfacedef/Operation.java | 209 ----------- .../interfacedef/OverloadedOperationException.java | 45 --- .../sca/interfacedef/impl/DataTypeImpl.java | 219 ------------ .../interfacedef/impl/InterfaceContractImpl.java | 128 ------- .../impl/InterfaceContractMapperImpl.java | 390 -------------------- .../sca/interfacedef/impl/InterfaceImpl.java | 259 -------------- .../sca/interfacedef/impl/OperationImpl.java | 284 --------------- .../tuscany/sca/interfacedef/util/ElementInfo.java | 114 ------ .../sca/interfacedef/util/FaultException.java | 82 ----- .../sca/interfacedef/util/JavaXMLMapper.java | 143 -------- .../tuscany/sca/interfacedef/util/TypeInfo.java | 100 ------ .../tuscany/sca/interfacedef/util/WrapperInfo.java | 190 ---------- .../tuscany/sca/interfacedef/util/XMLType.java | 152 -------- ...uscany.sca.interfacedef.InterfaceContractMapper | 18 - .../impl/ContractCompatibilityTestCase.java | 395 --------------------- .../impl/InterfaceContractTestCase.java | 70 ---- java/sca/modules/policy-logging/pom.xml | 5 - java/sca/modules/policy-xml-ws/pom.xml | 2 +- java/sca/modules/policy-xml/pom.xml | 2 +- java/sca/modules/pom.xml | 3 - 111 files changed, 6431 insertions(+), 3926 deletions(-) create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationException.java create mode 100644 java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java create mode 100644 java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory create mode 100644 java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper create mode 100644 java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory create mode 100644 java/sca/modules/assembly/src/main/resources/definitions-validation-messages.properties create mode 100644 java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java create mode 100644 java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java create mode 100644 java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java delete mode 100644 java/sca/modules/interface/LICENSE delete mode 100644 java/sca/modules/interface/META-INF/MANIFEST.MF delete mode 100644 java/sca/modules/interface/NOTICE delete mode 100644 java/sca/modules/interface/pom.xml delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java delete mode 100644 java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java delete mode 100644 java/sca/modules/interface/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper delete mode 100644 java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java delete mode 100644 java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java (limited to 'java') diff --git a/java/sca/features/core/pom.xml b/java/sca/features/core/pom.xml index a0e44668f4..f722cf72c7 100644 --- a/java/sca/features/core/pom.xml +++ b/java/sca/features/core/pom.xml @@ -222,11 +222,6 @@ - - org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT - org.apache.tuscany.sca tuscany-policy-security diff --git a/java/sca/modules/assembly-xml/pom.xml b/java/sca/modules/assembly-xml/pom.xml index adab44d15b..bb0f6cc5ed 100644 --- a/java/sca/modules/assembly-xml/pom.xml +++ b/java/sca/modules/assembly-xml/pom.xml @@ -35,18 +35,6 @@ 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-definitions - 2.0-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT - - org.apache.tuscany.sca tuscany-contribution diff --git a/java/sca/modules/assembly/META-INF/MANIFEST.MF b/java/sca/modules/assembly/META-INF/MANIFEST.MF index 544337cd89..e2a3b1db39 100644 --- a/java/sca/modules/assembly/META-INF/MANIFEST.MF +++ b/java/sca/modules/assembly/META-INF/MANIFEST.MF @@ -10,12 +10,51 @@ Export-Package: org.apache.tuscany.sca.assembly;version="2.0.0"; org.apache.tuscany.sca.definitions, org.apache.tuscany.sca.core, org.apache.tuscany.sca.monitor", + org.apache.tuscany.sca.assembly.builder.impl;version="2.0.0"; + uses:="org.apache.tuscany.sca.assembly, + org.apache.tuscany.sca.definitions, + org.apache.tuscany.sca.core, + org.apache.tuscany.sca.monitor", org.apache.tuscany.sca.assembly.impl;version="2.0.0"; uses:="javax.xml.xpath, org.apache.tuscany.sca.assembly, org.apache.tuscany.sca.policy, org.apache.tuscany.sca.interfacedef, - javax.xml.namespace" + javax.xml.namespace", + org.apache.tuscany.sca.policy.util;version="2.0.0"; + uses:="javax.xml.parsers, + javax.xml.transform.dom, + org.apache.tuscany.sca.policy, + org.apache.tuscany.sca.extensibility, + org.w3c.dom,javax.xml.namespace, + javax.xml.xpath,javax.xml.transform, + javax.xml.transform.stream", + org.apache.tuscany.sca.policy.impl;version="2.0.0"; + uses:="javax.xml.xpath, + org.apache.tuscany.sca.policy, + javax.xml.namespace", + org.apache.tuscany.sca.policy;version="2.0.0"; + uses:="javax.xml.xpath, + org.apache.tuscany.sca.policy.impl, + javax.xml.namespace", + org.apache.tuscany.sca.interfacedef.util;version="2.0.0"; + uses:="javax.xml.transform, + org.apache.tuscany.sca.interfacedef.impl, + org.apache.tuscany.sca.interfacedef, + javax.xml.datatype, + javax.xml.namespace", + org.apache.tuscany.sca.interfacedef.impl;version="2.0.0"; + uses:="org.apache.tuscany.sca.interfacedef.util, + org.apache.tuscany.sca.policy, + org.apache.tuscany.sca.interfacedef", + org.apache.tuscany.sca.interfacedef;version="2.0.0"; + uses:="org.apache.tuscany.sca.interfacedef.util, + org.apache.tuscany.sca.policy", + org.apache.tuscany.sca.definitions;version="2.0.0"; + uses:="org.apache.tuscany.sca.policy, + javax.xml.namespace", + org.apache.tuscany.sca.definitions.util;version="2.0.0"; + uses:="org.apache.tuscany.sca.definitions" Private-Package: org.apache.tuscany.sca.assembly.builder.impl;version= "2.0.0" Tool: Bnd-0.0.255 @@ -27,11 +66,13 @@ Bnd-LastModified: 1225397097203 Bundle-ManifestVersion: 2 Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt Bundle-Description: Apache Tuscany SCA Assembly Model -Import-Package: javax.xml.namespace, +Import-Package: javax.xml.datatype, + javax.xml.namespace, javax.xml.parsers, javax.xml.transform, javax.xml.transform.dom, javax.xml.transform.sax, + javax.xml.transform.stream, javax.xml.xpath, org.apache.tuscany.sca.assembly;version="2.0.0", org.apache.tuscany.sca.assembly.builder;version="2.0.0", @@ -43,6 +84,7 @@ Import-Package: javax.xml.namespace, org.apache.tuscany.sca.interfacedef.impl;version="2.0.0";resolution:=optional, org.apache.tuscany.sca.monitor;version="2.0.0", org.apache.tuscany.sca.policy;version="2.0.0", + org.apache.tuscany.sca.policy.impl;version="2.0.0", org.apache.tuscany.sca.policy.util;version="2.0.0", org.w3c.dom, org.xml.sax diff --git a/java/sca/modules/assembly/pom.xml b/java/sca/modules/assembly/pom.xml index 5e9fc08eec..11fa07c1e6 100644 --- a/java/sca/modules/assembly/pom.xml +++ b/java/sca/modules/assembly/pom.xml @@ -32,25 +32,12 @@ org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-interface - 2.0-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-definitions + tuscany-monitor 2.0-SNAPSHOT - - + org.apache.tuscany.sca - tuscany-monitor + tuscany-extensibility 2.0-SNAPSHOT diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java new file mode 100644 index 0000000000..156fd0af75 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.definitions; + +import org.apache.tuscany.sca.definitions.impl.DefinitionsImpl; + +/** + * Default Implementation of DefinitionsFactory + */ +public class DefaultDefinitionsFactory implements DefinitionsFactory { + + public Definitions createDefinitions() { + return new DefinitionsImpl(); + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java new file mode 100644 index 0000000000..979ff7c187 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java @@ -0,0 +1,83 @@ + /* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.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.PolicySet; + + +/** + * Represents SCA Definitions. + * + * @version $Rev$ $Date$ + */ +public interface Definitions { + /** + * Returns the target namespace for this SCA Definition + * @return the target namespace + */ + String getTargetNamespace(); + + /** + * Sets the target names for this SCA Definition. + * + * @param ns the target namespace for this SCA Definition + */ + void setTargetNamespace(String ns); + + /** + * Returns a list of domain wide Policy Intents + * + * @return a list of domain wide Policy Intents + */ + List getIntents(); + + /** + * Returns a list of domain wide PolicySets + * + * @return a list of domain wide PolicySets + */ + List getPolicySets(); + + /** + * Returns a list of domain wide Binding Types + * + * @return a list of domain wide Binding Types + */ + List getBindingTypes(); + + + /** + * Returns a list of domain wide Implementation Types + * + * @return a list of domain wide Implementation Types + */ + List getImplementationTypes(); + + /** + * Returns a list of domain wide binding definition objects + * + * @return a list of domain wide binding definition objects + */ + List getBindings(); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java new file mode 100644 index 0000000000..5c68c6cbff --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.definitions; + + +/** + * Interface to abstract building of SCA Definitions for a Domain + * + * @version $Rev$ $Date$ + */ +public interface DefinitionsBuilder { + /** + * Builds the SCA definitions + * + * @param scaDefns + */ + void build(Definitions scaDefns) throws DefinitionsBuilderException; +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java new file mode 100644 index 0000000000..f45be80888 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.definitions; + +/** + * Builder Exception + * + * @version $Rev$ $Date$ + */ +public class DefinitionsBuilderException extends Exception { + private static final long serialVersionUID = 2513219325230252783L; + + public DefinitionsBuilderException() { + } + + public DefinitionsBuilderException(String message) { + super(message); + } + + public DefinitionsBuilderException(Throwable cause) { + super(cause); + } + + public DefinitionsBuilderException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java new file mode 100644 index 0000000000..616616ae7a --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.definitions; + +/** + * Factory interface to create SCA definitions model + * + */ +public interface DefinitionsFactory { + /** + * Create an instance of SCA definitions + * @return a new instance of SCA definitions + */ + Definitions createDefinitions(); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java new file mode 100644 index 0000000000..d87d45b27a --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java @@ -0,0 +1,307 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.definitions.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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.IntentMap; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.Qualifier; + +/** + * Provides a concrete implementation for a SCADefinitionsBuilder + * + * @version $Rev$ $Date$ + */ +public class DefinitionsBuilderImpl implements DefinitionsBuilder { + + public void build(Definitions scaDefns) throws DefinitionsBuilderException { + Map definedIntents = new HashMap(); + for (Intent intent : scaDefns.getIntents()) { + definedIntents.put(intent.getName(), intent); + } + + Map definedPolicySets = new HashMap(); + for (PolicySet policySet : scaDefns.getPolicySets()) { + definedPolicySets.put(policySet.getName(), policySet); + } + + Map definedBindingTypes = new HashMap(); + for (BindingType bindingType : scaDefns.getBindingTypes()) { + definedBindingTypes.put(bindingType.getType(), bindingType); + } + + Map definedImplTypes = new HashMap(); + 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 definedBindingTypes, + Map definedIntents) throws DefinitionsBuilderException { + for (BindingType bindingType : scaDefns.getBindingTypes()) { + buildAlwaysProvidedIntents(bindingType, definedIntents); + buildMayProvideIntents(bindingType, definedIntents); + } + + } + + private void buildImplementationTypes(Definitions scaDefns, + Map definedImplTypes, + Map definedIntents) throws DefinitionsBuilderException { + for (ImplementationType implType : scaDefns.getImplementationTypes()) { + buildAlwaysProvidedIntents(implType, definedIntents); + buildMayProvideIntents(implType, definedIntents); + } + } + + private void buildPolicyIntents(Definitions scaDefns, Map definedIntents) + throws DefinitionsBuilderException { + for (Intent policyIntent : scaDefns.getIntents()) { + if (!policyIntent.getRequiredIntents().isEmpty()) { + buildProfileIntent(policyIntent, definedIntents); + } + + if (!policyIntent.getQualifiedIntents().isEmpty()) { + buildQualifiedIntent(policyIntent, definedIntents); + } + } + } + + private void buildPolicySets(Definitions scaDefns, + Map definedPolicySets, + Map definedIntents) throws DefinitionsBuilderException { + + for (PolicySet policySet : scaDefns.getPolicySets()) { + buildProvidedIntents(policySet, definedIntents); + buildIntentsInMappedPolicies(policySet, definedIntents); + buildReferredPolicySets(policySet, definedPolicySets); + } + + for (PolicySet policySet : scaDefns.getPolicySets()) { + for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) { + includeReferredPolicySets(policySet, referredPolicySet); + } + } + } + + private void buildProfileIntent(Intent policyIntent, Map 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) { + //resolve all required intents + List requiredIntents = new ArrayList(); + for (Intent requiredIntent : policyIntent.getRequiredIntents()) { + if (requiredIntent.isUnresolved()) { + Intent resolvedRequiredIntent = definedIntents.get(requiredIntent.getName()); + if (resolvedRequiredIntent != null) { + requiredIntents.add(resolvedRequiredIntent); + } else { + throw new DefinitionsBuilderException("Required Intent - " + requiredIntent + + " not found for ProfileIntent " + + policyIntent); + + } + } else { + requiredIntents.add(requiredIntent); + } + } + policyIntent.getRequiredIntents().clear(); + policyIntent.getRequiredIntents().addAll(requiredIntents); + } + } + + private void buildQualifiedIntent(Intent policyIntent, Map definedIntents) + throws DefinitionsBuilderException { + /* + if (policyIntent != null) { + //resolve the qualifiable intent + Intent qualifiableIntent = policyIntent.getQualifiableIntent(); + if (qualifiableIntent.isUnresolved()) { + Intent resolvedQualifiableIntent = definedIntents.get(qualifiableIntent.getName()); + + if (resolvedQualifiableIntent != null) { + policyIntent.setQualifiableIntent(resolvedQualifiableIntent); + } else { + throw new DefinitionsBuilderException("Qualifiable Intent - " + qualifiableIntent + + " not found for QualifiedIntent " + + policyIntent); + } + + } + } + */ + } + + private void buildAlwaysProvidedIntents(ExtensionType extensionType, Map definedIntents) + throws DefinitionsBuilderException { + if (extensionType != null) { + // resolve all provided intents + List alwaysProvided = new ArrayList(); + for (Intent providedIntent : extensionType.getAlwaysProvidedIntents()) { + if (providedIntent.isUnresolved()) { + Intent resolvedProvidedIntent = definedIntents.get(providedIntent.getName()); + if (resolvedProvidedIntent != null) { + alwaysProvided.add(resolvedProvidedIntent); + } else { + throw new DefinitionsBuilderException("Always Provided Intent - " + providedIntent + + " not found for ExtensionType " + + extensionType); + + } + } else { + alwaysProvided.add(providedIntent); + } + } + extensionType.getAlwaysProvidedIntents().clear(); + extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided); + } + } + + private void buildMayProvideIntents(ExtensionType extensionType, Map definedIntents) + throws DefinitionsBuilderException { + if (extensionType != null) { + // resolve all provided intents + List mayProvide = new ArrayList(); + 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); + + } + } else { + mayProvide.add(providedIntent); + } + } + extensionType.getMayProvidedIntents().clear(); + extensionType.getMayProvidedIntents().addAll(mayProvide); + } + } + + private void buildProvidedIntents(PolicySet policySet, Map definedIntents) + throws DefinitionsBuilderException { + if (policySet != null) { + //resolve all provided intents + List providedIntents = new ArrayList(); + for (Intent providedIntent : policySet.getProvidedIntents()) { + if (providedIntent.isUnresolved()) { + Intent resolvedProvidedIntent = definedIntents.get(providedIntent.getName()); + if (resolvedProvidedIntent != null) { + providedIntents.add(resolvedProvidedIntent); + } else { + throw new DefinitionsBuilderException("Provided Intent - " + providedIntent + + " not found for PolicySet " + + policySet); + + } + } else { + providedIntents.add(providedIntent); + } + } + policySet.getProvidedIntents().clear(); + policySet.getProvidedIntents().addAll(providedIntents); + } + } + + private void buildIntentsInMappedPolicies(PolicySet policySet, Map definedIntents) + throws DefinitionsBuilderException { + 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); + + } + } + } + } + } + + private void buildReferredPolicySets(PolicySet policySet, Map definedPolicySets) + throws DefinitionsBuilderException { + + List referredPolicySets = new ArrayList(); + for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) { + if (referredPolicySet.isUnresolved()) { + PolicySet resolvedReferredPolicySet = definedPolicySets.get(referredPolicySet.getName()); + if (resolvedReferredPolicySet != null) { + referredPolicySets.add(resolvedReferredPolicySet); + } else { + throw new DefinitionsBuilderException("Referred PolicySet - " + referredPolicySet + + "not found for PolicySet - " + + policySet); + } + } else { + referredPolicySets.add(referredPolicySet); + } + } + policySet.getReferencedPolicySets().clear(); + policySet.getReferencedPolicySets().addAll(referredPolicySets); + } + + private void includeReferredPolicySets(PolicySet policySet, PolicySet referredPolicySet) { + for (PolicySet furtherReferredPolicySet : referredPolicySet.getReferencedPolicySets()) { + includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet); + } + policySet.getPolicies().addAll(referredPolicySet.getPolicies()); + policySet.getIntentMaps().addAll(referredPolicySet.getIntentMaps()); + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java new file mode 100644 index 0000000000..1987b39abe --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.definitions.impl; + +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.PolicySet; + +/** + * Provides a concrete implementation for SCADefinitions + * + * @version $Rev$ $Date$ + */ +public class DefinitionsImpl implements Definitions { + private String targetNamespace = null; + private List intents = new CopyOnWriteArrayList(); + private List policySets = new CopyOnWriteArrayList(); + private List bindingTypes = new CopyOnWriteArrayList(); + private List implementationTypes = new CopyOnWriteArrayList(); + private List bindings = new CopyOnWriteArrayList(); + + + public List getBindingTypes() { + return bindingTypes; + } + + public List getImplementationTypes() { + return implementationTypes; + } + + public List getIntents() { + return intents; + } + + public List getPolicySets() { + return policySets; + } + + public String getTargetNamespace() { + return targetNamespace; + } + + public void setTargetNamespace(String ns) { + this.targetNamespace = ns; + } + + public List getBindings() { + return bindings; + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java new file mode 100644 index 0000000000..ba5a792c64 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.definitions.util; + +import java.util.HashSet; + +import org.apache.tuscany.sca.definitions.Definitions; +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.PolicySet; + +/** + * Some utility functions to deal with SCADefinitions + * + * @version $Rev$ $Date$ + */ +public class DefinitionsUtil { + + /** + * Add the source set of definitions into the target set of definitions checking that + * definitions artifacts are unique in the process + * + * @param source the input definitions collection + * @param target the definition collection into which source will aggregated + */ + public static void aggregate(Definitions source, Definitions target, Monitor monitor) { + + HashSet intents = new HashSet(target.getIntents()); + for(Intent intent : source.getIntents()){ + if (intents.contains(intent)){ + Monitor.error(monitor, + target, + "definitions-validation-messages", + "DuplicateIntent", + intent.getName().toString()); + } else { + target.getIntents().add(intent); + } + } + + HashSet policySets = new HashSet(target.getPolicySets()); + for(PolicySet policySet : source.getPolicySets()){ + if (policySets.contains(policySet)){ + Monitor.error(monitor, + target, + "definitions-validation-messages", + "DuplicatePolicySet", + policySet.getName().toString()); + } else { + target.getPolicySets().add(policySet); + } + } + + HashSet bindingTypes = new HashSet(target.getBindingTypes()); + for(BindingType bindingType : source.getBindingTypes()){ + if (bindingTypes.contains(bindingType)){ + Monitor.error(monitor, + target, + "definitions-validation-messages", + "DuplicateBindingType", + bindingType.getType().toString()); + } else { + target.getBindingTypes().add(bindingType); + } + } + + HashSet implementationTypes = new HashSet(target.getImplementationTypes()); + for(ImplementationType implementationType : source.getImplementationTypes()){ + if (implementationTypes.contains(implementationType)){ + Monitor.error(monitor, + target, + "definitions-validation-messages", + "DuplicateImplementationType", + implementationType.getType().toString()); + } else { + target.getImplementationTypes().add(implementationType); + } + } + + target.getBindings().addAll(source.getBindings()); + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java new file mode 100644 index 0000000000..247a432330 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.interfacedef; + +/** + * Enum of the Conversation Sequence values. + * + * @version $Rev$ $Date$ + */ +public enum ConversationSequence { + CONVERSATION_NONE, CONVERSATION_START, CONVERSATION_CONTINUE, CONVERSATION_END +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java new file mode 100644 index 0000000000..1f5620c0b9 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java @@ -0,0 +1,119 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef; + +import java.lang.reflect.Type; + +/** + * Representation of the type of data associated with an operation. Data is + * represented in two forms: the physical form used by the runtime and a logical + * form used by the assembly. The physical form is a Java Type because the + * runtime is written in Java. This may be the same form used by the application + * but it may not; for example, an application that is performing stream + * processing may want a physical form such as an + * {@link java.io.InputStream InputStream} to semantially operate on application + * data such as a purchase order. The logical description is that used by the + * assembly model and is an identifier into some well-known type space; examples + * may be a Java type represented by its Class or an XML type represented by its + * QName. Every data type may also contain metadata describing the expected + * data; for example, it could specify a preferred data binding technology or + * the size of a typical instance. + * + * @version $Rev$ $Date$ + */ +public interface DataType extends Cloneable { + /** + * Set the java type for the data + * @param cls + */ + void setPhysical(Class cls); + + /** + * Returns the physical type used by the runtime. + * + * @return the physical type used by the runtime + */ + Class getPhysical(); + + /** + * Get the java generic type + * @return The java generic type + */ + Type getGenericType(); + + /** + * Set the java generic type + * @param genericType + */ + void setGenericType(Type genericType); + + /** + * Returns the logical identifier used by the assembly. The type of this + * value identifies the logical type system in use. Known values are: + *
    + *
  • a Class identifies a Java type by name and + * ClassLoader; this includes Java Classes as they are specializations of + * Type
  • + *
  • a XMLType identifies an XML type by local name and + * namespace
  • + *
+ * + * @return the logical type name + */ + L getLogical(); + + /** + * Get the databinding for the given data type + * @return the databinding + */ + String getDataBinding(); + + /** + * Set the databinding for the given data type + * @param dataBinding the dataBinding to set + */ + void setDataBinding(String dataBinding); + + /** + * Clone a data type + * @return The cloned data type + * @throws CloneNotSupportedException + */ + Object clone() throws CloneNotSupportedException; + + /** + * Set the logical type of the data type + * @param logical the logical to set + */ + void setLogical(L logical); + + /** + * Get the databinding-specific metadata + * @param type The java type of the metadata + * @return the databinding-specific metadata + */ + T getMetaData(Class type); + /** + * Set the databinding-specific metadata + * @param type The java type of the metadata + * @param metaData the databinding-specific metadata, such as SDO's commonj.sdo.Type or + * JAXB's javax.xml.bind.JAXBContext + */ + void setMetaData(Class type, T metaData); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java new file mode 100644 index 0000000000..70f6d5b403 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.interfacedef; + +/** + * This interface represents the mapping between WSDL faults and Java exceptions + * + * @version $Rev$ $Date$ + */ +@SuppressWarnings("unchecked") +public interface FaultExceptionMapper { + /** + * Introspect an exception class to find out the fault data type following the WSDL2Java + * mapping rules. The result will be populated into the logical type of the exception data + * type + * + * @param exceptionDataType The data type representing a java exception class + * @param operation TODO + * @param generatingFaultBean If JAXWS Section 3.7 Fault Bean will be generated + * @return true if the introspection can recognize the exception data type + */ + boolean introspectFaultDataType(DataType exceptionDataType, Operation operation, boolean generatingFaultBean); + + /** + * Create a java exception to wrap the fault data + * + * @param exceptionType The DataType for the exception + * @param message message for the exception + * @param faultInfo The fault data + * @param cause of the exception + * @param operation TODO + * @return An instance of java exception to represent the fault + */ + Throwable wrapFaultInfo(DataType exceptionType, String message, Object faultInfo, Throwable cause, Operation operation); + + /** + * Retrieve the fault info from a java exception + * + * @param exception The java exception that represents the fault data + * @param faultBeanClass + * @param operation TODO + * @return The fault data + */ + Object getFaultInfo(Throwable exception, Class faultBeanClass, Operation operation); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java new file mode 100644 index 0000000000..179dc1755e --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.interfacedef; + +/** + * Denotes incompatible service contracts for a wire + * + * @version $Rev$ $Date$ + */ +public class IncompatibleInterfaceContractException extends Exception { + private static final long serialVersionUID = 5127478601823295587L; + private final InterfaceContract source; + private final InterfaceContract target; + private final Operation sourceOperation; + private final Operation targetOperation; + + public IncompatibleInterfaceContractException(String message, InterfaceContract source, InterfaceContract target) { + super(message); + this.source = source; + this.target = target; + this.sourceOperation = null; + this.targetOperation = null; + } + + public IncompatibleInterfaceContractException(String message, + InterfaceContract source, + InterfaceContract target, + Operation sourceOperation, + Operation targetOperation) { + super(message); + this.source = source; + this.target = target; + this.sourceOperation = sourceOperation; + this.targetOperation = targetOperation; + } + + public InterfaceContract getTarget() { + return target; + } + + public InterfaceContract getSource() { + return source; + } + + public Operation getSourceOperation() { + return sourceOperation; + } + + public Operation getTargetOperation() { + return targetOperation; + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java new file mode 100644 index 0000000000..24f23e255d --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef; + +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.policy.PolicySubject; + +/** + * Represents a service interface. This interface will typically be extended to + * support concrete interface type systems, such as Java interfaces, WSDL 1.1 + * portTypes and WSDL 2.0 interfaces. + * + * @version $Rev$ $Date$ + */ +public interface Interface extends Cloneable, PolicySubject { + + /** + * Returns true if the interface is a remotable interface.. + * + * @return true if the interface is a remotable interface + */ + boolean isRemotable(); + + /** + * Sets whether the interface is a remotable or local interface. + * + * @param remotable indicates whether the interface is remotable or local + */ + void setRemotable(boolean remotable); + + + // FIXME: [rfeng] We need to re-consider the conversational as an intent + /** + * Test if the interface is conversational + * @return + */ + boolean isConversational(); + + /** + * Set whether the interface is conversational + * @param conversational + */ + void setConversational(boolean conversational); + + /** + * Returns the operations defined on this interface. + * + * @return the operations defined on this interface + */ + List getOperations(); + + /** + * Set the databinding for the interface + * @param dataBinding + * @deprecated Please use resetDataBinding + */ + @Deprecated + void setDefaultDataBinding(String dataBinding); + + /** + * Reset the databinding for the interface + * @param dataBinding + */ + void resetDataBinding(String dataBinding); + + /** + * Returns true if the Interface is dynamic. + * + * @return true if the Interface is dynamic. + */ + boolean isDynamic(); + + /** + * Get a map of attributes assoicated with the interface + * @return A map of attributes + */ + Map getAttributes(); + + /** + * Implementations must support cloning. + */ + Object clone() throws CloneNotSupportedException; + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java new file mode 100644 index 0000000000..568a6c595c --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.interfacedef; + + +/** + * Interface contracts define one or more business functions. These business + * functions are provided by services and are used by references. + * + * @version $Rev$ $Date$ + */ +public interface InterfaceContract extends Cloneable { + + /** + * Returns the interface definition representing the interface for + * invocations from the requestor to the provider. + * + * @return the interface definition representing the interface for + * invocations from the requestor to the provider + */ + Interface getInterface(); + + /** + * Sets the interface definition representing the interface for invocations + * from the requestor to the provider. + * + * @param callInterface the interface definition representing the interface + * for invocations from the requestor to the provider + */ + void setInterface(Interface callInterface); + + /** + * Returns the interface definition representing the interface for + * invocations from the provider to the requestor. + * + * @return the interface definition representing the interface for + * invocations from the provider to the requestor. + */ + Interface getCallbackInterface(); + + /** + * Sets the interface definition representing the interface for invocations + * from the provider to the requestor. + * + * @param callbackInterface the interface definition representing the + * interface for invocations from the provider to the requestor. + */ + void setCallbackInterface(Interface callbackInterface); + + // FIXME: We need a better way to do this + /** + * Convert an interface contract to a unidirectional interface contract + * + * @param isCallback true for a callback interface contract, false for + * a forward interface contract + * @return A unidirectional interface contract, cloned if necessary + */ + InterfaceContract makeUnidirectional(boolean isCallback); + + /** + * Implementations must support cloning. + */ + Object clone() throws CloneNotSupportedException; + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java new file mode 100644 index 0000000000..8dfeb29833 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java @@ -0,0 +1,139 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef; + +/** + * The InterfaceContractMapper is responsible to match interfaces + * + * @version $Rev$ $Date$ + */ +public interface InterfaceContractMapper { + /** + * Check the compatibility of the source and the target interface contracts. + *

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

+ *

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

+ *

+ * This relationship implies that the source contract is a subset of the target + * contract - ie all the operations of the source must be present in the target, but + * the target can in principle contain additional operations not present in the + * source + *

+ *

+ * Please note this test is not symmetric: the success of isCompatible(A, B) + * does NOT imply isCompatible(B, A) + * + * @param source The source interface contract + * @param target The target interface contract + * @return true if the source contract can be supported by the target + * contract + */ + boolean isCompatible(InterfaceContract source, InterfaceContract target); + + /** + * Check that two interface contracts are equal. The contracts are equal if the two contracts have the + * same set of operations, with each operation having the same signature. + * @param source - the source contract + * @param target - the target contract + * @return + */ + boolean isEqual(InterfaceContract source, InterfaceContract target); + + /** + * Check that two interfaces are equal. The interfaces are equal if the two interfaces have the + * same set of operations, with each operation having the same signature. + * @param source an interface + * @param target a second interface + * @return true if the two interfaces are equal, otherwise return false + */ + public boolean isEqual(Interface source, Interface target); + + /** + * @param source + * @param target + * @param ignoreCallback + * @param silent + * @return + * @throws IncompatibleInterfaceContractException + */ + boolean checkCompatibility(InterfaceContract source, + InterfaceContract target, + boolean ignoreCallback, + boolean silent) throws IncompatibleInterfaceContractException; + + /** + * Test if the source data type is compatible with the target data type. The + * compatibility is defined as follows. + *

    + *
  • source's logical type is either the same or subtype of the target's + * logical type + *
+ * For example, if the source type is a SDO Customer and the target type is + * a JAXB Customer and both Customer are generated from the same XSD type. + * + * @param source The source data type + * @param target The target data type + * @return + */ + boolean isCompatible(DataType source, DataType target, boolean remotable); + + /** + * Check if source operation is compatible with the target operation + * + * @param source The source operation + * @param target The target operation + * @return true if the source operation is compatible with the target + * operation + */ + boolean isCompatible(Operation source, Operation target, boolean remotable); + + /** + * @param source + * @param target + * @return + */ + boolean isCompatible(Interface source, Interface target); + + /** + * Map the source operation to a compatible operation in the target + * interface + * + * @param target The target interface + * @param source The source operation + * @return A compatible operation + */ + Operation map(Interface target, Operation source); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java new file mode 100644 index 0000000000..f952a86478 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.interfacedef; + + +/** + * Denotes an illegal callback interface + * + * @version $Rev$ $Date$ + */ + +public class InvalidCallbackException extends InvalidInterfaceException { + private static final long serialVersionUID = 2727755895702116397L; + + public InvalidCallbackException(String message) { + super(message); + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java new file mode 100644 index 0000000000..2a273c9a26 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.interfacedef; + +/** + * @version $Rev$ $Date$ + */ +public abstract class InvalidInterfaceException extends Exception { + + public InvalidInterfaceException() { + super(); + } + + public InvalidInterfaceException(String message) { + super(message); + } + + public InvalidInterfaceException(String message, Throwable cause) { + super(message, cause); + } + + public InvalidInterfaceException(Throwable cause) { + super(cause); + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java new file mode 100644 index 0000000000..b19805c5b1 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.interfacedef; + +import java.lang.reflect.Method; + +/** + * Denotes an invalid conversational interface definition + * + * @version $Rev$ $Date$ + */ +public class InvalidOperationException extends InvalidInterfaceException { + + private static final long serialVersionUID = -1797615361821517091L; + private final Method operation; + + public InvalidOperationException(String message, Method operation) { + super(message); + this.operation = operation; + } + + public Method getOperation() { + return operation; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java new file mode 100644 index 0000000000..55f00b82c8 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java @@ -0,0 +1,209 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef; + +import java.util.List; +import java.util.Map; + +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.PolicySubject; + +/** + * Represents an operation on a service interface. + * + * @version $Rev$ $Date$ + */ +public interface Operation extends Cloneable, PolicySubject { + /** + * 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 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); + + /** + * Get the data type that represents the input of this operation. The logic + * type is a list of data types and each element represents a parameter + * + * @return the inputType + */ + DataType> getInputType(); + + /** + * @param inputType + */ + void setInputType(DataType> inputType); + + /** + * Get the data type for the output + * + * @return the outputType + */ + DataType getOutputType(); + + /** + * @param outputType + */ + void setOutputType(DataType outputType); + + /** + * Get a list of data types to represent the faults/exceptions + * + * @return the faultTypes + */ + List getFaultTypes(); + + /** + * @param faultTypes + */ + void setFaultTypes(List faultTypes); + + /** + * Get the owning interface + * @return + */ + Interface getInterface(); + + /** + * Set the owning interface + * @param interfaze + */ + void setInterface(Interface interfaze); + + /** + * Get the sequence of the conversation + * @return + */ + ConversationSequence getConversationSequence(); + + /** + * Set the sequence of conversation for the operation + * @param sequence + */ + void setConversationSequence(ConversationSequence sequence); + + /** + * Indicate if the operation is non-blocking + * @return + */ + boolean isNonBlocking(); + + /** + * Set the operation to be non-blocking + */ + void setNonBlocking(boolean nonBlocking); + + /** + * @return the wrapperInfo + */ + WrapperInfo getWrapper(); + + /** + * @param wrapperInfo the wrapperInfo to set + */ + void setWrapper(WrapperInfo wrapperInfo); + + /** + * @return the wrapperStyle + */ + boolean isWrapperStyle(); + + /** + * @param wrapperStyle the wrapperStyle to set + */ + void setWrapperStyle(boolean wrapperStyle); + + /** + * @deprecated This should be the WrapperInfo.getDataBinding() + * Get the databinding for the operation + * @return + */ + @Deprecated + String getDataBinding(); + + /** + * @deprecated This should be the WrapperInfo.setDataBinding() + * Set the databinding for the operation + * @param dataBinding + */ + @Deprecated + void setDataBinding(String dataBinding); + + /** + * Returns true if the operation is dynamic. + * + * @return true if the operation is dynamic otherwise false + */ + boolean isDynamic(); + + /** + * Set if the operation is dynamic + * @param b + */ + void setDynamic(boolean b); + + /** + * Get the synthesized fault beans for this operation + * + * @return the fault beans + */ + Map>> getFaultBeans(); + + /** + * Set the synthesized fault beans for this operation + * @param faultBeans + */ + void setFaultBeans(Map>> faultBeans); + + /** + * Get a map of attributes assoicated with the operation + * @return A map of attributes + */ + Map getAttributes(); + + /** + * Implementations must support cloning. + */ + Object clone() throws CloneNotSupportedException; + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java new file mode 100644 index 0000000000..6773b29088 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.interfacedef; + +import java.lang.reflect.Method; + +/** + * Exception thrown to indicate that a service contract specification contains + * an overloaded method. + * + * @version $Rev$ $Date$ + */ +public class OverloadedOperationException extends InvalidInterfaceException { + private static final long serialVersionUID = -4658711318608885638L; + private final Method operation; + + public OverloadedOperationException(Method operation) { + super(operation == null ? + null : "Cannot overload operation " + operation.getName() + + " on " + operation.getDeclaringClass().getName() + + " as it is a @Remotable interface"); + this.operation = operation; + } + + public Method getOperation() { + return operation; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java new file mode 100644 index 0000000000..c1c8400b71 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java @@ -0,0 +1,219 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.impl; + +import java.lang.reflect.Type; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.tuscany.sca.interfacedef.DataType; + +/** + * Representation of the type of data associated with an operation. Data is + * represented in two forms: the physical form used by the runtime and a logical + * form used by the assembly. The physical form is a Java Type because the + * runtime is written in Java. This may be the same form used by the application + * but it may not; for example, an application that is performing stream + * processing may want a physical form such as an + * {@link java.io.InputStream InputStream} to semantially operate on application + * data such as a purchase order. The logical description is that used by the + * assembly model and is an identifier into some well-known type space; examples + * may be a Java type represented by its Class or an XML type represented by its + * QName. Every data type may also contain metadata describing the expected + * data; for example, it could specify a preferred data binding technology or + * the size of a typical instance. + * + * @version $Rev$ $Date$ + */ +public class DataTypeImpl implements DataType { + private String dataBinding; + private Class physical; + private Type genericType; + private L logical; + private Map, Object> metaDataMap; + + /** + * Construct a data type specifying the physical and logical types. + * + * @param physical the physical class used by the runtime + * @param logical the logical type + * @see #getLogical() + */ + public DataTypeImpl(Class physical, L logical) { + this(null, physical, physical, logical); + } + + /** + * @param dataBinding + * @param physical + * @param logical + */ + public DataTypeImpl(String dataBinding, Class physical, L logical) { + this(dataBinding, physical, physical, logical); + } + + /** + * @param dataBinding + * @param physical + * @param genericType + * @param logical + */ + public DataTypeImpl(String dataBinding, Class physical, Type genericType, L logical) { + super(); + this.dataBinding = dataBinding; + this.physical = physical; + this.genericType = genericType; + this.logical = logical; + } + + /** + * Returns the physical type used by the runtime. + * + * @return the physical type used by the runtime + */ + public Class getPhysical() { + return physical; + } + + /** + * @param physical the physical to set + */ + public void setPhysical(Class physical) { + this.physical = physical; + } + + /** + * Get the java generic type + * @return The java generic type + */ + public Type getGenericType() { + return genericType; + } + + /** + * Set the java generic type + * @param genericType + */ + public void setGenericType(Type genericType) { + this.genericType = genericType; + } + + /** + * Returns the logical identifier used by the assembly. The type of this + * value identifies the logical type system in use. Known values are: + *
    + *
  • a java.lang.reflect.Type identifies a Java type by name and + * ClassLoader; this includes Java Classes as they are specializations of + * Type
  • + *
  • a javax.xml.namespace.QName identifies an XML type by local name and + * namespace
  • + *
+ * + * @return the logical type name + */ + public L getLogical() { + return logical; + } + + /** + * @param logical the logical to set + */ + public void setLogical(L logical) { + this.logical = logical; + } + + public String getDataBinding() { + return dataBinding; + } + + /** + * @param dataBinding the dataBinding to set + */ + public void setDataBinding(String dataBinding) { + this.dataBinding = dataBinding; + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(physical).append(" ").append(dataBinding).append(" ").append(logical); + return sb.toString(); + } + + @SuppressWarnings("unchecked") + @Override + public Object clone() throws CloneNotSupportedException { + DataTypeImpl copy = (DataTypeImpl)super.clone(); + return copy; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((dataBinding == null) ? 0 : dataBinding.hashCode()); + result = prime * result + ((genericType == null) ? 0 : genericType.hashCode()); + result = prime * result + ((logical == null) ? 0 : logical.hashCode()); + result = prime * result + ((physical == null) ? 0 : physical.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; + final DataTypeImpl other = (DataTypeImpl)obj; + if (dataBinding == null) { + if (other.dataBinding != null) + return false; + } else if (!dataBinding.equals(other.dataBinding)) + return false; + if (genericType == null) { + if (other.genericType != null) + return false; + } else if (!genericType.equals(other.genericType)) + return false; + if (logical == null) { + if (other.logical != null) + return false; + } else if (!logical.equals(other.logical)) + return false; + if (physical == null) { + if (other.physical != null) + return false; + } else if (!physical.equals(other.physical)) + return false; + return true; + } + + public T getMetaData(Class type) { + return metaDataMap == null ? null : type.cast(metaDataMap.get(type)); + } + + public void setMetaData(Class type, T metaData) { + if (metaDataMap == null) { + metaDataMap = new ConcurrentHashMap, Object>(); + } + metaDataMap.put(type, metaData); + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java new file mode 100644 index 0000000000..15581b5e04 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.interfacedef.impl; + +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; + +/** + * Represents an interface contract. InterfaceContractImpl + * + * @version $Rev$ $Date$ + */ +public abstract class InterfaceContractImpl implements InterfaceContract { + private Interface callInterface; + private Interface callbackInterface; + + public Interface getCallbackInterface() { + return callbackInterface; + } + + public Interface getInterface() { + return callInterface; + } + + public void setCallbackInterface(Interface callbackInterface) { + this.callbackInterface = callbackInterface; + } + + public void setInterface(Interface callInterface) { + this.callInterface = callInterface; + } + + public InterfaceContract makeUnidirectional(boolean isCallback) { + if (!isCallback && callbackInterface == null) + return this; // already a unidirectional forward interface contract + + if (isCallback && callInterface == null) + return this; // already a unidirectional callback interface contract + + // contract is bidirectional, so create a new unidirectional contract + try { + InterfaceContract newContract = clone(); + if (!isCallback) { + newContract.setCallbackInterface(null); // create unidirectional forward interface contract + } else { + newContract.setInterface(null); // create unidirectional callback interface contract + } + return newContract; + } catch (CloneNotSupportedException e) { + // will not happen + return null; + } + } + + @Override + public InterfaceContractImpl clone() throws CloneNotSupportedException { + InterfaceContractImpl copy = (InterfaceContractImpl)super.clone(); + if (this.callbackInterface != null) { + copy.callbackInterface = (Interface)this.callbackInterface.clone(); + } + if (this.callInterface != null) { + copy.callInterface = (Interface)this.callInterface.clone(); + } + return copy; + } + + /** + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((callInterface == null) ? 0 : callInterface.hashCode()); + result = prime * result + ((callbackInterface == null) ? 0 : callbackInterface.hashCode()); + return result; + } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final InterfaceContractImpl other = (InterfaceContractImpl)obj; + if (callInterface == null) { + if (other.callInterface != null) { + return false; + } + } else if (!callInterface.equals(other.callInterface)) { + return false; + } + if (callbackInterface == null) { + if (other.callbackInterface != null) { + return false; + } + } else if (!callbackInterface.equals(other.callbackInterface)) { + return false; + } + return true; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java new file mode 100644 index 0000000000..289fd25594 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java @@ -0,0 +1,390 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.impl; + +import java.util.List; + +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.Operation; + +/** + * @version $Rev$ $Date$ + */ +public class InterfaceContractMapperImpl implements InterfaceContractMapper { + + public boolean isCompatible(DataType source, DataType target, boolean remotable) { + if (source == target) { + return true; + } + if (!remotable) { + if (source == null || target == null) { + return false; + } + // For local case + return target.getPhysical().isAssignableFrom(source.getPhysical()); + } else { + // FIXME: How to test if two remotable data type is compatible? + // return target.getLogical().equals(source.getLogical()); + return true; + } + + } + + + /** + * Check that two interface contracts are equal. The contracts are equal if the two contracts have the + * same set of operations, with each operation having the same signature, both for forward and callback + * interfaces + * @param source + * @param target + * @return + */ + public boolean isEqual(InterfaceContract source, InterfaceContract target) { + // Are the forward interfaces equal? + if( isEqual( source.getInterface(), target.getInterface()) ) { + // Is there a Callback interface? + if( source.getCallbackInterface() == null && target.getCallbackInterface() == null ) { + return true; + } else { + if( isEqual( source.getCallbackInterface(), target.getCallbackInterface()) ) { + return true; + } // end if + } // end if + } // end if + return false; + } // end method isEqual + + /** + * Check that two interfaces are equal. The interfaces are equal if the two interfaces have the + * same set of operations, with each operation having the same signature. + * @param source + * @param target + * @return + */ + public boolean isEqual(Interface source, Interface target) { + if (source == target) { + // Shortcut for performance + return true; + } // end if + if (source == null || target == null) { + return false; + } // end if + + if (source.isDynamic() || target.isDynamic()) { + return true; + } + + if (source.isRemotable() != target.isRemotable()) { + return false; + } + if (source.isConversational() != target.isConversational()) { + return false; + } + if( source.getOperations().size() != target.getOperations().size() ) { + return false; + } + + for (Operation operation : source.getOperations()) { + Operation targetOperation = getOperation(target.getOperations(), operation.getName()); + if (targetOperation == null) { + return false; + } + if (!isCompatible(operation, targetOperation, source.isRemotable())) { + return false; + } + } + return true; + } // end method isEqual + + public boolean isCompatible(Operation source, Operation target, boolean remotable) { + if (source == target) { + return true; + } + + if (source.isDynamic() || target.isDynamic()) { + return true; + } + + // Check name + if (!source.getName().equals(target.getName())) { + return false; + } + + if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) { + return false; + } + + // if (source.getInterface().isRemotable()) { + // return true; + // } + + // FIXME: We need to deal with wrapped<-->unwrapped conversion + + // Check output type + DataType sourceOutputType = source.getOutputType(); + DataType targetOutputType = target.getOutputType(); + + boolean checkSourceWrapper = true; + List sourceInputType = source.getInputType().getLogical(); + if (source.isWrapperStyle() && source.getWrapper() != null) { + sourceInputType = source.getWrapper().getUnwrappedInputType().getLogical(); + sourceOutputType = source.getWrapper().getUnwrappedOutputType(); + checkSourceWrapper = false; + } + boolean checkTargetWrapper = true; + List targetInputType = target.getInputType().getLogical(); + if (target.isWrapperStyle() && target.getWrapper() != null) { + targetInputType = target.getWrapper().getUnwrappedInputType().getLogical(); + targetOutputType = target.getWrapper().getUnwrappedOutputType(); + checkTargetWrapper = false; + } + + if (checkSourceWrapper != checkTargetWrapper) { + return true; + } + + if (!isCompatible(targetOutputType, sourceOutputType, remotable)) { + return false; + } + + if (sourceInputType.size() != targetInputType.size()) { + return false; + } + + int size = sourceInputType.size(); + for (int i = 0; i < size; i++) { + if (!isCompatible(sourceInputType.get(i), targetInputType.get(i), remotable)) { + return false; + } + } + + // Check fault types + for (DataType targetFaultType : target.getFaultTypes()) { + // Source fault types must be the same or superset of target fault + // types + boolean found = true; + for (DataType sourceFaultType : source.getFaultTypes()) { + found = false; + if (isCompatible(targetFaultType, sourceFaultType, remotable)) { + // Target fault type can be covered by the source fault type + found = true; + break; + } + } + if (!found) { + return false; + } + } + + return true; + } + + // FIXME: How to improve the performance for the lookup + private Operation getOperation(List operations, String name) { + for (Operation op : operations) { + if (op.getName().equals(name)) { + return op; + } + } + return null; + } + + public boolean checkCompatibility(InterfaceContract source, + InterfaceContract target, + boolean ignoreCallback, + boolean silent) throws IncompatibleInterfaceContractException { + if (source == target) { + // Shortcut for performance + return true; + } + + if (source == null || target == null){ + return false; + } + + if (source.getInterface() == target.getInterface()){ + return true; + } + + if (source.getInterface() == null || target.getInterface() == null){ + return false; + } + + if (source.getInterface().isDynamic() || target.getInterface().isDynamic()) { + return true; + } + + if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) { + if (!silent) { + throw new IncompatibleInterfaceContractException("Remotable settings do not match", source, target); + } else { + return false; + } + } + if (source.getInterface().isConversational() != target.getInterface().isConversational()) { + if (!silent) { + throw new IncompatibleInterfaceContractException("Interaction scopes do not match", source, target); + } else { + return false; + } + } + + for (Operation operation : source.getInterface().getOperations()) { + Operation targetOperation = map(target.getInterface(), operation); + if (targetOperation == null) { + if (!silent) { + throw new IncompatibleInterfaceContractException("Operation not found on target", source, target); + } else { + return false; + } + } + if (!source.getInterface().isRemotable()) { + // FIXME: for remotable operation, only compare name for now + if (!isCompatible(operation, targetOperation, false)) { + if (!silent) { + throw new IncompatibleInterfaceContractException("Target operations are not compatible", + source, target); + } else { + return false; + } + } + } + } + + if (ignoreCallback) { + return true; + } + + if (source.getCallbackInterface() == null && target.getCallbackInterface() == null) { + return true; + } + if (source.getCallbackInterface() == null || target.getCallbackInterface() == null) { + if (!silent) { + throw new IncompatibleInterfaceContractException("Callback interface doesn't match", source, target); + } else { + return false; + } + } + + if (source.getCallbackInterface().isConversational() != target.getCallbackInterface().isConversational()) { + if (!silent) { + throw new IncompatibleInterfaceContractException("Interaction scopes do not match", source, target); + } else { + return false; + } + } + + for (Operation operation : source.getCallbackInterface().getOperations()) { + Operation targetOperation = + getOperation(target.getCallbackInterface().getOperations(), operation.getName()); + if (targetOperation == null) { + if (!silent) { + throw new IncompatibleInterfaceContractException("Callback operation not found on target", source, + target, null, targetOperation); + } else { + return false; + } + } + if (!source.getCallbackInterface().isRemotable()) { + // FIXME: for remotable operation, only compare name for now + if (!operation.equals(targetOperation)) { + if (!silent) { + throw new IncompatibleInterfaceContractException("Target callback operation is not compatible", + source, target, operation, targetOperation); + } else { + return false; + } + } + } + } + return true; + } + + public boolean isCompatible(Interface source, Interface target) { + if (source == target) { + // Shortcut for performance + return true; + } + if (source == null || target == null) { + return false; + } + + if (source.isDynamic() || target.isDynamic()) { + return true; + } + + if (source.isRemotable() != target.isRemotable()) { + return false; + } + if (source.isConversational() != target.isConversational()) { + return false; + } + + for (Operation operation : source.getOperations()) { + Operation targetOperation = getOperation(target.getOperations(), operation.getName()); + if (targetOperation == null) { + return false; + } + if (!isCompatible(operation, targetOperation, source.isRemotable())) { + return false; + } + } + return true; + } + + public boolean isCompatible(InterfaceContract source, InterfaceContract target) { + try { + return checkCompatibility(source, target, false, false); + } catch (IncompatibleInterfaceContractException e) { + return false; + } + } + + /** + * @see org.apache.tuscany.sca.interfacedef.InterfaceContractMapper#map(org.apache.tuscany.sca.interfacedef.Interface, + * org.apache.tuscany.sca.interfacedef.Operation) + */ + public Operation map(Interface target, Operation source) { + // TODO: How to handle the case that source operation is dynamic? + if (target == null || target.isDynamic()) { + return source; + } else if (target.isRemotable()) { + for (Operation op : target.getOperations()) { + if (op.getName().equals(source.getName())) { + return op; + } + } + return null; + } else { + for (Operation op : target.getOperations()) { + if (isCompatible(source, op, target.isRemotable())) { + return op; + } + } + return null; + } + + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java new file mode 100644 index 0000000000..67aae7da4d --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java @@ -0,0 +1,259 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.impl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.tuscany.sca.interfacedef.DataType; +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.ExtensionType; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Represents a service interface. + * + * @version $Rev$ $Date$ + */ +public class InterfaceImpl implements Interface { + + private boolean remotable; + private boolean conversational; + private OperationList operations = new OperationList(); + private boolean unresolved; + + private ExtensionType type; + private List policySets = new ArrayList(); + private List requiredIntents = new ArrayList(); + private Map attributes = new ConcurrentHashMap(); + + public boolean isRemotable() { + return remotable; + } + + public void setRemotable(boolean local) { + this.remotable = local; + } + + public List getOperations() { + return operations; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean undefined) { + this.unresolved = undefined; + } + + /** + * @return the conversational + */ + public boolean isConversational() { + return conversational; + } + + /** + * @param conversational the conversational to set + */ + public void setConversational(boolean conversational) { + this.conversational = conversational; + } + + private class OperationList extends ArrayList { + private static final long serialVersionUID = -903469106307606099L; + + @Override + public Operation set(int index, Operation element) { + element.setInterface(InterfaceImpl.this); + return super.set(index, element); + } + + @Override + public void add(int index, Operation element) { + element.setInterface(InterfaceImpl.this); + super.add(index, element); + } + + @Override + public boolean add(Operation o) { + o.setInterface(InterfaceImpl.this); + return super.add(o); + } + + @Override + public boolean addAll(Collection c) { + for (Operation op : c) { + op.setInterface(InterfaceImpl.this); + } + return super.addAll(c); + } + + @Override + public boolean addAll(int index, Collection c) { + for (Operation op : c) { + op.setInterface(InterfaceImpl.this); + } + return super.addAll(index, c); + } + + } + + @Deprecated + public void setDefaultDataBinding(String dataBinding) { + for (Operation op : getOperations()) { + if (op.getDataBinding() == null) { + op.setDataBinding(dataBinding); + DataType> inputType = op.getInputType(); + if (inputType != null) { + for (DataType d : inputType.getLogical()) { + if (d.getDataBinding() == null) { + d.setDataBinding(dataBinding); + } + } + } + DataType outputType = op.getOutputType(); + if (outputType != null && outputType.getDataBinding() == null) { + outputType.setDataBinding(dataBinding); + } + List faultTypes = op.getFaultTypes(); + if (faultTypes != null) { + for (DataType d : faultTypes) { + if (d.getDataBinding() == null) { + d.setDataBinding(dataBinding); + } + DataType ft = (DataType) d.getLogical(); + if (ft.getDataBinding() == null) { + ft.setDataBinding(dataBinding); + } + + } + } + if (op.isWrapperStyle()) { + WrapperInfo wrapper = op.getWrapper(); + if (wrapper != null) { + DataType> unwrappedInputType = wrapper.getUnwrappedInputType(); + if (unwrappedInputType != null) { + for (DataType d : unwrappedInputType.getLogical()) { + if (d.getDataBinding() == null) { + d.setDataBinding(dataBinding); + } + } + } + DataType unwrappedOutputType = wrapper.getUnwrappedOutputType(); + if (unwrappedOutputType != null && unwrappedOutputType.getDataBinding() == null) { + unwrappedOutputType.setDataBinding(dataBinding); + } + } + } + } + } + } + + private void setDataBinding(DataType dataType, String dataBinding) { + if ("java:array".equals(dataType.getDataBinding())) { + setDataBinding((DataType)dataType.getLogical(), dataBinding); + } else { + dataType.setDataBinding(dataBinding); + } + } + + public void resetDataBinding(String dataBinding) { + for (Operation op : getOperations()) { + op.setDataBinding(dataBinding); + DataType> inputType = op.getInputType(); + if (inputType != null) { + for (DataType d : inputType.getLogical()) { + setDataBinding(d, dataBinding); + } + } + DataType outputType = op.getOutputType(); + if (outputType != null) { + setDataBinding(outputType, dataBinding); + } + List faultTypes = op.getFaultTypes(); + if (faultTypes != null) { + for (DataType d : faultTypes) { + setDataBinding(d, dataBinding); + setDataBinding((DataType) d.getLogical(), dataBinding); + } + } + if (op.isWrapperStyle()) { + WrapperInfo wrapper = op.getWrapper(); + if (wrapper != null) { + DataType> unwrappedInputType = wrapper.getUnwrappedInputType(); + if (unwrappedInputType != null) { + for (DataType d : unwrappedInputType.getLogical()) { + setDataBinding(d, dataBinding); + } + } + DataType unwrappedOutputType = wrapper.getUnwrappedOutputType(); + if (unwrappedOutputType != null) { + setDataBinding(unwrappedOutputType, dataBinding); + } + } + } + } + } + + public boolean isDynamic() { + return false; + } + + public List getPolicySets() { + return policySets; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public ExtensionType getExtensionType() { + return type; + } + + public void setExtensionType(ExtensionType type) { + this.type = type; + } + + @Override + public Object clone() throws CloneNotSupportedException { + InterfaceImpl copy = (InterfaceImpl)super.clone(); + copy.operations = new OperationList(); + for (Operation operation : this.operations) { + Operation clonedOperation = (Operation)operation.clone(); + copy.operations.add(clonedOperation); + } + copy.attributes = new ConcurrentHashMap(); + copy.attributes.putAll(attributes); + return copy; + } + + public Map getAttributes() { + return attributes; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java new file mode 100644 index 0000000000..26144e92cb --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java @@ -0,0 +1,284 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.interfacedef.ConversationSequence; +import org.apache.tuscany.sca.interfacedef.DataType; +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.interfacedef.util.XMLType; +import org.apache.tuscany.sca.policy.ExtensionType; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Represents an operation on a service interface. + * + * @version $Rev$ $Date$ + */ +public class OperationImpl implements Operation { + + private String name; + private boolean unresolved; + private DataType outputType; + private DataType> inputType; + private List faultTypes; + private Interface interfaze; + private ConversationSequence conversationSequence = ConversationSequence.CONVERSATION_NONE; + private boolean nonBlocking; + private boolean wrapperStyle; + private WrapperInfo wrapper; + private boolean dynamic; + + private Map attributes = new ConcurrentHashMap(); + + private Map>> faultBeans; + + private List applicablePolicySets = new ArrayList(); + private List policySets = new ArrayList(); + private List requiredIntents = new ArrayList(); + private ExtensionType type; + + /** + * @param name + */ + public OperationImpl() { + inputType = new DataTypeImpl>("idl:input", Object[].class, new ArrayList()); + faultTypes = new ArrayList(); + faultBeans = new HashMap>>(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean undefined) { + this.unresolved = undefined; + } + + /** + * @return the faultTypes + */ + public List getFaultTypes() { + return faultTypes; + } + + /** + * @param faultTypes the faultTypes to set + */ + public void setFaultTypes(List faultTypes) { + this.faultTypes = faultTypes; + } + + /** + * @return the inputType + */ + public DataType> getInputType() { + return inputType; + } + + /** + * @param inputType the inputType to set + */ + public void setInputType(DataType> inputType) { + this.inputType = inputType; + } + + /** + * @return the outputType + */ + public DataType getOutputType() { + return outputType; + } + + /** + * @param outputType the outputType to set + */ + public void setOutputType(DataType outputType) { + this.outputType = outputType; + } + + /** + * @return the interface + */ + public Interface getInterface() { + return interfaze; + } + + /** + * @param interfaze the interface to set + */ + public void setInterface(Interface interfaze) { + this.interfaze = interfaze; + } + + /** + * @return the conversationSequence + */ + public ConversationSequence getConversationSequence() { + return conversationSequence; + } + + /** + * @param conversationSequence the conversationSequence to set + */ + public void setConversationSequence(ConversationSequence conversationSequence) { + this.conversationSequence = conversationSequence; + } + + /** + * @return the nonBlocking + */ + public boolean isNonBlocking() { + return nonBlocking; + } + + /** + * @param nonBlocking the nonBlocking to set + */ + public void setNonBlocking(boolean nonBlocking) { + this.nonBlocking = nonBlocking; + } + + /** + * @return the wrapperInfo + */ + public WrapperInfo getWrapper() { + return wrapper; + } + + /** + * @param wrapperInfo the wrapperInfo to set + */ + public void setWrapper(WrapperInfo wrapperInfo) { + this.wrapper = wrapperInfo; + } + + /** + * @return the wrapperStyle + */ + public boolean isWrapperStyle() { + return wrapperStyle; + } + + /** + * @param wrapperStyle the wrapperStyle to set + */ + public void setWrapperStyle(boolean wrapperStyle) { + this.wrapperStyle = wrapperStyle; + } + + public String getDataBinding() { + return wrapper != null ? wrapper.getDataBinding() : null; + } + + public void setDataBinding(String dataBinding) { + if (wrapper != null) { + wrapper.setDataBinding(dataBinding); + } + } + + public boolean isDynamic() { + return dynamic; + } + + public void setDynamic(boolean b) { + this.dynamic = b; + } + + public Map>> getFaultBeans() { + return faultBeans; + } + + public void setFaultBeans(Map>> faultBeans) { + this.faultBeans = faultBeans; + } + + @Override + public OperationImpl clone() throws CloneNotSupportedException { + OperationImpl copy = (OperationImpl) super.clone(); + + final List clonedFaultTypes = new ArrayList(this.faultTypes.size()); + for (DataType t : this.faultTypes) { + clonedFaultTypes.add((DataType) t.clone()); + } + copy.faultTypes = clonedFaultTypes; + + List clonedLogicalTypes = new ArrayList(); + for (DataType t : inputType.getLogical()) { + DataType type = (DataType) t.clone(); + clonedLogicalTypes.add(type); + } + DataType> clonedInputType = + new DataTypeImpl>(inputType.getPhysical(), clonedLogicalTypes); + clonedInputType.setDataBinding(inputType.getDataBinding()); + copy.inputType = clonedInputType; + + if (this.outputType != null) { + copy.outputType = (DataType) this.outputType.clone(); + } + + copy.attributes = new ConcurrentHashMap(); + copy.attributes.putAll(attributes); + + return copy; + } + + public List getApplicablePolicySets() { + return applicablePolicySets; + } + + public List getPolicySets() { + return policySets; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public ExtensionType getExtensionType() { + return type; + } + + public void setExtensionType(ExtensionType type) { + this.type = type; + } + + public Map getAttributes() { + return attributes; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java new file mode 100644 index 0000000000..777fa567f1 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.util; + +import javax.xml.namespace.QName; + +/** + * An abstraction of XML schema elements. + * + * @version $Rev$ $Date$ + */ +public class ElementInfo { + private final QName name; + private final TypeInfo type; + private boolean many = false; + private boolean nillable = false; + + /** + * @param name + * @param type + */ + public ElementInfo(QName name, TypeInfo type) { + super(); + this.name = name; + this.type = type; + } + + /** + * @return the name + */ + public QName getQName() { + return name; + } + + /** + * @return the type + */ + public TypeInfo getType() { + return type; + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("Element: ").append(name).append(" ").append(type); + return sb.toString(); + } + + public boolean isMany() { + return many; + } + + public void setMany(boolean many) { + this.many = many; + } + + public boolean isNillable() { + return nillable; + } + + public void setNillable(boolean nillable) { + this.nillable = nillable; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((type == null) ? 0 : type.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; + final ElementInfo other = (ElementInfo)obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + /* + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + */ + return true; + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java new file mode 100644 index 0000000000..844b0af509 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.interfacedef.util; + +import javax.xml.namespace.QName; + +/** + * The generic java exception to wrap service faults + * + * @version $Rev$ $Date$ + */ +public class FaultException extends Exception { + private static final long serialVersionUID = -8002583655240625792L; + private transient Object faultInfo; // FIXME: How to serialize it? + private QName faultName; + + /** + * @param message + * @param faultInfo + */ + public FaultException(String message, Object faultInfo) { + super(message); + this.faultInfo = faultInfo; + } + + /** + * @param message + * @param faultInfo + * @param cause + */ + public FaultException(String message, Object faultInfo, Throwable cause) { + super(message, cause); + this.faultInfo = faultInfo; + } + + /** + * @return the faultInfo + */ + public Object getFaultInfo() { + return faultInfo; + } + + public QName getFaultName() { + return faultName; + } + + public void setFaultName(QName logical) { + this.faultName = logical; + } + + public boolean isMatchingType(Object type) { + if (faultName == null) { + return false; + } + + if ((type instanceof QName) && faultName.equals(type)) { + return true; + } + if (type instanceof XMLType && faultName.equals(((XMLType)type).getElementName())) { + return true; + } + return false; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java new file mode 100644 index 0000000000..54c0a3ec11 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java @@ -0,0 +1,143 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.util; + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.namespace.QName; + +/** + * Utility class that can be used to map XSD types to Java classes and Java classes to XSD types. + * + * @version $Rev$ $Date$ + */ +public final class JavaXMLMapper { + public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema"; + private static final Map JAVA2XML = new HashMap(); + private static final Map XML2JAVA = new HashMap(); + + private JavaXMLMapper() { + } + + static { + JAVA2XML.put(boolean.class, getTypeName("boolean")); + JAVA2XML.put(byte.class, getTypeName("byte")); + JAVA2XML.put(short.class, getTypeName("short")); + JAVA2XML.put(int.class, getTypeName("int")); + JAVA2XML.put(long.class, getTypeName("long")); + JAVA2XML.put(float.class, getTypeName("float")); + JAVA2XML.put(double.class, getTypeName("double")); + JAVA2XML.put(Boolean.class, getTypeName("boolean")); + JAVA2XML.put(Byte.class, getTypeName("byte")); + JAVA2XML.put(Short.class, getTypeName("short")); + JAVA2XML.put(Integer.class, getTypeName("int")); + JAVA2XML.put(Long.class, getTypeName("long")); + JAVA2XML.put(Float.class, getTypeName("float")); + JAVA2XML.put(Double.class, getTypeName("double")); + JAVA2XML.put(java.lang.String.class, getTypeName("string")); + JAVA2XML.put(java.math.BigInteger.class, getTypeName("integer")); + JAVA2XML.put(java.math.BigDecimal.class, getTypeName("decimal")); + JAVA2XML.put(java.util.Calendar.class, getTypeName("dateTime")); + JAVA2XML.put(java.util.Date.class, getTypeName("dateTime")); + JAVA2XML.put(javax.xml.namespace.QName.class, getTypeName("QName")); + JAVA2XML.put(java.net.URI.class, getTypeName("string")); + JAVA2XML.put(javax.xml.datatype.XMLGregorianCalendar.class, getTypeName("anySimpleType")); + JAVA2XML.put(javax.xml.datatype.Duration.class, getTypeName("duration")); + JAVA2XML.put(java.lang.Object.class, getTypeName("anyType")); + JAVA2XML.put(java.awt.Image.class, getTypeName("base64Binary")); + JAVA2XML.put(byte[].class, getTypeName("base64Binary")); + // java2XSD.put(javax.activation.DataHandler.class, getTypeName("base64Binary")); + JAVA2XML.put(javax.xml.transform.Source.class, getTypeName("base64Binary")); + JAVA2XML.put(java.util.UUID.class, getTypeName("string")); + } + + static { + XML2JAVA.put("string", java.lang.String.class); + XML2JAVA.put("integer", java.math.BigInteger.class); + XML2JAVA.put("int", int.class); + XML2JAVA.put("long", long.class); + XML2JAVA.put("short", short.class); + XML2JAVA.put("decimal", java.math.BigDecimal.class); + XML2JAVA.put("float", float.class); + XML2JAVA.put("double", double.class); + XML2JAVA.put("boolean", boolean.class); + XML2JAVA.put("byte", byte.class); + XML2JAVA.put("QName", javax.xml.namespace.QName.class); + XML2JAVA.put("dateTime", javax.xml.datatype.XMLGregorianCalendar.class); + XML2JAVA.put("base64Binary", byte[].class); + XML2JAVA.put("hexBinary", byte[].class); + XML2JAVA.put("unsignedInt", long.class); + XML2JAVA.put("unsignedShort", int.class); + XML2JAVA.put("unsignedByte", short.class); + XML2JAVA.put("time", javax.xml.datatype.XMLGregorianCalendar.class); + XML2JAVA.put("date", javax.xml.datatype.XMLGregorianCalendar.class); + XML2JAVA.put("gDay", javax.xml.datatype.XMLGregorianCalendar.class); + XML2JAVA.put("gMonth", javax.xml.datatype.XMLGregorianCalendar.class); + XML2JAVA.put("gYear", javax.xml.datatype.XMLGregorianCalendar.class); + XML2JAVA.put("gYearMonth", javax.xml.datatype.XMLGregorianCalendar.class); + XML2JAVA.put("gMonthDay", javax.xml.datatype.XMLGregorianCalendar.class); + XML2JAVA.put("anySimpleType", java.lang.Object.class); // For elements + // XML2JAVA.put("anySimpleType", java.lang.String.class); // For + // attributes + XML2JAVA.put("duration", javax.xml.datatype.Duration.class); + XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class); + } + + public static Class getJavaType(QName xmlType) { + if (URI_2001_SCHEMA_XSD.equals(xmlType.getNamespaceURI())) { + return XML2JAVA.get(xmlType.getLocalPart()); + } else { + return null; + } + } + + private static QName getTypeName(String name) { + return new QName(URI_2001_SCHEMA_XSD, name); + } + + public static QName getXMLType(Class javaType) { + return JAVA2XML.get(javaType); + } + + private static String getPackageName(Class cls) { + String name = cls.getName(); + int index = name.lastIndexOf('.'); + return index == -1 ? "" : name.substring(0, index); + } + + public static String getNamespace(Class cls) { + String packageName = getPackageName(cls); + if ("".equals(packageName)) { + return ""; + } + StringBuffer ns = new StringBuffer("http://"); + String[] names = packageName.split("\\."); + for (int i = names.length - 1; i >= 0; i--) { + ns.append(names[i]); + if (i != 0) { + ns.append('.'); + } + } + ns.append('/'); + return ns.toString(); + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java new file mode 100644 index 0000000000..2598dc8545 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.interfacedef.util; + +import javax.xml.namespace.QName; + +/** + * An abstraction of XML schema types + * + * @version $Rev$ $Date$ + */ +public class TypeInfo { + private QName name; + + private boolean isSimpleType; + + private TypeInfo baseType; + + /** + * @param name + * @param isSimpleType + */ + public TypeInfo(QName name, boolean isSimpleType, TypeInfo baseType) { + super(); + this.name = name; + this.isSimpleType = isSimpleType; + this.baseType = baseType; + } + + /** + * @return the isSimpleType + */ + public boolean isSimpleType() { + return isSimpleType; + } + + /** + * @return the name + */ + public QName getQName() { + return name; + } + + /** + * @return the baseType + */ + public TypeInfo getBaseType() { + return baseType; + } + + @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("Type: ").append(name); + return sb.toString(); + } + + @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; + final TypeInfo other = (TypeInfo)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/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java new file mode 100644 index 0000000000..12db460959 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java @@ -0,0 +1,190 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.util; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; + +/** + * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based + * Web Services (JAX-WS) 2.0 specification, section 2.3.1.2 Wrapper Style.

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

    + *
  • (i) The operation�s input and output messages (if present) each contain + * only a single part + *
  • (ii) The input message part refers to a global element declaration whose + * localname is equal to the operation name + *
  • (iii) The output message part refers to a global element declaration + *
  • (iv) The elements referred to by the input and output message parts + * (henceforth referred to as wrapper elements) are both complex types defined + * using the xsd:sequence compositor + *
  • (v) The wrapper elements only contain child elements, they must not + * contain other structures such as wildcards (element or attribute), + * xsd:choice, substitution groups (element references are not permitted) or + * attributes; furthermore, they must not be nillable. + *
+ * + * @version $Rev$ $Date$ + */ +public class WrapperInfo { + private ElementInfo inputWrapperElement; + + private ElementInfo outputWrapperElement; + + private List inputChildElements; + + private List outputChildElements; + + // The data type of the unwrapped input child elements + private DataType> unwrappedInputType; + + // The data type of the unwrapped output child element (we only supports one child) + private DataType unwrappedOutputType; + + // The data for the input/output wrappers + private String dataBinding; + + // The data type for the input (request) wrapper bean + private DataType inputWrapperType; + // The data type for the output (response) wrapper bean + private DataType outputWrapperType; + + public WrapperInfo(String dataBinding, + ElementInfo inputWrapperElement, + ElementInfo outputWrapperElement, + List inputElements, + List outputElements) { + super(); + this.dataBinding = dataBinding; + this.inputWrapperElement = inputWrapperElement; + this.outputWrapperElement = outputWrapperElement; + this.inputChildElements = inputElements; + this.outputChildElements = outputElements; + } + + /** + * @return the inputElements + */ + public List getInputChildElements() { + return inputChildElements; + } + + /** + * @return the inputWrapperElement + */ + public ElementInfo getInputWrapperElement() { + return inputWrapperElement; + } + + /** + * @return the outputElements + */ + public List getOutputChildElements() { + return outputChildElements; + } + + /** + * @return the outputWrapperElement + */ + public ElementInfo getOutputWrapperElement() { + return outputWrapperElement; + } + + /** + * @return the unwrappedInputType + */ + public DataType> getUnwrappedInputType() { + if (unwrappedInputType == null) { + List childTypes = new ArrayList(); + for (ElementInfo element : getInputChildElements()) { + DataType type = getDataType(element); + childTypes.add(type); + } + unwrappedInputType = new DataTypeImpl>("idl:unwrapped.input", Object[].class, childTypes); + } + return unwrappedInputType; + } + + private DataType getDataType(ElementInfo element) { + DataType type = null; + if (element.isMany()) { + DataType logical = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); + type = new DataTypeImpl("java:array", Object[].class, logical); + } else { + type = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); + } + return type; + } + + /** + * @return the unwrappedOutputType + */ + public DataType getUnwrappedOutputType() { + if (unwrappedOutputType == null) { + List elements = getOutputChildElements(); + if (elements != null && elements.size() > 0) { + if (elements.size() > 1) { + // We don't support output with multiple parts + // throw new IllegalArgumentException("Multi-part output is not supported"); + } + ElementInfo element = elements.get(0); + + unwrappedOutputType = getDataType(element); + } + } + return unwrappedOutputType; + } + + public Class getInputWrapperClass() { + return inputWrapperType == null ? null : inputWrapperType.getPhysical(); + } + + public Class getOutputWrapperClass() { + return outputWrapperType == null ? null : outputWrapperType.getPhysical(); + } + + public String getDataBinding() { + return dataBinding; + } + + public void setDataBinding(String dataBinding) { + this.dataBinding = dataBinding; + } + + public DataType getInputWrapperType() { + return inputWrapperType; + } + + public void setInputWrapperType(DataType inputWrapperType) { + this.inputWrapperType = inputWrapperType; + } + + public DataType getOutputWrapperType() { + return outputWrapperType; + } + + public void setOutputWrapperType(DataType outputWrapperType) { + this.outputWrapperType = outputWrapperType; + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java new file mode 100644 index 0000000000..26ecf6e352 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.interfacedef.util; + +import javax.xml.namespace.QName; + +/** + * The metadata for an XML element or type. + * + * @version $Rev$ $Date$ + */ +public class XMLType { + public static final XMLType UNKNOWN = new XMLType(null, null); + protected QName element; + protected QName type; + protected boolean nillable = true; + protected boolean many = false; + + /** + * @param element + */ + public XMLType(ElementInfo element) { + super(); + this.element = element.getQName(); + if (element.getType() != null) { + this.type = element.getType().getQName(); + } + } + + /** + * @param element + */ + public XMLType(TypeInfo type) { + this.element = null; + this.type = type.getQName(); + } + + public XMLType(QName element, QName type) { + this.element = element; + this.type = type; + } + + /** + * @return the type + */ + public QName getTypeName() { + return type; + } + + public boolean isElement() { + return element != null; + } + + public QName getElementName() { + return element; + } + + public void setElementName(QName element) { + this.element = element; + } + + public void setTypeName(QName type) { + this.type = type; + } + + public static XMLType getType(QName type) { + return new XMLType(null, type); + } + + /** + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int PRIME = 31; + int result = 1; + result = PRIME * result + ((element == null) ? 0 : element.hashCode()); + result = PRIME * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + /** + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final XMLType other = (XMLType)obj; + if (element == null) { + if (other.element != null) { + return false; + } + } else if (!element.equals(other.element)) { + return false; + } + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "Element: " + element + " Type: " + type; + } + + public boolean isNillable() { + return nillable; + } + + public void setNillable(boolean niable) { + this.nillable = niable; + } + + public boolean isMany() { + return many; + } + + public void setMany(boolean many) { + this.many = many; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java new file mode 100644 index 0000000000..f43c428563 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy; + + +/** + * Definition of binding type which extends from sca:binding + */ +public interface BindingType extends ExtensionType { +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java new file mode 100644 index 0000000000..2da41675a1 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy; + +import org.apache.tuscany.sca.policy.impl.PolicyFactoryImpl; + +/** + * A factory for the policy model. + * + * @version $Rev$ $Date$ + */ +public class DefaultPolicyFactory extends PolicyFactoryImpl implements PolicyFactory { + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java new file mode 100644 index 0000000000..e7a93c8907 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.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/200903", "binding"); + QName IMPLEMENTATION_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "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 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 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/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java new file mode 100644 index 0000000000..d142015f57 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy; + + +/** + * Definition of an implementation type which extends from sca:implementation + */ +public interface ImplementationType extends ExtensionType { +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java new file mode 100644 index 0000000000..b79ccdab78 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java @@ -0,0 +1,160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** + * Represents a policy intent. See the Policy Framework specification for a + * description of this element. + * + * @version $Rev$ $Date$ + */ +public interface Intent { + enum Type { + interaction, implementation + }; + + /** + * Returns the intent name. + * + * @return the intent name + */ + QName getName(); + + /** + * Sets the intent name + * + * @param name the intent name + */ + void setName(QName name); + + /** + * 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 + */ + List getConstrainedTypes(); + + /** + * Return a list of required intents + * @return The list of required intents + */ + List getRequiredIntents(); + + /** + * Returns the list of intents which are mutually exclusive with this intent. + * + * @return the list of mutually exclusive intents. + */ + List getExcludedIntents(); + + /** + * Returns the list of qualified intents. + * + * @return the list of qualified intents. + */ + List getQualifiedIntents(); + + /** + * Get the default qualified intent + * + * @return + */ + Intent getDefaultQualifiedIntent(); + + /** + * Set the default qualified intent + * + * @param qualifiedIntent + */ + 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. + * + * @return the intent description + */ + String getDescription(); + + /** + * Sets the intent description. + * + * @param description the intent description + */ + void setDescription(String description); + + /** + * Returns true if the model element is unresolved. + * + * @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 getQualifiableIntent(); + + /** + * Set the parent intent for a qualified intent + * @param intent + */ + void setQualifiableIntent(Intent intent); + + 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/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java new file mode 100644 index 0000000000..efed4bfdb1 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy; + +import java.util.List; + +import org.apache.tuscany.sca.policy.Intent; + + +/** + * Map policies to the qualified intents + */ +public interface IntentMap { + /** + * Returns the intent realized by this intent map. + * + * @return the intent realized by this intent map + */ + Intent getProvidedIntent(); + + /** + * Sets the intent realized by this intent map. + * + * @param providedIntent the intent realized by this intent map + */ + void setProvidedIntent(Intent providedIntent); + + /** + * Get a list of qualifiers + * + * @return A list of qualifiers + */ + List getQualifiers(); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java new file mode 100644 index 0000000000..ee4f5b5236 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy; + +import java.util.List; + +/** + * Attach a policySet to a collection of policy subjects + */ +public interface PolicyAttachment { + PolicySet getPolicySet(); + void setPolicySet(PolicySet policySet); + List getPolicySubjects(); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java new file mode 100644 index 0000000000..a29f214f98 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.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 getPolicy(); + + /** + * Set the policy definition + * @param expression + */ + void setPolicy(T policy); + + /** + * + * @param unresolved + */ + void setUnresolved(boolean unresolved); + + /** + * + * @return + */ + boolean isUnresolved(); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java new file mode 100644 index 0000000000..9e7de2f6da --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy; + +/** + * A factory for the policy model. + * + * @version $Rev$ $Date$ + */ +public interface PolicyFactory { + + /** + * Create a new intent. + * + * @return a new intent + */ + Intent createIntent(); + + /** + * Create a new policy set. + * + * @return a new policy set + */ + PolicySet createPolicySet(); + + /** + * Create a new intent map. + * + * @return a new intent map + */ + IntentMap createIntentMap(); + + /** + * create a new Qualifier + * + * @return a Qualifier + */ + Qualifier createQualifier(); + + /** + * Create a new PolicyExpression + * @return + */ + PolicyExpression createPolicyExpression(); + + ExtensionType createExtensionType(); + BindingType createBindingType(); + ImplementationType createImplementationType(); + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java new file mode 100644 index 0000000000..2b5b8458d5 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java @@ -0,0 +1,146 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; +import javax.xml.xpath.XPathExpression; + +/** + * Represents a policy set. See the Policy Framework specification for a + * description of this element. + * + * @version $Rev$ $Date$ + */ +public interface PolicySet { + + /** + * Returns the intent name. + * + * @return the intent name + */ + QName getName(); + + /** + * Sets the intent name + * + * @param name the intent name + */ + void setName(QName name); + + /** + * Returns the list of + * + * @return + */ + List getReferencedPolicySets(); + + /** + * Returns the list of provided intents + * + * @return + */ + List getProvidedIntents(); + + /** + * 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 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); + + /** + * Returns the XPath expression that is to be used to evaluate + * if this PolicySet applies to specific policy subject + * + * @return the XPath expression + */ + String getAppliesTo(); + + /** + * Sets the XPath expression that is to be used to evaluate + * if this PolicySet applies to specific policy subject + * + */ + void setAppliesTo(String xpath); + + /** + * 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 + */ + XPathExpression getAttachToXPathExpression(); + + /** + * Set the resolved XPathExpression for attachTo + * @param expression + */ + void setAttachToXPathExpression(XPathExpression expression); + + /** + * Returns the policies / policy attachments provided thro intent maps + * + * @return + */ + List getIntentMaps(); + + /** + * Get the XPath expression for the appliesTo attribute + * @return the XPath expression for the appliesTo attribute + */ + XPathExpression getAppliesToXPathExpression(); + + /** + * Set the XPath expression for the appliesTo attribute + * @param xpathExpression the XPath expression for the appliesTo attribute + */ + void setAppliesToXPathExpression(XPathExpression xpathExpression); + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java new file mode 100644 index 0000000000..35a86ceedf --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy; + +import java.util.List; + +/** + * 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: + *
    + *
  • composite + *
  • component + *
  • implementation + *
  • service + *
  • reference + *
  • binding + *
  • interface + *
+ */ +public interface PolicySubject { + /** + * Get a list of required intents + * + * @return + */ + List getRequiredIntents(); + + /** + * Get a list of attached policySets + * + * @return A list of policySets + */ + List getPolicySets(); + + ExtensionType getExtensionType(); + void setExtensionType(ExtensionType type); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java new file mode 100644 index 0000000000..c1862283c7 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.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 getPolicies(); +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java new file mode 100644 index 0000000000..1a2a9c5bad --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.policy.BindingType; + +/** + * Concrete implementation for a BindingType + * + * @version $Rev$ $Date$ + */ +public class BindingTypeImpl extends ExtensionTypeImpl implements BindingType { + protected BindingTypeImpl() { + super(); + } + + public QName getBaseType() { + return BINDING_BASE; + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java new file mode 100644 index 0000000000..97fbc19ced --- /dev/null +++ b/java/sca/modules/assembly/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 alwaysProvides = new ArrayList(); + private List mayProvide = new ArrayList(); + private QName typeName; + private boolean unResolved = true; + + protected ExtensionTypeImpl() { + + } + + public List getAlwaysProvidedIntents() { + return alwaysProvides; + } + + public List 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/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java new file mode 100644 index 0000000000..5c285e4d95 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy.impl; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.policy.ImplementationType; + +/** + * Concrete implementation for a Implementation Type + * + * @version $Rev$ $Date$ + */ +public class ImplementationTypeImpl extends ExtensionTypeImpl implements ImplementationType { + protected ImplementationTypeImpl() { + super(); + } + + public QName getBaseType() { + return IMPLEMENTATION_BASE; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java new file mode 100644 index 0000000000..27a77f3ba8 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java @@ -0,0 +1,168 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** + * Represents a policy intent. + * + * @version $Rev$ $Date$ + */ +public class IntentImpl implements Intent { + + private QName name; + private Type type; + private List constrainedTypes = new ArrayList(); + private String description; + private List qualifiedIntents = new ArrayList(); + private Intent defaultQualifiedIntent; + private Intent parent; + private List requiredIntents = new ArrayList(); + private List excludedIntents = new ArrayList(); + private boolean mutuallyExclusive; + private boolean unresolved = true; + + protected IntentImpl() { + } + + public QName getName() { + return name; + } + + public void setName(QName name) { + this.name = name; + } + + public List getConstrainedTypes() { + return constrainedTypes; + } + + public void setConstrainedTypes(List constrainedTypes) { + this.constrainedTypes = constrainedTypes; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Intent getQualifiableIntent() { + return parent; + } + + public void setQualifiableIntent(Intent parent) { + this.parent = parent; + } + + public List getQualifiedIntents() { + return qualifiedIntents; + } + + public void setQualifiedIntents(List qualifiedIntents) { + this.qualifiedIntents = qualifiedIntents; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public void setRequiredIntents(List requiredIntents) { + this.requiredIntents = requiredIntents; + } + + public List getExcludedIntents() { + return excludedIntents; + } + + public void setExcludedIntents(List excludedIntents) { + this.excludedIntents = excludedIntents; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + 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; + 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; + IntentImpl other = (IntentImpl)obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + public String toString() { + return String.valueOf(name); + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java new file mode 100644 index 0000000000..6e2941ff5c --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.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. + * + * @version $Rev$ $Date$ + */ +public class IntentMapImpl implements IntentMap { + + private boolean unresolved; + private Intent providedIntent; + private List qualifiers = new ArrayList(); + + protected IntentMapImpl() { + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + public Intent getProvidedIntent() { + return providedIntent; + } + + public void setProvidedIntent(Intent providedIntent) { + this.providedIntent = providedIntent; + } + + public List getQualifiers() { + return qualifiers; + } +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java new file mode 100644 index 0000000000..71e5eef6a7 --- /dev/null +++ b/java/sca/modules/assembly/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 getPolicy() { + return (T)policy; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setName(QName name) { + this.name = name; + } + + public 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/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java new file mode 100644 index 0000000000..c67ff1eab8 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.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.Qualifier; + +/** + * A factory for the policy model. + * + * @version $Rev$ $Date$ + */ +public abstract class PolicyFactoryImpl implements PolicyFactory { + + public Intent createIntent() { + return new IntentImpl(); + } + + public PolicySet createPolicySet() { + return new PolicySetImpl(); + } + + public IntentMap createIntentMap() { + return new IntentMapImpl(); + } + + 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 ExtensionType createExtensionType() { + return new ExtensionTypeImpl(); + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java new file mode 100644 index 0000000000..75d1229cd8 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 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; + +/** + * Represents a policy set. + * + * @version $Rev$ $Date$ + */ +public class PolicySetImpl implements PolicySet { + + private QName name; + private String appliesTo; + private String attachTo; + private List providedIntents = new ArrayList(); + private List referencedPolicySets = new ArrayList(); + private boolean unresolved = true; + + private XPathExpression appliesToXPathExpression; + private XPathExpression attachToXPathExpression; + + private List intentMaps = new ArrayList(); + private List policies = new ArrayList(); + + public QName getName() { + return name; + } + + public void setName(QName name) { + this.name = name; + } + + public String getAppliesTo() { + return appliesTo; + } + + public void setAppliesTo(String appliesTo) { + this.appliesTo = appliesTo; + } + + public String getAttachTo() { + return attachTo; + } + + public void setAttachTo(String attachTo) { + this.attachTo = attachTo; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + public XPathExpression getAppliesToXPathExpression() { + return appliesToXPathExpression; + } + + public void setAppliesToXPathExpression(XPathExpression appliesToXPathExpression) { + this.appliesToXPathExpression = appliesToXPathExpression; + } + + public XPathExpression getAttachToXPathExpression() { + return attachToXPathExpression; + } + + public void setAttachToXPathExpression(XPathExpression attachToXPathExpression) { + this.attachToXPathExpression = attachToXPathExpression; + } + + public List getIntentMaps() { + return intentMaps; + } + + public List getProvidedIntents() { + return providedIntents; + } + + public List getReferencedPolicySets() { + return referencedPolicySets; + } + + public List 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; + } + + @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/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java new file mode 100644 index 0000000000..102bea8d41 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.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 policies = new ArrayList(); + + protected QualifierImpl() { + } + + public Intent getIntent() { + return intent; + } + + public List getPolicies() { + return policies; + } + + public void setIntent(Intent intent) { + this.intent = intent; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java new file mode 100644 index 0000000000..fe61ce707c --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyComputationUtils.java @@ -0,0 +1,370 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI; + +import java.io.InputStream; +import java.io.StringWriter; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +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.PolicySet; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * Utility methods used during computation of PolicyIntents and PolicySets sets + * + * @version $Rev$ $Date$ + */ +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.1"; + private static final String APPLICABLE_POLICYSET_ATTR = "applicablePolicySets"; + private static final String POLICY_SETS_ATTR = "policySets"; + private static final String APPLICABLE_POLICYSET_ATTR_PREFIX = "tuscany"; + private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; + + /** + * This method unconditionally adds intents from the source list to the target list. + * It is used for intermediate intent inheritance between promotion levels + * (e.g. between a composite service and a component service). It does not check + * whether there are conflicting (mutually exclusive) intents. This is because + * promotion cannot override intents. If the resulting target list has conflicting + * intents, this will be detected later during policy computation. + */ + public static void addInheritedIntents(List sourceList, List targetList) { + if (sourceList != null) { + targetList.addAll(sourceList); + } + } + + public static void addInheritedPolicySets(List sourceList, + List targetList, + boolean checkOverrides) { + // check overrides is true when policysets are to be copied from + // componentType to component level + if (checkOverrides) { + // aggregate all the provided intents present in the target + List targetProvidedIntents = new ArrayList(); + for (PolicySet policySet : targetList) { + targetProvidedIntents.addAll(policySet.getProvidedIntents()); + } + + // for every policy set in the source check if it provides one of + // the intents that is + // already provided by the policysets in the destination and do not + // copy them. + for (PolicySet policySet : sourceList) { + for (Intent sourceProvidedIntent : policySet.getProvidedIntents()) { + if (!targetProvidedIntents.contains(sourceProvidedIntent)) { + targetList.add(policySet); + } + } + } + } else { + targetList.addAll(sourceList); + } + } + + /** + * This method is used to inherit intents and policy sets between hierarchical levels + * within the same composite (e.g. between a component and its services and references). + * In this case the source intents and policy sets provide defaults which are inherited + * into the target lists only when there is no conflict. For example consider a component + * with 3 references. The component level requires intent 'propagatesTransaction'. + * Reference 1 and 2 do not specify an intent, but reference 3 requires 'suspendsTransaction'. + * In this case the 'propagatesTransaction' intent is inherited by reference 1 and 2 + * but not by reference 3. + */ + public static void addDefaultPolicies(List sourceIntents, + List sourcePolicySets, + List targetIntents, + List targetPolicySets) { + // form a list of all intents required by the target + List combinedTargetIntents = new ArrayList(); + combinedTargetIntents.addAll(findAndExpandProfileIntents(targetIntents)); + for (PolicySet targetPolicySet : targetPolicySets) { + combinedTargetIntents.addAll(findAndExpandProfileIntents(targetPolicySet.getProvidedIntents())); + } + + // inherit intents in the source list that do not conflict with intents already in the target list + for (Intent sourceIntent : findAndExpandProfileIntents(sourceIntents)) { + boolean conflict = false; + for (Intent excluded : sourceIntent.getExcludedIntents()) { + if (combinedTargetIntents.contains(excluded)) { + conflict = true; + break; + } + } + if (!conflict) { + targetIntents.add(sourceIntent); + } + } + + // inherit policy sets in the source list that do not conflict with policy sets or intents + // in the target list + for (PolicySet sourcePolicySet : sourcePolicySets) { + boolean conflict = false; + List providedIntents = findAndExpandProfileIntents(sourcePolicySet.getProvidedIntents()); + checkConflict: for (Intent intent : providedIntents) { + for (Intent excluded : intent.getExcludedIntents()) { + if (combinedTargetIntents.contains(excluded)) { + conflict = true; + break checkConflict; + } + } + } + if (!conflict) + targetPolicySets.add(sourcePolicySet); + } + + } + + public static void checkForMutuallyExclusiveIntents(List intents, + List policySets, + ExtensionType intentAttachPointType, + String id) throws PolicyValidationException { + // gather all intents (keeping track of where they come from) + Map combinedIntents = new HashMap(); + for (PolicySet policySet : policySets) { + for (Intent providedIntent : findAndExpandProfileIntents(policySet.getProvidedIntents())) { + combinedIntents.put(providedIntent, policySet); + } + } + for (Intent intent : intents) { + combinedIntents.put(intent, null); + } + + // check for conflicts + for (Intent intent : combinedIntents.keySet()) { + for (Intent excluded : intent.getExcludedIntents()) { + if (combinedIntents.keySet().contains(excluded)) { + String sIntent1, sIntent2; + if (combinedIntents.get(intent) == null) + sIntent1 = intent.getName().toString(); + else + 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.getType() + " for " + + id + + " uses mutually-exclusive intents " + + sIntent1 + + " and " + + sIntent2); + } + } + } + } + + public static void expandProfileIntents(List intents) { + List expandedIntents = null; + if (intents.size() > 0) { + expandedIntents = findAndExpandProfileIntents(intents); + intents.clear(); + intents.addAll(expandedIntents); + } + } + + public static List findAndExpandProfileIntents(List intents) { + List expandedIntents = new ArrayList(); + for (Intent intent : intents) { + if (!intent.getRequiredIntents().isEmpty()) { + List requiredIntents = intent.getRequiredIntents(); + expandedIntents.addAll(findAndExpandProfileIntents(requiredIntents)); + } else { + expandedIntents.add(intent); + } + } + return expandedIntents; + } + + private static byte[] addApplicablePolicySets(Document doc, Collection policySets) + throws XPathExpressionException, TransformerConfigurationException, TransformerException { + + for (PolicySet policySet : policySets) { + if (policySet.getAppliesTo() != null) { + addApplicablePolicySets(policySet, doc); + } + } + + StringWriter sw = new StringWriter(); + final Source domSource = new DOMSource(doc); + final Result finalResult = new StreamResult(sw); + final Transformer transformer = TransformerFactory.newInstance().newTransformer(); + // transformer.setOutputProperty("omit-xml-declaration", "yes"); + // Allow priviledged access to let transformers read property files. Requires + // PropertyPermission in security policy. + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws TransformerException { + transformer.transform(domSource, finalResult); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw (TransformerException)e.getException(); + } + + return sw.toString().getBytes(); + } + + private static void addApplicablePolicySets(PolicySet policySet, Document doc) throws XPathExpressionException { + XPathExpression expression = policySet.getAppliesToXPathExpression(); + 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 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) { + applicablePolicySets = + aResultNode.getAttributes().getNamedItemNS(APPLICABLE_POLICYSET_ATTR_NS, + APPLICABLE_POLICYSET_ATTR).getNodeValue(); + } + + if (applicablePolicySets != null && applicablePolicySets.length() > 0) { + applicablePolicySets = + applicablePolicySets + " " + policySetPrefix + ":" + policySet.getName().getLocalPart(); + } else { + applicablePolicySets = policySetPrefix + ":" + policySet.getName().getLocalPart(); + } + + ((Element)aResultNode).setAttributeNS(APPLICABLE_POLICYSET_ATTR_NS, appPolicyAttrPrefix + ":" + + APPLICABLE_POLICYSET_ATTR, applicablePolicySets); + } + } + } + + public static byte[] addApplicablePolicySets(InputStream is, + Collection 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; + + /** + * @param node + */ + public DOMNamespaceContext(Node node) { + super(); + this.node = node; + } + + public String getNamespaceURI(String prefix) { + return node.lookupNamespaceURI(prefix); + } + + public String getPrefix(String namespaceURI) { + return node.lookupPrefix(namespaceURI); + } + + public Iterator getPrefixes(String namespaceURI) { + return null; + } + + } + + private static String declareNamespace(Element element, String ns) { + if (ns == null) { + ns = ""; + } + Node node = element; + String prefix = ""; + boolean declared = false; + while (node != null && node.getNodeType() == Node.ELEMENT_NODE) { + if (node.lookupPrefix(ns) != null) { + prefix = node.lookupPrefix(ns); + declared = true; + break; + } else { + /*NamedNodeMap attrs = node.getAttributes(); + if (attrs == null) { + break; + } + Node attr = attrs.getNamedItem(qname); + if (attr != null) { + declared = ns.equals(attr.getNodeValue()); + break; + }*/ + node = node.getParentNode(); + } + } + if (!declared) { + // Find an available prefix + for (int i = 1;; i++) { + prefix = POLICYSET_PREFIX + i; + if (element.lookupNamespaceURI(prefix) == null) { + break; + } + } + String qname = "xmlns:" + prefix; + org.w3c.dom.Attr attr = element.getOwnerDocument().createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, qname); + attr.setValue(ns); + element.setAttributeNodeNS(attr); + } + return prefix; + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationException.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationException.java new file mode 100644 index 0000000000..3ed4eac5a2 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationException.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.policy.util; + +/** + * Exception to be throw for invalid policy intents / policysets + * + * @version $Rev$ $Date$ + */ +public class PolicyValidationException extends Exception { + private static final long serialVersionUID = 506979037642587755L; + + public PolicyValidationException(String message) { + super(message); + } + + public PolicyValidationException(Throwable e) { + super(e); + } + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java new file mode 100644 index 0000000000..616eab5737 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyValidationUtils.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.ExtensionType; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySubject; + +/** + * @version $Rev$ $Date$ + */ +public class PolicyValidationUtils { + + public static boolean isConstrained(ExtensionType constrained, ExtensionType attachPointType) { + return (attachPointType != null + && (attachPointType.equals(constrained)) || (attachPointType.getBaseType().equals(constrained))); + } + + public static void validateIntents(PolicySubject attachPoint, ExtensionType attachPointType) + throws PolicyValidationException { + boolean found = false; + if (attachPointType != null) { + // validate intents specified against the parent (binding / + // implementation) + found = false; + for (Intent intent : attachPoint.getRequiredIntents()) { + if (!intent.isUnresolved()) { + for (ExtensionType constrained : intent.getConstrainedTypes()) { + if (isConstrained(constrained, attachPointType)) { + found = true; + break; + } + } + + if (!found) { + throw new PolicyValidationException("Policy Intent '" + intent.getName() + + "' does not constrain extension type " + + attachPointType.getType()); + } + } else { + throw new PolicyValidationException("Policy Intent '" + intent.getName() + + "' is not defined in this domain "); + } + } + } + } + + public static void validatePolicySets(PolicySubject subject) throws PolicyValidationException { + // validatePolicySets(subject, subject.getType(), subject.getAttachedPolicySets()); + } + + public static void validatePolicySets(PolicySubject subject, ExtensionType attachPointType) + throws PolicyValidationException { + validatePolicySets(subject, attachPointType, subject.getPolicySets()); + } + + public static void validatePolicySets(PolicySubject subject, + ExtensionType attachPointType, + List 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 : subject.getPolicySets()) { + if (!definedPolicySet.isUnresolved()) { + if (!applicablePolicySets.contains(definedPolicySet)) { + throw new PolicyValidationException("Policy Set '" + definedPolicySet.getName() + + "' does not apply to extension type " + + attachPointType.getType()); + } + } else { + throw new PolicyValidationException("Policy Set '" + definedPolicySet.getName() + + "' is not defined in this domain "); + + } + } + } +} diff --git a/java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory b/java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory new file mode 100644 index 0000000000..521d94f518 --- /dev/null +++ b/java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT 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.definitions.DefaultDefinitionsFactory \ No newline at end of file diff --git a/java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper b/java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper new file mode 100644 index 0000000000..821c58bde1 --- /dev/null +++ b/java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +org.apache.tuscany.sca.interfacedef.impl.InterfaceContractMapperImpl diff --git a/java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory b/java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory new file mode 100644 index 0000000000..846b3b24a4 --- /dev/null +++ b/java/sca/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +org.apache.tuscany.sca.policy.DefaultPolicyFactory \ No newline at end of file diff --git a/java/sca/modules/assembly/src/main/resources/definitions-validation-messages.properties b/java/sca/modules/assembly/src/main/resources/definitions-validation-messages.properties new file mode 100644 index 0000000000..4cf9c01da5 --- /dev/null +++ b/java/sca/modules/assembly/src/main/resources/definitions-validation-messages.properties @@ -0,0 +1,25 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# + +DuplicateIntent = Duplicate intent {0} found in domain +DuplicatePolicysSet = Duplicate policy set {0} found in domain +DuplicateImplementationType = Duplicate implementation type {0} found in domain +DuplicateBindingType = Duplicate binding type {0} found in domain diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java new file mode 100644 index 0000000000..acdaae799e --- /dev/null +++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java @@ -0,0 +1,395 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.impl; + +import static org.junit.Assert.fail; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.junit.Before; +import org.junit.Test; + +/** + * TODO some tests commented out due to DataType.equals() needing to be strict + * + * @version $Rev$ $Date$ + */ +public class ContractCompatibilityTestCase { + + private InterfaceContractMapper mapper; + + @Before + public void setUp() throws Exception { + ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + mapper = utilities.getUtility(InterfaceContractMapper.class); + } + + @Test + public void testNoOperation() throws Exception { + InterfaceContract source = new MockContract("FooContract"); + InterfaceContract target = new MockContract("FooContract"); + mapper.checkCompatibility(source, target, false, false); + } + + @Test + public void testBasic() throws Exception { + InterfaceContract source = new MockContract("FooContract"); + Operation opSource1 = newOperation("op1"); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + InterfaceContract target = new MockContract("FooContract"); + Operation opSource2 = newOperation("op1"); + Map targetOperations = new HashMap(); + targetOperations.put("op1", opSource2); + target.getInterface().getOperations().addAll(targetOperations.values()); + mapper.checkCompatibility(source, target, false, false); + } + + @Test + public void testBasicIncompatibleOperationNames() throws Exception { + InterfaceContract source = new MockContract("FooContract"); + Operation opSource1 = newOperation("op1"); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + InterfaceContract target = new MockContract("FooContract"); + Operation opSource2 = newOperation("op2"); + Map targetOperations = new HashMap(); + targetOperations.put("op2", opSource2); + target.getInterface().getOperations().addAll(targetOperations.values()); + try { + mapper.checkCompatibility(source, target, false, false); + fail(); + } catch (IncompatibleInterfaceContractException e) { + // expected + } + } + + @Test + public void testInputTypes() throws Exception { + InterfaceContract source = new MockContract("FooContract"); + List sourceInputTypes = new ArrayList(); + sourceInputTypes.add(new DataTypeImpl(Object.class, Object.class)); + DataType> inputType = new DataTypeImpl>(String.class, sourceInputTypes); + Operation opSource1 = newOperation("op1"); + opSource1.setInputType(inputType); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + List targetInputTypes = new ArrayList(); + targetInputTypes.add(new DataTypeImpl(Object.class, Object.class)); + DataType> targetInputType = new DataTypeImpl>(String.class, targetInputTypes); + + Operation opTarget = newOperation("op1"); + opTarget.setInputType(targetInputType); + Map targetOperations = new HashMap(); + targetOperations.put("op1", opTarget); + target.getInterface().getOperations().addAll(targetOperations.values()); + mapper.checkCompatibility(source, target, false, false); + } + + @Test + public void testIncompatibleInputTypes() throws Exception { + InterfaceContract source = new MockContract("FooContract"); + List sourceInputTypes = new ArrayList(); + sourceInputTypes.add(new DataTypeImpl(Integer.class, Integer.class)); + DataType> inputType = new DataTypeImpl>(String.class, sourceInputTypes); + Operation opSource1 = newOperation("op1"); + opSource1.setInputType(inputType); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + List targetInputTypes = new ArrayList(); + targetInputTypes.add(new DataTypeImpl(String.class, String.class)); + DataType> targetInputType = new DataTypeImpl>(String.class, targetInputTypes); + + Operation opTarget = newOperation("op1"); + opTarget.setInputType(targetInputType); + Map targetOperations = new HashMap(); + targetOperations.put("op1", opTarget); + target.getInterface().getOperations().addAll(targetOperations.values()); + try { + mapper.checkCompatibility(source, target, false, false); + fail(); + } catch (IncompatibleInterfaceContractException e) { + // expected + } + } + + /** + * Verifies source input types can be super types of the target + */ + @Test + public void testSourceSuperTypeInputCompatibility() throws Exception { + // InterfaceContract source = new MockContract("FooContract"); + // List sourceInputTypes = new ArrayList(); + // sourceInputTypes.add(new DataTypeImpl(Object.class, + // Object.class)); + // DataType> inputType = new + // DataTypeImpl>(String.class, sourceInputTypes); + // Operation opSource1 = newOperationImpl("op1", inputType, null, null, + // false, null); + // Map sourceOperations = new HashMap(); + // sourceOperations.put("op1", opSource1); + // source.getInterface().getOperations().addAll(sourceOperations.values()); + // + // InterfaceContract target = new MockContract("FooContract"); + // List targetInputTypes = new ArrayList(); + // targetInputTypes.add(new DataTypeImpl(String.class, + // String.class)); + // DataType> targetInputType = + // new DataTypeImpl>(String.class, targetInputTypes); + // + // Operation opTarget = newOperationImpl("op1", targetInputType, null, + // null, false, null); + // Map targetOperations = new HashMap(); + // targetOperations.put("op1", opTarget); + // target.getInterface().getOperations().addAll(targetOperations.values()); + // wireService.checkCompatibility(source, target, false); + } + + @Test + public void testOutputTypes() throws Exception { + InterfaceContract source = new MockContract("FooContract"); + DataType sourceOutputType = new DataTypeImpl(String.class, String.class); + Operation opSource1 = newOperation("op1"); + opSource1.setOutputType(sourceOutputType); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + DataType targetOutputType = new DataTypeImpl(String.class, String.class); + Operation opTarget = newOperation("op1"); + opTarget.setOutputType(targetOutputType); + Map targetOperations = new HashMap(); + targetOperations.put("op1", opTarget); + target.getInterface().getOperations().addAll(targetOperations.values()); + mapper.checkCompatibility(source, target, false, false); + } + + /** + * Verifies a return type that is a supertype of of the target is compatible + */ + @Test + public void testSupertypeOutputTypes() throws Exception { + // InterfaceContract source = new MockContract("FooContract"); + // DataType sourceOutputType = new DataTypeImpl(Object.class, + // Object.class); + // Operation opSource1 = newOperationImpl("op1", null, + // sourceOutputType, null, false, null); + // Map sourceOperations = new HashMap(); + // sourceOperations.put("op1", opSource1); + // source.getInterface().getOperations().addAll(sourceOperations.values()); + // + // InterfaceContract target = new MockContract("FooContract"); + // DataType targetOutputType = new DataTypeImpl(String.class, + // String.class); + // Operation opTarget = newOperationImpl("op1", null, targetOutputType, + // null, false, null); + // Map targetOperations = new HashMap(); + // targetOperations.put("op1", opTarget); + // target.getInterface().getOperations().addAll(targetOperations.values()); + // wireService.checkCompatibility(source, target, false); + } + + @Test + public void testIncompatibleOutputTypes() throws Exception { + InterfaceContract source = new MockContract("FooContract"); + DataType sourceOutputType = new DataTypeImpl(String.class, String.class); + Operation opSource1 = newOperation("op1"); + opSource1.setOutputType(sourceOutputType); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + DataType targetOutputType = new DataTypeImpl(Integer.class, Integer.class); + Operation opTarget = newOperation("op1"); + opTarget.setOutputType(targetOutputType); + Map targetOperations = new HashMap(); + targetOperations.put("op1", opTarget); + target.getInterface().getOperations().addAll(targetOperations.values()); + try { + mapper.checkCompatibility(source, target, false, false); + fail(); + } catch (IncompatibleInterfaceContractException e) { + // expected + } + } + + @Test + public void testFaultTypes() throws Exception { + InterfaceContract source = new MockContract("FooContract"); + DataType sourceFaultType = new DataTypeImpl(String.class, String.class); + List sourceFaultTypes = new ArrayList(); + sourceFaultTypes.add(0, sourceFaultType); + Operation opSource1 = newOperation("op1"); + opSource1.setFaultTypes(sourceFaultTypes); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + DataType targetFaultType = new DataTypeImpl(String.class, String.class); + List targetFaultTypes = new ArrayList(); + targetFaultTypes.add(0, targetFaultType); + + Operation opTarget = newOperation("op1"); + opTarget.setFaultTypes(targetFaultTypes); + Map targetOperations = new HashMap(); + targetOperations.put("op1", opTarget); + target.getInterface().getOperations().addAll(targetOperations.values()); + mapper.checkCompatibility(source, target, false, false); + } + + @Test + public void testSourceFaultTargetNoFaultCompatibility() throws Exception { + InterfaceContract source = new MockContract("FooContract"); + DataType sourceFaultType = new DataTypeImpl(String.class, String.class); + List sourceFaultTypes = new ArrayList(); + sourceFaultTypes.add(0, sourceFaultType); + Operation opSource1 = newOperation("op1"); + opSource1.setFaultTypes(sourceFaultTypes); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + Operation opTarget = newOperation("op1"); + Map targetOperations = new HashMap(); + targetOperations.put("op1", opTarget); + target.getInterface().getOperations().addAll(targetOperations.values()); + mapper.checkCompatibility(source, target, false, false); + } + + /** + * Verifies a source's fault which is a supertype of the target's fault are + * compatible + * + * @throws Exception + */ + @Test + public void testFaultSuperTypes() throws Exception { + // InterfaceContract source = new MockContract("FooContract"); + // DataType sourceFaultType = new DataTypeImpl(Exception.class, + // Exception.class); + // List sourceFaultTypes = new ArrayList(); + // sourceFaultTypes.add(0, sourceFaultType); + // Operation opSource1 = newOperationImpl("op1", null, null, + // sourceFaultTypes, false, null); + // Map sourceOperations = new HashMap(); + // sourceOperations.put("op1", opSource1); + // source.getInterface().getOperations().addAll(sourceOperations.values()); + // + // InterfaceContract target = new MockContract("FooContract"); + // DataType targetFaultType = new + // DataTypeImpl(TuscanyException.class, TuscanyException.class); + // List targetFaultTypes = new ArrayList(); + // targetFaultTypes.add(0, targetFaultType); + // + // Operation opTarget = newOperationImpl("op1", null, null, + // targetFaultTypes, false, null); + // Map targetOperations = new HashMap(); + // targetOperations.put("op1", opTarget); + // target.getInterface().getOperations().addAll(targetOperations.values()); + // wireService.checkCompatibility(source, target, false); + } + + /** + * Verifies a source's faults which are supertypes and a superset of the + * target's faults are compatible + */ + @Test + public void testFaultSuperTypesAndSuperset() throws Exception { + // InterfaceContract source = new MockContract("FooContract"); + // DataType sourceFaultType = new DataTypeImpl(Exception.class, + // Exception.class); + // DataType sourceFaultType2 = new + // DataTypeImpl(RuntimeException.class, RuntimeException.class); + // List sourceFaultTypes = new ArrayList(); + // sourceFaultTypes.add(0, sourceFaultType); + // sourceFaultTypes.add(1, sourceFaultType2); + // Operation opSource1 = newOperationImpl("op1", null, null, + // sourceFaultTypes, false, null); + // Map sourceOperations = new HashMap(); + // sourceOperations.put("op1", opSource1); + // source.getInterface().getOperations().addAll(sourceOperations.values()); + // + // InterfaceContract target = new MockContract("FooContract"); + // DataType targetFaultType = new + // DataTypeImpl(TuscanyException.class, TuscanyException.class); + // List targetFaultTypes = new ArrayList(); + // targetFaultTypes.add(0, targetFaultType); + // + // Operation opTarget = newOperationImpl("op1", null, null, + // targetFaultTypes, false, null); + // Map targetOperations = new HashMap(); + // targetOperations.put("op1", opTarget); + // target.getInterface().getOperations().addAll(targetOperations.values()); + // wireService.checkCompatibility(source, target, false); + } + + private static class MockInterface extends InterfaceImpl { + + } + + private class MockContract extends InterfaceContractImpl { + public MockContract() { + } + + public MockContract(String interfaceClass) { + Interface jInterface = new MockInterface(); + setInterface(jInterface); + } + } + + private static Operation newOperation(String name) { + Operation operation = new OperationImpl(); + operation.setName(name); + return operation; + } +} diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java new file mode 100644 index 0000000000..d1faa5cf2b --- /dev/null +++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.interfacedef.impl; + + +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @version $Rev$ $Date$ + */ +public class InterfaceContractTestCase { + private InterfaceContract contract; + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + contract = new MockInterfaceContract(); + Interface i1 = new MockInterface(); + contract.setInterface(i1); + Operation op1 = newOperation("op1"); + i1.getOperations().add(op1); + Interface i2 = new MockInterface(); + contract.setCallbackInterface(i2); + Operation callbackOp1 = newOperation("callbackOp1"); + i2.getOperations().add(callbackOp1); + } + + @Test + public void testClone() throws Exception { + InterfaceContract copy = (InterfaceContract) contract.clone(); + Assert.assertNotNull(copy); + Assert.assertNotSame(copy.getCallbackInterface(), contract.getCallbackInterface()); + Assert.assertNotSame(copy.getInterface(), contract.getInterface()); + } + + private static class MockInterfaceContract extends InterfaceContractImpl implements InterfaceContract { + } + + private static class MockInterface extends InterfaceImpl implements Interface { + } + + private static Operation newOperation(String name) { + Operation operation = new OperationImpl(); + operation.setName(name); + return operation; + } +} diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java new file mode 100644 index 0000000000..2775c4ac71 --- /dev/null +++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sca.policy; + +import static org.junit.Assert.assertEquals; + +import javax.xml.namespace.QName; + +import org.junit.Before; +import org.junit.Test; + +/** + * Test building of policy model instances using the policy factory. + * + * @version $Rev$ $Date$ + */ +public class PolicyFactoryTestCase { + + PolicyFactory factory; + + @Before + public void setUp() throws Exception { + factory = new DefaultPolicyFactory(); + } + + @Test + public void testCreateIntent() { + Intent intent = factory.createIntent(); + intent.setName(new QName("http://test", "reliability")); + assertEquals(intent.getName(), new QName("http://test", "reliability")); + } + + @Test + public void testCreatePolicySet() { + PolicySet policySet = factory.createPolicySet(); + policySet.setName(new QName("http://test", "reliability")); + assertEquals(policySet.getName(), new QName("http://test", "reliability")); + } +} diff --git a/java/sca/modules/binding-ejb/pom.xml b/java/sca/modules/binding-ejb/pom.xml index 7fa7b2d6c3..c761485717 100644 --- a/java/sca/modules/binding-ejb/pom.xml +++ b/java/sca/modules/binding-ejb/pom.xml @@ -49,12 +49,6 @@ 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT - - junit junit diff --git a/java/sca/modules/core-spi/pom.xml b/java/sca/modules/core-spi/pom.xml index a4580f30dc..f3367c5cbb 100644 --- a/java/sca/modules/core-spi/pom.xml +++ b/java/sca/modules/core-spi/pom.xml @@ -47,25 +47,6 @@ 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-definitions - 2.0-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT - - - - org.apache.tuscany.sca - tuscany-interface - 2.0-SNAPSHOT - compile - - org.apache.tuscany.sca tuscany-contribution diff --git a/java/sca/modules/databinding/pom.xml b/java/sca/modules/databinding/pom.xml index db2eb46039..354d31c05a 100644 --- a/java/sca/modules/databinding/pom.xml +++ b/java/sca/modules/databinding/pom.xml @@ -37,7 +37,7 @@ org.apache.tuscany.sca - tuscany-interface + tuscany-assembly 2.0-SNAPSHOT diff --git a/java/sca/modules/definitions-xml/pom.xml b/java/sca/modules/definitions-xml/pom.xml index f52515e7b9..8863ae2cb2 100644 --- a/java/sca/modules/definitions-xml/pom.xml +++ b/java/sca/modules/definitions-xml/pom.xml @@ -29,12 +29,13 @@ Apache Tuscany SCA Definitions XML Model - + + org.apache.tuscany.sca - tuscany-policy + tuscany-assembly 2.0-SNAPSHOT - + org.apache.tuscany.sca tuscany-policy-xml @@ -48,12 +49,6 @@ 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-definitions - 2.0-SNAPSHOT - - org.apache.tuscany.sca tuscany-assembly-xsd diff --git a/java/sca/modules/endpoint-wrapper/pom.xml b/java/sca/modules/endpoint-wrapper/pom.xml index dbec69e775..339e0a7e38 100644 --- a/java/sca/modules/endpoint-wrapper/pom.xml +++ b/java/sca/modules/endpoint-wrapper/pom.xml @@ -85,11 +85,5 @@ 2.0-SNAPSHOT test - - org.apache.tuscany.sca - tuscany-definitions - 2.0-SNAPSHOT - test - diff --git a/java/sca/modules/implementation-bpel-runtime/pom.xml b/java/sca/modules/implementation-bpel-runtime/pom.xml index 67c6cdcd30..42b454e9d3 100644 --- a/java/sca/modules/implementation-bpel-runtime/pom.xml +++ b/java/sca/modules/implementation-bpel-runtime/pom.xml @@ -43,11 +43,6 @@ tuscany-core 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-interface - 2.0-SNAPSHOT - org.apache.tuscany.sca tuscany-assembly-xml diff --git a/java/sca/modules/implementation-bpel/pom.xml b/java/sca/modules/implementation-bpel/pom.xml index eefd83a0a8..b0e0a54c79 100644 --- a/java/sca/modules/implementation-bpel/pom.xml +++ b/java/sca/modules/implementation-bpel/pom.xml @@ -41,12 +41,6 @@ 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-interface - 2.0-SNAPSHOT - - org.apache.tuscany.sca tuscany-interface-wsdl diff --git a/java/sca/modules/implementation-spring/pom.xml b/java/sca/modules/implementation-spring/pom.xml index 1e84fc0156..77b45b751a 100644 --- a/java/sca/modules/implementation-spring/pom.xml +++ b/java/sca/modules/implementation-spring/pom.xml @@ -44,11 +44,6 @@ tuscany-assembly 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-interface - 2.0-SNAPSHOT - org.apache.tuscany.sca tuscany-assembly-xml diff --git a/java/sca/modules/implementation-web/pom.xml b/java/sca/modules/implementation-web/pom.xml index c6328c0e11..cc1c76b88e 100644 --- a/java/sca/modules/implementation-web/pom.xml +++ b/java/sca/modules/implementation-web/pom.xml @@ -49,12 +49,6 @@ 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT - - org.apache.tuscany.sca tuscany-contribution @@ -68,13 +62,6 @@ test - - org.apache.tuscany.sca - tuscany-definitions - 2.0-SNAPSHOT - test - - junit junit diff --git a/java/sca/modules/interface-java/pom.xml b/java/sca/modules/interface-java/pom.xml index 01c8f64cbe..913b22ae94 100644 --- a/java/sca/modules/interface-java/pom.xml +++ b/java/sca/modules/interface-java/pom.xml @@ -35,12 +35,6 @@ 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-interface - 2.0-SNAPSHOT - - org.apache.tuscany.sca tuscany-assembly-xml diff --git a/java/sca/modules/interface-wsdl/pom.xml b/java/sca/modules/interface-wsdl/pom.xml index 1aed2db83b..a0f0894ef6 100644 --- a/java/sca/modules/interface-wsdl/pom.xml +++ b/java/sca/modules/interface-wsdl/pom.xml @@ -29,12 +29,6 @@ Apache Tuscany SCA WSDL Interface Model - - org.apache.tuscany.sca - tuscany-interface - 2.0-SNAPSHOT - - org.apache.tuscany.sca tuscany-xsd @@ -47,12 +41,6 @@ 2.0-SNAPSHOT - - org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT - - org.apache.ws.commons.schema XmlSchema diff --git a/java/sca/modules/interface/LICENSE b/java/sca/modules/interface/LICENSE deleted file mode 100644 index 8aa906c321..0000000000 --- a/java/sca/modules/interface/LICENSE +++ /dev/null @@ -1,205 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - diff --git a/java/sca/modules/interface/META-INF/MANIFEST.MF b/java/sca/modules/interface/META-INF/MANIFEST.MF deleted file mode 100644 index 504b2f43d8..0000000000 --- a/java/sca/modules/interface/META-INF/MANIFEST.MF +++ /dev/null @@ -1,27 +0,0 @@ -Manifest-Version: 1.0 -Export-Package: org.apache.tuscany.sca.interfacedef.util;uses:="javax. - xml.transform,org.apache.tuscany.sca.interfacedef.impl,org.apache.tus - cany.sca.interfacedef,javax.xml.datatype,javax.xml.namespace";version - ="2.0.0",org.apache.tuscany.sca.interfacedef.impl;uses:="org.apache.tus - cany.sca.interfacedef.util,org.apache.tuscany.sca.policy,org.apache.t - uscany.sca.interfacedef";version="2.0.0",org.apache.tuscany.sca.interfa - cedef;uses:="org.apache.tuscany.sca.interfacedef.util,org.apache.tusc - any.sca.policy";version="2.0.0" -Tool: Bnd-0.0.255 -Bundle-Name: Apache Tuscany SCA Interface Model -Created-By: 1.6.0_07 (Sun Microsystems Inc.) -Bundle-Vendor: The Apache Software Foundation -Bundle-Version: 2.0.0 -Bnd-LastModified: 1225397086703 -Bundle-ManifestVersion: 2 -Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt -Bundle-Description: Apache Tuscany SCA Interface Model -Import-Package: javax.xml.datatype,javax.xml.namespace,javax.xml.trans - form,org.apache.tuscany.sca.interfacedef;version="2.0.0",org.apache.tus - cany.sca.interfacedef.impl;version="2.0.0",org.apache.tuscany.sca.inter - facedef.util;version="2.0.0",org.apache.tuscany.sca.policy;version="1.4 - ",org.apache.tuscany.sca.core;ve - rsion="2.0.0";resolution:=optional -Bundle-SymbolicName: org.apache.tuscany.sca.interface -Bundle-DocURL: http://www.apache.org/ -Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6 diff --git a/java/sca/modules/interface/NOTICE b/java/sca/modules/interface/NOTICE deleted file mode 100644 index 25bb89c9b2..0000000000 --- a/java/sca/modules/interface/NOTICE +++ /dev/null @@ -1,6 +0,0 @@ -${pom.name} -Copyright (c) 2005 - 2009 The Apache Software Foundation - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - diff --git a/java/sca/modules/interface/pom.xml b/java/sca/modules/interface/pom.xml deleted file mode 100644 index 3b1b59a4fc..0000000000 --- a/java/sca/modules/interface/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - 4.0.0 - - org.apache.tuscany.sca - tuscany-modules - 2.0-SNAPSHOT - ../pom.xml - - tuscany-interface - Apache Tuscany SCA Interface Model - - - - org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT - - - - diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java deleted file mode 100644 index 247a432330..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef; - -/** - * Enum of the Conversation Sequence values. - * - * @version $Rev$ $Date$ - */ -public enum ConversationSequence { - CONVERSATION_NONE, CONVERSATION_START, CONVERSATION_CONTINUE, CONVERSATION_END -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java deleted file mode 100644 index 1f5620c0b9..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.interfacedef; - -import java.lang.reflect.Type; - -/** - * Representation of the type of data associated with an operation. Data is - * represented in two forms: the physical form used by the runtime and a logical - * form used by the assembly. The physical form is a Java Type because the - * runtime is written in Java. This may be the same form used by the application - * but it may not; for example, an application that is performing stream - * processing may want a physical form such as an - * {@link java.io.InputStream InputStream} to semantially operate on application - * data such as a purchase order. The logical description is that used by the - * assembly model and is an identifier into some well-known type space; examples - * may be a Java type represented by its Class or an XML type represented by its - * QName. Every data type may also contain metadata describing the expected - * data; for example, it could specify a preferred data binding technology or - * the size of a typical instance. - * - * @version $Rev$ $Date$ - */ -public interface DataType extends Cloneable { - /** - * Set the java type for the data - * @param cls - */ - void setPhysical(Class cls); - - /** - * Returns the physical type used by the runtime. - * - * @return the physical type used by the runtime - */ - Class getPhysical(); - - /** - * Get the java generic type - * @return The java generic type - */ - Type getGenericType(); - - /** - * Set the java generic type - * @param genericType - */ - void setGenericType(Type genericType); - - /** - * Returns the logical identifier used by the assembly. The type of this - * value identifies the logical type system in use. Known values are: - *
    - *
  • a Class identifies a Java type by name and - * ClassLoader; this includes Java Classes as they are specializations of - * Type
  • - *
  • a XMLType identifies an XML type by local name and - * namespace
  • - *
- * - * @return the logical type name - */ - L getLogical(); - - /** - * Get the databinding for the given data type - * @return the databinding - */ - String getDataBinding(); - - /** - * Set the databinding for the given data type - * @param dataBinding the dataBinding to set - */ - void setDataBinding(String dataBinding); - - /** - * Clone a data type - * @return The cloned data type - * @throws CloneNotSupportedException - */ - Object clone() throws CloneNotSupportedException; - - /** - * Set the logical type of the data type - * @param logical the logical to set - */ - void setLogical(L logical); - - /** - * Get the databinding-specific metadata - * @param type The java type of the metadata - * @return the databinding-specific metadata - */ - T getMetaData(Class type); - /** - * Set the databinding-specific metadata - * @param type The java type of the metadata - * @param metaData the databinding-specific metadata, such as SDO's commonj.sdo.Type or - * JAXB's javax.xml.bind.JAXBContext - */ - void setMetaData(Class type, T metaData); -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java deleted file mode 100644 index 70f6d5b403..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef; - -/** - * This interface represents the mapping between WSDL faults and Java exceptions - * - * @version $Rev$ $Date$ - */ -@SuppressWarnings("unchecked") -public interface FaultExceptionMapper { - /** - * Introspect an exception class to find out the fault data type following the WSDL2Java - * mapping rules. The result will be populated into the logical type of the exception data - * type - * - * @param exceptionDataType The data type representing a java exception class - * @param operation TODO - * @param generatingFaultBean If JAXWS Section 3.7 Fault Bean will be generated - * @return true if the introspection can recognize the exception data type - */ - boolean introspectFaultDataType(DataType exceptionDataType, Operation operation, boolean generatingFaultBean); - - /** - * Create a java exception to wrap the fault data - * - * @param exceptionType The DataType for the exception - * @param message message for the exception - * @param faultInfo The fault data - * @param cause of the exception - * @param operation TODO - * @return An instance of java exception to represent the fault - */ - Throwable wrapFaultInfo(DataType exceptionType, String message, Object faultInfo, Throwable cause, Operation operation); - - /** - * Retrieve the fault info from a java exception - * - * @param exception The java exception that represents the fault data - * @param faultBeanClass - * @param operation TODO - * @return The fault data - */ - Object getFaultInfo(Throwable exception, Class faultBeanClass, Operation operation); -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java deleted file mode 100644 index 179dc1755e..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef; - -/** - * Denotes incompatible service contracts for a wire - * - * @version $Rev$ $Date$ - */ -public class IncompatibleInterfaceContractException extends Exception { - private static final long serialVersionUID = 5127478601823295587L; - private final InterfaceContract source; - private final InterfaceContract target; - private final Operation sourceOperation; - private final Operation targetOperation; - - public IncompatibleInterfaceContractException(String message, InterfaceContract source, InterfaceContract target) { - super(message); - this.source = source; - this.target = target; - this.sourceOperation = null; - this.targetOperation = null; - } - - public IncompatibleInterfaceContractException(String message, - InterfaceContract source, - InterfaceContract target, - Operation sourceOperation, - Operation targetOperation) { - super(message); - this.source = source; - this.target = target; - this.sourceOperation = sourceOperation; - this.targetOperation = targetOperation; - } - - public InterfaceContract getTarget() { - return target; - } - - public InterfaceContract getSource() { - return source; - } - - public Operation getSourceOperation() { - return sourceOperation; - } - - public Operation getTargetOperation() { - return targetOperation; - } -} 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 deleted file mode 100644 index 24f23e255d..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef; - -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.policy.PolicySubject; - -/** - * Represents a service interface. This interface will typically be extended to - * support concrete interface type systems, such as Java interfaces, WSDL 1.1 - * portTypes and WSDL 2.0 interfaces. - * - * @version $Rev$ $Date$ - */ -public interface Interface extends Cloneable, PolicySubject { - - /** - * Returns true if the interface is a remotable interface.. - * - * @return true if the interface is a remotable interface - */ - boolean isRemotable(); - - /** - * Sets whether the interface is a remotable or local interface. - * - * @param remotable indicates whether the interface is remotable or local - */ - void setRemotable(boolean remotable); - - - // FIXME: [rfeng] We need to re-consider the conversational as an intent - /** - * Test if the interface is conversational - * @return - */ - boolean isConversational(); - - /** - * Set whether the interface is conversational - * @param conversational - */ - void setConversational(boolean conversational); - - /** - * Returns the operations defined on this interface. - * - * @return the operations defined on this interface - */ - List getOperations(); - - /** - * Set the databinding for the interface - * @param dataBinding - * @deprecated Please use resetDataBinding - */ - @Deprecated - void setDefaultDataBinding(String dataBinding); - - /** - * Reset the databinding for the interface - * @param dataBinding - */ - void resetDataBinding(String dataBinding); - - /** - * Returns true if the Interface is dynamic. - * - * @return true if the Interface is dynamic. - */ - boolean isDynamic(); - - /** - * Get a map of attributes assoicated with the interface - * @return A map of attributes - */ - Map getAttributes(); - - /** - * Implementations must support cloning. - */ - Object clone() throws CloneNotSupportedException; - -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java deleted file mode 100644 index 568a6c595c..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.interfacedef; - - -/** - * Interface contracts define one or more business functions. These business - * functions are provided by services and are used by references. - * - * @version $Rev$ $Date$ - */ -public interface InterfaceContract extends Cloneable { - - /** - * Returns the interface definition representing the interface for - * invocations from the requestor to the provider. - * - * @return the interface definition representing the interface for - * invocations from the requestor to the provider - */ - Interface getInterface(); - - /** - * Sets the interface definition representing the interface for invocations - * from the requestor to the provider. - * - * @param callInterface the interface definition representing the interface - * for invocations from the requestor to the provider - */ - void setInterface(Interface callInterface); - - /** - * Returns the interface definition representing the interface for - * invocations from the provider to the requestor. - * - * @return the interface definition representing the interface for - * invocations from the provider to the requestor. - */ - Interface getCallbackInterface(); - - /** - * Sets the interface definition representing the interface for invocations - * from the provider to the requestor. - * - * @param callbackInterface the interface definition representing the - * interface for invocations from the provider to the requestor. - */ - void setCallbackInterface(Interface callbackInterface); - - // FIXME: We need a better way to do this - /** - * Convert an interface contract to a unidirectional interface contract - * - * @param isCallback true for a callback interface contract, false for - * a forward interface contract - * @return A unidirectional interface contract, cloned if necessary - */ - InterfaceContract makeUnidirectional(boolean isCallback); - - /** - * Implementations must support cloning. - */ - Object clone() throws CloneNotSupportedException; - -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java deleted file mode 100644 index 8dfeb29833..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef; - -/** - * The InterfaceContractMapper is responsible to match interfaces - * - * @version $Rev$ $Date$ - */ -public interface InterfaceContractMapper { - /** - * Check the compatibility of the source and the target interface contracts. - *

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

- *

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

- *

- * This relationship implies that the source contract is a subset of the target - * contract - ie all the operations of the source must be present in the target, but - * the target can in principle contain additional operations not present in the - * source - *

- *

- * Please note this test is not symmetric: the success of isCompatible(A, B) - * does NOT imply isCompatible(B, A) - * - * @param source The source interface contract - * @param target The target interface contract - * @return true if the source contract can be supported by the target - * contract - */ - boolean isCompatible(InterfaceContract source, InterfaceContract target); - - /** - * Check that two interface contracts are equal. The contracts are equal if the two contracts have the - * same set of operations, with each operation having the same signature. - * @param source - the source contract - * @param target - the target contract - * @return - */ - boolean isEqual(InterfaceContract source, InterfaceContract target); - - /** - * Check that two interfaces are equal. The interfaces are equal if the two interfaces have the - * same set of operations, with each operation having the same signature. - * @param source an interface - * @param target a second interface - * @return true if the two interfaces are equal, otherwise return false - */ - public boolean isEqual(Interface source, Interface target); - - /** - * @param source - * @param target - * @param ignoreCallback - * @param silent - * @return - * @throws IncompatibleInterfaceContractException - */ - boolean checkCompatibility(InterfaceContract source, - InterfaceContract target, - boolean ignoreCallback, - boolean silent) throws IncompatibleInterfaceContractException; - - /** - * Test if the source data type is compatible with the target data type. The - * compatibility is defined as follows. - *

    - *
  • source's logical type is either the same or subtype of the target's - * logical type - *
- * For example, if the source type is a SDO Customer and the target type is - * a JAXB Customer and both Customer are generated from the same XSD type. - * - * @param source The source data type - * @param target The target data type - * @return - */ - boolean isCompatible(DataType source, DataType target, boolean remotable); - - /** - * Check if source operation is compatible with the target operation - * - * @param source The source operation - * @param target The target operation - * @return true if the source operation is compatible with the target - * operation - */ - boolean isCompatible(Operation source, Operation target, boolean remotable); - - /** - * @param source - * @param target - * @return - */ - boolean isCompatible(Interface source, Interface target); - - /** - * Map the source operation to a compatible operation in the target - * interface - * - * @param target The target interface - * @param source The source operation - * @return A compatible operation - */ - Operation map(Interface target, Operation source); -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java deleted file mode 100644 index f952a86478..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.interfacedef; - - -/** - * Denotes an illegal callback interface - * - * @version $Rev$ $Date$ - */ - -public class InvalidCallbackException extends InvalidInterfaceException { - private static final long serialVersionUID = 2727755895702116397L; - - public InvalidCallbackException(String message) { - super(message); - } -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java deleted file mode 100644 index 2a273c9a26..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.interfacedef; - -/** - * @version $Rev$ $Date$ - */ -public abstract class InvalidInterfaceException extends Exception { - - public InvalidInterfaceException() { - super(); - } - - public InvalidInterfaceException(String message) { - super(message); - } - - public InvalidInterfaceException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidInterfaceException(Throwable cause) { - super(cause); - } -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java deleted file mode 100644 index b19805c5b1..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.interfacedef; - -import java.lang.reflect.Method; - -/** - * Denotes an invalid conversational interface definition - * - * @version $Rev$ $Date$ - */ -public class InvalidOperationException extends InvalidInterfaceException { - - private static final long serialVersionUID = -1797615361821517091L; - private final Method operation; - - public InvalidOperationException(String message, Method operation) { - super(message); - this.operation = operation; - } - - public Method getOperation() { - return operation; - } - -} 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 deleted file mode 100644 index 55f00b82c8..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef; - -import java.util.List; -import java.util.Map; - -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.PolicySubject; - -/** - * Represents an operation on a service interface. - * - * @version $Rev$ $Date$ - */ -public interface Operation extends Cloneable, PolicySubject { - /** - * 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 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); - - /** - * Get the data type that represents the input of this operation. The logic - * type is a list of data types and each element represents a parameter - * - * @return the inputType - */ - DataType> getInputType(); - - /** - * @param inputType - */ - void setInputType(DataType> inputType); - - /** - * Get the data type for the output - * - * @return the outputType - */ - DataType getOutputType(); - - /** - * @param outputType - */ - void setOutputType(DataType outputType); - - /** - * Get a list of data types to represent the faults/exceptions - * - * @return the faultTypes - */ - List getFaultTypes(); - - /** - * @param faultTypes - */ - void setFaultTypes(List faultTypes); - - /** - * Get the owning interface - * @return - */ - Interface getInterface(); - - /** - * Set the owning interface - * @param interfaze - */ - void setInterface(Interface interfaze); - - /** - * Get the sequence of the conversation - * @return - */ - ConversationSequence getConversationSequence(); - - /** - * Set the sequence of conversation for the operation - * @param sequence - */ - void setConversationSequence(ConversationSequence sequence); - - /** - * Indicate if the operation is non-blocking - * @return - */ - boolean isNonBlocking(); - - /** - * Set the operation to be non-blocking - */ - void setNonBlocking(boolean nonBlocking); - - /** - * @return the wrapperInfo - */ - WrapperInfo getWrapper(); - - /** - * @param wrapperInfo the wrapperInfo to set - */ - void setWrapper(WrapperInfo wrapperInfo); - - /** - * @return the wrapperStyle - */ - boolean isWrapperStyle(); - - /** - * @param wrapperStyle the wrapperStyle to set - */ - void setWrapperStyle(boolean wrapperStyle); - - /** - * @deprecated This should be the WrapperInfo.getDataBinding() - * Get the databinding for the operation - * @return - */ - @Deprecated - String getDataBinding(); - - /** - * @deprecated This should be the WrapperInfo.setDataBinding() - * Set the databinding for the operation - * @param dataBinding - */ - @Deprecated - void setDataBinding(String dataBinding); - - /** - * Returns true if the operation is dynamic. - * - * @return true if the operation is dynamic otherwise false - */ - boolean isDynamic(); - - /** - * Set if the operation is dynamic - * @param b - */ - void setDynamic(boolean b); - - /** - * Get the synthesized fault beans for this operation - * - * @return the fault beans - */ - Map>> getFaultBeans(); - - /** - * Set the synthesized fault beans for this operation - * @param faultBeans - */ - void setFaultBeans(Map>> faultBeans); - - /** - * Get a map of attributes assoicated with the operation - * @return A map of attributes - */ - Map getAttributes(); - - /** - * Implementations must support cloning. - */ - Object clone() throws CloneNotSupportedException; - -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java deleted file mode 100644 index 6773b29088..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.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.interfacedef; - -import java.lang.reflect.Method; - -/** - * Exception thrown to indicate that a service contract specification contains - * an overloaded method. - * - * @version $Rev$ $Date$ - */ -public class OverloadedOperationException extends InvalidInterfaceException { - private static final long serialVersionUID = -4658711318608885638L; - private final Method operation; - - public OverloadedOperationException(Method operation) { - super(operation == null ? - null : "Cannot overload operation " + operation.getName() - + " on " + operation.getDeclaringClass().getName() - + " as it is a @Remotable interface"); - this.operation = operation; - } - - public Method getOperation() { - return operation; - } - -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java deleted file mode 100644 index c1c8400b71..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.interfacedef.impl; - -import java.lang.reflect.Type; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.sca.interfacedef.DataType; - -/** - * Representation of the type of data associated with an operation. Data is - * represented in two forms: the physical form used by the runtime and a logical - * form used by the assembly. The physical form is a Java Type because the - * runtime is written in Java. This may be the same form used by the application - * but it may not; for example, an application that is performing stream - * processing may want a physical form such as an - * {@link java.io.InputStream InputStream} to semantially operate on application - * data such as a purchase order. The logical description is that used by the - * assembly model and is an identifier into some well-known type space; examples - * may be a Java type represented by its Class or an XML type represented by its - * QName. Every data type may also contain metadata describing the expected - * data; for example, it could specify a preferred data binding technology or - * the size of a typical instance. - * - * @version $Rev$ $Date$ - */ -public class DataTypeImpl implements DataType { - private String dataBinding; - private Class physical; - private Type genericType; - private L logical; - private Map, Object> metaDataMap; - - /** - * Construct a data type specifying the physical and logical types. - * - * @param physical the physical class used by the runtime - * @param logical the logical type - * @see #getLogical() - */ - public DataTypeImpl(Class physical, L logical) { - this(null, physical, physical, logical); - } - - /** - * @param dataBinding - * @param physical - * @param logical - */ - public DataTypeImpl(String dataBinding, Class physical, L logical) { - this(dataBinding, physical, physical, logical); - } - - /** - * @param dataBinding - * @param physical - * @param genericType - * @param logical - */ - public DataTypeImpl(String dataBinding, Class physical, Type genericType, L logical) { - super(); - this.dataBinding = dataBinding; - this.physical = physical; - this.genericType = genericType; - this.logical = logical; - } - - /** - * Returns the physical type used by the runtime. - * - * @return the physical type used by the runtime - */ - public Class getPhysical() { - return physical; - } - - /** - * @param physical the physical to set - */ - public void setPhysical(Class physical) { - this.physical = physical; - } - - /** - * Get the java generic type - * @return The java generic type - */ - public Type getGenericType() { - return genericType; - } - - /** - * Set the java generic type - * @param genericType - */ - public void setGenericType(Type genericType) { - this.genericType = genericType; - } - - /** - * Returns the logical identifier used by the assembly. The type of this - * value identifies the logical type system in use. Known values are: - *
    - *
  • a java.lang.reflect.Type identifies a Java type by name and - * ClassLoader; this includes Java Classes as they are specializations of - * Type
  • - *
  • a javax.xml.namespace.QName identifies an XML type by local name and - * namespace
  • - *
- * - * @return the logical type name - */ - public L getLogical() { - return logical; - } - - /** - * @param logical the logical to set - */ - public void setLogical(L logical) { - this.logical = logical; - } - - public String getDataBinding() { - return dataBinding; - } - - /** - * @param dataBinding the dataBinding to set - */ - public void setDataBinding(String dataBinding) { - this.dataBinding = dataBinding; - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(physical).append(" ").append(dataBinding).append(" ").append(logical); - return sb.toString(); - } - - @SuppressWarnings("unchecked") - @Override - public Object clone() throws CloneNotSupportedException { - DataTypeImpl copy = (DataTypeImpl)super.clone(); - return copy; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((dataBinding == null) ? 0 : dataBinding.hashCode()); - result = prime * result + ((genericType == null) ? 0 : genericType.hashCode()); - result = prime * result + ((logical == null) ? 0 : logical.hashCode()); - result = prime * result + ((physical == null) ? 0 : physical.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; - final DataTypeImpl other = (DataTypeImpl)obj; - if (dataBinding == null) { - if (other.dataBinding != null) - return false; - } else if (!dataBinding.equals(other.dataBinding)) - return false; - if (genericType == null) { - if (other.genericType != null) - return false; - } else if (!genericType.equals(other.genericType)) - return false; - if (logical == null) { - if (other.logical != null) - return false; - } else if (!logical.equals(other.logical)) - return false; - if (physical == null) { - if (other.physical != null) - return false; - } else if (!physical.equals(other.physical)) - return false; - return true; - } - - public T getMetaData(Class type) { - return metaDataMap == null ? null : type.cast(metaDataMap.get(type)); - } - - public void setMetaData(Class type, T metaData) { - if (metaDataMap == null) { - metaDataMap = new ConcurrentHashMap, Object>(); - } - metaDataMap.put(type, metaData); - } -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java deleted file mode 100644 index 15581b5e04..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.impl; - -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; - -/** - * Represents an interface contract. InterfaceContractImpl - * - * @version $Rev$ $Date$ - */ -public abstract class InterfaceContractImpl implements InterfaceContract { - private Interface callInterface; - private Interface callbackInterface; - - public Interface getCallbackInterface() { - return callbackInterface; - } - - public Interface getInterface() { - return callInterface; - } - - public void setCallbackInterface(Interface callbackInterface) { - this.callbackInterface = callbackInterface; - } - - public void setInterface(Interface callInterface) { - this.callInterface = callInterface; - } - - public InterfaceContract makeUnidirectional(boolean isCallback) { - if (!isCallback && callbackInterface == null) - return this; // already a unidirectional forward interface contract - - if (isCallback && callInterface == null) - return this; // already a unidirectional callback interface contract - - // contract is bidirectional, so create a new unidirectional contract - try { - InterfaceContract newContract = clone(); - if (!isCallback) { - newContract.setCallbackInterface(null); // create unidirectional forward interface contract - } else { - newContract.setInterface(null); // create unidirectional callback interface contract - } - return newContract; - } catch (CloneNotSupportedException e) { - // will not happen - return null; - } - } - - @Override - public InterfaceContractImpl clone() throws CloneNotSupportedException { - InterfaceContractImpl copy = (InterfaceContractImpl)super.clone(); - if (this.callbackInterface != null) { - copy.callbackInterface = (Interface)this.callbackInterface.clone(); - } - if (this.callInterface != null) { - copy.callInterface = (Interface)this.callInterface.clone(); - } - return copy; - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((callInterface == null) ? 0 : callInterface.hashCode()); - result = prime * result + ((callbackInterface == null) ? 0 : callbackInterface.hashCode()); - return result; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final InterfaceContractImpl other = (InterfaceContractImpl)obj; - if (callInterface == null) { - if (other.callInterface != null) { - return false; - } - } else if (!callInterface.equals(other.callInterface)) { - return false; - } - if (callbackInterface == null) { - if (other.callbackInterface != null) { - return false; - } - } else if (!callbackInterface.equals(other.callbackInterface)) { - return false; - } - return true; - } - -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java deleted file mode 100644 index 289fd25594..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.impl; - -import java.util.List; - -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException; -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.Operation; - -/** - * @version $Rev$ $Date$ - */ -public class InterfaceContractMapperImpl implements InterfaceContractMapper { - - public boolean isCompatible(DataType source, DataType target, boolean remotable) { - if (source == target) { - return true; - } - if (!remotable) { - if (source == null || target == null) { - return false; - } - // For local case - return target.getPhysical().isAssignableFrom(source.getPhysical()); - } else { - // FIXME: How to test if two remotable data type is compatible? - // return target.getLogical().equals(source.getLogical()); - return true; - } - - } - - - /** - * Check that two interface contracts are equal. The contracts are equal if the two contracts have the - * same set of operations, with each operation having the same signature, both for forward and callback - * interfaces - * @param source - * @param target - * @return - */ - public boolean isEqual(InterfaceContract source, InterfaceContract target) { - // Are the forward interfaces equal? - if( isEqual( source.getInterface(), target.getInterface()) ) { - // Is there a Callback interface? - if( source.getCallbackInterface() == null && target.getCallbackInterface() == null ) { - return true; - } else { - if( isEqual( source.getCallbackInterface(), target.getCallbackInterface()) ) { - return true; - } // end if - } // end if - } // end if - return false; - } // end method isEqual - - /** - * Check that two interfaces are equal. The interfaces are equal if the two interfaces have the - * same set of operations, with each operation having the same signature. - * @param source - * @param target - * @return - */ - public boolean isEqual(Interface source, Interface target) { - if (source == target) { - // Shortcut for performance - return true; - } // end if - if (source == null || target == null) { - return false; - } // end if - - if (source.isDynamic() || target.isDynamic()) { - return true; - } - - if (source.isRemotable() != target.isRemotable()) { - return false; - } - if (source.isConversational() != target.isConversational()) { - return false; - } - if( source.getOperations().size() != target.getOperations().size() ) { - return false; - } - - for (Operation operation : source.getOperations()) { - Operation targetOperation = getOperation(target.getOperations(), operation.getName()); - if (targetOperation == null) { - return false; - } - if (!isCompatible(operation, targetOperation, source.isRemotable())) { - return false; - } - } - return true; - } // end method isEqual - - public boolean isCompatible(Operation source, Operation target, boolean remotable) { - if (source == target) { - return true; - } - - if (source.isDynamic() || target.isDynamic()) { - return true; - } - - // Check name - if (!source.getName().equals(target.getName())) { - return false; - } - - if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) { - return false; - } - - // if (source.getInterface().isRemotable()) { - // return true; - // } - - // FIXME: We need to deal with wrapped<-->unwrapped conversion - - // Check output type - DataType sourceOutputType = source.getOutputType(); - DataType targetOutputType = target.getOutputType(); - - boolean checkSourceWrapper = true; - List sourceInputType = source.getInputType().getLogical(); - if (source.isWrapperStyle() && source.getWrapper() != null) { - sourceInputType = source.getWrapper().getUnwrappedInputType().getLogical(); - sourceOutputType = source.getWrapper().getUnwrappedOutputType(); - checkSourceWrapper = false; - } - boolean checkTargetWrapper = true; - List targetInputType = target.getInputType().getLogical(); - if (target.isWrapperStyle() && target.getWrapper() != null) { - targetInputType = target.getWrapper().getUnwrappedInputType().getLogical(); - targetOutputType = target.getWrapper().getUnwrappedOutputType(); - checkTargetWrapper = false; - } - - if (checkSourceWrapper != checkTargetWrapper) { - return true; - } - - if (!isCompatible(targetOutputType, sourceOutputType, remotable)) { - return false; - } - - if (sourceInputType.size() != targetInputType.size()) { - return false; - } - - int size = sourceInputType.size(); - for (int i = 0; i < size; i++) { - if (!isCompatible(sourceInputType.get(i), targetInputType.get(i), remotable)) { - return false; - } - } - - // Check fault types - for (DataType targetFaultType : target.getFaultTypes()) { - // Source fault types must be the same or superset of target fault - // types - boolean found = true; - for (DataType sourceFaultType : source.getFaultTypes()) { - found = false; - if (isCompatible(targetFaultType, sourceFaultType, remotable)) { - // Target fault type can be covered by the source fault type - found = true; - break; - } - } - if (!found) { - return false; - } - } - - return true; - } - - // FIXME: How to improve the performance for the lookup - private Operation getOperation(List operations, String name) { - for (Operation op : operations) { - if (op.getName().equals(name)) { - return op; - } - } - return null; - } - - public boolean checkCompatibility(InterfaceContract source, - InterfaceContract target, - boolean ignoreCallback, - boolean silent) throws IncompatibleInterfaceContractException { - if (source == target) { - // Shortcut for performance - return true; - } - - if (source == null || target == null){ - return false; - } - - if (source.getInterface() == target.getInterface()){ - return true; - } - - if (source.getInterface() == null || target.getInterface() == null){ - return false; - } - - if (source.getInterface().isDynamic() || target.getInterface().isDynamic()) { - return true; - } - - if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) { - if (!silent) { - throw new IncompatibleInterfaceContractException("Remotable settings do not match", source, target); - } else { - return false; - } - } - if (source.getInterface().isConversational() != target.getInterface().isConversational()) { - if (!silent) { - throw new IncompatibleInterfaceContractException("Interaction scopes do not match", source, target); - } else { - return false; - } - } - - for (Operation operation : source.getInterface().getOperations()) { - Operation targetOperation = map(target.getInterface(), operation); - if (targetOperation == null) { - if (!silent) { - throw new IncompatibleInterfaceContractException("Operation not found on target", source, target); - } else { - return false; - } - } - if (!source.getInterface().isRemotable()) { - // FIXME: for remotable operation, only compare name for now - if (!isCompatible(operation, targetOperation, false)) { - if (!silent) { - throw new IncompatibleInterfaceContractException("Target operations are not compatible", - source, target); - } else { - return false; - } - } - } - } - - if (ignoreCallback) { - return true; - } - - if (source.getCallbackInterface() == null && target.getCallbackInterface() == null) { - return true; - } - if (source.getCallbackInterface() == null || target.getCallbackInterface() == null) { - if (!silent) { - throw new IncompatibleInterfaceContractException("Callback interface doesn't match", source, target); - } else { - return false; - } - } - - if (source.getCallbackInterface().isConversational() != target.getCallbackInterface().isConversational()) { - if (!silent) { - throw new IncompatibleInterfaceContractException("Interaction scopes do not match", source, target); - } else { - return false; - } - } - - for (Operation operation : source.getCallbackInterface().getOperations()) { - Operation targetOperation = - getOperation(target.getCallbackInterface().getOperations(), operation.getName()); - if (targetOperation == null) { - if (!silent) { - throw new IncompatibleInterfaceContractException("Callback operation not found on target", source, - target, null, targetOperation); - } else { - return false; - } - } - if (!source.getCallbackInterface().isRemotable()) { - // FIXME: for remotable operation, only compare name for now - if (!operation.equals(targetOperation)) { - if (!silent) { - throw new IncompatibleInterfaceContractException("Target callback operation is not compatible", - source, target, operation, targetOperation); - } else { - return false; - } - } - } - } - return true; - } - - public boolean isCompatible(Interface source, Interface target) { - if (source == target) { - // Shortcut for performance - return true; - } - if (source == null || target == null) { - return false; - } - - if (source.isDynamic() || target.isDynamic()) { - return true; - } - - if (source.isRemotable() != target.isRemotable()) { - return false; - } - if (source.isConversational() != target.isConversational()) { - return false; - } - - for (Operation operation : source.getOperations()) { - Operation targetOperation = getOperation(target.getOperations(), operation.getName()); - if (targetOperation == null) { - return false; - } - if (!isCompatible(operation, targetOperation, source.isRemotable())) { - return false; - } - } - return true; - } - - public boolean isCompatible(InterfaceContract source, InterfaceContract target) { - try { - return checkCompatibility(source, target, false, false); - } catch (IncompatibleInterfaceContractException e) { - return false; - } - } - - /** - * @see org.apache.tuscany.sca.interfacedef.InterfaceContractMapper#map(org.apache.tuscany.sca.interfacedef.Interface, - * org.apache.tuscany.sca.interfacedef.Operation) - */ - public Operation map(Interface target, Operation source) { - // TODO: How to handle the case that source operation is dynamic? - if (target == null || target.isDynamic()) { - return source; - } else if (target.isRemotable()) { - for (Operation op : target.getOperations()) { - if (op.getName().equals(source.getName())) { - return op; - } - } - return null; - } else { - for (Operation op : target.getOperations()) { - if (isCompatible(source, op, target.isRemotable())) { - return op; - } - } - return null; - } - - } - -} 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 deleted file mode 100644 index 67aae7da4d..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.sca.interfacedef.DataType; -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.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Represents a service interface. - * - * @version $Rev$ $Date$ - */ -public class InterfaceImpl implements Interface { - - private boolean remotable; - private boolean conversational; - private OperationList operations = new OperationList(); - private boolean unresolved; - - private ExtensionType type; - private List policySets = new ArrayList(); - private List requiredIntents = new ArrayList(); - private Map attributes = new ConcurrentHashMap(); - - public boolean isRemotable() { - return remotable; - } - - public void setRemotable(boolean local) { - this.remotable = local; - } - - public List getOperations() { - return operations; - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean undefined) { - this.unresolved = undefined; - } - - /** - * @return the conversational - */ - public boolean isConversational() { - return conversational; - } - - /** - * @param conversational the conversational to set - */ - public void setConversational(boolean conversational) { - this.conversational = conversational; - } - - private class OperationList extends ArrayList { - private static final long serialVersionUID = -903469106307606099L; - - @Override - public Operation set(int index, Operation element) { - element.setInterface(InterfaceImpl.this); - return super.set(index, element); - } - - @Override - public void add(int index, Operation element) { - element.setInterface(InterfaceImpl.this); - super.add(index, element); - } - - @Override - public boolean add(Operation o) { - o.setInterface(InterfaceImpl.this); - return super.add(o); - } - - @Override - public boolean addAll(Collection c) { - for (Operation op : c) { - op.setInterface(InterfaceImpl.this); - } - return super.addAll(c); - } - - @Override - public boolean addAll(int index, Collection c) { - for (Operation op : c) { - op.setInterface(InterfaceImpl.this); - } - return super.addAll(index, c); - } - - } - - @Deprecated - public void setDefaultDataBinding(String dataBinding) { - for (Operation op : getOperations()) { - if (op.getDataBinding() == null) { - op.setDataBinding(dataBinding); - DataType> inputType = op.getInputType(); - if (inputType != null) { - for (DataType d : inputType.getLogical()) { - if (d.getDataBinding() == null) { - d.setDataBinding(dataBinding); - } - } - } - DataType outputType = op.getOutputType(); - if (outputType != null && outputType.getDataBinding() == null) { - outputType.setDataBinding(dataBinding); - } - List faultTypes = op.getFaultTypes(); - if (faultTypes != null) { - for (DataType d : faultTypes) { - if (d.getDataBinding() == null) { - d.setDataBinding(dataBinding); - } - DataType ft = (DataType) d.getLogical(); - if (ft.getDataBinding() == null) { - ft.setDataBinding(dataBinding); - } - - } - } - if (op.isWrapperStyle()) { - WrapperInfo wrapper = op.getWrapper(); - if (wrapper != null) { - DataType> unwrappedInputType = wrapper.getUnwrappedInputType(); - if (unwrappedInputType != null) { - for (DataType d : unwrappedInputType.getLogical()) { - if (d.getDataBinding() == null) { - d.setDataBinding(dataBinding); - } - } - } - DataType unwrappedOutputType = wrapper.getUnwrappedOutputType(); - if (unwrappedOutputType != null && unwrappedOutputType.getDataBinding() == null) { - unwrappedOutputType.setDataBinding(dataBinding); - } - } - } - } - } - } - - private void setDataBinding(DataType dataType, String dataBinding) { - if ("java:array".equals(dataType.getDataBinding())) { - setDataBinding((DataType)dataType.getLogical(), dataBinding); - } else { - dataType.setDataBinding(dataBinding); - } - } - - public void resetDataBinding(String dataBinding) { - for (Operation op : getOperations()) { - op.setDataBinding(dataBinding); - DataType> inputType = op.getInputType(); - if (inputType != null) { - for (DataType d : inputType.getLogical()) { - setDataBinding(d, dataBinding); - } - } - DataType outputType = op.getOutputType(); - if (outputType != null) { - setDataBinding(outputType, dataBinding); - } - List faultTypes = op.getFaultTypes(); - if (faultTypes != null) { - for (DataType d : faultTypes) { - setDataBinding(d, dataBinding); - setDataBinding((DataType) d.getLogical(), dataBinding); - } - } - if (op.isWrapperStyle()) { - WrapperInfo wrapper = op.getWrapper(); - if (wrapper != null) { - DataType> unwrappedInputType = wrapper.getUnwrappedInputType(); - if (unwrappedInputType != null) { - for (DataType d : unwrappedInputType.getLogical()) { - setDataBinding(d, dataBinding); - } - } - DataType unwrappedOutputType = wrapper.getUnwrappedOutputType(); - if (unwrappedOutputType != null) { - setDataBinding(unwrappedOutputType, dataBinding); - } - } - } - } - } - - public boolean isDynamic() { - return false; - } - - public List getPolicySets() { - return policySets; - } - - public List getRequiredIntents() { - return requiredIntents; - } - - public ExtensionType getExtensionType() { - return type; - } - - public void setExtensionType(ExtensionType type) { - this.type = type; - } - - @Override - public Object clone() throws CloneNotSupportedException { - InterfaceImpl copy = (InterfaceImpl)super.clone(); - copy.operations = new OperationList(); - for (Operation operation : this.operations) { - Operation clonedOperation = (Operation)operation.clone(); - copy.operations.add(clonedOperation); - } - copy.attributes = new ConcurrentHashMap(); - copy.attributes.putAll(attributes); - return copy; - } - - public Map getAttributes() { - return attributes; - } - -} 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 deleted file mode 100644 index 26144e92cb..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.interfacedef.impl; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.sca.interfacedef.ConversationSequence; -import org.apache.tuscany.sca.interfacedef.DataType; -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.interfacedef.util.XMLType; -import org.apache.tuscany.sca.policy.ExtensionType; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; - -/** - * Represents an operation on a service interface. - * - * @version $Rev$ $Date$ - */ -public class OperationImpl implements Operation { - - private String name; - private boolean unresolved; - private DataType outputType; - private DataType> inputType; - private List faultTypes; - private Interface interfaze; - private ConversationSequence conversationSequence = ConversationSequence.CONVERSATION_NONE; - private boolean nonBlocking; - private boolean wrapperStyle; - private WrapperInfo wrapper; - private boolean dynamic; - - private Map attributes = new ConcurrentHashMap(); - - private Map>> faultBeans; - - private List applicablePolicySets = new ArrayList(); - private List policySets = new ArrayList(); - private List requiredIntents = new ArrayList(); - private ExtensionType type; - - /** - * @param name - */ - public OperationImpl() { - inputType = new DataTypeImpl>("idl:input", Object[].class, new ArrayList()); - faultTypes = new ArrayList(); - faultBeans = new HashMap>>(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public boolean isUnresolved() { - return unresolved; - } - - public void setUnresolved(boolean undefined) { - this.unresolved = undefined; - } - - /** - * @return the faultTypes - */ - public List getFaultTypes() { - return faultTypes; - } - - /** - * @param faultTypes the faultTypes to set - */ - public void setFaultTypes(List faultTypes) { - this.faultTypes = faultTypes; - } - - /** - * @return the inputType - */ - public DataType> getInputType() { - return inputType; - } - - /** - * @param inputType the inputType to set - */ - public void setInputType(DataType> inputType) { - this.inputType = inputType; - } - - /** - * @return the outputType - */ - public DataType getOutputType() { - return outputType; - } - - /** - * @param outputType the outputType to set - */ - public void setOutputType(DataType outputType) { - this.outputType = outputType; - } - - /** - * @return the interface - */ - public Interface getInterface() { - return interfaze; - } - - /** - * @param interfaze the interface to set - */ - public void setInterface(Interface interfaze) { - this.interfaze = interfaze; - } - - /** - * @return the conversationSequence - */ - public ConversationSequence getConversationSequence() { - return conversationSequence; - } - - /** - * @param conversationSequence the conversationSequence to set - */ - public void setConversationSequence(ConversationSequence conversationSequence) { - this.conversationSequence = conversationSequence; - } - - /** - * @return the nonBlocking - */ - public boolean isNonBlocking() { - return nonBlocking; - } - - /** - * @param nonBlocking the nonBlocking to set - */ - public void setNonBlocking(boolean nonBlocking) { - this.nonBlocking = nonBlocking; - } - - /** - * @return the wrapperInfo - */ - public WrapperInfo getWrapper() { - return wrapper; - } - - /** - * @param wrapperInfo the wrapperInfo to set - */ - public void setWrapper(WrapperInfo wrapperInfo) { - this.wrapper = wrapperInfo; - } - - /** - * @return the wrapperStyle - */ - public boolean isWrapperStyle() { - return wrapperStyle; - } - - /** - * @param wrapperStyle the wrapperStyle to set - */ - public void setWrapperStyle(boolean wrapperStyle) { - this.wrapperStyle = wrapperStyle; - } - - public String getDataBinding() { - return wrapper != null ? wrapper.getDataBinding() : null; - } - - public void setDataBinding(String dataBinding) { - if (wrapper != null) { - wrapper.setDataBinding(dataBinding); - } - } - - public boolean isDynamic() { - return dynamic; - } - - public void setDynamic(boolean b) { - this.dynamic = b; - } - - public Map>> getFaultBeans() { - return faultBeans; - } - - public void setFaultBeans(Map>> faultBeans) { - this.faultBeans = faultBeans; - } - - @Override - public OperationImpl clone() throws CloneNotSupportedException { - OperationImpl copy = (OperationImpl) super.clone(); - - final List clonedFaultTypes = new ArrayList(this.faultTypes.size()); - for (DataType t : this.faultTypes) { - clonedFaultTypes.add((DataType) t.clone()); - } - copy.faultTypes = clonedFaultTypes; - - List clonedLogicalTypes = new ArrayList(); - for (DataType t : inputType.getLogical()) { - DataType type = (DataType) t.clone(); - clonedLogicalTypes.add(type); - } - DataType> clonedInputType = - new DataTypeImpl>(inputType.getPhysical(), clonedLogicalTypes); - clonedInputType.setDataBinding(inputType.getDataBinding()); - copy.inputType = clonedInputType; - - if (this.outputType != null) { - copy.outputType = (DataType) this.outputType.clone(); - } - - copy.attributes = new ConcurrentHashMap(); - copy.attributes.putAll(attributes); - - return copy; - } - - public List getApplicablePolicySets() { - return applicablePolicySets; - } - - public List getPolicySets() { - return policySets; - } - - public List getRequiredIntents() { - return requiredIntents; - } - - public ExtensionType getExtensionType() { - return type; - } - - public void setExtensionType(ExtensionType type) { - this.type = type; - } - - public Map getAttributes() { - return attributes; - } - -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java deleted file mode 100644 index 777fa567f1..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.util; - -import javax.xml.namespace.QName; - -/** - * An abstraction of XML schema elements. - * - * @version $Rev$ $Date$ - */ -public class ElementInfo { - private final QName name; - private final TypeInfo type; - private boolean many = false; - private boolean nillable = false; - - /** - * @param name - * @param type - */ - public ElementInfo(QName name, TypeInfo type) { - super(); - this.name = name; - this.type = type; - } - - /** - * @return the name - */ - public QName getQName() { - return name; - } - - /** - * @return the type - */ - public TypeInfo getType() { - return type; - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("Element: ").append(name).append(" ").append(type); - return sb.toString(); - } - - public boolean isMany() { - return many; - } - - public void setMany(boolean many) { - this.many = many; - } - - public boolean isNillable() { - return nillable; - } - - public void setNillable(boolean nillable) { - this.nillable = nillable; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((type == null) ? 0 : type.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; - final ElementInfo other = (ElementInfo)obj; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - /* - if (type == null) { - if (other.type != null) - return false; - } else if (!type.equals(other.type)) - return false; - */ - return true; - } -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java deleted file mode 100644 index 844b0af509..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.util; - -import javax.xml.namespace.QName; - -/** - * The generic java exception to wrap service faults - * - * @version $Rev$ $Date$ - */ -public class FaultException extends Exception { - private static final long serialVersionUID = -8002583655240625792L; - private transient Object faultInfo; // FIXME: How to serialize it? - private QName faultName; - - /** - * @param message - * @param faultInfo - */ - public FaultException(String message, Object faultInfo) { - super(message); - this.faultInfo = faultInfo; - } - - /** - * @param message - * @param faultInfo - * @param cause - */ - public FaultException(String message, Object faultInfo, Throwable cause) { - super(message, cause); - this.faultInfo = faultInfo; - } - - /** - * @return the faultInfo - */ - public Object getFaultInfo() { - return faultInfo; - } - - public QName getFaultName() { - return faultName; - } - - public void setFaultName(QName logical) { - this.faultName = logical; - } - - public boolean isMatchingType(Object type) { - if (faultName == null) { - return false; - } - - if ((type instanceof QName) && faultName.equals(type)) { - return true; - } - if (type instanceof XMLType && faultName.equals(((XMLType)type).getElementName())) { - return true; - } - return false; - } - -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java deleted file mode 100644 index 54c0a3ec11..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.util; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -/** - * Utility class that can be used to map XSD types to Java classes and Java classes to XSD types. - * - * @version $Rev$ $Date$ - */ -public final class JavaXMLMapper { - public static final String URI_2001_SCHEMA_XSD = "http://www.w3.org/2001/XMLSchema"; - private static final Map JAVA2XML = new HashMap(); - private static final Map XML2JAVA = new HashMap(); - - private JavaXMLMapper() { - } - - static { - JAVA2XML.put(boolean.class, getTypeName("boolean")); - JAVA2XML.put(byte.class, getTypeName("byte")); - JAVA2XML.put(short.class, getTypeName("short")); - JAVA2XML.put(int.class, getTypeName("int")); - JAVA2XML.put(long.class, getTypeName("long")); - JAVA2XML.put(float.class, getTypeName("float")); - JAVA2XML.put(double.class, getTypeName("double")); - JAVA2XML.put(Boolean.class, getTypeName("boolean")); - JAVA2XML.put(Byte.class, getTypeName("byte")); - JAVA2XML.put(Short.class, getTypeName("short")); - JAVA2XML.put(Integer.class, getTypeName("int")); - JAVA2XML.put(Long.class, getTypeName("long")); - JAVA2XML.put(Float.class, getTypeName("float")); - JAVA2XML.put(Double.class, getTypeName("double")); - JAVA2XML.put(java.lang.String.class, getTypeName("string")); - JAVA2XML.put(java.math.BigInteger.class, getTypeName("integer")); - JAVA2XML.put(java.math.BigDecimal.class, getTypeName("decimal")); - JAVA2XML.put(java.util.Calendar.class, getTypeName("dateTime")); - JAVA2XML.put(java.util.Date.class, getTypeName("dateTime")); - JAVA2XML.put(javax.xml.namespace.QName.class, getTypeName("QName")); - JAVA2XML.put(java.net.URI.class, getTypeName("string")); - JAVA2XML.put(javax.xml.datatype.XMLGregorianCalendar.class, getTypeName("anySimpleType")); - JAVA2XML.put(javax.xml.datatype.Duration.class, getTypeName("duration")); - JAVA2XML.put(java.lang.Object.class, getTypeName("anyType")); - JAVA2XML.put(java.awt.Image.class, getTypeName("base64Binary")); - JAVA2XML.put(byte[].class, getTypeName("base64Binary")); - // java2XSD.put(javax.activation.DataHandler.class, getTypeName("base64Binary")); - JAVA2XML.put(javax.xml.transform.Source.class, getTypeName("base64Binary")); - JAVA2XML.put(java.util.UUID.class, getTypeName("string")); - } - - static { - XML2JAVA.put("string", java.lang.String.class); - XML2JAVA.put("integer", java.math.BigInteger.class); - XML2JAVA.put("int", int.class); - XML2JAVA.put("long", long.class); - XML2JAVA.put("short", short.class); - XML2JAVA.put("decimal", java.math.BigDecimal.class); - XML2JAVA.put("float", float.class); - XML2JAVA.put("double", double.class); - XML2JAVA.put("boolean", boolean.class); - XML2JAVA.put("byte", byte.class); - XML2JAVA.put("QName", javax.xml.namespace.QName.class); - XML2JAVA.put("dateTime", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("base64Binary", byte[].class); - XML2JAVA.put("hexBinary", byte[].class); - XML2JAVA.put("unsignedInt", long.class); - XML2JAVA.put("unsignedShort", int.class); - XML2JAVA.put("unsignedByte", short.class); - XML2JAVA.put("time", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("date", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gDay", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gMonth", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gYear", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gYearMonth", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("gMonthDay", javax.xml.datatype.XMLGregorianCalendar.class); - XML2JAVA.put("anySimpleType", java.lang.Object.class); // For elements - // XML2JAVA.put("anySimpleType", java.lang.String.class); // For - // attributes - XML2JAVA.put("duration", javax.xml.datatype.Duration.class); - XML2JAVA.put("NOTATION", javax.xml.namespace.QName.class); - } - - public static Class getJavaType(QName xmlType) { - if (URI_2001_SCHEMA_XSD.equals(xmlType.getNamespaceURI())) { - return XML2JAVA.get(xmlType.getLocalPart()); - } else { - return null; - } - } - - private static QName getTypeName(String name) { - return new QName(URI_2001_SCHEMA_XSD, name); - } - - public static QName getXMLType(Class javaType) { - return JAVA2XML.get(javaType); - } - - private static String getPackageName(Class cls) { - String name = cls.getName(); - int index = name.lastIndexOf('.'); - return index == -1 ? "" : name.substring(0, index); - } - - public static String getNamespace(Class cls) { - String packageName = getPackageName(cls); - if ("".equals(packageName)) { - return ""; - } - StringBuffer ns = new StringBuffer("http://"); - String[] names = packageName.split("\\."); - for (int i = names.length - 1; i >= 0; i--) { - ns.append(names[i]); - if (i != 0) { - ns.append('.'); - } - } - ns.append('/'); - return ns.toString(); - } - -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java deleted file mode 100644 index 2598dc8545..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.util; - -import javax.xml.namespace.QName; - -/** - * An abstraction of XML schema types - * - * @version $Rev$ $Date$ - */ -public class TypeInfo { - private QName name; - - private boolean isSimpleType; - - private TypeInfo baseType; - - /** - * @param name - * @param isSimpleType - */ - public TypeInfo(QName name, boolean isSimpleType, TypeInfo baseType) { - super(); - this.name = name; - this.isSimpleType = isSimpleType; - this.baseType = baseType; - } - - /** - * @return the isSimpleType - */ - public boolean isSimpleType() { - return isSimpleType; - } - - /** - * @return the name - */ - public QName getQName() { - return name; - } - - /** - * @return the baseType - */ - public TypeInfo getBaseType() { - return baseType; - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("Type: ").append(name); - return sb.toString(); - } - - @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; - final TypeInfo other = (TypeInfo)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/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java deleted file mode 100644 index 12db460959..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.util; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; - -/** - * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based - * Web Services (JAX-WS) 2.0 specification, section 2.3.1.2 Wrapper Style.

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

    - *
  • (i) The operation�s input and output messages (if present) each contain - * only a single part - *
  • (ii) The input message part refers to a global element declaration whose - * localname is equal to the operation name - *
  • (iii) The output message part refers to a global element declaration - *
  • (iv) The elements referred to by the input and output message parts - * (henceforth referred to as wrapper elements) are both complex types defined - * using the xsd:sequence compositor - *
  • (v) The wrapper elements only contain child elements, they must not - * contain other structures such as wildcards (element or attribute), - * xsd:choice, substitution groups (element references are not permitted) or - * attributes; furthermore, they must not be nillable. - *
- * - * @version $Rev$ $Date$ - */ -public class WrapperInfo { - private ElementInfo inputWrapperElement; - - private ElementInfo outputWrapperElement; - - private List inputChildElements; - - private List outputChildElements; - - // The data type of the unwrapped input child elements - private DataType> unwrappedInputType; - - // The data type of the unwrapped output child element (we only supports one child) - private DataType unwrappedOutputType; - - // The data for the input/output wrappers - private String dataBinding; - - // The data type for the input (request) wrapper bean - private DataType inputWrapperType; - // The data type for the output (response) wrapper bean - private DataType outputWrapperType; - - public WrapperInfo(String dataBinding, - ElementInfo inputWrapperElement, - ElementInfo outputWrapperElement, - List inputElements, - List outputElements) { - super(); - this.dataBinding = dataBinding; - this.inputWrapperElement = inputWrapperElement; - this.outputWrapperElement = outputWrapperElement; - this.inputChildElements = inputElements; - this.outputChildElements = outputElements; - } - - /** - * @return the inputElements - */ - public List getInputChildElements() { - return inputChildElements; - } - - /** - * @return the inputWrapperElement - */ - public ElementInfo getInputWrapperElement() { - return inputWrapperElement; - } - - /** - * @return the outputElements - */ - public List getOutputChildElements() { - return outputChildElements; - } - - /** - * @return the outputWrapperElement - */ - public ElementInfo getOutputWrapperElement() { - return outputWrapperElement; - } - - /** - * @return the unwrappedInputType - */ - public DataType> getUnwrappedInputType() { - if (unwrappedInputType == null) { - List childTypes = new ArrayList(); - for (ElementInfo element : getInputChildElements()) { - DataType type = getDataType(element); - childTypes.add(type); - } - unwrappedInputType = new DataTypeImpl>("idl:unwrapped.input", Object[].class, childTypes); - } - return unwrappedInputType; - } - - private DataType getDataType(ElementInfo element) { - DataType type = null; - if (element.isMany()) { - DataType logical = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); - type = new DataTypeImpl("java:array", Object[].class, logical); - } else { - type = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); - } - return type; - } - - /** - * @return the unwrappedOutputType - */ - public DataType getUnwrappedOutputType() { - if (unwrappedOutputType == null) { - List elements = getOutputChildElements(); - if (elements != null && elements.size() > 0) { - if (elements.size() > 1) { - // We don't support output with multiple parts - // throw new IllegalArgumentException("Multi-part output is not supported"); - } - ElementInfo element = elements.get(0); - - unwrappedOutputType = getDataType(element); - } - } - return unwrappedOutputType; - } - - public Class getInputWrapperClass() { - return inputWrapperType == null ? null : inputWrapperType.getPhysical(); - } - - public Class getOutputWrapperClass() { - return outputWrapperType == null ? null : outputWrapperType.getPhysical(); - } - - public String getDataBinding() { - return dataBinding; - } - - public void setDataBinding(String dataBinding) { - this.dataBinding = dataBinding; - } - - public DataType getInputWrapperType() { - return inputWrapperType; - } - - public void setInputWrapperType(DataType inputWrapperType) { - this.inputWrapperType = inputWrapperType; - } - - public DataType getOutputWrapperType() { - return outputWrapperType; - } - - public void setOutputWrapperType(DataType outputWrapperType) { - this.outputWrapperType = outputWrapperType; - } -} diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java deleted file mode 100644 index 26ecf6e352..0000000000 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.util; - -import javax.xml.namespace.QName; - -/** - * The metadata for an XML element or type. - * - * @version $Rev$ $Date$ - */ -public class XMLType { - public static final XMLType UNKNOWN = new XMLType(null, null); - protected QName element; - protected QName type; - protected boolean nillable = true; - protected boolean many = false; - - /** - * @param element - */ - public XMLType(ElementInfo element) { - super(); - this.element = element.getQName(); - if (element.getType() != null) { - this.type = element.getType().getQName(); - } - } - - /** - * @param element - */ - public XMLType(TypeInfo type) { - this.element = null; - this.type = type.getQName(); - } - - public XMLType(QName element, QName type) { - this.element = element; - this.type = type; - } - - /** - * @return the type - */ - public QName getTypeName() { - return type; - } - - public boolean isElement() { - return element != null; - } - - public QName getElementName() { - return element; - } - - public void setElementName(QName element) { - this.element = element; - } - - public void setTypeName(QName type) { - this.type = type; - } - - public static XMLType getType(QName type) { - return new XMLType(null, type); - } - - /** - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int PRIME = 31; - int result = 1; - result = PRIME * result + ((element == null) ? 0 : element.hashCode()); - result = PRIME * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - /** - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final XMLType other = (XMLType)obj; - if (element == null) { - if (other.element != null) { - return false; - } - } else if (!element.equals(other.element)) { - return false; - } - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - return true; - } - - @Override - public String toString() { - return "Element: " + element + " Type: " + type; - } - - public boolean isNillable() { - return nillable; - } - - public void setNillable(boolean niable) { - this.nillable = niable; - } - - public boolean isMany() { - return many; - } - - public void setMany(boolean many) { - this.many = many; - } - -} diff --git a/java/sca/modules/interface/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper b/java/sca/modules/interface/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper deleted file mode 100644 index 821c58bde1..0000000000 --- a/java/sca/modules/interface/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper +++ /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.interfacedef.impl.InterfaceContractMapperImpl diff --git a/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java b/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java deleted file mode 100644 index acdaae799e..0000000000 --- a/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tuscany.sca.interfacedef.impl; - -import static org.junit.Assert.fail; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; -import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.interfacedef.DataType; -import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException; -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.junit.Before; -import org.junit.Test; - -/** - * TODO some tests commented out due to DataType.equals() needing to be strict - * - * @version $Rev$ $Date$ - */ -public class ContractCompatibilityTestCase { - - private InterfaceContractMapper mapper; - - @Before - public void setUp() throws Exception { - ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); - mapper = utilities.getUtility(InterfaceContractMapper.class); - } - - @Test - public void testNoOperation() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - InterfaceContract target = new MockContract("FooContract"); - mapper.checkCompatibility(source, target, false, false); - } - - @Test - public void testBasic() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - Operation opSource1 = newOperation("op1"); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - InterfaceContract target = new MockContract("FooContract"); - Operation opSource2 = newOperation("op1"); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opSource2); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, false, false); - } - - @Test - public void testBasicIncompatibleOperationNames() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - Operation opSource1 = newOperation("op1"); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - InterfaceContract target = new MockContract("FooContract"); - Operation opSource2 = newOperation("op2"); - Map targetOperations = new HashMap(); - targetOperations.put("op2", opSource2); - target.getInterface().getOperations().addAll(targetOperations.values()); - try { - mapper.checkCompatibility(source, target, false, false); - fail(); - } catch (IncompatibleInterfaceContractException e) { - // expected - } - } - - @Test - public void testInputTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - List sourceInputTypes = new ArrayList(); - sourceInputTypes.add(new DataTypeImpl(Object.class, Object.class)); - DataType> inputType = new DataTypeImpl>(String.class, sourceInputTypes); - Operation opSource1 = newOperation("op1"); - opSource1.setInputType(inputType); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - List targetInputTypes = new ArrayList(); - targetInputTypes.add(new DataTypeImpl(Object.class, Object.class)); - DataType> targetInputType = new DataTypeImpl>(String.class, targetInputTypes); - - Operation opTarget = newOperation("op1"); - opTarget.setInputType(targetInputType); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, false, false); - } - - @Test - public void testIncompatibleInputTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - List sourceInputTypes = new ArrayList(); - sourceInputTypes.add(new DataTypeImpl(Integer.class, Integer.class)); - DataType> inputType = new DataTypeImpl>(String.class, sourceInputTypes); - Operation opSource1 = newOperation("op1"); - opSource1.setInputType(inputType); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - List targetInputTypes = new ArrayList(); - targetInputTypes.add(new DataTypeImpl(String.class, String.class)); - DataType> targetInputType = new DataTypeImpl>(String.class, targetInputTypes); - - Operation opTarget = newOperation("op1"); - opTarget.setInputType(targetInputType); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - try { - mapper.checkCompatibility(source, target, false, false); - fail(); - } catch (IncompatibleInterfaceContractException e) { - // expected - } - } - - /** - * Verifies source input types can be super types of the target - */ - @Test - public void testSourceSuperTypeInputCompatibility() throws Exception { - // InterfaceContract source = new MockContract("FooContract"); - // List sourceInputTypes = new ArrayList(); - // sourceInputTypes.add(new DataTypeImpl(Object.class, - // Object.class)); - // DataType> inputType = new - // DataTypeImpl>(String.class, sourceInputTypes); - // Operation opSource1 = newOperationImpl("op1", inputType, null, null, - // false, null); - // Map sourceOperations = new HashMap(); - // sourceOperations.put("op1", opSource1); - // source.getInterface().getOperations().addAll(sourceOperations.values()); - // - // InterfaceContract target = new MockContract("FooContract"); - // List targetInputTypes = new ArrayList(); - // targetInputTypes.add(new DataTypeImpl(String.class, - // String.class)); - // DataType> targetInputType = - // new DataTypeImpl>(String.class, targetInputTypes); - // - // Operation opTarget = newOperationImpl("op1", targetInputType, null, - // null, false, null); - // Map targetOperations = new HashMap(); - // targetOperations.put("op1", opTarget); - // target.getInterface().getOperations().addAll(targetOperations.values()); - // wireService.checkCompatibility(source, target, false); - } - - @Test - public void testOutputTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - DataType sourceOutputType = new DataTypeImpl(String.class, String.class); - Operation opSource1 = newOperation("op1"); - opSource1.setOutputType(sourceOutputType); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - DataType targetOutputType = new DataTypeImpl(String.class, String.class); - Operation opTarget = newOperation("op1"); - opTarget.setOutputType(targetOutputType); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, false, false); - } - - /** - * Verifies a return type that is a supertype of of the target is compatible - */ - @Test - public void testSupertypeOutputTypes() throws Exception { - // InterfaceContract source = new MockContract("FooContract"); - // DataType sourceOutputType = new DataTypeImpl(Object.class, - // Object.class); - // Operation opSource1 = newOperationImpl("op1", null, - // sourceOutputType, null, false, null); - // Map sourceOperations = new HashMap(); - // sourceOperations.put("op1", opSource1); - // source.getInterface().getOperations().addAll(sourceOperations.values()); - // - // InterfaceContract target = new MockContract("FooContract"); - // DataType targetOutputType = new DataTypeImpl(String.class, - // String.class); - // Operation opTarget = newOperationImpl("op1", null, targetOutputType, - // null, false, null); - // Map targetOperations = new HashMap(); - // targetOperations.put("op1", opTarget); - // target.getInterface().getOperations().addAll(targetOperations.values()); - // wireService.checkCompatibility(source, target, false); - } - - @Test - public void testIncompatibleOutputTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - DataType sourceOutputType = new DataTypeImpl(String.class, String.class); - Operation opSource1 = newOperation("op1"); - opSource1.setOutputType(sourceOutputType); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - DataType targetOutputType = new DataTypeImpl(Integer.class, Integer.class); - Operation opTarget = newOperation("op1"); - opTarget.setOutputType(targetOutputType); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - try { - mapper.checkCompatibility(source, target, false, false); - fail(); - } catch (IncompatibleInterfaceContractException e) { - // expected - } - } - - @Test - public void testFaultTypes() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - DataType sourceFaultType = new DataTypeImpl(String.class, String.class); - List sourceFaultTypes = new ArrayList(); - sourceFaultTypes.add(0, sourceFaultType); - Operation opSource1 = newOperation("op1"); - opSource1.setFaultTypes(sourceFaultTypes); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - DataType targetFaultType = new DataTypeImpl(String.class, String.class); - List targetFaultTypes = new ArrayList(); - targetFaultTypes.add(0, targetFaultType); - - Operation opTarget = newOperation("op1"); - opTarget.setFaultTypes(targetFaultTypes); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, false, false); - } - - @Test - public void testSourceFaultTargetNoFaultCompatibility() throws Exception { - InterfaceContract source = new MockContract("FooContract"); - DataType sourceFaultType = new DataTypeImpl(String.class, String.class); - List sourceFaultTypes = new ArrayList(); - sourceFaultTypes.add(0, sourceFaultType); - Operation opSource1 = newOperation("op1"); - opSource1.setFaultTypes(sourceFaultTypes); - Map sourceOperations = new HashMap(); - sourceOperations.put("op1", opSource1); - source.getInterface().getOperations().addAll(sourceOperations.values()); - - InterfaceContract target = new MockContract("FooContract"); - Operation opTarget = newOperation("op1"); - Map targetOperations = new HashMap(); - targetOperations.put("op1", opTarget); - target.getInterface().getOperations().addAll(targetOperations.values()); - mapper.checkCompatibility(source, target, false, false); - } - - /** - * Verifies a source's fault which is a supertype of the target's fault are - * compatible - * - * @throws Exception - */ - @Test - public void testFaultSuperTypes() throws Exception { - // InterfaceContract source = new MockContract("FooContract"); - // DataType sourceFaultType = new DataTypeImpl(Exception.class, - // Exception.class); - // List sourceFaultTypes = new ArrayList(); - // sourceFaultTypes.add(0, sourceFaultType); - // Operation opSource1 = newOperationImpl("op1", null, null, - // sourceFaultTypes, false, null); - // Map sourceOperations = new HashMap(); - // sourceOperations.put("op1", opSource1); - // source.getInterface().getOperations().addAll(sourceOperations.values()); - // - // InterfaceContract target = new MockContract("FooContract"); - // DataType targetFaultType = new - // DataTypeImpl(TuscanyException.class, TuscanyException.class); - // List targetFaultTypes = new ArrayList(); - // targetFaultTypes.add(0, targetFaultType); - // - // Operation opTarget = newOperationImpl("op1", null, null, - // targetFaultTypes, false, null); - // Map targetOperations = new HashMap(); - // targetOperations.put("op1", opTarget); - // target.getInterface().getOperations().addAll(targetOperations.values()); - // wireService.checkCompatibility(source, target, false); - } - - /** - * Verifies a source's faults which are supertypes and a superset of the - * target's faults are compatible - */ - @Test - public void testFaultSuperTypesAndSuperset() throws Exception { - // InterfaceContract source = new MockContract("FooContract"); - // DataType sourceFaultType = new DataTypeImpl(Exception.class, - // Exception.class); - // DataType sourceFaultType2 = new - // DataTypeImpl(RuntimeException.class, RuntimeException.class); - // List sourceFaultTypes = new ArrayList(); - // sourceFaultTypes.add(0, sourceFaultType); - // sourceFaultTypes.add(1, sourceFaultType2); - // Operation opSource1 = newOperationImpl("op1", null, null, - // sourceFaultTypes, false, null); - // Map sourceOperations = new HashMap(); - // sourceOperations.put("op1", opSource1); - // source.getInterface().getOperations().addAll(sourceOperations.values()); - // - // InterfaceContract target = new MockContract("FooContract"); - // DataType targetFaultType = new - // DataTypeImpl(TuscanyException.class, TuscanyException.class); - // List targetFaultTypes = new ArrayList(); - // targetFaultTypes.add(0, targetFaultType); - // - // Operation opTarget = newOperationImpl("op1", null, null, - // targetFaultTypes, false, null); - // Map targetOperations = new HashMap(); - // targetOperations.put("op1", opTarget); - // target.getInterface().getOperations().addAll(targetOperations.values()); - // wireService.checkCompatibility(source, target, false); - } - - private static class MockInterface extends InterfaceImpl { - - } - - private class MockContract extends InterfaceContractImpl { - public MockContract() { - } - - public MockContract(String interfaceClass) { - Interface jInterface = new MockInterface(); - setInterface(jInterface); - } - } - - private static Operation newOperation(String name) { - Operation operation = new OperationImpl(); - operation.setName(name); - return operation; - } -} diff --git a/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java b/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java deleted file mode 100644 index d1faa5cf2b..0000000000 --- a/java/sca/modules/interface/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.tuscany.sca.interfacedef.impl; - - -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * @version $Rev$ $Date$ - */ -public class InterfaceContractTestCase { - private InterfaceContract contract; - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - contract = new MockInterfaceContract(); - Interface i1 = new MockInterface(); - contract.setInterface(i1); - Operation op1 = newOperation("op1"); - i1.getOperations().add(op1); - Interface i2 = new MockInterface(); - contract.setCallbackInterface(i2); - Operation callbackOp1 = newOperation("callbackOp1"); - i2.getOperations().add(callbackOp1); - } - - @Test - public void testClone() throws Exception { - InterfaceContract copy = (InterfaceContract) contract.clone(); - Assert.assertNotNull(copy); - Assert.assertNotSame(copy.getCallbackInterface(), contract.getCallbackInterface()); - Assert.assertNotSame(copy.getInterface(), contract.getInterface()); - } - - private static class MockInterfaceContract extends InterfaceContractImpl implements InterfaceContract { - } - - private static class MockInterface extends InterfaceImpl implements Interface { - } - - private static Operation newOperation(String name) { - Operation operation = new OperationImpl(); - operation.setName(name); - return operation; - } -} diff --git a/java/sca/modules/policy-logging/pom.xml b/java/sca/modules/policy-logging/pom.xml index c4d65c66fe..d9fd1fb4b4 100644 --- a/java/sca/modules/policy-logging/pom.xml +++ b/java/sca/modules/policy-logging/pom.xml @@ -48,11 +48,6 @@ 2.0-SNAPSHOT
- - org.apache.tuscany.sca - tuscany-policy - 2.0-SNAPSHOT -
diff --git a/java/sca/modules/policy-xml-ws/pom.xml b/java/sca/modules/policy-xml-ws/pom.xml index 8dd362479b..d1cc161867 100644 --- a/java/sca/modules/policy-xml-ws/pom.xml +++ b/java/sca/modules/policy-xml-ws/pom.xml @@ -31,7 +31,7 @@ org.apache.tuscany.sca - tuscany-policy + tuscany-assembly 2.0-SNAPSHOT diff --git a/java/sca/modules/policy-xml/pom.xml b/java/sca/modules/policy-xml/pom.xml index c9e7787111..7383a3514f 100644 --- a/java/sca/modules/policy-xml/pom.xml +++ b/java/sca/modules/policy-xml/pom.xml @@ -31,7 +31,7 @@ org.apache.tuscany.sca - tuscany-policy + tuscany-assembly 2.0-SNAPSHOT diff --git a/java/sca/modules/pom.xml b/java/sca/modules/pom.xml index f5f70877db..192e292d17 100644 --- a/java/sca/modules/pom.xml +++ b/java/sca/modules/pom.xml @@ -54,7 +54,6 @@ databinding-axiom databinding-jaxb databinding-jaxb-axiom - definitions definitions-xml domain-node endpoint @@ -74,7 +73,6 @@ implementation-spring-sca implementation-web implementation-web-runtime - interface interface-java interface-java-jaxws interface-wsdl @@ -85,7 +83,6 @@ node-impl node-launcher node-launcher-equinox - policy policy-security policy-xml policy-xml-ws -- cgit v1.2.3