Author: svkrish
Date: Mon Aug 13 10:33:09 2007
New Revision: 565450
URL: http://svn.apache.org/viewvc?view=rev&rev=565450
Log:
adding support for processing extension types metadata info from definitions.xml
Added:
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
Modified:
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsBuilderImpl.java
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java
incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
incubator/tuscany/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/definitions.xml
Added:
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java?view=auto&rev=565450
==============================================================================
---
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
(added)
+++
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
Mon Aug 13 10:33:09 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionTypeFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+
+/*
+ * Processor for handling xml models of BindingType meta data definitions
+ */
+public class BindingTypeProcessor extends ExtensionTypeProcessor<BindingType> {
+
+ public BindingTypeProcessor(PolicyFactory policyFactory,
ExtensionTypeFactory extnTypeFactory, StAXArtifactProcessor<Object>
extensionProcessor) {
+ super(policyFactory, extnTypeFactory, extensionProcessor);
+ }
+
+ public BindingType read(XMLStreamReader reader) throws
ContributionReadException {
+ QName type = getQName(reader, TYPE);
+
+ if ( type != null ) {
+ BindingType bindingType = extnTypeFactory.createBindingType();
+ bindingType.setTypeName(type);
+
+ readAlwaysProvidedIntents(bindingType, reader);
+ readMayProvideIntents(bindingType, reader);
+ return bindingType;
+ } else {
+ throw new ContributionReadException("Required attribute '" + TYPE
+
+ "' missing from BindingType
Definition");
+ }
+ }
+
+ public QName getArtifactType() {
+ return BINDING_TYPE_QNAME;
+ }
+
+ public Class<BindingType> getModelType() {
+ return BindingType.class;
+ }
+}
Added:
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java?view=auto&rev=565450
==============================================================================
---
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
(added)
+++
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
Mon Aug 13 10:33:09 2007
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import
org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.policy.BindingType;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.ExtensionTypeFactory;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+
+/*
+ * Processor for handling xml models of ExtensionType meta data definitions
+ */
+public abstract class ExtensionTypeProcessor<T extends ExtensionType>
implements StAXArtifactProcessor<T>, PolicyConstants {
+
+ protected ExtensionTypeFactory extnTypeFactory;
+ protected PolicyFactory policyFactory;
+ protected StAXArtifactProcessor<Object> extensionProcessor;
+
+
+ public ExtensionTypeProcessor(PolicyFactory policyFactory,
ExtensionTypeFactory extnTypeFactory, StAXArtifactProcessor<Object>
extensionProcessor) {
+ this.policyFactory = policyFactory;
+ this.extnTypeFactory = extnTypeFactory;
+ this.extensionProcessor = extensionProcessor;
+ }
+
+ protected void readAlwaysProvidedIntents(ExtensionType extnType,
XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, ALWAYS_PROVIDES);
+ if (value != null) {
+ List<Intent> alwaysProvided = extnType.getAlwaysProvidedIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value);
tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ alwaysProvided.add(intent);
+ }
+ }
+ }
+
+ protected void readMayProvideIntents(ExtensionType extnType,
XMLStreamReader reader) {
+ String value = reader.getAttributeValue(null, MAY_PROVIDE);
+ if (value != null) {
+ List<Intent> mayProvide = extnType.getMayProvideIntents();
+ for (StringTokenizer tokens = new StringTokenizer(value);
tokens.hasMoreTokens();) {
+ QName qname = getQNameValue(reader, tokens.nextToken());
+ Intent intent = policyFactory.createIntent();
+ intent.setName(qname);
+ mayProvide.add(intent);
+ }
+ }
+ }
+
+ public void write(T extnType, XMLStreamWriter writer) throws
ContributionWriteException {
+ try {
+ // Write an <sca:bindingType or sca:implementationType>
+ if ( extnType instanceof BindingType ) {
+ writer.writeStartElement(SCA10_NS, BINDING_TYPE);
+ } else if ( extnType instanceof ImplementationType ) {
+ writer.writeStartElement(SCA10_NS, IMPLEMENATION_TYPE);
+ }
+
+ writeAlwaysProvidesIntentsAttribute(extnType, writer);
+ writeMayProvideIntentsAttribute(extnType, writer);
+
+ writer.writeEndElement();
+
+ } catch (XMLStreamException e) {
+ throw new ContributionWriteException(e);
+ }
+ }
+
+ protected void writeMayProvideIntentsAttribute(ExtensionType extnType,
XMLStreamWriter writer) throws XMLStreamException {
+ StringBuffer sb = new StringBuffer();
+ for ( Intent intent : extnType.getMayProvideIntents() ) {
+ writer.writeNamespace(intent.getName().getPrefix(),
intent.getName().getNamespaceURI());
+ sb.append(intent.getName().getPrefix() + COLON +
intent.getName().getLocalPart());
+ sb.append(WHITE_SPACE);
+ }
+
+ if ( sb.length() > 0 ) {
+ writer.writeAttribute(MAY_PROVIDE, sb.toString());
+ }
+ }
+
+ protected void writeAlwaysProvidesIntentsAttribute(ExtensionType extnType,
XMLStreamWriter writer) throws XMLStreamException {
+ StringBuffer sb = new StringBuffer();
+ for ( Intent intent : extnType.getAlwaysProvidedIntents() ) {
+ writer.writeNamespace(intent.getName().getPrefix(),
intent.getName().getNamespaceURI());
+ sb.append(intent.getName().getPrefix() + COLON +
intent.getName().getLocalPart());
+ sb.append(WHITE_SPACE);
+ }
+
+ if ( sb.length() > 0 ) {
+ writer.writeAttribute(ALWAYS_PROVIDES, sb.toString());
+
+ }
+ }
+
+ private void resolveExtensionType(T extnType, ModelResolver resolver)
throws ContributionResolveException {
+ //FIXME: need to resolve the binding and implementations across the
assembly model
+ extnType.setUnresolved(false);
+ }
+
+ public void resolve(T extnType, ModelResolver resolver) throws
ContributionResolveException {
+ resolveExtensionType(extnType, resolver);
+
+ if ( !extnType.isUnresolved() ) {
+ resolver.addModel(extnType);
+ }
+ }
+
+ private void resolveAlwaysProvidedIntents(ExtensionType extnType,
ModelResolver resolver) throws ContributionResolveException {
+ boolean isUnresolved = false;
+ if (extnType != null && extnType.isUnresolved()) {
+ //resolve alwaysProvided Intents
+ List<Intent> alwaysProvided = new ArrayList<Intent>();
+ for ( Intent providedIntent : extnType.getAlwaysProvidedIntents()
) {
+ if ( providedIntent.isUnresolved() ) {
+ providedIntent = resolver.resolveModel(Intent.class,
providedIntent);
+ alwaysProvided.add(providedIntent);
+ if (providedIntent.isUnresolved()) {
+ isUnresolved = true;
+ }
+ }
+ }
+ extnType.getAlwaysProvidedIntents().clear();
+ extnType.getAlwaysProvidedIntents().addAll(alwaysProvided);
+ }
+ extnType.setUnresolved(isUnresolved);
+ }
+
+ private void resolveMayProvideIntents(ExtensionType extnType,
ModelResolver resolver) throws ContributionResolveException {
+ boolean isUnresolved = false;
+ if (extnType != null && extnType.isUnresolved()) {
+ //resolve may provide Intents
+ List<Intent> mayProvide = new ArrayList<Intent>();
+ for ( Intent providedIntent : extnType.getMayProvideIntents() ) {
+ if ( providedIntent.isUnresolved() ) {
+ providedIntent = resolver.resolveModel(Intent.class,
providedIntent);
+ mayProvide.add(providedIntent);
+ if (providedIntent.isUnresolved()) {
+ isUnresolved = true;
+ }
+ }
+ }
+ extnType.getAlwaysProvidedIntents().clear();
+ extnType.getAlwaysProvidedIntents().addAll(mayProvide);
+ }
+ extnType.setUnresolved(isUnresolved);
+ }
+
+ protected QName getQNameValue(XMLStreamReader reader, String value) {
+ if (value != null) {
+ int index = value.indexOf(':');
+ String prefix = index == -1 ? "" : value.substring(0, index);
+ String localName = index == -1 ? value : value.substring(index +
1);
+ String ns = reader.getNamespaceContext().getNamespaceURI(prefix);
+ if (ns == null) {
+ ns = "";
+ }
+ return new QName(ns, localName, prefix);
+ } else {
+ return null;
+ }
+ }
+
+ protected QName getQName(XMLStreamReader reader, String name) {
+ String qname = reader.getAttributeValue(null, name);
+ return getQNameValue(reader, qname);
+ }
+
+
+ protected String getString(XMLStreamReader reader, String name) {
+ return reader.getAttributeValue(null, name);
+ }
+}
Added:
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java?view=auto&rev=565450
==============================================================================
---
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
(added)
+++
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
Mon Aug 13 10:33:09 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.policy.xml;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.policy.ExtensionTypeFactory;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+
+/*
+ * Processor for handling xml models of ImplementationType meta data
definitions
+ */
+public class ImplementationTypeProcessor extends
ExtensionTypeProcessor<ImplementationType> {
+
+ public ImplementationTypeProcessor(PolicyFactory policyFactory,
ExtensionTypeFactory extnTypeFactory, StAXArtifactProcessor<Object>
extensionProcessor) {
+ super(policyFactory, extnTypeFactory, extensionProcessor);
+ }
+
+ public ImplementationType read(XMLStreamReader reader) throws
ContributionReadException {
+ QName type = getQName(reader, TYPE);
+
+ if ( type != null ) {
+ ImplementationType implType =
extnTypeFactory.createImplementationType();
+ implType.setTypeName(type);
+
+ readAlwaysProvidedIntents(implType, reader);
+ readMayProvideIntents(implType, reader);
+ return implType;
+ } else {
+ throw new ContributionReadException("Required attribute '" + TYPE
+
+ "' missing from
ImplementationType Definition");
+ }
+ }
+
+ public QName getArtifactType() {
+ return IMPLEMENTATION_TYPE_QNAME;
+ }
+
+ public Class<ImplementationType> getModelType() {
+ return ImplementationType.class;
+ }
+}
Modified:
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java?view=diff&rev=565450&r1=565449&r2=565450
==============================================================================
---
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
(original)
+++
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
Mon Aug 13 10:33:09 2007
@@ -25,6 +25,7 @@
*
*/
public interface PolicyConstants {
+ String WHITE_SPACE = " ";
String COLON = ":";
String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
String INTENT = "intent";
@@ -43,6 +44,13 @@
String REQUIRES = "requires";
String DEFAULT = "default";
+ String ALWAYS_PROVIDES = "alwaysProvides";
+ String MAY_PROVIDE = "mayProvide";
+ String TYPE = "type";
+ String IMPLEMENATION_TYPE = "implementationType";
+ String BINDING_TYPE = "bindingType";
+ QName IMPLEMENTATION_TYPE_QNAME = new QName(SCA10_NS, IMPLEMENATION_TYPE);
+ QName BINDING_TYPE_QNAME = new QName(SCA10_NS, BINDING_TYPE);
QName POLICY_INTENT_QNAME = new QName(SCA10_NS, INTENT);
QName POLICY_SET_QNAME = new QName(SCA10_NS, POLICY_SET);
Modified:
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsBuilderImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsBuilderImpl.java?view=diff&rev=565450&r1=565449&r2=565450
==============================================================================
---
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsBuilderImpl.java
(original)
+++
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsBuilderImpl.java
Mon Aug 13 10:33:09 2007
@@ -26,6 +26,9 @@
import javax.xml.namespace.QName;
+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.Policy;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -49,9 +52,42 @@
for (PolicySet policySet : scaDefns.getPolicySets()) {
definedPolicySets.put(policySet.getName(), policySet);
}
+
+ Map<QName, BindingType> definedBindingTypes = new HashMap<QName,
BindingType>();
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ definedBindingTypes.put(bindingType.getTypeName(), bindingType);
+ }
+
+ Map<QName, ImplementationType> definedImplTypes = new HashMap<QName,
ImplementationType>();
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
+ definedImplTypes.put(implType.getTypeName(), implType);
+ }
+
buildPolicyIntents(scaDefns, definedIntents);
buildPolicySets(scaDefns, definedPolicySets, definedIntents);
+ buildBindingTypes(scaDefns, definedBindingTypes, definedIntents);
+ buildImplementationTypes(scaDefns, definedImplTypes, definedIntents);
+ }
+
+ private void buildBindingTypes(SCADefinitions scaDefns,
+ Map<QName, BindingType>
definedBindingTypes,
+ Map<QName, Intent> definedIntents) throws
SCADefinitionsBuilderException {
+ for (BindingType bindingType : scaDefns.getBindingTypes()) {
+ buildAlwaysProvidedIntents(bindingType, definedIntents);
+ buildMayProvideIntents(bindingType, definedIntents);
+ }
+
+ }
+
+ private void buildImplementationTypes(SCADefinitions scaDefns,
+ Map<QName, ImplementationType>
definedImplTypes,
+ Map<QName, Intent> definedIntents) throws
SCADefinitionsBuilderException {
+ for (ImplementationType implType : scaDefns.getImplementationTypes()) {
+ buildAlwaysProvidedIntents(implType, definedIntents);
+ buildMayProvideIntents(implType, definedIntents);
+ }
}
+
private void buildPolicyIntents(SCADefinitions scaDefns, Map<QName,
Intent> definedIntents)
throws SCADefinitionsBuilderException {
@@ -82,7 +118,7 @@
}
}
}
-
+
private void buildProfileIntent(ProfileIntent policyIntent, Map<QName,
Intent> definedIntents)
throws SCADefinitionsBuilderException {
//FIXME: Need to check for cyclic references first i.e an A requiring
B and then B requiring A...
@@ -126,6 +162,59 @@
}
}
+ }
+ }
+
+
+ private void buildAlwaysProvidedIntents(ExtensionType extensionType,
+ Map<QName, Intent> definedIntents)
throws SCADefinitionsBuilderException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> alwaysProvided = new ArrayList<Intent>();
+ for (Intent providedIntent :
extensionType.getAlwaysProvidedIntents()) {
+ if (providedIntent.isUnresolved()) {
+ Intent resolvedProvidedIntent =
definedIntents.get(providedIntent.getName());
+ if (resolvedProvidedIntent != null) {
+ alwaysProvided.add(resolvedProvidedIntent);
+ } else {
+ throw new SCADefinitionsBuilderException(
+ "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<QName, Intent> definedIntents)
throws SCADefinitionsBuilderException {
+ if (extensionType != null) {
+ // resolve all provided intents
+ List<Intent> mayProvide = new ArrayList<Intent>();
+ for (Intent providedIntent : extensionType.getMayProvideIntents())
{
+ if (providedIntent.isUnresolved()) {
+ Intent resolvedProvidedIntent =
definedIntents.get(providedIntent.getName());
+ if (resolvedProvidedIntent != null) {
+ mayProvide.add(resolvedProvidedIntent);
+ } else {
+ throw new SCADefinitionsBuilderException(
+ "May Provide
Intent - " + providedIntent
+ + " not
found for ExtensionType "
+ +
extensionType);
+
+ }
+ } else {
+ mayProvide.add(providedIntent);
+ }
+ }
+ extensionType.getMayProvideIntents().clear();
+ extensionType.getMayProvideIntents().addAll(mayProvide);
}
}
Modified:
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java?view=diff&rev=565450&r1=565449&r2=565450
==============================================================================
---
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java
(original)
+++
incubator/tuscany/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/SCADefinitionsProcessor.java
Mon Aug 13 10:33:09 2007
@@ -274,14 +274,12 @@
for (int count = 0, size = scaDefns.getBindingTypes().size(); count <
size; count++) {
BindingType bindingType = scaDefns.getBindingTypes().get(count);
- bindingType = resolver.resolveModel(BindingType.class,
bindingType);
- scaDefns.getBindingTypes().set(count, bindingType);
+ extensionProcessor.resolve(bindingType, resolver);
}
for (int count = 0, size = scaDefns.getImplementationTypes().size();
count < size; count++) {
ImplementationType implType =
scaDefns.getImplementationTypes().get(count);
- implType = resolver.resolveModel(ImplementationType.class,
implType);
- scaDefns.getImplementationTypes().set(count, implType);
+ extensionProcessor.resolve(implType, resolver);
}
}
Modified:
incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java?view=diff&rev=565450&r1=565449&r2=565450
==============================================================================
---
incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
(original)
+++
incubator/tuscany/java/sca/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
Mon Aug 13 10:33:09 2007
@@ -34,13 +34,17 @@
import
org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint;
import
org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.policy.BindingType;
import org.apache.tuscany.sca.policy.DefaultPolicyFactory;
+import org.apache.tuscany.sca.policy.ExtensionTypeFactory;
+import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.ProfileIntent;
import org.apache.tuscany.sca.policy.QualifiedIntent;
import org.apache.tuscany.sca.policy.SCADefinitions;
+import org.apache.tuscany.sca.policy.impl.DefaultExtensionTypeFactory;
/**
* Test reading SCA XML assembly documents.
@@ -56,6 +60,8 @@
private SCADefinitions scaDefinitions;
Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
+ Map<QName, BindingType> bindingTypesTable = new Hashtable<QName,
BindingType>();
+ Map<QName, ImplementationType> implTypesTable = new Hashtable<QName,
ImplementationType>();
public static final String namespace = "http://www.osoa.org/xmlns/sca/1.0";
private static final QName confidentiality = new QName(namespace,
"confidentiality");
@@ -67,11 +73,14 @@
private static final QName secureMessagingPolicies = new QName(namespace,
"SecureMessagingPolicies");
private static final QName securityPolicy = new QName(namespace,
"SecurityPolicy");
private static final QName basicAuthMsgProtSecurity = new QName(namespace,
"BasicAuthMsgProtSecurity");
+ private static final QName wsBinding = new QName(namespace, "binding.ws");
+ private static final QName javaImpl = new QName(namespace,
"implementation.java");
public void setUp() throws Exception {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
PolicyFactory policyFactory = new DefaultPolicyFactory();
+ ExtensionTypeFactory extnTypeFactory = new
DefaultExtensionTypeFactory();
this.resolver = new SCADefinitionsResolver();
this.builder = new SCADefinitionsBuilderImpl();
@@ -87,6 +96,8 @@
staxProcessors.addArtifactProcessor(new
ProfileIntentProcessor(policyFactory, staxProcessor));
staxProcessors.addArtifactProcessor(new
QualifiedIntentProcessor(policyFactory, staxProcessor));
staxProcessors.addArtifactProcessor(new
PolicySetProcessor(policyFactory, staxProcessor));
+ staxProcessors.addArtifactProcessor(new
ImplementationTypeProcessor(policyFactory, extnTypeFactory, staxProcessor));
+ staxProcessors.addArtifactProcessor(new
BindingTypeProcessor(policyFactory, extnTypeFactory, staxProcessor));
staxProcessors.addArtifactProcessor(new MockPolicyProcessor());
URL url = getClass().getResource("definitions.xml");
@@ -100,6 +111,14 @@
for ( PolicySet policySet : scaDefinitions.getPolicySets() ) {
policySetTable.put(policySet.getName(), policySet);
}
+
+ for ( BindingType bindingType : scaDefinitions.getBindingTypes() ) {
+ bindingTypesTable.put(bindingType.getTypeName(), bindingType);
+ }
+
+ for ( ImplementationType implType :
scaDefinitions.getImplementationTypes() ) {
+ implTypesTable.put(implType.getTypeName(), implType);
+ }
}
public void tearDown() throws Exception {
@@ -122,6 +141,11 @@
assertNotNull(policySetTable.get(secureMessagingPolicies));
assertEquals(policySetTable.get(secureMessagingPolicies).getMappedPolicies().size(),
3);
+
+ assertEquals(bindingTypesTable.size(), 1);
+ assertNotNull(bindingTypesTable.get(wsBinding));
+ assertEquals(implTypesTable.size(), 1);
+ assertNotNull(implTypesTable.get(javaImpl));
}
public void testResolveSCADefinitions() throws Exception {
@@ -148,6 +172,14 @@
assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
assertTrue(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
+ BindingType wsBindingType = bindingTypesTable.get(wsBinding);
+
assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+
assertNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
+
+ ImplementationType javaImplType = implTypesTable.get(javaImpl);
+
assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+
assertNull(javaImplType.getMayProvideIntents().get(0).getDescription());
+
scaDefnDocProcessor.resolve(scaDefinitions, resolver);
//builder.build(scaDefinitions);
@@ -171,5 +203,11 @@
assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
assertFalse(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
assertNotNull(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
+
+
assertNotNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
+
assertNotNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
+
+
assertNotNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
+
assertNotNull(javaImplType.getMayProvideIntents().get(0).getDescription());
}
}
Modified:
incubator/tuscany/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/definitions.xml
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/definitions.xml?view=diff&rev=565450&r1=565449&r2=565450
==============================================================================
---
incubator/tuscany/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/definitions.xml
(original)
+++
incubator/tuscany/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/definitions.xml
Mon Aug 13 10:33:09 2007
@@ -3,6 +3,12 @@
targetNamespace="http://test"
xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+<!-- Extension Types Metadata -->
+<implementationType type="sca:implementation.java" alwaysProvides="logging"
+ mayProvide="tracing"/>
+<bindingType type="sca:binding.ws" alwaysProvides="confidentiality"
+ mayProvide="integrity"/>
+
<!-- qualified intents -->
<intent name="confidentiality.transport" />
<intent name="confidentiality.message" />
@@ -151,6 +157,20 @@
<description>
Communitcation thro this binding required
Authentication.
+ </description>
+ </intent>
+
+ <intent name="logging"
+ constrains="sca:implementation">
+ <description>
+ All messages to and from this implementation
must be logged
+ </description>
+ </intent>
+
+ <intent name="tracing"
+ constrains="sca:implementation.java">
+ <description>
+ Need to figure out some description for this
</description>
</intent>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]