return this.composite;
}
public Component read(XMLStreamReader reader)
throws ContributionReadException, XMLStreamException {
Composite include = null;
Component component = null;
Property property = null;
ComponentService componentService = null;
ComponentReference componentReference = null;
ComponentProperty componentProperty = null;
CompositeService compositeService = null;
CompositeReference compositeReference = null;
Contract contract = null;
Wire wire = null;
Callback callback = null;
QName name = null;
// Read the component scdl
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
QName itemName = reader.getName();
if (!itemName.getNamespaceURI().equals(SCA10_NS))
name = new QName(SCA10_NS, itemName.getLocalPart());
else
name = itemName;
if (SERVICE_QNAME.equals(name)) {
if (component != null) {
// Read a <component><service>
componentService = assemblyFactory
.createComponentService();
contract = componentService;
componentService.setName(getString(reader, NAME));
component.getServices().add(componentService);
policyProcessor.readPolicies(contract, reader);
}
} else if (REFERENCE_QNAME.equals(name)) {
if (component != null) {
// Read a <component><reference>
componentReference = assemblyFactory
.createComponentReference();
contract = componentReference;
componentReference.setName(getString(reader, NAME));
readMultiplicity(componentReference, reader);
if (isSet(reader, AUTOWIRE)) {
componentReference.setAutowire(getBoolean(reader,
AUTOWIRE));
}
readTargets(componentReference, reader);
componentReference.setWiredByImpl(getBoolean(reader,
WIRED_BY_IMPL));
component.getReferences().add(componentReference);
policyProcessor.readPolicies(contract, reader);
}
} else if (PROPERTY_QNAME.equals(name)) {
if (component != null) {
// Read a <component><property>
componentProperty = assemblyFactory
.createComponentProperty();
property = componentProperty;
componentProperty.setSource(getString(reader, SOURCE));
componentProperty.setFile(getString(reader, FILE));
policyProcessor.readPolicies(property, reader);
readAbstractProperty(componentProperty, reader);
// Read the property value
Document value = readPropertyValue(property
.getXSDElement(), property.getXSDType(), reader);
property.setValue(value);
component.getProperties().add(componentProperty);
}
} else if (COMPONENT_QNAME.equals(name)) {
// Read a <component>
component = assemblyFactory.createComponent();
component.setName(getString(reader, NAME));
if (isSet(reader, AUTOWIRE)) {
component.setAutowire(getBoolean(reader, AUTOWIRE));
}
if (isSet(reader, URI)) {
component.setURI(getString(reader, URI));
}
component.setConstrainingType(readConstrainingType(reader));
composite.getComponents().add(component);
policyProcessor.readPolicies(component, reader);
} else if (WIRE_QNAME.equals(name)) {
// Read a <wire>
wire = assemblyFactory.createWire();
ComponentReference source = assemblyFactory
.createComponentReference();
source.setUnresolved(true);
source.setName(getString(reader, SOURCE));
wire.setSource(source);
ComponentService target = assemblyFactory
.createComponentService();
target.setUnresolved(true);
target.setName(getString(reader, TARGET));
wire.setTarget(target);
composite.getWires().add(wire);
policyProcessor.readPolicies(wire, reader);
} else if (CALLBACK_QNAME.equals(name)) {
// Read a <callback>
callback = assemblyFactory.createCallback();
contract.setCallback(callback);
policyProcessor.readPolicies(callback, reader);
} else if (OPERATION_QNAME.equals(name)) {
// Read an <operation>
Operation operation = assemblyFactory.createOperation();
operation.setName(getString(reader, NAME));
operation.setUnresolved(true);
if (callback != null) {
policyProcessor.readPolicies(callback, operation,
reader);
} else {
policyProcessor.readPolicies(contract, operation,
reader);
}
} else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) {
// Read an implementation.composite
Composite implementation = assemblyFactory
.createComposite();
implementation.setName(getQName(reader, NAME));
implementation.setUnresolved(true);
component.setImplementation(implementation);
policyProcessor.readPolicies(implementation, reader);
} else {
// Read an extension element