} // end findPartnerLinkType
protected BPELProcessDefinition indexRead2(URL doc) throws Exception {
BPELProcessDefinition processDefinition = factory.createBPELProcessDefinition();
processDefinition.setUnresolved(true);
processDefinition.setLocation(doc);
InputStream is = doc.openStream();
XMLStreamReader reader = null;
try {
reader = inputFactory.createXMLStreamReader(is);
/*
* The principle here is to look for partnerLink elements, which form either services
* or references. A partnerLink can be EITHER - the algorithm for deciding is:
* 1) Explicit marking with sca:reference or sca:service attribute
* 2) "first use" of the partnerLink by specific BPEL activity elements:
* <onEvent../>, <receive../> or <pick../> elements imply a service
* <invoke../> implies a reference
*/
// TODO - need to handle <scope../> elements as kind of "nested" processes
// - and scopes introduce the possibility of partnerLinks with the same name at
// different levels of scope.... (yuk!!)
boolean completed = false;
while (!completed) {
switch (reader.next()) {
case START_ELEMENT:
QName qname = reader.getName();
//System.out.println("BPEL TypeLoader - found element with name: " + qname.toString());
if (BPEL_PROCESS_DEFINITION.equals(qname) ||
BPEL_EXECUTABLE_DEFINITION.equals(qname)) {
QName processName = new QName(getString(reader, org.apache.tuscany.sca.assembly.xml.Constants.TARGET_NAMESPACE),
getString(reader, NAME_ELEMENT));
processDefinition.setName(processName);
} else if (PARTNERLINK_ELEMENT.equals(qname)) {
processDefinition.getPartnerLinks().add(processPartnerLinkElement( reader ));
} else if (ONEVENT_ELEMENT.equals(qname) ||
RECEIVE_ELEMENT.equals(qname) ||
ONMESSAGE_ELEMENT.equals(qname) ) {
processPartnerLinkAsService( reader.getAttributeValue(null, "partnerLink"), processDefinition.getPartnerLinks() );
} else if (INVOKE_ELEMENT.equals(qname)) {
processPartnerLinkAsReference( reader.getAttributeValue(null, "partnerLink"), processDefinition.getPartnerLinks() );
} else if (IMPORT_ELEMENT.equals(qname)) {
processDefinition.getImports().add( processImportElement( reader ) );
} // end if
break;
case END_ELEMENT:
if (PROCESS_ELEMENT.equals(reader.getName())) {
//System.out.println("BPEL TypeLoader - finished read of process file");