You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ed...@apache.org on 2008/05/07 23:17:30 UTC

svn commit: r654282 - in /incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel: ./ impl/ xml/

Author: edwardsmj
Date: Wed May  7 14:17:29 2008
New Revision: 654282

URL: http://svn.apache.org/viewvc?rev=654282&view=rev
Log:
Updates to implementation-bpel to support introspection of the component type from the BPEL process itself - meaning that the process can run without a component type side file.

Added:
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java
Modified:
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java
    incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java

Modified: incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java?rev=654282&r1=654281&r2=654282&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java Wed May  7 14:17:29 2008
@@ -20,6 +20,7 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.tuscany.sca.assembly.ComponentType;
 import org.apache.tuscany.sca.assembly.Implementation;
 
 /**
@@ -51,4 +52,15 @@
      * @param processDefinition
      */
     void setProcessDefinition(BPELProcessDefinition processDefinition);
+    
+    /** 
+     * Returns the componentType for this Spring implementation 
+     */
+    public ComponentType getComponentType(); 
+
+    /**
+     * Sets the componentType for this Spring implementation
+     * @parma componentType the component type to set
+     */
+    public void setComponentType(ComponentType componentType); 
 }

Modified: incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java?rev=654282&r1=654281&r2=654282&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java Wed May  7 14:17:29 2008
@@ -19,12 +19,21 @@
 
 package org.apache.tuscany.sca.implementation.bpel;
 
+import java.util.List;
+import java.util.Collection;
+
 import java.net.URI;
 import java.net.URL;
 
 import javax.xml.namespace.QName;
+import javax.wsdl.PortType;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
 
 import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELPartnerLinkElement;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELImportElement;
+
 
 
 /**
@@ -68,4 +77,38 @@
      * @param url
      */
     void setLocation(URL location);
+    
+    /**
+     * Return the list of PartnerLinks for this process
+     */
+    List<BPELPartnerLinkElement> getPartnerLinks();
+    
+    /**
+     * Return the list of imports for this process
+     */
+    List<BPELImportElement> getImports();
+    
+    /**
+     * Set the associated collection of port types
+     * @param thePortTypes
+     */
+    public void setPortTypes( Collection<PortType> thePortTypes ) ;
+    
+    /**
+     * Return the collection of associated port types
+     * @return
+     */
+    public Collection<PortType> getPortTypes() ;
+    
+    /**
+     * Set the associated collection of WSDL interfaces
+     * @param theInterfaces
+     */
+    public void setInterfaces( Collection<WSDLInterface> theInterfaces ) ;
+    
+    /**
+     * Return the collection of associated WSDL interfaces
+     * @return
+     */
+    public Collection<WSDLInterface> getInterfaces() ;
 }

Modified: incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java?rev=654282&r1=654281&r2=654282&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java Wed May  7 14:17:29 2008
@@ -19,10 +19,17 @@
 
 package org.apache.tuscany.sca.implementation.bpel.impl;
 
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
@@ -30,6 +37,15 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+import javax.wsdl.Definition;
+import javax.wsdl.extensions.ExtensibilityElement;
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+import javax.wsdl.PortType;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+
 import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
@@ -38,23 +54,52 @@
 import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
 import org.apache.tuscany.sca.implementation.bpel.BPELFactory;
 import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELImportElement;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELPartnerLinkElement;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELPartnerLinkTypeElement;
+
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLObject;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.xml.BPELPartnerLinkTypeExt;
 
 /**
  * BPEL document processor responsible for reading a BPEL file and producing necessary model info about it
  * 
+ * TODO: The namespaces for WS-BPEL include 2 versions - only the earlier BPEL 1.1 versions are
+ * supported at present - the BPEL 2.0 namespaces also need support.  This will require inspection
+ * of both BPEL process files and of WSDL files for their BPEL namespaces
  * @version $Rev$ $Date$
  */
 public class BPELDocumentProcessor extends BaseStAXArtifactProcessor implements URLArtifactProcessor<BPELProcessDefinition> {
     public final static QName BPEL_PROCESS_DEFINITION = new QName("http://schemas.xmlsoap.org/ws/2004/03/business-process/", "process");
     public final static QName BPEL_EXECUTABLE_DEFINITION = new QName("http://docs.oasis-open.org/wsbpel/2.0/process/executable", "process");
+    private static final String SCA_BPEL_NS = "http://docs.oasis-open.org/ns/opencsa/sca-bpel/200801";
+    private static final String BPEL_NS = "http://schemas.xmlsoap.org/ws/2004/03/business-process/";
+    private static final String BPEL_PLINK_NS = "http://schemas.xmlsoap.org/ws/2004/03/partner-link/";
+    private static final QName PROCESS_ELEMENT = new QName(BPEL_NS, "process");
+    private static final QName PARTNERLINK_ELEMENT = new QName(BPEL_NS, "partnerLink");
+    private static final QName ONEVENT_ELEMENT = new QName(BPEL_NS, "onEvent");
+    private static final QName RECEIVE_ELEMENT = new QName(BPEL_NS, "receive");
+    private static final QName ONMESSAGE_ELEMENT = new QName(BPEL_NS, "onMessage");
+    private static final QName INVOKE_ELEMENT = new QName(BPEL_NS, "invoke");
+    private static final QName IMPORT_ELEMENT = new QName(BPEL_NS, "import");
+    private static final String LINKTYPE_NAME = "partnerLinkType";
+    private static final QName LINKTYPE_ELEMENT = new QName(BPEL_PLINK_NS, LINKTYPE_NAME);
+
     public final static String NAME_ELEMENT = "name";
     
     private final static XMLInputFactory inputFactory = XMLInputFactory.newInstance();
     
     private final BPELFactory factory;
-    
+    private WSDLFactory WSDLfactory;
+
     public BPELDocumentProcessor(ModelFactoryExtensionPoint modelFactories) {
-        this.factory = modelFactories.getFactory(BPELFactory.class);
+        this.factory     = modelFactories.getFactory(BPELFactory.class);
+        this.WSDLfactory = modelFactories.getFactory(WSDLFactory.class);
     }
     
     public String getArtifactType() {
@@ -71,7 +116,7 @@
             //for now we are just using process name
             //and relying on componentType file for service definition
             //so it's OK to set resolved for now
-            processDefinition = indexRead(artifactURL);
+            processDefinition = indexRead2(artifactURL);
             processDefinition.setURI(artifactURI);
             processDefinition.setUnresolved(false);
         } catch (Exception e) {
@@ -81,20 +126,207 @@
         return processDefinition;
     }
 
-
-    public void resolve(BPELProcessDefinition model, ModelResolver resolver) throws ContributionResolveException {
-        
-    }
+    /**
+     * Resolve the BPEL process
+     * - one of the things that needs doing is to pin down the WSDLs that are being used by
+     * the process, in particular the partnerLinkType and the related PortType definitions
+     */
+    public void resolve(BPELProcessDefinition model, ModelResolver resolver) 
+    	throws ContributionResolveException {
+        // FIXME - serious resolving needs to happen here
+    	
+    	// Step 1 is to resolve the WSDL files referenced from this BPEL process
+    	// - one complexity here is that the WSDL definitions hold BPEL extension elements for
+    	// the partnerLinkType declarations - and these must be used in later steps
+    	//
+    	// Step 2 is to take all the partnerLink definitions and establish the PortType being
+    	// used, by tracing through the related partnerLinkType declarations - the PortType is
+    	// effectively a definition of the interface used by the partnerLink.
+    	// - another consideration here is that each partnerLink can involve 2 interfaces, one
+    	// for the forward calls to the process, the other for calls from the process - depending
+    	// on whether the partnerLink is a reference or a service, one of these interfaces is a
+    	// callback interface.
+    	
+    	List<BPELImportElement> theImports = model.getImports();
+    	for ( BPELImportElement theImport : theImports ) {
+    		// Deal with WSDL imports
+    		if ( theImport.getImportType().equals("http://schemas.xmlsoap.org/wsdl/") ) {
+    			String WSDLLocation = theImport.getLocation();
+    			String WSDLNamespace = theImport.getNamespace();
+    			// FIXME both Location & Namespace attributes are optional - for the present
+    			// we don't deal with these cases - they are skipped
+    			if ( WSDLLocation == null || WSDLNamespace == null ) continue;
+    			// Resolve the WSDL definition
+                WSDLDefinition proxy = WSDLfactory.createWSDLDefinition();
+                proxy.setUnresolved(true);
+                proxy.setNamespace(WSDLNamespace);
+                proxy.setLocation(URI.create(WSDLLocation));
+                WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, proxy);
+                if (resolved != null && !resolved.isUnresolved()) {
+                    theImport.setWSDLDefinition( resolved );
+                } // end if	
+    		} // end if
+    	} // end for
+    	
+    	// Fetch the sets of partner links, port types and interfaces
+    	List<BPELPartnerLinkTypeElement> thePLinkTypes = getPartnerLinkTypes( theImports );
+    	Collection<WSDLInterface> theInterfaces = (Collection<WSDLInterface>)new ArrayList<WSDLInterface>();
+    	Collection<PortType> thePortTypes = getAllPortTypes( theImports, theInterfaces, resolver );
+    	
+    	// Store the Port Types and the Interfaces for later calculation of the component type...
+    	model.setPortTypes(thePortTypes);
+    	model.setInterfaces(theInterfaces);
+    	
+    	// Now, for each partnerLink in the BPEL process, find the related partnerLinkType
+    	// element 
+    	List<BPELPartnerLinkElement> thePartnerLinks = model.getPartnerLinks();
+    	for ( BPELPartnerLinkElement thePartnerLink : thePartnerLinks ) {
+    		QName partnerLinkType = thePartnerLink.getPartnerLinkType();
+    		BPELPartnerLinkTypeElement pLinkType = 
+    			findPartnerLinkType( partnerLinkType, thePLinkTypes );
+    		if( pLinkType == null ) throw new ContributionResolveException( "PartnerLink " 
+    				+ thePartnerLink.getName() + " has no matching partner link type");	
+    		thePartnerLink.setPartnerLinkType(pLinkType);
+    	} // end for
+    	
+    } // end resolve
+    
+    /*
+     * Retrieve all the Partner Link types defined in the imported WSDL files
+     */
+    private List<BPELPartnerLinkTypeElement> getPartnerLinkTypes( List<BPELImportElement> theImports )
+    	throws ContributionResolveException {
+    	
+    	List<BPELPartnerLinkTypeElement> thePLinks = 
+    		new ArrayList<BPELPartnerLinkTypeElement>();
+    		
+    	// We must find the partner link type elements from amongst the imported WSDLs
+    	for ( BPELImportElement theImport : theImports ){
+    		WSDLDefinition theWSDL = theImport.getWSDLDefinition();
+    		Definition WSDLDefinition = theWSDL.getDefinition();
+    		// The BPEL partnerLinkType elements are extension elements within the WSDL
+    		List<ExtensibilityElement> extensibilityElements = WSDLDefinition.getExtensibilityElements();
+    		
+    		for ( ExtensibilityElement theElement : extensibilityElements ) {
+    			QName elementType = theElement.getElementType();
+    			if ( elementType.equals( LINKTYPE_ELEMENT ) ) {
+    				BPELPartnerLinkTypeExt pLinkExt = (BPELPartnerLinkTypeExt)theElement;
+    				// Fetch the name of the partnerLinkType
+    				String name = pLinkExt.getName();
+    				QName qName = new QName( WSDLDefinition.getTargetNamespace(), name );
+    				BPELPartnerLinkTypeElement pLinkElement = new BPELPartnerLinkTypeElement( qName );
+    				
+    				// The partnerLinkType must have one and may have 2 role child elements
+    				int count = 0;
+    				for( int i = 0; i < 2; i++ ) {
+    					if(pLinkExt.getRoleName(i) == null ) continue;
+    					PortType pType = WSDLDefinition.getPortType(pLinkExt.getRolePortType(i));
+    					if ( count == 0 ) {
+    						pLinkElement.setRole1(pLinkExt.getRoleName(i),
+    								              pLinkExt.getRolePortType(i),
+    								              pType );
+    						count++;
+    					} else if (count == 1) {
+    						pLinkElement.setRole2(pLinkExt.getRoleName(i),
+						                          pLinkExt.getRolePortType(i),
+						                          pType );
+    						count++;
+    					} else {
+    						break;
+    					} // end if 
+    				} // end for
+    				if( count == 0 ) throw new ContributionResolveException( "partnerLinkType "+ 
+    						                         pLinkElement.getName() +" has no Roles defined" );
+    				thePLinks.add( pLinkElement );
+    			} // end if
+    			
+    		} // end for
+    	} // end for
+    	return thePLinks;
+    } // end getPartnerLinkTypes
+    
+    protected Collection<PortType> getAllPortTypes( List<BPELImportElement> theImports,
+    												Collection<WSDLInterface> theInterfaces,
+    												ModelResolver resolver) 
+    				throws ContributionResolveException {
+    	
+    	Collection<PortType> thePortTypes = (Collection<PortType>)new ArrayList<PortType>();
+    	for ( BPELImportElement theImport : theImports ){
+    		WSDLDefinition theWSDL = theImport.getWSDLDefinition();
+    		Definition wsdlDefinition = theWSDL.getDefinition();
+    		
+    		Collection<PortType> portTypes = (Collection<PortType>)wsdlDefinition.getPortTypes().values();
+    		thePortTypes.addAll( portTypes );
+    		
+    		// Create WSDLInterface elements for each PortType found
+    		for( PortType portType : portTypes ) {
+    			WSDLObject<PortType> wsdlPortType = theWSDL.getWSDLObject(PortType.class, portType.getQName() );
+    			WSDLInterface wsdlInterface;
+                if (wsdlPortType != null) {      
+                    // Introspect the WSDL portType and add the resulting
+                    // WSDLInterface to the resolver
+                    try {
+                        theWSDL.setDefinition( wsdlPortType.getDefinition() );
+                        wsdlInterface = WSDLfactory.createWSDLInterface(wsdlPortType.getElement(), 
+                        		theWSDL, resolver);
+                        wsdlInterface.setWsdlDefinition(theWSDL);
+                    } catch (InvalidInterfaceException e) {
+                        throw new ContributionResolveException(e);
+                    } // end try
+                    resolver.addModel(wsdlInterface);
+                    theInterfaces.add(wsdlInterface);
+                } // end if
+            } // end for
+      
+    		//-----------------------
+    		
+    	} // end for
+    	
+    	return thePortTypes;
+    } // end getAllPortTypes
     
     /**
-     * Read the namespace for the WSDL definition and inline schemas
-     * 
-     * @param doc
+     * Returns a QName from a string.  
+     * @param definition - a WSDL Definition
+     * @param value - the String from which to form the QName in the form "pref:localName"
      * @return
-     * @throws IOException
-     * @throws XMLStreamException
      */
-    protected BPELProcessDefinition indexRead(URL doc) throws Exception {
+    protected QName getQNameValue(Definition definition, String value) {
+        if (value != null && definition != null) {
+            int index = value.indexOf(':');
+            String prefix = index == -1 ? "" : value.substring(0, index);
+            String localName = index == -1 ? value : value.substring(index + 1);
+            String ns = definition.getNamespace(prefix);
+            if (ns == null) {
+                ns = "";
+            }
+            return new QName(ns, localName, prefix);
+        } else {
+            return null;
+        }
+    } // end getQNameValue
+
+    
+    /*
+     * Method which finds a partnerLinkType definition within the WSDLs imported by the BPEL
+     * process.
+     * @param partnerLinkTypeName - the name of the partnerLinkType
+     * @param theImports a list of the WSDL import declarations
+     * @returns a BPELPartnerLinkTypeElement for the partnerLinkType or null if it cannot be
+     * found
+     */
+    private BPELPartnerLinkTypeElement findPartnerLinkType( QName partnerLinkTypeName,
+    										List<BPELPartnerLinkTypeElement> thePLinkTypes) {
+    	// We must find the partner link type element from amongst the imported WSDLs
+    	for ( BPELPartnerLinkTypeElement thePLinkType : thePLinkTypes ){
+    		if( thePLinkType.getName().equals(partnerLinkTypeName) ) return thePLinkType;
+     	} // end for
+    	return null;
+    } // end findPartnerLinkType
+    
+    
+
+    protected BPELProcessDefinition indexRead2(URL doc) throws Exception {
         BPELProcessDefinition processDefinition = factory.createBPELProcessDefinition();
         processDefinition.setUnresolved(true);
         processDefinition.setLocation(doc);
@@ -103,31 +335,138 @@
         XMLStreamReader reader = null;
         try {
             reader = inputFactory.createXMLStreamReader(is);
-            int eventType = reader.getEventType();
-            while (true) {
-                if (eventType == XMLStreamConstants.START_ELEMENT) {
-                    QName elementName = reader.getName();
-                    if (BPEL_PROCESS_DEFINITION.equals(elementName) || BPEL_EXECUTABLE_DEFINITION.equals(elementName) ) {
-                        QName processName = new QName(getString(reader, org.apache.tuscany.sca.assembly.xml.Constants.TARGET_NAMESPACE), getString(reader, NAME_ELEMENT));
-                        processDefinition.setName(processName);
+            /*
+             * 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;
-                    }
-                }
-                if (reader.hasNext()) {
-                    eventType = reader.next();
-                } else {
-                    break;
-                }
-            }
+                    case END_ELEMENT:
+                        if (PROCESS_ELEMENT.equals(reader.getName())) {
+                            //System.out.println("BPEL TypeLoader - finished read of process file");
+                            completed = true;
+                            break;
+                        } // end if
+                } // end switch
+            } // end while
         } finally {
-            if(reader != null) {
-                reader.close();
-            }
+            if(reader != null) reader.close();
             is.close();
-        }
+        } // end try
         
         return processDefinition;
-    }
-    
+    } // end indexRead2
+
+	/*
+	 * Processes a partnerLink element from the BPEL process and creates a
+	 * BPELPartnerLink object
+	 */
+	private BPELPartnerLinkElement processPartnerLinkElement( XMLStreamReader reader ) 
+					throws ContributionReadException {
+		BPELPartnerLinkElement partnerLink = new BPELPartnerLinkElement(
+	    		reader.getAttributeValue(null, "name"), 
+	    		getQNameValue(reader, reader.getAttributeValue(null, "partnerLinkType") ),
+	    		reader.getAttributeValue(null, "myRole"),
+	    		reader.getAttributeValue(null, "partnerRole"));
+	    // See if there are any SCA extension attributes
+	    String scaService = reader.getAttributeValue( SCA_BPEL_NS, "service");
+	    String scaReference = reader.getAttributeValue( SCA_BPEL_NS, "reference");
+	    if( (scaService != null) && (scaReference != null) ) {
+	    	// It is incorrect to set both service & reference attributes
+	    	throw new ContributionReadException( "BPEL PartnerLink " 
+	    			+ reader.getAttributeValue(null, "name") + 
+	    			" has both sca:reference and sca:service attributes set" );
+	    }
+	    // Set the SCA type and the related name, if present
+	    if( scaService != null ) partnerLink.setAsService( scaService );
+	    else if ( scaReference != null ) partnerLink.setAsReference( scaReference );
+	    return partnerLink;
+	} // end processPartnerLinkElement
+
+	/*
+	 * Processes an <import../> element from the BPEL process and creates a 
+	 * BPELImportElement object
+	 */
+	private BPELImportElement processImportElement( XMLStreamReader reader ) {
+		return ( new BPELImportElement( reader.getAttributeValue(null, "location"),
+				                        reader.getAttributeValue(null, "importType"),
+				                        reader.getAttributeValue(null, "namespace") ));
+	} // end processImportElement
+
+	/*
+	 * Mark a named partnerLink as a Service, unless it is already marked as a Reference
+	 */
+	private void processPartnerLinkAsService( String partnerLinkName, 
+										List<BPELPartnerLinkElement> partnerLinks ) {
+		BPELPartnerLinkElement partnerLink = findPartnerLinkByName( partnerLinks, partnerLinkName );
+		if( partnerLink == null ) {
+			System.out.println("BPEL TypeLoader - element references partnerLink " 
+								+ partnerLinkName + " not in the list");
+		} else {
+			// Set the type of the partnerLink to "service" if not already set...
+			if( !partnerLink.isSCATyped() ) partnerLink.setAsService( partnerLinkName );
+		} // endif
+	} // end processPartnerLinkAsReference
+
+	/*
+	 * Mark a named partnerLink as a Reference, unless it is already marked as a Service
+	 */
+	private void processPartnerLinkAsReference( String partnerLinkName, 
+			List<BPELPartnerLinkElement> partnerLinks ) {
+		BPELPartnerLinkElement partnerLink = findPartnerLinkByName( partnerLinks, partnerLinkName );
+		if( partnerLink == null ) {
+			System.out.println("BPEL TypeLoader - element references partnerLink " 
+								+ partnerLinkName + " not in the list");
+		} else {
+			// Set the type of the partnerLink to "service" if not already set...
+			if( !partnerLink.isSCATyped() ) partnerLink.setAsReference( partnerLinkName );
+		} // endif
+	} // end processPartnerLinkAsReference
+
+	/*
+	 * Finds a PartnerLink by name from a List of PartnerLinks
+	 * 
+	 * returns null if there is no partnerLink with a matching name
+	 * - returns the PartnerLink with a matching name
+	 */
+	private BPELPartnerLinkElement findPartnerLinkByName( List<BPELPartnerLinkElement> partnerLinks, 
+														  String partnerLinkName ) {
+		// Scan the list looking for a partner link with the supplied name
+		Iterator<BPELPartnerLinkElement> it = partnerLinks.iterator();
+		while( it.hasNext() ) {
+			BPELPartnerLinkElement thePartnerLink = it.next();
+			if( thePartnerLink.getName().equals(partnerLinkName) ) return thePartnerLink;
+		}
+		return null;
+	} // end method findPartnerLinkByName
+
 
 }

Modified: incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java?rev=654282&r1=654281&r2=654282&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java Wed May  7 14:17:29 2008
@@ -24,8 +24,11 @@
 import javax.xml.namespace.QName;
 
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
 import org.apache.tuscany.sca.assembly.ConstrainingType;
 import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
 import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
 import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
 import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
@@ -40,6 +43,7 @@
 
     private QName _processName;
     private BPELProcessDefinition _processDefinition;
+    private ComponentType componentType;
 
     /**
      * Constructs a new BPEL implementation.
@@ -88,6 +92,36 @@
         return Collections.emptyList();
     }
     
+    /* 
+     * Returns the componentType for this BPEL process implementation 
+     */
+    public ComponentType getComponentType() {
+        return componentType;
+    }
+
+    /*
+     * Sets the componentType for this BPEL process implementation
+     */
+    public void setComponentType(ComponentType componentType) {
+        this.componentType = componentType;
+    }
+    
+    @Override
+    /**
+     * Returns a List of the services for this BPEL process implementation
+     */
+    public List<Service> getServices() {
+        return componentType.getServices();
+    }
+
+    @Override
+    /**
+     * Returns a List of the references for this BPEL process implementation
+     */
+    public List<Reference> getReferences() {
+        return componentType.getReferences();
+    }
+    
     @Override
     public int hashCode() {
         return String.valueOf(this.getProcess()).hashCode();

Modified: incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java?rev=654282&r1=654281&r2=654282&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java Wed May  7 14:17:29 2008
@@ -22,14 +22,19 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.List;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import javax.wsdl.PortType;
+
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Multiplicity;
 import org.apache.tuscany.sca.assembly.Property;
 import org.apache.tuscany.sca.assembly.Reference;
 import org.apache.tuscany.sca.assembly.Service;
@@ -42,10 +47,19 @@
 import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
 import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
 import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory;
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
+
 import org.apache.tuscany.sca.implementation.bpel.BPELFactory;
 import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
 import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
 import org.apache.tuscany.sca.implementation.bpel.DefaultBPELFactory;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELPartnerLinkElement;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
 
 /**
  * Implements a STAX artifact processor for BPEL implementations.
@@ -64,9 +78,11 @@
     
     private AssemblyFactory assemblyFactory;
     private BPELFactory bpelFactory;
+    private WSDLFactory wsdlFactory;
     
     public BPELImplementationProcessor(ModelFactoryExtensionPoint modelFactories) {
         this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+        this.wsdlFactory = modelFactories.getFactory(WSDLFactory.class);
         this.bpelFactory = new DefaultBPELFactory(modelFactories);
     }
 
@@ -113,6 +129,9 @@
             
             impl.setProcessDefinition(processDefinition);
             
+            // Get the component type from the process definition
+            generateComponentType( impl );
+            
             //resolve component type
             mergeComponentType(resolver, impl);
                         
@@ -120,7 +139,7 @@
             impl.setUnresolved(false);
         }
         
-    }
+    } // end resolve
 
     /*
      * Write out the XML representation of the BPEL implementation
@@ -149,7 +168,7 @@
 
         writer.writeEndElement();
 
-    }
+    } // end write
 
     private BPELProcessDefinition resolveBPELProcessDefinition(BPELImplementation impl, ModelResolver resolver) throws ContributionResolveException {
         QName processName = impl.getProcess();
@@ -158,16 +177,136 @@
         processDefinition.setUnresolved(true);
         
         return resolver.resolveModel(BPELProcessDefinition.class, processDefinition);
-    }
+    } // end resolveBPELProcessDefinition
+    
+    // Calculates the component type of the supplied implementation and attaches it to the
+    // implementation
+    private void generateComponentType(BPELImplementation impl ) {
+        // Create a ComponentType and mark it unresolved
+        ComponentType componentType = assemblyFactory.createComponentType();
+        componentType.setUnresolved(true);
+        impl.setComponentType(componentType);
+        
+        // Each partner link in the process represents either a service or a reference
+        // - or both, in the sense of involving a callback
+        BPELProcessDefinition theProcess = impl.getProcessDefinition();
+        List<BPELPartnerLinkElement> partnerLinks = theProcess.getPartnerLinks();
+        
+        for( BPELPartnerLinkElement pLink : partnerLinks ) {
+        	// check that the partner link has been designated as service or reference in SCA terms
+        	if ( pLink.isSCATyped() ) {
+        		String SCAName = pLink.getSCAName(); 
+        		if( pLink.querySCAType().equals("reference") ) {
+        			componentType.getReferences().add(
+	        			generateReference( SCAName, 
+	        					           pLink.getMyRolePortType(), 
+	        					           pLink.getPartnerRolePortType(),
+		        					       theProcess.getInterfaces() )
+        			);
+        		} else {
+        			componentType.getServices().add(
+	        			generateService( SCAName, 
+	        					         pLink.getMyRolePortType(), 
+	        					         pLink.getPartnerRolePortType(),
+	        					         theProcess.getInterfaces() ) 
+        			);
+        		} // end if
+        	} // end if
+        } // end for
+        
+    	
+    } // end getComponentType
     
+    /**
+     * Create an SCA reference for a partnerLink
+     * @param name - name of the reference
+     * @param myRolePT - partner link type of myRole
+     * @param partnerRolePT - partner link type of partnerRole
+     * @param theInterfaces - list of WSDL interfaces associated with the BPEL process
+     * @return
+     */
+    private Reference generateReference( String name, PortType myRolePT, 
+    		PortType partnerRolePT, Collection<WSDLInterface> theInterfaces  ) {
+        Reference reference = assemblyFactory.createReference();
+        WSDLInterfaceContract interfaceContract = wsdlFactory.createWSDLInterfaceContract();
+        reference.setInterfaceContract(interfaceContract);
+        
+        // Set the name of the reference to the supplied name and the multiplicity of the reference
+        // to 1..1 
+        // TODO: support other multiplicities 
+        reference.setName(name);
+        reference.setMultiplicity(Multiplicity.ONE_ONE);
+
+        // Set the call interface and, if present, the callback interface
+        WSDLInterface callInterface = null;
+        for( WSDLInterface anInterface : theInterfaces ) {
+        	if( anInterface.getPortType().equals(myRolePT)) callInterface = anInterface;
+        } // end for
+        //TODO need to throw an exception here if no interface is found
+        reference.getInterfaceContract().setInterface(callInterface);
+ 
+        // There is a callback if the partner role is not null and if the partner role port type
+        // is not the same as the port type for my role
+        if (partnerRolePT != null && !myRolePT.equals(partnerRolePT) ) {
+            WSDLInterface callbackInterface = null;
+            for( WSDLInterface anInterface : theInterfaces ) {
+            	if( anInterface.getPortType().equals(myRolePT)) callbackInterface = anInterface;
+            } // end for
+            //TODO need to throw an exception here if no interface is found
+             reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+        } // end if
+    	
+    	return reference;
+    } // end generateReference
+    
+    /**
+     * Create an SCA service for a partnerLink
+     * @param name - name of the reference
+     * @param myRolePT - partner link type of myRole
+     * @param partnerRolePT - partner link type of partnerRole
+     * @param theInterfaces - list of WSDL interfaces associated with the BPEL process
+     * @return
+     */
+    private Service generateService( String name, PortType myRolePT, 
+    		PortType partnerRolePT, Collection<WSDLInterface> theInterfaces ) {
+        Service service = assemblyFactory.createService();
+        WSDLInterfaceContract interfaceContract = wsdlFactory.createWSDLInterfaceContract();
+        service.setInterfaceContract(interfaceContract);
+        
+        // Set the name of the service to the supplied name 
+        service.setName(name);
+
+        // Set the call interface and, if present, the callback interface
+        WSDLInterface callInterface = null;
+        for( WSDLInterface anInterface : theInterfaces ) {
+        	if( anInterface.getPortType().equals(myRolePT)) callInterface = anInterface;
+        } // end for
+        //TODO need to throw an exception here if no interface is found
+        service.getInterfaceContract().setInterface(callInterface);    
+        
+        // There is a callback if the partner role is not null and if the partner role port type
+        // is not the same as the port type for my role
+        if (partnerRolePT != null && !myRolePT.equals(partnerRolePT) ) {
+            WSDLInterface callbackInterface = null;
+            for( WSDLInterface anInterface : theInterfaces ) {
+            	if( anInterface.getPortType().equals(myRolePT)) callbackInterface = anInterface;
+            } // end for
+            //TODO need to throw an exception here if no interface is found
+            service.getInterfaceContract().setCallbackInterface(callbackInterface);
+        } // end if
+    	
+    	return service;
+    } // end generateService
     
     /**
-     * Merge the componentType from introspection and external file
+     * Merge the componentType from introspection and from external file
      * @param resolver
      * @param impl
      */
     private void mergeComponentType(ModelResolver resolver, BPELImplementation impl) {
         // FIXME: Need to clarify how to merge
+    	
+    	// Load the component type from a component type file, if any
         ComponentType componentType = getComponentType(resolver, impl);
         if (componentType != null && !componentType.isUnresolved()) {
             
@@ -184,17 +323,20 @@
             impl.getReferences().addAll(refMap.values());
 
             Map<String, Service> serviceMap = new HashMap<String, Service>();
-            for (Service svc : impl.getServices()) {
-                if(svc != null) {
-                    serviceMap.put(svc.getName(), svc);    
-                }
-            }
             for (Service service : componentType.getServices()) {
                 //set default dataBinding to DOM
                 service.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
                 
                 serviceMap.put(service.getName(), service);
             }
+            // For the present, overwrite anything arising from the component type sidefile if
+            // equivalent services are defined in the implementation
+            for (Service svc : impl.getServices()) {
+                if(svc != null) {
+                    serviceMap.put(svc.getName(), svc);    
+                }
+            }
+
             impl.getServices().clear();
             impl.getServices().addAll(serviceMap.values());
 
@@ -208,6 +350,8 @@
 
     private ComponentType getComponentType(ModelResolver resolver, BPELImplementation impl) {
         String bpelProcessURI = impl.getProcessDefinition().getURI().toString();
+        
+        // Get the component type definition contained in the componentType file, if any
         String componentTypeURI = bpelProcessURI.replace(".bpel", ".componentType");
         ComponentType componentType = assemblyFactory.createComponentType();
         componentType.setUnresolved(true);
@@ -217,9 +361,12 @@
             return componentType;
         }
         return null;
-    }
+    } // end getComponentType
 
     /*
+     * Returns a QName of a BPEL process as from its string representation in the process
+     * attribute in the process XML
+     * 
      * The process attribute of a BPEL process is a QName - this may be presented in one of
      * two alternative formats:
      * 1) In the form of a local name with a prefix, with the prefix referencing a namespace

Modified: incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java?rev=654282&r1=654281&r2=654282&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java Wed May  7 14:17:29 2008
@@ -21,10 +21,18 @@
 
 import java.net.URI;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collection;
 
 import javax.xml.namespace.QName;
+import javax.wsdl.PortType;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
 
 import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELImportElement;
+import org.apache.tuscany.sca.implementation.bpel.xml.BPELPartnerLinkElement;
 
 /**
  * The BPEL process definition implementation.
@@ -36,6 +44,10 @@
     private URI     uri;
     private URL     location;
     private boolean unresolved;
+    private List<BPELPartnerLinkElement> partnerLinks = new ArrayList<BPELPartnerLinkElement>();
+    private List<BPELImportElement> imports = new ArrayList<BPELImportElement>();
+    private Collection<PortType> thePortTypes = null;
+    private Collection<WSDLInterface> theInterfaces = null;
     
     public QName getName() {
         return name;
@@ -67,7 +79,47 @@
 
     public void setUnresolved(boolean undefined) {
         this.unresolved = undefined;
-    }   
+    }  
+    
+    /**
+     * Return the list of PartnerLinks for this process
+     * @return List<BPELPartnerLinkElement> the list of Partner Links
+     */
+    public List<BPELPartnerLinkElement> getPartnerLinks() {
+    	return partnerLinks;
+    }
+    
+    /**
+     * Return the list of imports for this process
+     * @return List<BPELImportElement> the list of Import elements
+     */
+    public List<BPELImportElement> getImports() {
+    	return imports;
+    }
+    
+    public void setPortTypes( Collection<PortType> thePortTypes ) {
+    	this.thePortTypes = thePortTypes;
+    }
+    
+    public Collection<PortType> getPortTypes() {
+    	return thePortTypes;
+    }
+    
+    /**
+     * Set the associated collection of WSDL interfaces
+     * @param theInterfaces
+     */
+    public void setInterfaces( Collection<WSDLInterface> theInterfaces ) {
+    	this.theInterfaces = theInterfaces;
+    } // end setInterfaces
+    
+    /**
+     * Return the collection of associated WSDL interfaces
+     * @return
+     */
+    public Collection<WSDLInterface> getInterfaces() {
+    	return theInterfaces;
+    } // end getInterfaces
     
     public void compile() {
         /*

Added: incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java?rev=654282&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java Wed May  7 14:17:29 2008
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.bpel.xml;
+
+import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
+
+/**
+ * Represents an <impotr.../> element in a BPEL process
+ * - this has attributes:
+ * 		location
+ * 		importType
+ * 		namespace
+ */
+public class BPELImportElement {
+	
+	private String location;
+    private String importType;
+    private String namespace;
+    private WSDLDefinition theWSDL = null;
+    
+    public BPELImportElement( String location, 
+    						  String importType,
+    						  String namespace  ) {
+        this.location = location;
+        this.importType = importType;
+        this.namespace = namespace;
+    }
+
+    public String getImportType() {
+        return importType;
+    }
+
+    public String getLocation() {
+        return location;
+    }
+    
+    public String getNamespace() {
+    	return namespace;
+    }
+    
+    public void setWSDLDefinition( WSDLDefinition theDefinition) {
+    	theWSDL = theDefinition;
+    }
+    
+    public WSDLDefinition getWSDLDefinition() {
+    	return theWSDL;
+    }
+    
+} // end class BPELImportElement

Added: incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java?rev=654282&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java Wed May  7 14:17:29 2008
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.bpel.xml;
+
+import javax.xml.namespace.QName;
+
+import javax.wsdl.PortType;
+
+/**
+ * Represents a <partnerLink.../> element in a BPEL process
+ * - this has attributes:
+ * 		name
+ * 		partnerLinkType
+ * 		myRole
+ * 		partnerRole
+ * - plus zero or more property elements as children
+ * 
+ * The partnerlink may also be given an SCA Type - either of service or of reference - this must
+ * generally be calculated and set on the partnerLink by inspecting the BPEL process
+ *
+ */
+public class BPELPartnerLinkElement {
+
+    private String 	REFERENCE_TYPE = "reference";
+    private String 	SERVICE_TYPE = "service";
+	private String 	name;
+	private QName	partnerLinkType;
+    private BPELPartnerLinkTypeElement 	pLinkType = null;
+    private String 	myRole;
+    private String 	partnerRole;
+    private String 	scaName;			// Holds the SCA reference or service name
+    private String 	scaType = null; 	// Holds the SCA type = null | service | reference
+    
+    public BPELPartnerLinkElement(String name, 
+    							  QName partnerLinkType,
+    							  String myRole, 
+    							  String partnerRole ) {
+        this.name = name;
+        this.partnerLinkType = partnerLinkType;
+        this.myRole = myRole;
+        this.partnerRole = partnerRole;
+        
+        scaName = null;
+    }
+
+    public QName getPartnerLinkType() {
+        return partnerLinkType;
+    }
+    
+    public void setPartnerLinkType( BPELPartnerLinkTypeElement pLinkType ) {
+    	this.pLinkType = pLinkType;
+    }
+    
+    
+    public PortType getMyRolePortType() {
+    	return getRolePortType( myRole );
+    }
+    
+    public PortType getPartnerRolePortType() {
+    	return getRolePortType( partnerRole );
+    }
+    
+    private PortType getRolePortType( String theRole ) {
+    	if ( pLinkType.getRole1Name().equals(theRole) ) {
+    		return pLinkType.getRole1pType();
+    	} else if ( pLinkType.getRole2Name().equals(theRole) ) {
+    		return pLinkType.getRole2pType();
+    	} // end if 
+    	return null;
+    } // end getRolePortType
+
+    public String getName() {
+        return name;
+    }
+    
+    public String getMyRole() {
+    	return myRole;
+    }
+    
+    public String getPartnerRole() {
+    	return partnerRole;
+    }
+    
+    public void setSCAName( String name ) {
+    	scaName = name;
+    }
+    
+    public String getSCAName() {
+    	return scaName;
+    }
+    
+    public boolean isSCATyped() {
+    	return ( !(scaType == null) );
+    }
+    
+    public void setAsReference( String name ) {
+    	scaType = REFERENCE_TYPE;
+    	scaName = name;
+    }
+    
+    public void setAsService( String name ) {
+    	scaType = SERVICE_TYPE;
+    	scaName = name;
+    }
+    
+    public String querySCAType() {
+    	return scaType;
+    }
+
+} // end class BPELPartnerLinkElement

Added: incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java?rev=654282&view=auto
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java Wed May  7 14:17:29 2008
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */package org.apache.tuscany.sca.implementation.bpel.xml;
+
+ import javax.xml.namespace.QName; 
+ 
+ import javax.wsdl.extensions.ExtensibilityElement;
+ import javax.wsdl.PortType;
+ 
+ /**
+  * Represents a <partnerLinkType.../> element related to a BPEL process
+  * - this has attributes:
+  * 		name
+  * 		Role1 name
+  * 		Role1 portType
+  * 		Role2 name
+  *         Role2 portType
+  *         
+  * - in the XML the 2 roles are child elements of the partnerLinkType element, but there
+  * seems little point in reflecting this back into this model - it is simpler to include
+  * both roles within the representation of the partnerLinkType itself
+  * 
+  */
+public class BPELPartnerLinkTypeElement implements ExtensibilityElement {
+	
+	private QName name;
+	private String Role1name = null;
+	private QName  Role1porttype = null;
+	private PortType	Role1pType = null;
+	private String Role2name = null;
+	private QName  Role2porttype = null;
+	private PortType	Role2pType = null;
+
+	
+	private QName  elementType = null;
+	private Boolean required = false;
+	
+	public BPELPartnerLinkTypeElement( QName name ) {
+		this.name = name;
+	}
+	
+	public QName getName(){
+		return name;
+	}
+	
+	public void setRole1( String name, QName portType, PortType pType ) {
+		Role1name = name;
+		Role1porttype = portType;
+		Role1pType = pType;
+	}
+	
+	public void setRole2( String name, QName portType, PortType pType ) {
+		Role2name = name;
+		Role2porttype = portType;
+		Role2pType = pType;
+	}
+	
+	public String getRole1Name() {
+		return Role1name;
+	}
+	public String getRole2Name() {
+		return Role2name;
+	}
+	
+	public QName getRole1PortType() {
+		return Role1porttype;
+	}
+	
+	public QName getRole2PortType() {
+		return Role2porttype;
+	}
+	
+	public PortType getRole1pType() {
+		return Role1pType;
+	}
+	
+	public PortType getRole2pType() {
+		return Role2pType;
+	}
+	
+	public QName getElementType() {
+		return elementType;
+	}
+	
+    public Boolean getRequired() {
+    	return required;
+    }
+    
+    public void setElementType(QName elementType) {
+    	this.elementType = elementType;
+    }
+    
+    public void setRequired(java.lang.Boolean required) {
+    	this.required = required;
+    }
+    
+} // end BPELPartnerLinkType