this.monitor = monitor;
}
public SCADefinitions read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
QName name = null;
SCADefinitions definitions = null;
String targetNamespace = null;
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT: {
name = reader.getName();
if ( SCA_DEFINITIONS_QNAME.equals(name)) {
definitions = new SCADefinitionsImpl();
targetNamespace = reader.getAttributeValue(null, TARGET_NAMESPACE);
definitions.setTargetNamespace(targetNamespace);
} else {
Object extension = extensionProcessor.read(reader);
if (extension != null) {
if ( extension instanceof Intent ) {
Intent intent = (Intent)extension;
intent.setName(new QName(targetNamespace,
intent.getName().getLocalPart()));
if ( intent instanceof QualifiedIntent ) {
QualifiedIntent qualifiedIntent = (QualifiedIntent)intent;
qualifiedIntent.getQualifiableIntent().
setName(new QName(targetNamespace,
qualifiedIntent.getQualifiableIntent().getName().getLocalPart()));
}
// FIXME: Workaround for TUSCANY-2499
intent.setUnresolved(false);
definitions.getPolicyIntents().add(intent);
} else if ( extension instanceof PolicySet ) {
PolicySet policySet = (PolicySet)extension;
policySet.setName(new QName(targetNamespace,
policySet.getName().getLocalPart()));
definitions.getPolicySets().add(policySet);
} else if ( extension instanceof Binding ) {
Binding binding = (Binding)extension;
if (binding instanceof DefinitionElement)
((DefinitionElement)binding).setTargetNamespace(targetNamespace);
definitions.getBindings().add(binding);
} else if ( extension instanceof IntentAttachPointType ) {
IntentAttachPointType type = (IntentAttachPointType)extension;
if ( type.getName().getLocalPart().startsWith(BINDING)) {
definitions.getBindingTypes().add((IntentAttachPointType)extension);
} else if ( type.getName().getLocalPart().startsWith(IMPLEMENTATION)) {
definitions.getImplementationTypes().add((IntentAttachPointType)extension);
}
}
}
break;
}