this.definitionsFactory = factoryExtensionPoint.getFactory(DefinitionsFactory.class);
}
public Definitions read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
QName name = null;
Definitions 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 = definitionsFactory.createDefinitions();
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.getIntents().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;
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;
}