summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-21 20:31:48 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-10-21 20:31:48 +0000
commitc9dbd184c6731e08baf3575a3e66e34993760b23 (patch)
tree7bc31031143ef16e2e6d84f94279976fe6f8e82a /branches/sca-equinox
parent2e3e92d8042285aaa02dd22d288292f1d6952bde (diff)
Format the code
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@706758 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-equinox')
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java26
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java28
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java133
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java14
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java207
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java314
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ProfileIntentProcessor.java2
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/QualifiedIntentProcessor.java4
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java131
-rw-r--r--branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java6
10 files changed, 447 insertions, 418 deletions
diff --git a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
index a91a021c6a..ae6805c832 100644
--- a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
+++ b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
@@ -31,7 +31,6 @@ import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.impl.BindingTypeImpl;
-
/**
* Processor for handling XML models of BindingType meta data definitions
*
@@ -39,30 +38,33 @@ import org.apache.tuscany.sca.policy.impl.BindingTypeImpl;
*/
public class BindingTypeProcessor extends IntentAttachPointTypeProcessor {
- public BindingTypeProcessor(PolicyFactory policyFactory, IntentAttachPointTypeFactory intentAttachPointTypeFactory,
- StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) {
+ public BindingTypeProcessor(PolicyFactory policyFactory,
+ IntentAttachPointTypeFactory intentAttachPointTypeFactory,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
super(policyFactory, intentAttachPointTypeFactory, extensionProcessor, monitor);
}
- public BindingTypeProcessor(FactoryExtensionPoint modelFactories,
- StAXArtifactProcessor<Object> extensionProcessor,
- Monitor monitor) {
- super(modelFactories.getFactory(PolicyFactory.class),
- modelFactories.getFactory(IntentAttachPointTypeFactory.class), extensionProcessor, monitor);
+ public BindingTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
+ super(modelFactories.getFactory(PolicyFactory.class), modelFactories
+ .getFactory(IntentAttachPointTypeFactory.class), extensionProcessor, monitor);
}
public QName getArtifactType() {
return BINDING_TYPE_QNAME;
}
-
+
@Override
- protected IntentAttachPointType resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver) throws ContributionResolveException {
- if ( extnType instanceof BindingTypeImpl ) {
+ protected IntentAttachPointType resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (extnType instanceof BindingTypeImpl) {
BindingTypeImpl bindingType = (BindingTypeImpl)extnType;
return resolver.resolveModel(BindingTypeImpl.class, bindingType);
} else {
return extnType;
}
-
+
}
}
diff --git a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
index a794d7cf91..e405da21c7 100644
--- a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
+++ b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
@@ -31,38 +31,40 @@ import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.impl.ImplementationTypeImpl;
-
/**
* Processor for handling XML models of ImplementationType meta data definitions
*
* @version $Rev$ $Date$
*/
public class ImplementationTypeProcessor extends IntentAttachPointTypeProcessor {
-
- public ImplementationTypeProcessor(PolicyFactory policyFactory, IntentAttachPointTypeFactory intentAttachPointTypeFactory,
- StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) {
+
+ public ImplementationTypeProcessor(PolicyFactory policyFactory,
+ IntentAttachPointTypeFactory intentAttachPointTypeFactory,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
super(policyFactory, intentAttachPointTypeFactory, extensionProcessor, monitor);
}
- public ImplementationTypeProcessor(FactoryExtensionPoint modelFactories,
- StAXArtifactProcessor<Object> extensionProcessor,
- Monitor monitor) {
- super(modelFactories.getFactory(PolicyFactory.class),
- modelFactories.getFactory(IntentAttachPointTypeFactory.class), extensionProcessor, monitor);
+ public ImplementationTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
+ super(modelFactories.getFactory(PolicyFactory.class), modelFactories
+ .getFactory(IntentAttachPointTypeFactory.class), extensionProcessor, monitor);
}
public QName getArtifactType() {
return IMPLEMENTATION_TYPE_QNAME;
}
-
+
@Override
- protected IntentAttachPointType resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver) throws ContributionResolveException {
- if ( extnType instanceof ImplementationTypeImpl ) {
+ protected IntentAttachPointType resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver)
+ throws ContributionResolveException {
+ if (extnType instanceof ImplementationTypeImpl) {
ImplementationTypeImpl implType = (ImplementationTypeImpl)extnType;
return resolver.resolveModel(ImplementationTypeImpl.class, implType);
} else {
return extnType;
}
-
+
}
}
diff --git a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java
index 3ad17c8404..a85ef28572 100644
--- a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java
+++ b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentAttachPointTypeProcessor.java
@@ -37,7 +37,6 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
@@ -45,29 +44,30 @@ import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.impl.BindingTypeImpl;
import org.apache.tuscany.sca.policy.impl.ImplementationTypeImpl;
-
/**
* Processor for handling XML models of ExtensionType meta data definitions
*
* @version $Rev$ $Date$
*/
-abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<IntentAttachPointType>, PolicyConstants {
+abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<IntentAttachPointType>, PolicyConstants {
private IntentAttachPointTypeFactory attachPointTypeFactory;
private PolicyFactory policyFactory;
private Monitor monitor;
-
- protected abstract IntentAttachPointType resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver) throws ContributionResolveException;
- public IntentAttachPointTypeProcessor(PolicyFactory policyFactory,
- IntentAttachPointTypeFactory attachPointTypeFactory,
- StAXArtifactProcessor<Object> extensionProcessor,
- Monitor monitor) {
+ protected abstract IntentAttachPointType resolveExtensionType(IntentAttachPointType extnType, ModelResolver resolver)
+ throws ContributionResolveException;
+
+ public IntentAttachPointTypeProcessor(PolicyFactory policyFactory,
+ IntentAttachPointTypeFactory attachPointTypeFactory,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
this.policyFactory = policyFactory;
this.attachPointTypeFactory = attachPointTypeFactory;
this.monitor = monitor;
}
-
+
/**
* Report a error.
*
@@ -76,41 +76,47 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
* @param model
*/
private void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "policy-xml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
}
-
+
public IntentAttachPointType read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
QName type = getQName(reader, TYPE);
-
- if ( type != null ) {
- if ( type.getLocalPart().startsWith(BINDING) ) {
+
+ if (type != null) {
+ if (type.getLocalPart().startsWith(BINDING)) {
IntentAttachPointType bindingType = attachPointTypeFactory.createBindingType();
bindingType.setName(type);
bindingType.setUnresolved(true);
-
+
readAlwaysProvidedIntents(bindingType, reader);
readMayProvideIntents(bindingType, reader);
- return bindingType;
- } else if ( type.getLocalPart().startsWith(IMPLEMENTATION) ) {
+ return bindingType;
+ } else if (type.getLocalPart().startsWith(IMPLEMENTATION)) {
IntentAttachPointType implType = attachPointTypeFactory.createImplementationType();
implType.setName(type);
implType.setUnresolved(true);
-
+
readAlwaysProvidedIntents(implType, reader);
readMayProvideIntents(implType, reader);
return implType;
} else {
- error("UnrecognizedIntentAttachPointType", reader, type);
+ error("UnrecognizedIntentAttachPointType", reader, type);
//throw new ContributionReadException("Unrecognized IntentAttachPointType - " + type);
}
} else {
- error("RequiredAttributeMissing", reader, TYPE);
+ error("RequiredAttributeMissing", reader, TYPE);
//throw new ContributionReadException("Required attribute '" + TYPE +
- //"' missing from BindingType Definition");
- }
+ //"' missing from BindingType Definition");
+ }
return null;
}
@@ -126,7 +132,7 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
}
}
}
-
+
private void readMayProvideIntents(IntentAttachPointType extnType, XMLStreamReader reader) {
String value = reader.getAttributeValue(null, MAY_PROVIDE);
if (value != null) {
@@ -139,61 +145,64 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
}
}
}
-
- public void write(IntentAttachPointType extnType, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ public void write(IntentAttachPointType extnType, XMLStreamWriter writer) throws ContributionWriteException,
+ XMLStreamException {
// Write an <sca:bindingType or sca:implementationType>
- if ( extnType instanceof BindingTypeImpl ) {
+ if (extnType instanceof BindingTypeImpl) {
writer.writeStartElement(SCA10_NS, BINDING_TYPE);
- } else if ( extnType instanceof ImplementationTypeImpl ) {
+ } else if (extnType instanceof ImplementationTypeImpl) {
writer.writeStartElement(SCA10_NS, IMPLEMENTATION_TYPE);
}
-
+
writeAlwaysProvidesIntentsAttribute(extnType, writer);
writeMayProvideIntentsAttribute(extnType, writer);
-
+
writer.writeEndElement();
}
-
- private void writeMayProvideIntentsAttribute(IntentAttachPointType extnType, XMLStreamWriter writer) throws XMLStreamException {
- StringBuffer sb = new StringBuffer();
- for ( Intent intent : extnType.getMayProvideIntents() ) {
+
+ private void writeMayProvideIntentsAttribute(IntentAttachPointType 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 ) {
+
+ if (sb.length() > 0) {
writer.writeAttribute(MAY_PROVIDE, sb.toString());
}
}
-
- private void writeAlwaysProvidesIntentsAttribute(IntentAttachPointType extnType, XMLStreamWriter writer) throws XMLStreamException {
- StringBuffer sb = new StringBuffer();
- for ( Intent intent : extnType.getAlwaysProvidedIntents() ) {
+
+ private void writeAlwaysProvidesIntentsAttribute(IntentAttachPointType 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 ) {
+
+ if (sb.length() > 0) {
writer.writeAttribute(ALWAYS_PROVIDES, sb.toString());
-
+
}
}
-
+
public void resolve(IntentAttachPointType extnType, ModelResolver resolver) throws ContributionResolveException {
-
- if (extnType != null && extnType.isUnresolved()) {
- resolveAlwaysProvidedIntents(extnType, resolver);
+
+ if (extnType != null && extnType.isUnresolved()) {
+ resolveAlwaysProvidedIntents(extnType, resolver);
resolveMayProvideIntents(extnType, resolver);
extnType.setUnresolved(false);
//resolveExtensionType(extnType, resolver);
}
}
- private void resolveAlwaysProvidedIntents(IntentAttachPointType extensionType,
- ModelResolver resolver) throws ContributionResolveException {
+ private void resolveAlwaysProvidedIntents(IntentAttachPointType extensionType, ModelResolver resolver)
+ throws ContributionResolveException {
if (extensionType != null) {
// resolve all provided intents
List<Intent> alwaysProvided = new ArrayList<Intent>();
@@ -203,10 +212,10 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
if (!providedIntent.isUnresolved()) {
alwaysProvided.add(providedIntent);
} else {
- error("AlwaysProvidedIntentNotFound", resolver, providedIntent, extensionType);
+ error("AlwaysProvidedIntentNotFound", resolver, providedIntent, extensionType);
//throw new ContributionResolveException("Always Provided Intent - " + providedIntent
- //+ " not found for ExtensionType "
- //+ extensionType);
+ //+ " not found for ExtensionType "
+ //+ extensionType);
}
} else {
alwaysProvided.add(providedIntent);
@@ -216,9 +225,9 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
extensionType.getAlwaysProvidedIntents().addAll(alwaysProvided);
}
}
-
- private void resolveMayProvideIntents(IntentAttachPointType extensionType,
- ModelResolver resolver) throws ContributionResolveException {
+
+ private void resolveMayProvideIntents(IntentAttachPointType extensionType, ModelResolver resolver)
+ throws ContributionResolveException {
if (extensionType != null) {
// resolve all provided intents
List<Intent> mayProvide = new ArrayList<Intent>();
@@ -228,10 +237,10 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
if (!providedIntent.isUnresolved()) {
mayProvide.add(providedIntent);
} else {
- error("MayProvideIntentNotFound", resolver, providedIntent, extensionType);
+ error("MayProvideIntentNotFound", resolver, providedIntent, extensionType);
//throw new ContributionResolveException("May Provide Intent - " + providedIntent
- //+ " not found for ExtensionType "
- //+ extensionType);
+ //+ " not found for ExtensionType "
+ //+ extensionType);
}
} else {
mayProvide.add(providedIntent);
@@ -241,7 +250,7 @@ abstract class IntentAttachPointTypeProcessor extends BaseStAXArtifactProcessor
extensionType.getMayProvideIntents().addAll(mayProvide);
}
}
-
+
public Class<IntentAttachPointType> getModelType() {
return IntentAttachPointType.class;
}
diff --git a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
index 3f1008e9a8..3f69df05d8 100644
--- a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
+++ b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
@@ -47,7 +47,7 @@ public interface PolicyConstants {
String REQUIRES = "requires";
String EXCLUDES = "excludes";
String DEFAULT = "default";
-
+
String ALWAYS_PROVIDES = "alwaysProvides";
String MAY_PROVIDE = "mayProvide";
String TYPE = "type";
@@ -57,19 +57,15 @@ public interface PolicyConstants {
QName BINDING_TYPE_QNAME = new QName(SCA10_NS, BINDING_TYPE);
String BINDING = "binding";
String IMPLEMENTATION = "implementation";
-
+
QName POLICY_INTENT_QNAME = new QName(SCA10_NS, INTENT);
QName POLICY_SET_QNAME = new QName(SCA10_NS, POLICY_SET);
- QName POLICY_INTENT_MAP_QNAME = new QName(SCA10_NS, INTENT_MAP);
+ QName POLICY_INTENT_MAP_QNAME = new QName(SCA10_NS, INTENT_MAP);
QName SCA_DEFINITIONS_QNAME = new QName(SCA10_NS, SCA_DEFINITIONS);
QName DESCRIPTION_QNAME = new QName(SCA10_NS, DESCRIPTION);
QName POLICY_INTENT_MAP_QUALIFIER_QNAME = new QName(SCA10_NS, INTENT_MAP_QUALIFIER);
QName POLICY_SET_REFERENCE_QNAME = new QName(SCA10_NS, POLICY_SET_REFERENCE);
-
+
String QUALIFIED_INTENT_CONSTRAINS_ERROR = " - Qualified Intents must not specify 'constrains' attribute";
-
-
-
-
-
+
}
diff --git a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
index 78a59a7276..03cd635596 100644
--- a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
+++ b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyIntentProcessor.java
@@ -41,7 +41,6 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.ProfileIntent;
@@ -52,7 +51,8 @@ import org.apache.tuscany.sca.policy.QualifiedIntent;
*
* @version $Rev$ $Date$
*/
-abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<T>, PolicyConstants {
+abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<T>, PolicyConstants {
private PolicyFactory policyFactory;
private Monitor monitor;
@@ -61,12 +61,12 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.monitor = monitor;
}
-
+
public PolicyIntentProcessor(PolicyFactory policyFactory, Monitor monitor) {
this.policyFactory = policyFactory;
this.monitor = monitor;
}
-
+
/**
* Report a error.
*
@@ -75,10 +75,16 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
* @param model
*/
private void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "policy-xml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
}
public T read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
@@ -88,31 +94,30 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
error("IntentNameMissing", reader);
return (T)policyIntent;
}
-
+
// Read an <sca:intent>
if (reader.getAttributeValue(null, REQUIRES) != null) {
policyIntent = policyFactory.createProfileIntent();
- } else if ( policyIntentName != null && policyIntentName.indexOf(QUALIFIER) != -1) {
+ } else if (policyIntentName != null && policyIntentName.indexOf(QUALIFIER) != -1) {
policyIntent = policyFactory.createQualifiedIntent();
-
+
int qualifierIndex = policyIntentName.lastIndexOf(QUALIFIER);
Intent qualifiableIntent = policyFactory.createIntent();
qualifiableIntent.setUnresolved(true);
qualifiableIntent.setName(new QName(policyIntentName.substring(0, qualifierIndex)));
-
+
((QualifiedIntent)policyIntent).setQualifiableIntent(qualifiableIntent);
} else {
policyIntent = policyFactory.createIntent();
}
policyIntent.setName(new QName(policyIntentName));
-
- if ( policyIntent instanceof ProfileIntent ) {
+
+ if (policyIntent instanceof ProfileIntent) {
readRequiredIntents((ProfileIntent)policyIntent, reader);
- }
- else {
+ } else {
readExcludedIntents(policyIntent, reader);
}
-
+
readConstrainedArtifacts(policyIntent, reader);
int event = reader.getEventType();
@@ -120,7 +125,7 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
while (reader.hasNext()) {
event = reader.getEventType();
switch (event) {
- case START_ELEMENT : {
+ case START_ELEMENT: {
name = reader.getName();
if (DESCRIPTION_QNAME.equals(name)) {
policyIntent.setDescription(reader.getElementText());
@@ -131,7 +136,7 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
if (event == END_ELEMENT && POLICY_INTENT_QNAME.equals(reader.getName())) {
break;
}
-
+
//Read the next element
if (reader.hasNext()) {
reader.next();
@@ -139,17 +144,16 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
}
return (T)policyIntent;
}
-
+
public void write(T policyIntent, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
// Write an <sca:intent>
writer.writeStartElement(PolicyConstants.SCA10_NS, INTENT);
writer.writeNamespace(policyIntent.getName().getPrefix(), policyIntent.getName().getNamespaceURI());
- writer.writeAttribute(PolicyConstants.NAME,
- policyIntent.getName().getPrefix() + COLON + policyIntent.getName().getLocalPart());
+ writer.writeAttribute(PolicyConstants.NAME, policyIntent.getName().getPrefix() + COLON
+ + policyIntent.getName().getLocalPart());
if (policyIntent instanceof ProfileIntent) {
ProfileIntent profileIntent = (ProfileIntent)policyIntent;
- if (profileIntent.getRequiredIntents() != null &&
- profileIntent.getRequiredIntents().size() > 0) {
+ if (profileIntent.getRequiredIntents() != null && profileIntent.getRequiredIntents().size() > 0) {
StringBuffer sb = new StringBuffer();
for (Intent requiredIntents : profileIntent.getRequiredIntents()) {
sb.append(requiredIntents.getName());
@@ -157,10 +161,8 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
}
writer.writeAttribute(PolicyConstants.REQUIRES, sb.toString());
}
- }
- else {
- if (policyIntent.getExcludedIntents() != null &&
- policyIntent.getExcludedIntents().size() > 0) {
+ } else {
+ if (policyIntent.getExcludedIntents() != null && policyIntent.getExcludedIntents().size() > 0) {
StringBuffer sb = new StringBuffer();
for (Intent excludedIntents : policyIntent.getExcludedIntents()) {
sb.append(excludedIntents.getName());
@@ -169,10 +171,9 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
writer.writeAttribute(PolicyConstants.EXCLUDES, sb.toString());
}
}
-
- if (!(policyIntent instanceof QualifiedIntent) ) {
- if (policyIntent.getConstrains() != null &&
- policyIntent.getConstrains().size() > 0) {
+
+ if (!(policyIntent instanceof QualifiedIntent)) {
+ if (policyIntent.getConstrains() != null && policyIntent.getConstrains().size() > 0) {
StringBuffer sb = new StringBuffer();
for (QName contrainedArtifact : policyIntent.getConstrains()) {
sb.append(contrainedArtifact.toString());
@@ -180,68 +181,68 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
}
writer.writeAttribute(CONSTRAINS, sb.toString());
} else {
- error("ContrainsAttributeMissing", policyIntent, policyIntent.getName());
+ error("ContrainsAttributeMissing", policyIntent, policyIntent.getName());
//throw new ContributionWriteException("Contrains attribute missing from " +
- //"Policy Intent Definition" + policyIntent.getName());
+ //"Policy Intent Definition" + policyIntent.getName());
}
}
-
- if ( policyIntent.getDescription() != null && policyIntent.getDescription().length() > 0) {
+
+ if (policyIntent.getDescription() != null && policyIntent.getDescription().length() > 0) {
writer.writeStartElement(PolicyConstants.SCA10_NS, DESCRIPTION);
writer.writeCData(policyIntent.getDescription());
writer.writeEndElement();
}
-
+
writer.writeEndElement();
}
//FIXME This method is never used
-// private Intent resolveRequiredIntents(ProfileIntent policyIntent, ModelResolver resolver) throws ContributionResolveException {
-// boolean isUnresolved = false;
-// //FIXME: Need to check for cyclic references first i.e an A requiring B and then B requiring A...
-// if (policyIntent != null && policyIntent.isUnresolved()) {
-//
-// //resolve all required intents
-// List<Intent> requiredIntents = new ArrayList<Intent>();
-// for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
-// if ( requiredIntent.isUnresolved() ) {
-// //policyIntent.getRequiredIntents().remove(requiredIntent);
-// requiredIntent = resolver.resolveModel(Intent.class, requiredIntent);
-// requiredIntents.add(requiredIntent);
-// if (requiredIntent.isUnresolved()) {
-// isUnresolved = true;
-// }
-// }
-// }
-// policyIntent.getRequiredIntents().clear();
-// policyIntent.getRequiredIntents().addAll(requiredIntents);
-// }
-// policyIntent.setUnresolved(isUnresolved);
-//
-// return policyIntent;
-// }
-
+ // private Intent resolveRequiredIntents(ProfileIntent policyIntent, ModelResolver resolver) throws ContributionResolveException {
+ // boolean isUnresolved = false;
+ // //FIXME: Need to check for cyclic references first i.e an A requiring B and then B requiring A...
+ // if (policyIntent != null && policyIntent.isUnresolved()) {
+ //
+ // //resolve all required intents
+ // List<Intent> requiredIntents = new ArrayList<Intent>();
+ // for (Intent requiredIntent : policyIntent.getRequiredIntents()) {
+ // if ( requiredIntent.isUnresolved() ) {
+ // //policyIntent.getRequiredIntents().remove(requiredIntent);
+ // requiredIntent = resolver.resolveModel(Intent.class, requiredIntent);
+ // requiredIntents.add(requiredIntent);
+ // if (requiredIntent.isUnresolved()) {
+ // isUnresolved = true;
+ // }
+ // }
+ // }
+ // policyIntent.getRequiredIntents().clear();
+ // policyIntent.getRequiredIntents().addAll(requiredIntents);
+ // }
+ // policyIntent.setUnresolved(isUnresolved);
+ //
+ // return policyIntent;
+ // }
+
//FIXME This method is never used
-// private Intent resolveQualifiableIntent(QualifiedIntent policyIntent, ModelResolver resolver) throws ContributionResolveException {
-// boolean isUnresolved = false;
-//
-// if (policyIntent != null && policyIntent.isUnresolved()) {
-// //resolve the qualifiable intent
-// Intent qualifiableIntent =
-// resolver.resolveModel(Intent.class, policyIntent.getQualifiableIntent());
-// policyIntent.setQualifiableIntent(qualifiableIntent);
-// isUnresolved = qualifiableIntent.isUnresolved();
-// }
-// policyIntent.setUnresolved(isUnresolved);
-//
-// return policyIntent;
-// }
-
+ // private Intent resolveQualifiableIntent(QualifiedIntent policyIntent, ModelResolver resolver) throws ContributionResolveException {
+ // boolean isUnresolved = false;
+ //
+ // if (policyIntent != null && policyIntent.isUnresolved()) {
+ // //resolve the qualifiable intent
+ // Intent qualifiableIntent =
+ // resolver.resolveModel(Intent.class, policyIntent.getQualifiableIntent());
+ // policyIntent.setQualifiableIntent(qualifiableIntent);
+ // isUnresolved = qualifiableIntent.isUnresolved();
+ // }
+ // policyIntent.setUnresolved(isUnresolved);
+ //
+ // return policyIntent;
+ // }
+
private void resolveContrainedArtifacts(Intent policyIntent, ModelResolver resolver) {
//FIXME : need to figure out this resolution.
policyIntent.setUnresolved(false);
}
-
+
private void resolveProfileIntent(ProfileIntent policyIntent, ModelResolver resolver)
throws ContributionResolveException {
// FIXME: Need to check for cyclic references first i.e an A requiring B
@@ -264,14 +265,14 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
resolveDependent(resolvedRequiredIntent, resolver);
}
}
-
+
if (!resolvedRequiredIntent.isUnresolved()) {
requiredIntents.add(resolvedRequiredIntent);
} else {
- error("RequiredIntentNotFound", resolver, requiredIntent, policyIntent);
- return;
+ error("RequiredIntentNotFound", resolver, requiredIntent, policyIntent);
+ return;
//throw new ContributionResolveException("Required Intent - " + requiredIntent
- //+ " not found for ProfileIntent " + policyIntent);
+ //+ " not found for ProfileIntent " + policyIntent);
}
} else {
requiredIntents.add(requiredIntent);
@@ -297,40 +298,39 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
resolveDependent(resolvedQualifiableIntent, resolver);
}
}
-
+
if (!resolvedQualifiableIntent.isUnresolved()) {
policyIntent.setQualifiableIntent(resolvedQualifiableIntent);
} else {
- error("QualifiableIntentNotFound", resolver, qualifiableIntent, policyIntent);
+ error("QualifiableIntentNotFound", resolver, qualifiableIntent, policyIntent);
//throw new ContributionResolveException("Qualifiable Intent - " + qualifiableIntent
- //+ " not found for QualifiedIntent " + policyIntent);
- }
+ //+ " not found for QualifiedIntent " + policyIntent);
+ }
}
}
}
-
+
public void resolveDependent(Intent policyIntent, ModelResolver resolver) throws ContributionResolveException {
if (policyIntent instanceof ProfileIntent)
resolveProfileIntent((ProfileIntent)policyIntent, resolver);
-
+
if (policyIntent instanceof QualifiedIntent)
resolveQualifiedIntent((QualifiedIntent)policyIntent, resolver);
-
+
resolveContrainedArtifacts(policyIntent, resolver);
}
-
+
public void resolve(T policyIntent, ModelResolver resolver) throws ContributionResolveException {
if (policyIntent instanceof ProfileIntent) {
resolveProfileIntent((ProfileIntent)policyIntent, resolver);
- }
- else {
+ } else {
resolveExcludedIntents(policyIntent, resolver);
}
if (policyIntent instanceof QualifiedIntent) {
resolveQualifiedIntent((QualifiedIntent)policyIntent, resolver);
}
-
+
resolveContrainedArtifacts(policyIntent, resolver);
/* This is too late in the processing
@@ -339,15 +339,18 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
}
*/
}
-
+
public QName getArtifactType() {
return POLICY_INTENT_QNAME;
}
-
+
private void readConstrainedArtifacts(Intent policyIntent, XMLStreamReader reader) throws ContributionReadException {
String value = reader.getAttributeValue(null, CONSTRAINS);
- if ( policyIntent instanceof QualifiedIntent && value != null) {
- error("ErrorInPolicyIntentDefinition", policyIntent, policyIntent.getName(), QUALIFIED_INTENT_CONSTRAINS_ERROR);
+ if (policyIntent instanceof QualifiedIntent && value != null) {
+ error("ErrorInPolicyIntentDefinition",
+ policyIntent,
+ policyIntent.getName(),
+ QUALIFIED_INTENT_CONSTRAINS_ERROR);
//String errorMsg = "Error in PolicyIntent Definition - " + policyIntent.getName() + QUALIFIED_INTENT_CONSTRAINS_ERROR;
//throw new ContributionReadException(errorMsg);
} else {
@@ -360,7 +363,7 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
}
}
}
-
+
private void readRequiredIntents(ProfileIntent policyIntent, XMLStreamReader reader) {
String value = reader.getAttributeValue(null, REQUIRES);
if (value != null) {
@@ -396,14 +399,14 @@ abstract class PolicyIntentProcessor<T extends Intent> extends BaseStAXArtifactP
List<Intent> excludedIntents = new ArrayList<Intent>();
for (Intent excludedIntent : policyIntent.getExcludedIntents()) {
if (excludedIntent.isUnresolved()) {
- Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent);
+ Intent resolvedExcludedIntent = resolver.resolveModel(Intent.class, excludedIntent);
if (!resolvedExcludedIntent.isUnresolved()) {
excludedIntents.add(resolvedExcludedIntent);
} else {
- error("ExcludedIntentNotFound", resolver, excludedIntent, policyIntent);
- return;
+ error("ExcludedIntentNotFound", resolver, excludedIntent, policyIntent);
+ return;
//throw new ContributionResolveException("Excluded Intent " + excludedIntent
- //+ " not found for intent " + policyIntent);
+ //+ " not found for intent " + policyIntent);
}
} else {
excludedIntents.add(excludedIntent);
diff --git a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
index cf99b681ef..93a8433d65 100644
--- a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
+++ b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
@@ -46,40 +46,39 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.monitor.impl.ProblemImpl;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
-
/**
* Processor for handling XML models of PolicySet definitions
*
* @version $Rev$ $Date$
*/
-public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<PolicySet>, PolicyConstants {
+public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<PolicySet>,
+ PolicyConstants {
private PolicyFactory policyFactory;
private StAXArtifactProcessor<Object> extensionProcessor;
private XPathFactory xpathFactory = XPathFactory.newInstance();
private Monitor monitor;
-
- public PolicySetProcessor(FactoryExtensionPoint modelFactories,
- StAXArtifactProcessor<Object> extensionProcessor,
- Monitor monitor) {
+
+ public PolicySetProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.extensionProcessor = extensionProcessor;
this.monitor = monitor;
}
-
- public PolicySetProcessor(PolicyFactory policyFactory,
- StAXArtifactProcessor<Object> extensionProcessor,
- Monitor monitor) {
+
+ public PolicySetProcessor(PolicyFactory policyFactory,
+ StAXArtifactProcessor<Object> extensionProcessor,
+ Monitor monitor) {
this.policyFactory = policyFactory;
this.extensionProcessor = extensionProcessor;
this.monitor = monitor;
}
-
+
/**
* Report a exception.
*
@@ -87,13 +86,19 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
* @param message
* @param model
*/
- private void error(String message, Object model, Exception ex) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "policy-xml-validation-messages", Severity.ERROR, model, message, ex);
- monitor.problem(problem);
- }
- }
-
+ private void error(String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
/**
* Report a error.
*
@@ -101,16 +106,22 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
* @param message
* @param model
*/
- private void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "policy-xml-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
- }
+ private void error(String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "policy-xml-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
public PolicySet read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
PolicySet policySet = null;
-
+
String policySetName = reader.getAttributeValue(null, NAME);
String appliesTo = reader.getAttributeValue(null, APPLIES_TO);
if (policySetName == null || appliesTo == null) {
@@ -120,27 +131,27 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
error("PolicySetAppliesToMissing", reader);
return policySet;
}
-
+
policySet = policyFactory.createPolicySet();
policySet.setName(new QName(policySetName));
String alwaysAppliesTo = reader.getAttributeValue(TUSCANY_NS, ALWAYS_APPLIES_TO);
-
+
//TODO: with 1.0 version of specs the applies to xpath is given related to the immediate
//parent whereas the runtime evaluates the xpath aginst the composite element. What the runtime
//is doing is what the future version of the specs could be tending towards. When that happens
//this 'if' must be deleted
- if ( appliesTo != null && !appliesTo.startsWith("/") ) {
+ if (appliesTo != null && !appliesTo.startsWith("/")) {
appliesTo = "//" + appliesTo;
}
-
- if ( alwaysAppliesTo != null && !alwaysAppliesTo.startsWith("/") ) {
+
+ if (alwaysAppliesTo != null && !alwaysAppliesTo.startsWith("/")) {
alwaysAppliesTo = "//" + alwaysAppliesTo;
}
-
+
policySet.setAppliesTo(appliesTo);
policySet.setAlwaysAppliesTo(alwaysAppliesTo);
- XPath path = xpathFactory.newXPath();
+ XPath path = xpathFactory.newXPath();
path.setNamespaceContext(reader.getNamespaceContext());
try {
if (appliesTo != null) {
@@ -150,27 +161,27 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
policySet.setAlwaysAppliesToXPathExpression(path.compile(alwaysAppliesTo));
}
} catch (XPathExpressionException e) {
- ContributionReadException ce = new ContributionReadException(e);
- error("ContributionReadException", policySet, ce);
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", policySet, ce);
//throw ce;
- }
-
+ }
+
readProvidedIntents(policySet, reader);
-
+
int event = reader.getEventType();
QName name = null;
reader.next();
while (reader.hasNext()) {
event = reader.getEventType();
switch (event) {
- case START_ELEMENT : {
+ case START_ELEMENT: {
name = reader.getName();
- if ( POLICY_INTENT_MAP_QNAME.equals(name) ) {
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
Intent mappedIntent = policyFactory.createIntent();
String provides = reader.getAttributeValue(null, PROVIDES);
if (provides != null) {
mappedIntent.setName(getQName(reader, PROVIDES));
- if ( policySet.getProvidedIntents().contains(mappedIntent) ) {
+ if (policySet.getProvidedIntents().contains(mappedIntent)) {
readIntentMap(reader, policySet, mappedIntent);
} else {
error("IntentNotSpecified", policySet, policySetName);
@@ -179,7 +190,7 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
} else {
error("IntentMapProvidesMissing", reader, policySetName);
}
- } else if ( POLICY_SET_REFERENCE_QNAME.equals(name) ) {
+ } else if (POLICY_SET_REFERENCE_QNAME.equals(name)) {
PolicySet referredPolicySet = policyFactory.createPolicySet();
String referencename = reader.getAttributeValue(null, NAME);
if (referencename != null) {
@@ -189,24 +200,24 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
error("PolicySetReferenceNameMissing", reader, policySetName);
}
} /*else if ( WS_POLICY_QNAME.equals(name) ) {
- OMElement policyElement = loadElement(reader);
- org.apache.neethi.Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
- policySet.getPolicies().add(wsPolicy);
- } */ else {
+ OMElement policyElement = loadElement(reader);
+ org.apache.neethi.Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
+ policySet.getPolicies().add(wsPolicy);
+ } */else {
Object extension = extensionProcessor.read(reader);
- if ( extension != null ) {
+ if (extension != null) {
policySet.getPolicies().add(extension);
}
}
break;
}
}
- if ( event == END_ELEMENT ) {
- if ( POLICY_SET_QNAME.equals(reader.getName()) ) {
+ if (event == END_ELEMENT) {
+ if (POLICY_SET_QNAME.equals(reader.getName())) {
break;
- }
+ }
}
-
+
//Read the next element
if (reader.hasNext()) {
reader.next();
@@ -214,72 +225,76 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
}
return policySet;
}
-
-
- public void readIntentMap(XMLStreamReader reader, PolicySet policySet, Intent mappedIntent) throws ContributionReadException {
+
+ public void readIntentMap(XMLStreamReader reader, PolicySet policySet, Intent mappedIntent)
+ throws ContributionReadException {
QName name = reader.getName();
Map<Intent, List<Object>> mappedPolicies = policySet.getMappedPolicies();
- if ( POLICY_INTENT_MAP_QNAME.equals(name) ) {
+ if (POLICY_INTENT_MAP_QNAME.equals(name)) {
//Intent mappedIntent = policyFactory.createIntent();
//mappedIntent.setName(getQName(reader, PROVIDES));
String defaultQualifier = getString(reader, DEFAULT);
-
+
String qualifierName = null;
String qualfiedIntentName = null;
Intent qualifiedIntent = null;
-
+
int event = reader.getEventType();
try {
reader.next();
while (reader.hasNext()) {
event = reader.getEventType();
switch (event) {
- case START_ELEMENT : {
+ case START_ELEMENT: {
name = reader.getName();
- if ( POLICY_INTENT_MAP_QUALIFIER_QNAME.equals(name)) {
- qualifierName = getString(reader, NAME);
+ if (POLICY_INTENT_MAP_QUALIFIER_QNAME.equals(name)) {
+ qualifierName = getString(reader, NAME);
if (qualifierName != null) {
- qualfiedIntentName = mappedIntent.getName().getLocalPart() +
- QUALIFIER + qualifierName;
+ qualfiedIntentName =
+ mappedIntent.getName().getLocalPart() + QUALIFIER + qualifierName;
qualifiedIntent = policyFactory.createIntent();
qualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(),
- qualfiedIntentName));
+ qualfiedIntentName));
} else {
error("QualifierNameMissing", reader, policySet.getName());
}
- } else if ( POLICY_INTENT_MAP_QNAME.equals(name) ) {
+ } else if (POLICY_INTENT_MAP_QNAME.equals(name)) {
QName providedIntent = getQName(reader, PROVIDES);
- if ( qualifierName.equals(providedIntent.getLocalPart()) ) {
+ if (qualifierName.equals(providedIntent.getLocalPart())) {
readIntentMap(reader, policySet, qualifiedIntent);
} else {
- error("IntentMapDoesNotMatch", providedIntent, providedIntent, qualifierName, policySet);
+ error("IntentMapDoesNotMatch",
+ providedIntent,
+ providedIntent,
+ qualifierName,
+ policySet);
//throw new ContributionReadException("Intent provided by IntentMap " +
- //providedIntent + " does not match parent qualifier " + qualifierName +
- //" in policyset - " + policySet);
+ //providedIntent + " does not match parent qualifier " + qualifierName +
+ //" in policyset - " + policySet);
}
}/* else if ( WS_POLICY_QNAME.equals(name) ) {
- OMElement policyElement = loadElement(reader);
- Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
- policySet.getPolicies().add(wsPolicy);
-
- List<Object> policyList = mappedPolicies.get(qualifiedIntent);
- if ( policyList == null ) {
- policyList = new ArrayList<Object>();
- mappedPolicies.put(qualifiedIntent, policyList);
-
- if (qualifierName.equals(defaultQualifier)) {
- mappedPolicies.put(mappedIntent, policyList);
- }
- }
- policyList.add((Policy)wsPolicy);
- }*/ else {
+ OMElement policyElement = loadElement(reader);
+ Policy wsPolicy = PolicyEngine.getPolicy(policyElement);
+ policySet.getPolicies().add(wsPolicy);
+
+ List<Object> policyList = mappedPolicies.get(qualifiedIntent);
+ if ( policyList == null ) {
+ policyList = new ArrayList<Object>();
+ mappedPolicies.put(qualifiedIntent, policyList);
+
+ if (qualifierName.equals(defaultQualifier)) {
+ mappedPolicies.put(mappedIntent, policyList);
+ }
+ }
+ policyList.add((Policy)wsPolicy);
+ }*/else {
Object extension = extensionProcessor.read(reader);
- if ( extension != null && qualifiedIntent != null) {
+ if (extension != null && qualifiedIntent != null) {
List<Object> policyList = mappedPolicies.get(qualifiedIntent);
- if ( policyList == null ) {
+ if (policyList == null) {
policyList = new ArrayList<Object>();
mappedPolicies.put(qualifiedIntent, policyList);
-
+
if (qualifierName.equals(defaultQualifier)) {
mappedPolicies.put(mappedIntent, policyList);
}
@@ -289,28 +304,29 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
}
break;
}
- case END_ELEMENT : {
- if ( POLICY_INTENT_MAP_QNAME.equals(reader.getName()) ) {
- if ( defaultQualifier != null ) {
- String qualifiedIntentName = mappedIntent.getName().getLocalPart() + QUALIFIER + defaultQualifier;
+ case END_ELEMENT: {
+ if (POLICY_INTENT_MAP_QNAME.equals(reader.getName())) {
+ if (defaultQualifier != null) {
+ String qualifiedIntentName =
+ mappedIntent.getName().getLocalPart() + QUALIFIER + defaultQualifier;
Intent defaultQualifiedIntent = policyFactory.createIntent();
defaultQualifiedIntent.setName(new QName(mappedIntent.getName().getNamespaceURI(),
qualifiedIntentName));
List<Object> policyList = mappedPolicies.get(defaultQualifiedIntent);
- if ( policyList != null ) {
+ if (policyList != null) {
mappedPolicies.put(mappedIntent, policyList);
} else {
- error("UnableToMapPolicies", mappedPolicies, mappedIntent, policySet);
+ error("UnableToMapPolicies", mappedPolicies, mappedIntent, policySet);
//throw new ContributionReadException("Unable to map policies for default qualifier in IntentMap for - " +
- //mappedIntent + " in policy set - " + policySet);
+ //mappedIntent + " in policy set - " + policySet);
}
defaultQualifier = null;
}
- }
+ }
break;
}
}
- if ( event == END_ELEMENT && POLICY_INTENT_MAP_QNAME.equals(reader.getName()) ) {
+ if (event == END_ELEMENT && POLICY_INTENT_MAP_QNAME.equals(reader.getName())) {
break;
}
//Read the next element
@@ -318,29 +334,29 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
reader.next();
}
}
- } catch (XMLStreamException e) {
- ContributionReadException ce = new ContributionReadException(e);
- error("ContributionReadException", reader, ce);
+ } catch (XMLStreamException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", reader, ce);
throw ce;
}
}
}
-
- public void write(PolicySet policySet, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
+
+ public void write(PolicySet policySet, XMLStreamWriter writer) throws ContributionWriteException,
+ XMLStreamException {
// Write an <sca:policySet>
writer.writeStartElement(SCA10_NS, POLICY_SET);
writer.writeNamespace(policySet.getName().getPrefix(), policySet.getName().getNamespaceURI());
- writer.writeAttribute(NAME,
- policySet.getName().getPrefix() + COLON + policySet.getName().getLocalPart());
+ writer.writeAttribute(NAME, policySet.getName().getPrefix() + COLON + policySet.getName().getLocalPart());
writer.writeAttribute(APPLIES_TO, policySet.getAppliesTo());
writer.writeAttribute(TUSCANY_NS, ALWAYS_APPLIES_TO, policySet.getAlwaysAppliesTo());
-
+
writeProvidedIntents(policySet, writer);
-
+
writer.writeEndElement();
}
-
+
private void readProvidedIntents(PolicySet policySet, XMLStreamReader reader) {
String value = reader.getAttributeValue(null, PROVIDES);
if (value != null) {
@@ -353,10 +369,9 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
}
}
}
-
+
private void writeProvidedIntents(PolicySet policySet, XMLStreamWriter writer) throws XMLStreamException {
- if (policySet.getProvidedIntents() != null &&
- policySet.getProvidedIntents().size() > 0) {
+ if (policySet.getProvidedIntents() != null && policySet.getProvidedIntents().size() > 0) {
StringBuffer sb = new StringBuffer();
for (Intent providedIntents : policySet.getProvidedIntents()) {
sb.append(providedIntents.getName());
@@ -366,30 +381,29 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
}
}
- private void resolvePolicies(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
- boolean unresolved = false;
- if (policySet != null) {
- for ( Object o : policySet.getPolicies() ) {
- extensionProcessor.resolve(o, resolver);
- /*if ( o instanceof Policy && ((Policy)o).isUnresolved() ) {
- unresolved = true;
- }*/
- }
- policySet.setUnresolved(unresolved);
- }
- }
-
-
-
+ private void resolvePolicies(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
+ boolean unresolved = false;
+ if (policySet != null) {
+ for (Object o : policySet.getPolicies()) {
+ extensionProcessor.resolve(o, resolver);
+ /*if ( o instanceof Policy && ((Policy)o).isUnresolved() ) {
+ unresolved = true;
+ }*/
+ }
+ policySet.setUnresolved(unresolved);
+ }
+ }
+
public QName getArtifactType() {
return POLICY_SET_QNAME;
}
-
+
public Class<PolicySet> getModelType() {
return PolicySet.class;
}
-
- private void resolveProvidedIntents(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
+
+ private void resolveProvidedIntents(PolicySet policySet, ModelResolver resolver)
+ throws ContributionResolveException {
if (policySet != null) {
//resolve all provided intents
List<Intent> providedIntents = new ArrayList<Intent>();
@@ -399,10 +413,10 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
if (!resolvedProvidedIntent.isUnresolved()) {
providedIntents.add(resolvedProvidedIntent);
} else {
- error("ProvidedIntentNotFound", policySet, providedIntent, policySet);
- return;
+ error("ProvidedIntentNotFound", policySet, providedIntent, policySet);
+ return;
//throw new ContributionResolveException("Provided Intent - " + providedIntent
- //+ " not found for PolicySet " + policySet);
+ //+ " not found for PolicySet " + policySet);
}
} else {
providedIntents.add(providedIntent);
@@ -411,9 +425,10 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
policySet.getProvidedIntents().clear();
policySet.getProvidedIntents().addAll(providedIntents);
}
- }
-
- private void resolveIntentsInMappedPolicies(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
+ }
+
+ private void resolveIntentsInMappedPolicies(PolicySet policySet, ModelResolver resolver)
+ throws ContributionResolveException {
Map<Intent, List<Object>> mappedPolicies = new Hashtable<Intent, List<Object>>();
for (Map.Entry<Intent, List<Object>> entry : policySet.getMappedPolicies().entrySet()) {
Intent mappedIntent = entry.getKey();
@@ -422,10 +437,10 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
if (!resolvedMappedIntent.isUnresolved()) {
mappedPolicies.put(resolvedMappedIntent, entry.getValue());
} else {
- error("MappedIntentNotFound", policySet, mappedIntent, policySet);
- return;
+ error("MappedIntentNotFound", policySet, mappedIntent, policySet);
+ return;
//throw new ContributionResolveException("Mapped Intent - " + mappedIntent
- //+ " not found for PolicySet " + policySet);
+ //+ " not found for PolicySet " + policySet);
}
} else {
mappedPolicies.put(mappedIntent, entry.getValue());
@@ -435,9 +450,10 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
policySet.getMappedPolicies().clear();
policySet.getMappedPolicies().putAll(mappedPolicies);
}
-
- private void resolveReferredPolicySets(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
-
+
+ private void resolveReferredPolicySets(PolicySet policySet, ModelResolver resolver)
+ throws ContributionResolveException {
+
List<PolicySet> referredPolicySets = new ArrayList<PolicySet>();
for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
if (referredPolicySet.isUnresolved()) {
@@ -445,10 +461,10 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
if (!resolvedReferredPolicySet.isUnresolved()) {
referredPolicySets.add(resolvedReferredPolicySet);
} else {
- error("ReferredPolicySetNotFound", policySet, referredPolicySet, policySet);
- return;
+ error("ReferredPolicySetNotFound", policySet, referredPolicySet, policySet);
+ return;
//throw new ContributionResolveException("Referred PolicySet - " + referredPolicySet
- //+ "not found for PolicySet - " + policySet);
+ //+ "not found for PolicySet - " + policySet);
}
} else {
referredPolicySets.add(referredPolicySet);
@@ -457,7 +473,7 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
policySet.getReferencedPolicySets().clear();
policySet.getReferencedPolicySets().addAll(referredPolicySets);
}
-
+
private void includeReferredPolicySets(PolicySet policySet, PolicySet referredPolicySet) {
for (PolicySet furtherReferredPolicySet : referredPolicySet.getReferencedPolicySets()) {
includeReferredPolicySets(referredPolicySet, furtherReferredPolicySet);
@@ -465,23 +481,23 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
policySet.getPolicies().addAll(referredPolicySet.getPolicies());
policySet.getMappedPolicies().putAll(referredPolicySet.getMappedPolicies());
}
-
+
public void resolve(PolicySet policySet, ModelResolver resolver) throws ContributionResolveException {
resolveProvidedIntents(policySet, resolver);
resolveIntentsInMappedPolicies(policySet, resolver);
resolveReferredPolicySets(policySet, resolver);
-
+
for (PolicySet referredPolicySet : policySet.getReferencedPolicySets()) {
includeReferredPolicySets(policySet, referredPolicySet);
}
-
- if ( policySet.isUnresolved() ) {
+
+ if (policySet.isUnresolved()) {
//resolve the policy attachments
resolvePolicies(policySet, resolver);
-
+
/*if ( !policySet.isUnresolved() ) {
resolver.addModel(policySet);
}*/
}
- }
- }
+ }
+}
diff --git a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ProfileIntentProcessor.java b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ProfileIntentProcessor.java
index 656107b470..d0b19af129 100644
--- a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ProfileIntentProcessor.java
+++ b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ProfileIntentProcessor.java
@@ -34,7 +34,7 @@ public class ProfileIntentProcessor extends PolicyIntentProcessor<ProfileIntent>
public ProfileIntentProcessor(PolicyFactory policyFactory, Monitor monitor) {
super(policyFactory, monitor);
}
-
+
public ProfileIntentProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
super(modelFactories, monitor);
}
diff --git a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/QualifiedIntentProcessor.java b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/QualifiedIntentProcessor.java
index 7270dbe6db..50d8cb06e2 100644
--- a/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/QualifiedIntentProcessor.java
+++ b/branches/sca-equinox/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/QualifiedIntentProcessor.java
@@ -30,11 +30,11 @@ import org.apache.tuscany.sca.policy.QualifiedIntent;
* @version $Rev$ $Date$
*/
public class QualifiedIntentProcessor extends PolicyIntentProcessor<QualifiedIntent> {
-
+
public QualifiedIntentProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
super(modelFactories, monitor);
}
-
+
public QualifiedIntentProcessor(PolicyFactory policyFactory, Monitor monitor) {
super(policyFactory, monitor);
}
diff --git a/branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java b/branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
index b1901e9f30..39964c297d 100644
--- a/branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
+++ b/branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
@@ -42,8 +42,8 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.monitor.DefaultMonitorFactory;
-import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentAttachPointType;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -62,20 +62,20 @@ public class ReadDocumentTestCase extends TestCase {
private ModelResolver resolver;
private StAXArtifactProcessor<Object> staxProcessor;
private Monitor monitor;
-
+
private static final QName elementToProcess = new QName("http://www.osoa.org/xmlns/sca/1.0", "implementationType");
-
+
private Map<QName, Intent> intentTable = new Hashtable<QName, Intent>();
private Map<QName, PolicySet> policySetTable = new Hashtable<QName, PolicySet>();
private Map<QName, IntentAttachPointType> bindingTypesTable = new Hashtable<QName, IntentAttachPointType>();
private Map<QName, IntentAttachPointType> implTypesTable = new Hashtable<QName, IntentAttachPointType>();
private static final String scaNamespace = "http://www.osoa.org/xmlns/sca/1.0";
private static final String namespace = "http://test";
-
+
private static final QName confidentiality = new QName(namespace, "confidentiality");
private static final QName integrity = new QName(namespace, "integrity");
private static final QName messageProtection = new QName(namespace, "messageProtection");
- private static final QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+ private static final QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
private static final QName confidentiality_message = new QName(namespace, "confidentiality.message");
private static final QName secureReliablePolicy = new QName(namespace, "SecureReliablePolicy");
private static final QName secureMessagingPolicies = new QName(namespace, "SecureMessagingPolicies");
@@ -83,7 +83,6 @@ public class ReadDocumentTestCase extends TestCase {
private static final QName basicAuthMsgProtSecurity = new QName(namespace, "BasicAuthMsgProtSecurity");
private static final QName wsBinding = new QName(scaNamespace, "binding.ws");
private static final QName javaImpl = new QName(scaNamespace, "implementation.java");
-
@Override
public void setUp() throws Exception {
@@ -92,62 +91,63 @@ public class ReadDocumentTestCase extends TestCase {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
// Create a monitor
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
- MonitorFactory monitorFactory = new DefaultMonitorFactory();
+ MonitorFactory monitorFactory = new DefaultMonitorFactory();
if (monitorFactory != null) {
monitor = monitorFactory.createMonitor();
utilities.addUtility(monitorFactory);
}
- StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ StAXArtifactProcessorExtensionPoint staxProcessors =
+ extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, monitor);
staxProcessors.addArtifactProcessor(new TestPolicyProcessor());
-
+
URL url = getClass().getResource("test_definitions.xml");
InputStream urlStream = url.openStream();
XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
reader.next();
-
- //position on the right element qname to get processed
- while(reader.hasNext()) {
- reader.next();
- int event = reader.getEventType();
- if(event == START_ELEMENT && reader.getName().equals(elementToProcess)) {
- break;
- }
+
+ //position on the right element qname to get processed
+ while (reader.hasNext()) {
+ reader.next();
+ int event = reader.getEventType();
+ if (event == START_ELEMENT && reader.getName().equals(elementToProcess)) {
+ break;
+ }
}
- while ( true ) {
+ while (true) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT: {
Object artifact = staxProcessor.read(reader);
- if ( artifact instanceof PolicySet ) {
+ if (artifact instanceof PolicySet) {
PolicySet policySet = (PolicySet)artifact;
policySet.setName(new QName(namespace, policySet.getName().getLocalPart()));
policySetTable.put(policySet.getName(), policySet);
- } else if ( artifact instanceof Intent ) {
+ } else if (artifact instanceof Intent) {
Intent intent = (Intent)artifact;
intent.setName(new QName(namespace, intent.getName().getLocalPart()));
- if ( intent instanceof QualifiedIntent ) {
- ((QualifiedIntent)intent).getQualifiableIntent().
- setName(new QName(namespace,
- ((QualifiedIntent)intent).getQualifiableIntent().getName().getLocalPart()));
+ if (intent instanceof QualifiedIntent) {
+ ((QualifiedIntent)intent).getQualifiableIntent()
+ .setName(new QName(namespace, ((QualifiedIntent)intent).getQualifiableIntent()
+ .getName().getLocalPart()));
}
intentTable.put(intent.getName(), intent);
- } else if ( artifact instanceof BindingTypeImpl ) {
+ } else if (artifact instanceof BindingTypeImpl) {
IntentAttachPointType bindingType = (IntentAttachPointType)artifact;
bindingTypesTable.put(bindingType.getName(), bindingType);
- } else if ( artifact instanceof ImplementationTypeImpl ) {
+ } else if (artifact instanceof ImplementationTypeImpl) {
IntentAttachPointType implType = (IntentAttachPointType)artifact;
implTypesTable.put(implType.getName(), implType);
}
-
- if ( artifact != null ) {
+
+ if (artifact != null) {
resolver.addModel(artifact);
}
-
+
break;
}
}
- if ( reader.hasNext() ) {
+ if (reader.hasNext()) {
reader.next();
} else {
break;
@@ -164,116 +164,119 @@ public class ReadDocumentTestCase extends TestCase {
assertNotNull(intentTable.get(confidentiality));
assertNotNull(intentTable.get(messageProtection));
assertNotNull(intentTable.get(confidentiality_transport));
- assertTrue(intentTable.get(confidentiality).getDescription().length() > 0 );
-
+ assertTrue(intentTable.get(confidentiality).getDescription().length() > 0);
+
assertNotNull(policySetTable.get(secureReliablePolicy));
assertTrue(policySetTable.get(secureReliablePolicy).getProvidedIntents().size() == 2);
assertTrue(policySetTable.get(secureReliablePolicy).getPolicies().size() == 2);
-
+
assertNotNull(policySetTable.get(secureMessagingPolicies));
assertEquals(policySetTable.get(secureMessagingPolicies).getMappedPolicies().size(), 3);
-
+
assertEquals(bindingTypesTable.size(), 1);
assertNotNull(bindingTypesTable.get(wsBinding));
assertEquals(implTypesTable.size(), 1);
assertNotNull(implTypesTable.get(javaImpl));
}
-
+
public void testResolution() throws Exception {
assertTrue(intentTable.get(messageProtection) instanceof ProfileIntent);
ProfileIntent profileIntent = (ProfileIntent)intentTable.get(new QName(namespace, "messageProtection"));
assertNull(profileIntent.getRequiredIntents().get(0).getDescription());
-
- QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
+
+ QName confidentiality_transport = new QName(namespace, "confidentiality.transport");
assertTrue(intentTable.get(confidentiality_transport) instanceof QualifiedIntent);
- QualifiedIntent qualifiedIntent = (QualifiedIntent)intentTable.get(new QName(namespace, "confidentiality.transport"));
+ QualifiedIntent qualifiedIntent =
+ (QualifiedIntent)intentTable.get(new QName(namespace, "confidentiality.transport"));
assertNull(qualifiedIntent.getQualifiableIntent().getDescription());
-
+
PolicySet secureReliablePolicySet = policySetTable.get(secureReliablePolicy);
PolicySet secureMessagingPolicySet = policySetTable.get(secureMessagingPolicies);
PolicySet securityPolicySet = policySetTable.get(securityPolicy);
-
+
assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
assertNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
assertTrue(secureMessagingPolicySet.isUnresolved());
assertEquals(securityPolicySet.getMappedPolicies().size(), 5);
-
+
//testing to ensure that inclusion of referred policy sets has not happened
PolicySet basicAuthMsgProtSecurityPolicySet = policySetTable.get(basicAuthMsgProtSecurity);
assertTrue(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
assertTrue(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
-
+
IntentAttachPointType wsBindingType = bindingTypesTable.get(wsBinding);
assertNull(wsBindingType.getAlwaysProvidedIntents().get(0).getDescription());
assertNull(wsBindingType.getMayProvideIntents().get(0).getDescription());
-
+
IntentAttachPointType javaImplType = implTypesTable.get(javaImpl);
assertNull(javaImplType.getAlwaysProvidedIntents().get(0).getDescription());
assertNull(javaImplType.getMayProvideIntents().get(0).getDescription());
-
+
List<Intent> simpleIntents = new ArrayList<Intent>();
List<ProfileIntent> profileIntents = new ArrayList<ProfileIntent>();
List<QualifiedIntent> qualifiedIntents = new ArrayList<QualifiedIntent>();
-
+
for (Intent intent : intentTable.values()) {
if (intent instanceof ProfileIntent)
profileIntents.add((ProfileIntent)intent);
else if (intent instanceof QualifiedIntent)
qualifiedIntents.add((QualifiedIntent)intent);
- else simpleIntents.add(intent);
+ else
+ simpleIntents.add(intent);
}
-
+
for (Intent intent : simpleIntents)
staxProcessor.resolve(intent, resolver);
-
+
for (ProfileIntent intent : profileIntents)
staxProcessor.resolve(intent, resolver);
-
+
for (QualifiedIntent intent : qualifiedIntents)
staxProcessor.resolve(intent, resolver);
-
- for ( PolicySet policySet : policySetTable.values() ) {
+
+ for (PolicySet policySet : policySetTable.values()) {
if (policySet.getReferencedPolicySets().isEmpty())
staxProcessor.resolve(policySet, resolver);
}
-
- for ( PolicySet policySet : policySetTable.values() ) {
+
+ for (PolicySet policySet : policySetTable.values()) {
if (!policySet.getReferencedPolicySets().isEmpty())
staxProcessor.resolve(policySet, resolver);
}
-
- for ( IntentAttachPointType bindingType : bindingTypesTable.values() ) {
+
+ for (IntentAttachPointType bindingType : bindingTypesTable.values()) {
staxProcessor.resolve(bindingType, resolver);
}
-
- for ( IntentAttachPointType implType : implTypesTable.values() ) {
+
+ for (IntentAttachPointType implType : implTypesTable.values()) {
staxProcessor.resolve(implType, resolver);
}
-
+
//testing if policy intents have been linked have property been linked up
assertNotNull(profileIntent.getRequiredIntents().get(0).getDescription());
assertNotNull(qualifiedIntent.getQualifiableIntent().getDescription());
assertEquals(secureReliablePolicySet.getProvidedIntents().get(1).getName(), integrity);
assertNotNull(secureReliablePolicySet.getProvidedIntents().get(1).getDescription());
-
+
//testing if policysets have been properly linked up with intents
assertFalse(secureMessagingPolicySet.isUnresolved());
assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
assertNotNull(secureMessagingPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
-
+
//testing if intent maps have been properly mapped to policies
assertFalse(securityPolicySet.isUnresolved());
assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality)));
assertNotNull(securityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_message)));
-
+
//testing for inclusion of referred policysets
assertFalse(basicAuthMsgProtSecurityPolicySet.getPolicies().isEmpty());
assertFalse(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().isEmpty());
- assertNotNull(basicAuthMsgProtSecurityPolicySet.getMappedPolicies().get(intentTable.get(confidentiality_transport)));
-
+ 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());
}
diff --git a/branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java b/branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
index c197ec42d1..2dc8a1cdc7 100644
--- a/branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
+++ b/branches/sca-equinox/modules/policy-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
@@ -44,8 +44,7 @@ public class TestPolicyProcessor implements StAXArtifactProcessor<Policy> {
return new MockPolicyImplOne();
}
- public void write(Policy arg0, XMLStreamWriter arg1) throws ContributionWriteException,
- XMLStreamException {
+ public void write(Policy arg0, XMLStreamWriter arg1) throws ContributionWriteException, XMLStreamException {
}
public Class<Policy> getModelType() {
@@ -57,7 +56,6 @@ public class TestPolicyProcessor implements StAXArtifactProcessor<Policy> {
}
-
public class MockPolicyImplOne implements Policy {
public QName getSchemaName() {
return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
@@ -69,6 +67,6 @@ public class TestPolicyProcessor implements StAXArtifactProcessor<Policy> {
public void setUnresolved(boolean unresolved) {
}
-
+
}
}