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;
try {
// Read the composite document
while (reader.hasNext()) {
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
name = reader.getName();
if (COMPOSITE_QNAME.equals(name)) {
// Read a <composite>
composite = assemblyFactory.createComposite();
composite.setName(new QName(getString(reader, TARGET_NAMESPACE),
getString(reader, NAME)));
composite.setAutowire(getBoolean(reader, AUTOWIRE));
composite.setLocal(getBoolean(reader, LOCAL));
composite.setConstrainingType(getConstrainingType(reader));
readPolicies(composite, reader);
} else if (INCLUDE_QNAME.equals(name)) {
// Read an <include>
include = assemblyFactory.createComposite();
include.setName(getQName(reader, "name"));
include.setUnresolved(true);
composite.getIncludes().add(include);
} else 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);
readPolicies(contract, reader);
} else {
// Read a <composite><service>
compositeService = assemblyFactory.createCompositeService();
contract = compositeService;
compositeService.setName(getString(reader, NAME));
String promoted = getString(reader, PROMOTE);
String promotedComponentName;
String promotedServiceName;
int s = promoted.indexOf('/');
if (s == -1) {
promotedComponentName = promoted;
promotedServiceName = null;
} else {
promotedComponentName = promoted.substring(0, s);
promotedServiceName = promoted.substring(s + 1);
}
Component promotedComponent = assemblyFactory.createComponent();
promotedComponent.setUnresolved(true);
promotedComponent.setName(promotedComponentName);
compositeService.setPromotedComponent(promotedComponent);
ComponentService promotedService =
assemblyFactory.createComponentService();
promotedService.setUnresolved(true);
promotedService.setName(promotedServiceName);
compositeService.setPromotedService(promotedService);
composite.getServices().add(compositeService);
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);
componentReference.setAutowire(getBoolean(reader, AUTOWIRE));
readTargets(componentReference, reader);
componentReference
.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
component.getReferences().add(componentReference);
readPolicies(contract, reader);
} else {
// Read a <composite><reference>
compositeReference = assemblyFactory.createCompositeReference();
contract = compositeReference;
compositeReference.setName(getString(reader, NAME));
readMultiplicity(compositeReference, reader);
readTargets(compositeReference, reader);
String promote = reader.getAttributeValue(null, Constants.PROMOTE);
if (promote != null) {
for (StringTokenizer tokens = new StringTokenizer(promote); tokens
.hasMoreTokens();) {
ComponentReference promotedReference =
assemblyFactory.createComponentReference();
promotedReference.setUnresolved(true);
promotedReference.setName(tokens.nextToken());
compositeReference.getPromotedReferences()
.add(promotedReference);
}
}
compositeReference
.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL));
composite.getReferences().add(compositeReference);
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));
readPolicies(property, reader);
readProperty(componentProperty, reader);
component.getProperties().add(componentProperty);
} else {