tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r718858 [6/9] - in /tuscany/java/sca/modules: ./ assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ assembly-xml/src/main/resources/ assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ assembly-xml/src/test/resource...
Date Wed, 19 Nov 2008 05:28:12 GMT
Modified: tuscany/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties (original)
+++ tuscany/java/sca/modules/contribution-namespace/src/main/resources/contribution-namespace-validation-messages.properties Tue Nov 18 21:27:58 2008
@@ -19,4 +19,5 @@
 #
 #
 AttributeNameSpaceMissing = Attribute 'namespace' is missing
+XMLStreamException = XMLStreamException occured due to : {0}
 

Modified: tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceExportProcessor.java Tue Nov 18 21:27:58 2008
@@ -71,6 +71,20 @@
 	        monitor.problem(problem);
     	 }
      }
+     
+     /**
+      * Report a exception.
+      * 
+      * @param problems
+      * @param message
+      * @param model
+      */
+     private void error(String message, Object model, Exception ex) {
+         if (monitor != null) {
+             Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-resource-validation-messages", Severity.ERROR, model, message, ex);
+             monitor.problem(problem);
+         }
+     }
 
     public QName getArtifactType() {
         return EXPORT_RESOURCE;
@@ -83,39 +97,45 @@
     /**
      * Process <export.resource uri=""/>
      */
-    public ResourceExport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+    public ResourceExport read(XMLStreamReader reader) throws ContributionReadException {
     	ResourceExport resourceExport = this.factory.createResourceExport();
         QName element = null;
         
-        while (reader.hasNext()) {
-            int event = reader.getEventType();
-            switch (event) {
-                case START_ELEMENT:
-                    element = reader.getName();
-                    
-                    // Read <export.resource>
-                    if (EXPORT_RESOURCE.equals(element)) {
-                        String uri = reader.getAttributeValue(null, URI);
-                        if (uri == null) {
-                        	error("AttributeURIMissing", reader);
-                            //throw new ContributionReadException("Attribute 'uri' is missing");
-                        } else
-                            resourceExport.setURI(uri);
-                    } 
-                    
-                    break;
-                case XMLStreamConstants.END_ELEMENT:
-                    if (EXPORT_RESOURCE.equals(reader.getName())) {
-                        return resourceExport;
-                    }
-                    break;        
-            }
-            
-            // Read the next element
-            if (reader.hasNext()) {
-                reader.next();
+        try {
+            while (reader.hasNext()) {
+                int event = reader.getEventType();
+                switch (event) {
+                    case START_ELEMENT:
+                        element = reader.getName();
+                        
+                        // Read <export.resource>
+                        if (EXPORT_RESOURCE.equals(element)) {
+                            String uri = reader.getAttributeValue(null, URI);
+                            if (uri == null) {
+                            	error("AttributeURIMissing", reader);
+                                //throw new ContributionReadException("Attribute 'uri' is missing");
+                            } else
+                                resourceExport.setURI(uri);
+                        } 
+                        
+                        break;
+                    case XMLStreamConstants.END_ELEMENT:
+                        if (EXPORT_RESOURCE.equals(reader.getName())) {
+                            return resourceExport;
+                        }
+                        break;        
+                }
+                
+                // Read the next element
+                if (reader.hasNext()) {
+                    reader.next();
+                }
             }
         }
+        catch (XMLStreamException e) {
+            ContributionReadException ex = new ContributionReadException(e);
+            error("XMLStreamException", reader, ex);
+        }
         
         return resourceExport;
     }

Modified: tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-resource/src/main/java/org/apache/tuscany/sca/contribution/resource/impl/ResourceImportProcessor.java Tue Nov 18 21:27:58 2008
@@ -73,6 +73,20 @@
 	        monitor.problem(problem);
     	 }
      }
+     
+     /**
+      * Report a exception.
+      * 
+      * @param problems
+      * @param message
+      * @param model
+      */
+     private void error(String message, Object model, Exception ex) {
+         if (monitor != null) {
+             Problem problem = new ProblemImpl(this.getClass().getName(), "contribution-resource-validation-messages", Severity.ERROR, model, message, ex);
+             monitor.problem(problem);
+         }
+     }
     
     public QName getArtifactType() {
         return IMPORT_RESOURCE;
@@ -85,43 +99,49 @@
     /**
      * Process <import.resource uri="" location=""/>
      */
-    public ResourceImport read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+    public ResourceImport read(XMLStreamReader reader) throws ContributionReadException {
     	ResourceImport resourceImport = this.factory.createResourceImport();
         QName element;
         
-        while (reader.hasNext()) {
-            int event = reader.getEventType();
-            switch (event) {
-                case START_ELEMENT:
-                    element = reader.getName();
-
-                    // Read <import>
-                    if (IMPORT_RESOURCE.equals(element)) {
-                        String uri = reader.getAttributeValue(null, URI);
-                        if (uri == null) {
-                        	error("AttributeURIMissing", reader);
-                            //throw new ContributionReadException("Attribute 'uri' is missing");
-                        } else
-                            resourceImport.setURI(uri);
-
-                        String location = reader.getAttributeValue(null, LOCATION);
-                        if (location != null) {
-                            resourceImport.setLocation(location);
+        try {
+            while (reader.hasNext()) {
+                int event = reader.getEventType();
+                switch (event) {
+                    case START_ELEMENT:
+                        element = reader.getName();
+    
+                        // Read <import>
+                        if (IMPORT_RESOURCE.equals(element)) {
+                            String uri = reader.getAttributeValue(null, URI);
+                            if (uri == null) {
+                            	error("AttributeURIMissing", reader);
+                                //throw new ContributionReadException("Attribute 'uri' is missing");
+                            } else
+                                resourceImport.setURI(uri);
+    
+                            String location = reader.getAttributeValue(null, LOCATION);
+                            if (location != null) {
+                                resourceImport.setLocation(location);
+                            }
                         }
-                    }
-                    break;
-                case XMLStreamConstants.END_ELEMENT:
-                    if (IMPORT_RESOURCE.equals(reader.getName())) {
-                        return resourceImport;
-                    }
-                    break;        
-            }
-            
-            // Read the next element
-            if (reader.hasNext()) {
-                reader.next();
+                        break;
+                    case XMLStreamConstants.END_ELEMENT:
+                        if (IMPORT_RESOURCE.equals(reader.getName())) {
+                            return resourceImport;
+                        }
+                        break;        
+                }
+                
+                // Read the next element
+                if (reader.hasNext()) {
+                    reader.next();
+                }
             }
         }
+        catch (XMLStreamException e) {
+            ContributionReadException ex = new ContributionReadException(e);
+            error("XMLStreamException", reader, ex);
+        }
         
         return resourceImport;
     }

Modified: tuscany/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties (original)
+++ tuscany/java/sca/modules/contribution-resource/src/main/resources/contribution-resource-validation-messages.properties Tue Nov 18 21:27:58 2008
@@ -19,4 +19,5 @@
 #
 #
 AttributeURIMissing = Attribute 'uri' is missing
+XMLStreamException = XMLStreamException occured due to : {0}
 

Propchange: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Nov 18 21:27:58 2008
@@ -0,0 +1 @@
+/tuscany/branches/sca-java-1.x/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor:713805-714043

Modified: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java Tue Nov 18 21:27:58 2008
@@ -23,13 +23,14 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.tuscany.sca.contribution.Constants;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
 import org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
 import org.apache.tuscany.sca.monitor.Monitor;
 
 /**
@@ -38,9 +39,9 @@
  * @version $Rev$ $Date$
  */
 public class AnyAttributeProcessor extends BaseStAXArtifactProcessor implements StAXAttributeProcessor<String> {
-	private static final QName ANY_ATTRIBUTE = new QName("http://www.w3.org/2001/XMLSchema", "anyAttribute");
+	private static final QName ANY_ATTRIBUTE = new QName(Constants.XMLSCHEMA_NS, "anyAttribute");
 	
-	public AnyAttributeProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
+	public AnyAttributeProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
 		
 	}
 	

Propchange: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java Tue Nov 18 21:27:58 2008
@@ -20,290 +20,155 @@
 
 import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
 import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.CHARACTERS;
+import static javax.xml.stream.XMLStreamConstants.COMMENT;
+import static javax.xml.stream.XMLStreamConstants.CDATA;
 
 import java.util.ArrayList;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
 
+import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.events.Characters;
+import javax.xml.stream.events.XMLEvent;
 
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.Constants;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
 import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.Problem;
-import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.DocumentTraversal;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.TreeWalker;
+import org.apache.tuscany.sca.contribution.processor.xml.XMLEventsStreamReader;
 
 public class AnyElementProcessor implements StAXArtifactProcessor<Object> {
-	private static final QName ANY_ELEMENT = new QName("http://www.w3.org/2001/XMLSchema", "anyElement");
-	
-	private static final Logger logger = Logger.getLogger(AnyElementProcessor.class.getName());
-	private DocumentBuilderFactory documentBuilderFactory;
-	private Document document;
+	private static final QName ANY_ELEMENT = new QName(Constants.XMLSCHEMA_NS,
+			"anyElement");
+
+	private XMLInputFactory xmlInputFactory;
+	@SuppressWarnings("unused")
 	private Monitor monitor;
-	
-	public AnyElementProcessor(FactoryExtensionPoint modelFactories, Monitor monitor) {
-		documentBuilderFactory = modelFactories.getFactory(DocumentBuilderFactory.class);
+	//Map<String, NamespaceContext> map = new HashMap<String, NamespaceContext>();
+
+	public AnyElementProcessor(ModelFactoryExtensionPoint modelFactories,
+			Monitor monitor) {
+		xmlInputFactory = modelFactories.getFactory(XMLInputFactory.class);
 		this.monitor = monitor;
 	}
-	
 
-    public QName getArtifactType() {
-        return ANY_ELEMENT;
-    }
-
-    public Class<Object> getModelType() {
-        return Object.class;
-    }
-    
+	public QName getArtifactType() {
+		return ANY_ELEMENT;
+	}
+
+	public Class<Object> getModelType() {
+		return Object.class;
+	}
+
 	/**
-	 * Reads the contetns of the unknown elements and generates the DOM	
+	 * Reads the contetns of the unknown elements and generates a custom
+	 * implementation of XMLStreamReader i.e. XMLEventsStreamReader
+	 * 
 	 * @param reader
-	 * @param name
 	 * @return
 	 * @throws XMLStreamException
 	 */
-    public Object read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
-		
-		int event = reader.getEventType();
-		int level = 0;
-		ArrayList<String> elementList = new ArrayList<String>();
-		document = createDocument();
-		
-		QName name = reader.getName();
-		
-		while(reader.hasNext()){
-	    	switch(event){
-		    	case START_ELEMENT:
-		    		elementList.add(reader.getName().getLocalPart());
-		    		if(level == 0){
-		    			generateDOM(reader,null);
-		    			level++;
-		    		}
-		    		else{
-		    			generateDOM(reader,elementList.get(elementList.size()-2).toString());
-		    		}
-		    		
-		    		break;
-		    	case END_ELEMENT:
-		    		elementList.remove(reader.getName().getLocalPart());
-	    	}
-	    	if(reader.hasNext()){
-	    		event = reader.next();
-	    	}
-	      	
-	      	if(event == START_ELEMENT || event == END_ELEMENT){
-	      		if(reader.getName().equals(name)){
-	      			break;
-	      		}
-	      	}
-	    }
-		return document;
-	}
+	@SuppressWarnings("unchecked")
+	public Object read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
 
-	/**
-	 * Writes unknown portions back to the writer
-	 * @param model
-	 * @param writer
-	 */
-	public void write(Object model, XMLStreamWriter writer) {
+		//Custom variables
+		String currentElement = null;
+		List eventsList = new ArrayList();
 		
-		if( ! (model instanceof Document)) {
-			return;
-		}
+		Map<String, NamespaceContext> eventContext = new HashMap<String, NamespaceContext>();
 		
-		Document doc = (Document)model;
 		try{
-			DocumentTraversal traversal = (DocumentTraversal)doc;
-			TreeWalker walker = traversal.createTreeWalker(doc.getDocumentElement(),NodeFilter.SHOW_ALL, null, true);
-			writeDOM(walker,writer);
-		}
-		catch(Exception e){
-			if (logger.isLoggable(Level.SEVERE)) {
-                logger.log(Level.SEVERE, "Document not created ");
-            }
-			error("Document not created",document,e);
-		}
-	}
-
-    public void resolve(Object arg0, ModelResolver arg1) throws ContributionResolveException {
-    	
-    }
-    
-	/**
-	 * Method to generate the DOM
-	 * @param reader
-	 * @param parent
-	 * @throws Exception 
-	 */
-	//private void generateDOM(String elementText, String parent) {
-	private void generateDOM(XMLStreamReader reader, String parent) {
-		try{
-			String elePrefix = reader.getPrefix();
-			String eleQName = reader.getLocalName();
-			if (elePrefix != null && elePrefix.length() != 0) {
-                eleQName = elePrefix + ":" + eleQName;
-            }
+			//Cast the block of unknown elements into document
+			XMLDocumentStreamReader docReader = new XMLDocumentStreamReader(reader);
+					
+			XMLEventReader xmlEventReader = xmlInputFactory.createXMLEventReader(docReader);
 			
-			Element element = document.createElementNS(reader.getNamespaceURI(), eleQName);
+			while (xmlEventReader.hasNext()) {
+				XMLEvent event = xmlEventReader.nextEvent();
 				
-			int attributeCount = reader.getAttributeCount();
-			for(int i = 0;i < attributeCount;i++){
-				String ns = reader.getAttributeNamespace(i);
-                String prefix = reader.getAttributePrefix(i);
-                String qname = reader.getAttributeLocalName(i);
-                String value = reader.getAttributeValue(i);
-                if (prefix != null && prefix.length() != 0) {
-                    qname = prefix + ":" + qname;
-                }
-                element.setAttributeNS(ns,qname,value);
-			}
-			if(parent == null){
-				if(document != null){
-					document.appendChild(element);
+				//Populate the eventContext map with the current element's name and corresponding NamesapceContext
+				if (currentElement != null && !(eventContext.containsKey(currentElement))) {
+					eventContext.put(currentElement, reader.getNamespaceContext());
 				}
-				else{
-					if (logger.isLoggable(Level.SEVERE)) {
-	                    logger.log(Level.SEVERE, "Document not created ");
-	                }
-					error("Document not created",document,element);
-				}
-			}
-			else{
-				Node parentNode = getParentNode(document,parent);
-				if(parentNode != null){
-					parentNode.appendChild(element);
+				
+				//Populate the list with the XMLEvents
+				eventsList.add(event);
+				if (event.isStartElement()) {
+					currentElement = reader.getName().getLocalPart();
 				}
-				else{
-					if (logger.isLoggable(Level.SEVERE)) {
-						logger.log(Level.SEVERE, "Parent node not found");
-					}
-					error("Parent node not found",document,parentNode.getNodeName());
+				if (event.isEndDocument()) {
+					return new XMLEventsStreamReader(eventsList, eventContext);
 				}
 			}
 		}
 		catch(Exception e){
 			e.printStackTrace();
-			if (logger.isLoggable(Level.SEVERE)) {
-                logger.log(Level.SEVERE, "Document not created ");
-            }
-			error("Document not created",document,e);
 		}
+		return null;
 	}
 
 	/**
-	 * Method to create an empty document
-	 * @return
-	 */
-	private Document createDocument() {
-		try {
-	        document = documentBuilderFactory.newDocumentBuilder().newDocument();
-	        return document;
-	    } catch (ParserConfigurationException e) {
-	    	e.printStackTrace();
-	    }
-	    return null;
-	}
-
-	/**
-	 * Method to traverse the DOM structure and write the elements 
-	 * @param walker
+	 * Writes unknown portions back to the writer
+	 * 
+	 * @param model
 	 * @param writer
-	 * @throws XMLStreamException
 	 */
-	private void writeDOM(TreeWalker walker,XMLStreamWriter writer) throws XMLStreamException {
-	  
-	    Node parent = walker.getCurrentNode();
-	    
-	    writer.writeStartElement(parent.getPrefix(), parent.getLocalName(), parent.getNamespaceURI());
-	    
-	    NamedNodeMap attributes = parent.getAttributes();
-	   
-	    for(int i = 0;i<attributes.getLength();i++){
-		   writer.writeAttribute(attributes.item(i).getPrefix(), attributes.item(i).getNamespaceURI(), attributes.item(i).getLocalName(), attributes.item(i).getNodeValue());
-	    }
-	    	   
-	    for (Node n = walker.firstChild();n != null;n = walker.nextSibling()) {
-	      writeDOM(walker,writer);
-	    }
-	    writer.writeEndElement();
-	    
-	    walker.setCurrentNode(parent);
-	}
-
-	/**
-	 * Method to get the Parent node out of the DOM structure
-	 * @param doc
-	 * @param parent
-	 * @return
-	 */
-	private Node getParentNode(Node doc,String parent) {
-		Node parentNode = null;
-		try{
-			DocumentTraversal traversal = (DocumentTraversal)doc;
-			
-			CharSequence prefixChar = ":";
-			NodeIterator iterator = traversal.createNodeIterator(document.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null, true);
-			for (Node n = iterator.nextNode(); n != null; n = iterator.nextNode()) {
-				String nodeName = n.getNodeName();
-				String[] str = null;
-				if(n.getNodeName().contains(prefixChar)){
-					str = nodeName.split(":");
-					nodeName = str[str.length-1];
-				}
-				if(parent.equalsIgnoreCase(nodeName)){
-			    	  parentNode = n;
-			    	}
-			    }
-			return parentNode;
+	public void write(Object model, XMLStreamWriter writer)
+			throws XMLStreamException {
+		if (!(model instanceof XMLStreamReader)) {
+			return;
 		}
-		catch(Exception e){
-			e.printStackTrace();
+		XMLStreamReader reader = (XMLStreamReader) model;
+		
+		int event = reader.getEventType();
+		while (reader.hasNext()) {
+			switch (event) {
+			case START_ELEMENT:
+											
+				writer.writeStartElement(reader.getPrefix(), reader
+						.getLocalName(), reader.getNamespaceURI());
+				for (int i = 1; i <= reader.getAttributeCount(); i++) {
+					writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), 
+							reader.getAttributeLocalName(i), reader.getAttributeValue(i));
+				}
+				break;
+				
+			case CHARACTERS:
+				writer.writeCharacters(reader.getText());	
+				break;
+				
+			case CDATA:				
+				writer.writeCData(reader.getText());
+				break;
+
+			case END_ELEMENT:
+				writer.writeEndElement();
+				break;
+			}
+			if (reader.hasNext()) {
+				event = reader.next();
+			}
 		}
-		return parentNode;
 	}
-	
-	 /**
-     * Marshals exceptions into the monitor
-     * 
-     * @param problems
-     * @param message
-     * @param model
-     */
-    private void error(String message, Object model, Exception ex) {
-    	if (monitor != null) {
-	        Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, ex);
-	        monitor.problem(problem);
-    	}
-    }
-    
-    /**
-     * Report a error.
-     * 
-     * @param problems
-     * @param message
-     * @param model
-     */
-    private void error(String message, Object model, Object... messageParameters) {
-    	if (monitor != null) {
-	        Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
-	        monitor.problem(problem);
-    	}
-    }
-	
+
+	public void resolve(Object model, ModelResolver resolver)
+			throws ContributionResolveException {
+		// TODO Auto-generated method stub
+
+	}
+
 }

Propchange: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Nov 18 21:27:58 2008
@@ -0,0 +1,2 @@
+/tuscany/branches/sca-java-1.3/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultUnknownElementProcessor.java:671193
+/tuscany/branches/sca-java-1.x/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java:713805-714043

Modified: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java Tue Nov 18 21:27:58 2008
@@ -33,6 +33,7 @@
 import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.core.FactoryExtensionPoint;
 import org.apache.tuscany.sca.monitor.Monitor;
@@ -60,7 +61,7 @@
     public ContributionMetadataDocumentProcessor(FactoryExtensionPoint modelFactories,
                                                  StAXArtifactProcessor staxProcessor,
                                                  Monitor monitor) {
-        this.inputFactory = modelFactories.getFactory(XMLInputFactory.class);
+        this.inputFactory = modelFactories.getFactory(ValidatingXMLInputFactory.class);
         this.staxProcessor = staxProcessor;
         this.monitor = monitor;
     }

Modified: tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java (original)
+++ tuscany/java/sca/modules/contribution-xml/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java Tue Nov 18 21:27:58 2008
@@ -105,63 +105,69 @@
         return ContributionMetadata.class;
     }
 
-    public ContributionMetadata read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+    public ContributionMetadata read(XMLStreamReader reader) throws ContributionReadException {
         ContributionMetadata contribution = null;
         QName name = null;
         
-        while (reader.hasNext()) {
-            int event = reader.getEventType();
-            switch (event) {
-                case START_ELEMENT:
-                    name = reader.getName();
-                    
-                    if (CONTRIBUTION_QNAME.equals(name)) {
-
-                        // Read <contribution>
-                        contribution = this.contributionFactory.createContributionMetadata();
-                        contribution.setUnresolved(true);
-                        
-                    } else if (DEPLOYABLE_QNAME.equals(name)) {                        
+        try {
+            while (reader.hasNext()) {
+                int event = reader.getEventType();
+                switch (event) {
+                    case START_ELEMENT:
+                        name = reader.getName();
                         
-                        // Read <deployable>
-                        QName compositeName = getQName(reader, "composite");
-                        if (compositeName == null) {
-                        	error("AttributeCompositeMissing", reader);
-                            //throw new ContributionReadException("Attribute 'composite' is missing");
+                        if (CONTRIBUTION_QNAME.equals(name)) {
+    
+                            // Read <contribution>
+                            contribution = this.contributionFactory.createContributionMetadata();
+                            contribution.setUnresolved(true);
+                            
+                        } else if (DEPLOYABLE_QNAME.equals(name)) {                        
+                            
+                            // Read <deployable>
+                            QName compositeName = getQName(reader, "composite");
+                            if (compositeName == null) {
+                            	error("AttributeCompositeMissing", reader);
+                                //throw new ContributionReadException("Attribute 'composite' is missing");
+                            } else {
+                                if (contribution != null) {
+                                    Composite composite = assemblyFactory.createComposite();
+                                    composite.setName(compositeName);
+                                    composite.setUnresolved(true);
+                                    contribution.getDeployables().add(composite);                         
+                                }
+                            }
                         } else {
-                            if (contribution != null) {
-                                Composite composite = assemblyFactory.createComposite();
-                                composite.setName(compositeName);
-                                composite.setUnresolved(true);
-                                contribution.getDeployables().add(composite);                         
+    
+                            // Read an extension element
+                            Object extension = extensionProcessor.read(reader);
+                            if (extension != null && contribution != null) {
+                                if (extension instanceof Import) {
+                                    contribution.getImports().add((Import)extension);
+                                } else if (extension instanceof Export) {
+                                    contribution.getExports().add((Export)extension);
+                                }
                             }
                         }
-                    } else {
-
-                        // Read an extension element
-                        Object extension = extensionProcessor.read(reader);
-                        if (extension != null && contribution != null) {
-                            if (extension instanceof Import) {
-                                contribution.getImports().add((Import)extension);
-                            } else if (extension instanceof Export) {
-                                contribution.getExports().add((Export)extension);
-                            }
+                        break;
+                        
+                    case XMLStreamConstants.END_ELEMENT:
+                        if (CONTRIBUTION_QNAME.equals(reader.getName())) {
+                            return contribution;
                         }
-                    }
-                    break;
-                    
-                case XMLStreamConstants.END_ELEMENT:
-                    if (CONTRIBUTION_QNAME.equals(reader.getName())) {
-                        return contribution;
-                    }
-                    break;        
-            }
-            
-            //Read the next element
-            if (reader.hasNext()) {
-                reader.next();
+                        break;        
+                }
+                
+                //Read the next element
+                if (reader.hasNext()) {
+                    reader.next();
+                }
             }
         }
+        catch (XMLStreamException e) {
+            ContributionReadException ex = new ContributionReadException(e);
+            error("XMLStreamException", reader, ex);
+        }
         
         return contribution;
     }

Modified: tuscany/java/sca/modules/contribution-xml/src/main/resources/contribution-xml-validation-messages.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-xml/src/main/resources/contribution-xml-validation-messages.properties?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution-xml/src/main/resources/contribution-xml-validation-messages.properties (original)
+++ tuscany/java/sca/modules/contribution-xml/src/main/resources/contribution-xml-validation-messages.properties Tue Nov 18 21:27:58 2008
@@ -18,6 +18,7 @@
 #    under the License.
 #
 #
-XMLStreamException = XMLStreamException occured due to:
-IOException = IOException occured due to:
-AttributeCompositeMissing = Attribute 'composite' is missing
\ No newline at end of file
+XMLStreamException = XMLStreamException occured due to : {0}
+IOException = IOException occured due to : {0}
+AttributeCompositeMissing = Attribute 'composite' is missing
+

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Constants.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Constants.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Constants.java (original)
+++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Constants.java Tue Nov 18 21:27:58 2008
@@ -25,6 +25,8 @@
  * @version $Rev$ $Date$
  */
 public interface Constants {
-    String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
+    String XMLSCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
+    
+	String SCA10_NS = "http://www.osoa.org/xmlns/sca/1.0";
     String SCA10_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.0";
 }

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java (original)
+++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java Tue Nov 18 21:27:58 2008
@@ -32,11 +32,26 @@
     String JAR = "application/x-compressed";
 
     /**
+     * Zip archive contribution package
+     */
+    String ZIP = "application/x-compressed";
+
+    /**
      * Filesystem folder contribution package
      */
     String FOLDER = "application/vnd.tuscany.folder";
     
     
     String BUNDLE = "application/osgi.bundle";
+    
+    /**
+     * Java EE Web Application Archive
+     */
+    String WAR = "application/war";
+    
+    /**
+     * Java EE Enterprise Application Archive
+     */
+    String EAR = "application/ear";
 
 }

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java (original)
+++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java Tue Nov 18 21:27:58 2008
@@ -33,6 +33,7 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.tuscany.sca.contribution.Constants;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
 import org.apache.tuscany.sca.monitor.Monitor;
 import org.apache.tuscany.sca.monitor.Problem;
@@ -47,9 +48,8 @@
  * @version $Rev$ $Date$
  */
 public class ExtensibleStAXArtifactProcessor implements StAXArtifactProcessor<Object> {
-    private static final Logger logger = Logger.getLogger(ExtensibleStAXArtifactProcessor.class.getName()); 
 	
-    private static final QName ANY_ELEMENT = new QName("http://www.w3.org/2001/XMLSchema", "anyElement");
+	private static final QName ANY_ELEMENT = new QName(Constants.XMLSCHEMA_NS, "anyElement");
 
     private XMLInputFactory inputFactory;
     private XMLOutputFactory outputFactory;
@@ -134,8 +134,14 @@
                 logger.warning("Element " + name + " cannot be processed. (" + location + ")");
             }
             warning("ElementCannotBeProcessed", processors, name, location);
+
+            StAXArtifactProcessor anyElementProcessor = processors.getProcessor(ANY_ELEMENT);
+            if(anyElementProcessor != null) {
+            	return anyElementProcessor.read(source);	
+            } else {
+            	return null;
+            }
             
-            return null;
             
             //FIXME Re-enable feature after complete merge is done
             /*
@@ -163,14 +169,10 @@
                     logger.warning("No StAX processor is configured to handle " + model.getClass());
                 }
                 warning("NoStaxProcessor", processors, model.getClass());
-                
-                //FIXME Re-enable feature after complete merge is done
-                /*
                 StAXArtifactProcessor anyElementProcessor = processors.getProcessor(ANY_ELEMENT);
-                if (anyElementProcessor != null) {
-                    anyElementProcessor.write(model, outputSource);
+                if(anyElementProcessor != null) {
+                	anyElementProcessor.write(model, outputSource);
                 }
-                */
             }
         }
     }

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java (original)
+++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java Tue Nov 18 21:27:58 2008
@@ -21,6 +21,7 @@
 
 import java.util.logging.Logger;
 
+import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 import javax.xml.stream.Location;
 import javax.xml.stream.XMLStreamConstants;
@@ -46,7 +47,8 @@
  *
  * @version $Rev$ $Date$
  */
-class ValidatingXMLStreamReader extends StreamReaderDelegate implements XMLStreamReader {
+class ValidatingXMLStreamReader extends TuscanyXMLStreamReader implements XMLStreamReader {
+
     private static final Logger logger = Logger.getLogger(ValidatingXMLStreamReader.class.getName());
     
     private int level;
@@ -259,6 +261,11 @@
         }
     }
     
+    @Override
+    public NamespaceContext getNamespaceContext(){
+    	return super.getNamespaceContext();
+    }
+    
     /**
      * Handle a start element event.
      * 

Modified: tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/CallableReferenceDataBinding.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/CallableReferenceDataBinding.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/CallableReferenceDataBinding.java (original)
+++ tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/CallableReferenceDataBinding.java Tue Nov 18 21:27:58 2008
@@ -26,12 +26,11 @@
 public class CallableReferenceDataBinding extends BaseDataBinding {
     
     public static final String NAME = CallableReference.class.getName();
-    public static final String[] ALIASES = new String[] {"callablereference"};
 
     private CallableReferenceTypeHelper xmlTypeHelper;
 
     public CallableReferenceDataBinding() {
-        super(NAME, ALIASES, CallableReference.class);
+        super(NAME, CallableReference.class);
         this.xmlTypeHelper = new CallableReferenceTypeHelper();
     }
 

Modified: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java (original)
+++ tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java Tue Nov 18 21:27:58 2008
@@ -18,6 +18,7 @@
  */
 package org.apache.tuscany.sca.invocation;
 
+import java.util.List;
 import java.util.Map;
 
 import org.apache.tuscany.sca.interfacedef.Operation;
@@ -29,7 +30,6 @@
  * @version $Rev $Date$
  */
 public interface Message {
-    String QOS_CTX_SECURITY_PRINCIPAL = "PRINCIPAL";
 
     /**
      * Returns the body of the message, which will be the payload or parameters associated with the wire
@@ -108,17 +108,9 @@
     void setOperation(Operation op);
     
     /** 
-     * Returns a map of objects that represents the QoS context that wraps this message such as 
-     * invoking authenticated principal and so on.
+     * Returns a list of objects that are contained in the message header
      * 
      * @return
      */
-    Map<String, Object> getQoSContext();
-    
-    /** 
-     * Returns a map of objects that are contained in the message header
-     * 
-     * @return
-     */
-    Map<String, Object> getHeader();
+    List<Object> getHeaders();
 }

Modified: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java (original)
+++ tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java Tue Nov 18 21:27:58 2008
@@ -37,6 +37,16 @@
     // reference binding invoker
     String REFERENCE_BINDING = "reference.binding";
 
+    String REFERENCE_BINDING_WIREFORMAT = "reference.binding.wireformat";
+    String REFERENCE_BINDING_POLICY = "reference.binding.policy";
+    String REFERENCE_BINDING_TRANSPORT = "reference.binding.transport";
+
+    String SERVICE_BINDING_TRANSPORT = "service.binding.transport";
+    String SERVICE_BINDING_OPERATION_SELECTOR = "service.binding.operationselector";
+    String SERVICE_BINDING_WIREFORMAT = "service.binding.wireformat";
+    String SERVICE_BINDING_POLICY = "service.binding.policy";
+    
+    
     // The first phase for incoming invocations via a service
     String SERVICE_BINDING = "service.binding";
 

Modified: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java (original)
+++ tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java Tue Nov 18 21:27:58 2008
@@ -113,6 +113,8 @@
         loadProviderFactories(BindingProviderFactory.class);
         loadProviderFactories(ImplementationProviderFactory.class);
         loadProviderFactories(PolicyProviderFactory.class);
+        loadProviderFactories(WireFormatProviderFactory.class);
+        loadProviderFactories(OperationSelectorProviderFactory.class);
 
         loaded = true;
     }
@@ -171,6 +173,26 @@
                     new LazyPolicyProviderFactory(registry, modelTypeName, factoryDeclaration);
                 factoryExtensionPoint.addProviderFactory(factory);
                 factories.add(factory);
+            } else if (factoryClass == WireFormatProviderFactory.class) {
+
+                // Load a wire format provider factory
+                String modelTypeName = attributes.get("model");
+
+                // Create a provider factory wrapper and register it
+                WireFormatProviderFactory factory =
+                    new LazyWireFormatProviderFactory(registry, modelTypeName, factoryDeclaration);
+                factoryExtensionPoint.addProviderFactory(factory);
+                factories.add(factory);
+            } else if (factoryClass == OperationSelectorProviderFactory.class) {
+
+                // Load a wire format provider factory
+                String modelTypeName = attributes.get("model");
+
+                // Create a provider factory wrapper and register it
+                OperationSelectorProviderFactory factory =
+                    new LazyOperationSelectorProviderFactory(registry, modelTypeName, factoryDeclaration);
+                factoryExtensionPoint.addProviderFactory(factory);
+                factories.add(factory);
             }
         }
         return factories;
@@ -356,7 +378,132 @@
             }
             return modelType;
         }
+    }
 
+    /**
+     * A wrapper around a wire format provider factory allowing lazy
+     * loading and initialization of wire format providers.
+     */
+    private class LazyWireFormatProviderFactory implements WireFormatProviderFactory {
+
+        private ExtensionPointRegistry registry;
+        private String modelTypeName;
+        private ServiceDeclaration providerClass;
+        private WireFormatProviderFactory factory;
+        private Class modelType;
+
+        private LazyWireFormatProviderFactory(ExtensionPointRegistry registry,
+                                              String modelTypeName,
+                                              ServiceDeclaration providerClass) {
+            this.registry = registry;
+            this.modelTypeName = modelTypeName;
+            this.providerClass = providerClass;
+        }
+
+        @SuppressWarnings("unchecked")
+        private WireFormatProviderFactory getFactory() {
+            if (factory == null) {
+                try {
+                    Class<WireFormatProviderFactory> factoryClass =
+                        (Class<WireFormatProviderFactory>)providerClass.loadClass();
+                    Constructor<WireFormatProviderFactory> constructor =
+                        factoryClass.getConstructor(ExtensionPointRegistry.class);
+                    factory = constructor.newInstance(registry);
+                } catch (Exception e) {
+                    throw new IllegalStateException(e);
+                }
+            }
+            return factory;
+        }
+
+        @SuppressWarnings("unchecked")
+        public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component,
+                                                                    RuntimeComponentReference reference,
+                                                                    Binding binding){
+            return getFactory().createReferenceWireFormatProvider(component, reference, binding);
+        }
+
+        @SuppressWarnings("unchecked")
+        public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component,
+                                                                  RuntimeComponentService service,
+                                                                  Binding binding){
+            return getFactory().createServiceWireFormatProvider(component, service, binding);
+        }
+
+        public Class getModelType() {
+            if (modelType == null) {
+                try {
+
+                    modelType = providerClass.loadClass(modelTypeName);
+                } catch (Exception e) {
+                    throw new IllegalStateException(e);
+                }
+            }
+            return modelType;
+        }
     }
 
+    /**
+     * A wrapper around a operation selector provider factory allowing lazy
+     * loading and initialization of operation selector providers.
+     */
+    private class LazyOperationSelectorProviderFactory implements OperationSelectorProviderFactory {
+
+        private ExtensionPointRegistry registry;
+        private String modelTypeName;
+        private ServiceDeclaration providerClass;
+        private OperationSelectorProviderFactory factory;
+        private Class modelType;
+
+        private LazyOperationSelectorProviderFactory(ExtensionPointRegistry registry,
+                                                     String modelTypeName,
+                                                     ServiceDeclaration providerClass) {
+            this.registry = registry;
+            this.modelTypeName = modelTypeName;
+            this.providerClass = providerClass;
+        }
+
+        @SuppressWarnings("unchecked")
+        private OperationSelectorProviderFactory getFactory() {
+            if (factory == null) {
+                try {
+                    Class<OperationSelectorProviderFactory> factoryClass =
+                        (Class<OperationSelectorProviderFactory>)providerClass.loadClass();
+                    Constructor<OperationSelectorProviderFactory> constructor =
+                        factoryClass.getConstructor(ExtensionPointRegistry.class);
+                    factory = constructor.newInstance(registry);
+                } catch (Exception e) {
+                    throw new IllegalStateException(e);
+                }
+            }
+            return factory;
+        }
+
+        @SuppressWarnings("unchecked")
+        public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component,
+                                                                    RuntimeComponentReference reference,
+                                                                    Binding binding){
+            return getFactory().createReferenceOperationSelectorProvider(component, reference, binding);
+        }
+
+        @SuppressWarnings("unchecked")
+        public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component,
+                                                                  RuntimeComponentService service,
+                                                                  Binding binding){
+            return getFactory().createServiceOperationSelectorProvider(component, service, binding);
+        }
+
+        public Class getModelType() {
+            if (modelType == null) {
+                try {
+
+                    modelType = providerClass.loadClass(modelTypeName);
+                } catch (Exception e) {
+                    throw new IllegalStateException(e);
+                }
+            }
+            return modelType;
+        }
+    }
+    
 }

Modified: tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java (original)
+++ tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java Tue Nov 18 21:27:58 2008
@@ -76,6 +76,22 @@
     InvocationChain getInvocationChain(Operation operation);
     
     /**
+     * Get the invocation chain for the binding-specific handling
+     * @return
+     */
+    InvocationChain getBindingInvocationChain();
+    
+    /**
+     * This invoke method assumes that the binding invocation chain is in force
+     * and that there will be an operation selector element there to
+     * determine which operation to call     
+     * @param msg The message
+     * @return The result
+     * @throws InvocationTargetException
+     */
+    Object invoke(Message msg) throws InvocationTargetException;    
+    
+    /**
      * Invoke an operation with given arguments
      * @param operation The operation
      * @param args The arguments

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointWireImpl.java Tue Nov 18 21:27:58 2008
@@ -24,6 +24,7 @@
 
 import org.apache.tuscany.sca.assembly.Endpoint;
 import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.core.invocation.InvocationChainImpl;
 import org.apache.tuscany.sca.endpointresolver.EndpointResolver;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
 import org.apache.tuscany.sca.interfacedef.Operation;
@@ -47,6 +48,7 @@
     private EndpointResolver endpointResolver;
     private EndpointReference source;
     private RuntimeWire wire;
+    private InvocationChain binidngInvocationChain;
 
     /**
      * @param endpoint
@@ -126,6 +128,11 @@
         }
     }
 
+    public Object invoke(Message msg) throws InvocationTargetException {
+        // not called as the endpoint wire only appears on the reference side
+        return null;
+    }
+    
     public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
         // not called as the endpoint wire only appears on the reference side
         return null;
@@ -150,6 +157,17 @@
 
     public void rebuild() {
     }
+    
+    public synchronized InvocationChain getBindingInvocationChain() {
+        if (binidngInvocationChain == null) {
+            if (source instanceof RuntimeComponentReference) {
+                binidngInvocationChain = new InvocationChainImpl(null, null, true);
+            } else {
+                binidngInvocationChain = new InvocationChainImpl(null, null, false);
+            }
+        }
+        return binidngInvocationChain;
+    }
 
     // TODO: TUSCANY-2580: give RuntimeComponentReferenceImpl a way to get at the endpoint
     public Endpoint getEndpoint() {

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java Tue Nov 18 21:27:58 2008
@@ -41,10 +41,15 @@
 import org.apache.tuscany.sca.invocation.Message;
 import org.apache.tuscany.sca.invocation.MessageFactory;
 import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
 import org.apache.tuscany.sca.provider.ImplementationProvider;
 import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderRRB;
 import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProviderRRB;
 import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB;
 import org.apache.tuscany.sca.runtime.EndpointReference;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
@@ -76,6 +81,7 @@
     private RuntimeWireImpl clonedFrom;
 
     private List<InvocationChain> chains;
+    private InvocationChain bindingInvocationChain;
 
     /**
      * @param source
@@ -110,6 +116,20 @@
         }
         return chains;
     }
+    
+    public synchronized InvocationChain getBindingInvocationChain() {
+        if (bindingInvocationChain == null) {
+            Contract source = wireSource.getContract();
+            if (source instanceof RuntimeComponentReference) {
+                bindingInvocationChain = new InvocationChainImpl(null, null, true);
+                initReferenceBindingInvocationChains();
+            } else {
+                bindingInvocationChain = new InvocationChainImpl(null, null, false);
+                initServiceBindingInvocationChains();
+            }
+        }
+        return bindingInvocationChain;
+    }
 
     public InvocationChain getInvocationChain(Operation operation) {
         for (InvocationChain chain : getInvocationChains()) {
@@ -127,6 +147,10 @@
         }
         return null;
     }
+    
+    public Object invoke(Message msg) throws InvocationTargetException {
+        return getBindingInvocationChain().getHeadInvoker().invoke(msg);
+    }    
 
     public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
         Message msg = messageFactory.createMessage();
@@ -167,6 +191,7 @@
                 addReferenceBindingInterceptor(reference, refBinding, chain, operation);
                 chains.add(chain);
             }
+            
         } else {
             // It's the service wire
             RuntimeComponentService service = (RuntimeComponentService)wireTarget.getContract();
@@ -189,9 +214,68 @@
                 addImplementationInterceptor(serviceComponent, service, chain, targetOperation);
                 chains.add(chain);
             }
+            
         }
         wireProcessor.process(this);
     }
+    
+    private void initReferenceBindingInvocationChains() {
+        RuntimeComponentReference reference = (RuntimeComponentReference)wireSource.getContract();
+        Binding referenceBinding = wireSource.getBinding();
+        
+        // add the binding interceptors to the reference binding wire
+        ReferenceBindingProvider provider = reference.getBindingProvider(referenceBinding);
+        if ((provider != null) &&
+            (provider instanceof ReferenceBindingProviderRRB)){
+            ((ReferenceBindingProviderRRB)provider).configureBindingChain(this);
+        }
+        
+        // add the policy interceptors to the service binding wire
+        // find out which policies are active
+        List<PolicyProvider> pps = ((RuntimeComponentReference)reference).getPolicyProviders(referenceBinding);
+        if (pps != null) {
+            for (PolicyProvider p : pps) {
+                if (p instanceof PolicyProviderRRB) {
+                    Interceptor interceptor = ((PolicyProviderRRB)p).createBindingInterceptor();
+                    if (interceptor != null) {
+                        bindingInvocationChain.addInterceptor(p.getPhase(), interceptor);
+                    }
+                }
+            }
+        }               
+    }    
+    
+    private void initServiceBindingInvocationChains() {
+        RuntimeComponentService service = (RuntimeComponentService)wireTarget.getContract();
+        Binding serviceBinding = wireTarget.getBinding();
+        
+        // add the binding interceptors to the service binding wire
+        ServiceBindingProvider provider = service.getBindingProvider(serviceBinding);
+        if ((provider != null) &&
+            (provider instanceof ServiceBindingProviderRRB)){
+            ((ServiceBindingProviderRRB)provider).configureBindingChain(this);
+        }
+        
+        // add the policy interceptors to the service binding wire
+        List<PolicyProvider> pps = ((RuntimeComponentService)service).getPolicyProviders(serviceBinding);
+        if (pps != null) {
+            for (PolicyProvider p : pps) {
+                if (p instanceof PolicyProviderRRB) {
+                    Interceptor interceptor = ((PolicyProviderRRB)p).createBindingInterceptor();
+                    if (interceptor != null) {
+                        bindingInvocationChain.addInterceptor(p.getPhase(), interceptor);
+                    }
+                }
+            }
+        }        
+        
+        
+        // TODO - add something on the end of the wire to invoke the 
+        //        invocation chain. Need to split out the runtime
+        //        wire invoker into conversation, callback interceptors etc
+        bindingInvocationChain.addInvoker(invoker);
+        
+    }
 
     public EndpointReference getSource() {
         return wireSource;
@@ -336,6 +420,7 @@
         copy.wireSource = (EndpointReference)wireSource.clone();
         copy.wireTarget = (EndpointReference)wireTarget.clone();
         copy.invoker = new RuntimeWireInvoker(copy.messageFactory, copy.conversationManager, copy);
+        copy.cachedWire = null; // TUSCANY-2630
         return copy;
     }
 

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/RequestContextImpl.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/RequestContextImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/RequestContextImpl.java Tue Nov 18 21:27:58 2008
@@ -48,7 +48,15 @@
     }
 
     public Subject getSecuritySubject() {
-        throw new UnsupportedOperationException();
+        Subject subject = null;
+        
+        for (Object header : ThreadMessageContext.getMessageContext().getHeaders()){
+            if (header instanceof Subject){
+                subject  = (Subject)header;
+                break;
+            }
+        }
+        return subject;
     }
 
     public String getServiceName() {

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/InvocationChainImpl.java Tue Nov 18 21:27:58 2008
@@ -45,8 +45,9 @@
     private boolean allowsPassByReference;
 
     public InvocationChainImpl(Operation sourceOperation, Operation targetOperation, boolean forReference) {
-        assert sourceOperation != null;
-        assert targetOperation != null;
+        // TODO - binding invocation chain doesn't provide operations
+        //assert sourceOperation != null;
+        //assert targetOperation != null;
         this.targetOperation = targetOperation;
         this.sourceOperation = sourceOperation;
         this.forReference = forReference;

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKProxyFactory.java Tue Nov 18 21:27:58 2008
@@ -19,11 +19,12 @@
 package org.apache.tuscany.sca.core.invocation;
 
 import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.List;
+import java.util.HashMap;
 
+import org.apache.tuscany.sca.core.invocation.SCAProxy;
 import org.apache.tuscany.sca.core.context.CallableReferenceImpl;
 import org.apache.tuscany.sca.core.context.ServiceReferenceImpl;
 import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
@@ -54,7 +55,7 @@
         ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, this);
         return createProxy(serviceReference);
     }
-
+    
     public <T> T createProxy(CallableReference<T> callableReference) throws ProxyCreationException {
         assert callableReference != null;
         final Class<T> interfaze = callableReference.getBusinessInterface();
@@ -62,10 +63,10 @@
         // Allow privileged access to class loader. Requires RuntimePermission in security policy.
         ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
             public ClassLoader run() {
-                return interfaze.getClassLoader();
+               return interfaze.getClassLoader();
             }
         });
-        Object proxy = Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler);
+        Object proxy = SCAProxy.newProxyInstance(cl, new Class[] {interfaze}, handler);
         ((CallableReferenceImpl)callableReference).setProxy(proxy);
         return interfaze.cast(proxy);
     }
@@ -80,13 +81,13 @@
         Class<T> interfaze = callbackReference.getBusinessInterface();
         InvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
         ClassLoader cl = interfaze.getClassLoader();
-		Object proxy = Proxy.newProxyInstance(cl, new Class[] {interfaze}, handler);
+		Object proxy = SCAProxy.newProxyInstance(cl, new Class[] {interfaze}, handler);
 		callbackReference.setProxy(proxy);
         return interfaze.cast(proxy);
     }
 
     public <B, R extends CallableReference<B>> R cast(B target) throws IllegalArgumentException {
-        InvocationHandler handler = Proxy.getInvocationHandler(target);
+        InvocationHandler handler = SCAProxy.getInvocationHandler(target);
         if (handler instanceof JDKInvocationHandler) {
             return (R)((JDKInvocationHandler)handler).getCallableReference();
         } else {
@@ -98,6 +99,6 @@
      * @see org.apache.tuscany.sca.core.invocation.ProxyFactory#isProxyClass(java.lang.Class)
      */
     public boolean isProxyClass(Class<?> clazz) {
-        return Proxy.isProxyClass(clazz);
+        return SCAProxy.isProxyClass(clazz);
     }
 }

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/MessageImpl.java Tue Nov 18 21:27:58 2008
@@ -18,8 +18,8 @@
  */
 package org.apache.tuscany.sca.core.invocation;
 
-import java.util.Hashtable;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.tuscany.sca.core.assembly.EndpointReferenceImpl;
 import org.apache.tuscany.sca.interfacedef.Operation;
@@ -32,12 +32,11 @@
  * @version $Rev $Date$
  */
 public class MessageImpl implements Message { 
-    private Map<String, Object> header = new Hashtable<String, Object>();
+    private List<Object> headers = new ArrayList<Object>();
     private Object body;
     private Object messageID;
     private boolean isFault;
     private Operation operation;
-    private Map<String, Object> qosContext = new Hashtable<String, Object>();
 
     private EndpointReference from;
     private EndpointReference to;
@@ -97,13 +96,9 @@
     public void setOperation(Operation op) {
         this.operation = op;
     }
-
-    public Map<String, Object> getQoSContext() {
-        return qosContext;
-    }
     
-    public Map<String, Object> getHeader() {
-        return qosContext;
+    public List<Object> getHeaders() {
+        return headers;
     }    
 
 }

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java Tue Nov 18 21:27:58 2008
@@ -19,6 +19,7 @@
 package org.apache.tuscany.sca.core.invocation;
 
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -186,7 +187,7 @@
             return null;
         }
         
-        public Map<String, Object> getHeader() {
+        public List<Object> getHeaders() {
             return null;
         }        
     }

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/PhaseManager.java Tue Nov 18 21:27:58 2008
@@ -19,6 +19,24 @@
 
 package org.apache.tuscany.sca.core.invocation;
 
+import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION;
+import static org.apache.tuscany.sca.invocation.Phase.IMPLEMENTATION_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_TRANSPORT;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_BINDING_WIREFORMAT;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_INTERFACE;
+import static org.apache.tuscany.sca.invocation.Phase.REFERENCE_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_POLICY;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_TRANSPORT;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_BINDING_WIREFORMAT;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_INTERFACE;
+import static org.apache.tuscany.sca.invocation.Phase.SERVICE_POLICY;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -42,15 +60,24 @@
     private static final Logger log = Logger.getLogger(PhaseManager.class.getName());
 
     public static final String STAGE_REFERENCE = "reference";
+    public static final String STAGE_REFERENCE_BINDING = "reference.binding";
+    public static final String STAGE_SERVICE_BINDING = "service.binding";
     public static final String STAGE_SERVICE = "service";
     public static final String STAGE_IMPLEMENTATION = "implementation";
+
     private static final String[] SYSTEM_REFERENCE_PHASES =
-        {Phase.REFERENCE, Phase.REFERENCE_INTERFACE, Phase.REFERENCE_POLICY, Phase.REFERENCE_BINDING};
+        {REFERENCE, REFERENCE_INTERFACE, REFERENCE_POLICY, REFERENCE_BINDING};
+
+    private static final String[] SYSTEM_REFERENCE_BINDING_PHASES =
+    {REFERENCE_BINDING_WIREFORMAT, REFERENCE_BINDING_POLICY, REFERENCE_BINDING_TRANSPORT};
 
+    private static final String[] SYSTEM_SERVICE_BINDING_PHASES =
+    {SERVICE_BINDING_TRANSPORT, SERVICE_BINDING_OPERATION_SELECTOR, SERVICE_BINDING_WIREFORMAT, SERVICE_BINDING_POLICY};
+    
     private static final String[] SYSTEM_SERVICE_PHASES =
-        {Phase.SERVICE_BINDING, Phase.SERVICE_POLICY, Phase.SERVICE_INTERFACE, Phase.SERVICE};
+        {SERVICE_BINDING, SERVICE_POLICY, SERVICE_INTERFACE, SERVICE};
 
-    private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {Phase.IMPLEMENTATION_POLICY, Phase.IMPLEMENTATION};
+    private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {IMPLEMENTATION_POLICY, IMPLEMENTATION};
 
     private String pattern = Phase.class.getName();
     private Map<String, Stage> stages;
@@ -116,6 +143,14 @@
         return getPhases(STAGE_SERVICE);
     }
 
+    public List<String> getReferenceBindingPhases() {
+        return getPhases(STAGE_REFERENCE_BINDING);
+    }
+
+    public List<String> getServiceBindingPhases() {
+        return getPhases(STAGE_SERVICE_BINDING);
+    }
+    
     public List<String> getImplementationPhases() {
         return getPhases(STAGE_IMPLEMENTATION);
     }
@@ -124,6 +159,8 @@
         if (phases == null) {
             phases = new ArrayList<String>();
             phases.addAll(getReferencePhases());
+            phases.addAll(getReferenceBindingPhases());
+            phases.addAll(getServiceBindingPhases());
             phases.addAll(getServicePhases());
             phases.addAll(getImplementationPhases());
         }
@@ -228,9 +265,22 @@
         for (int i = 1; i < SYSTEM_REFERENCE_PHASES.length; i++) {
             referenceStage.getSorter().addEdge(SYSTEM_REFERENCE_PHASES[i - 1], SYSTEM_REFERENCE_PHASES[i]);
         }
-        referenceStage.getLastSet().add(Phase.REFERENCE_BINDING);
+        referenceStage.getLastSet().add(REFERENCE_BINDING);
         stages.put(referenceStage.getName(), referenceStage);
 
+        Stage referenceBindingStage = new Stage(STAGE_REFERENCE_BINDING);
+        for (int i = 1; i < SYSTEM_REFERENCE_BINDING_PHASES.length; i++) {
+            referenceBindingStage.getSorter().addEdge(SYSTEM_REFERENCE_BINDING_PHASES[i - 1], SYSTEM_REFERENCE_BINDING_PHASES[i]);
+        }
+        stages.put(referenceBindingStage.getName(), referenceBindingStage);
+        
+        Stage serviceBindingStage = new Stage(STAGE_SERVICE_BINDING);
+        for (int i = 1; i < SYSTEM_SERVICE_BINDING_PHASES.length; i++) {
+            serviceBindingStage.getSorter().addEdge(SYSTEM_SERVICE_BINDING_PHASES[i - 1], SYSTEM_SERVICE_BINDING_PHASES[i]);
+        }
+        stages.put(serviceBindingStage.getName(), serviceBindingStage);
+        
+        
         Stage serviceStage = new Stage(STAGE_SERVICE);
         for (int i = 1; i < SYSTEM_SERVICE_PHASES.length; i++) {
             serviceStage.getSorter().addEdge(SYSTEM_SERVICE_PHASES[i - 1], SYSTEM_SERVICE_PHASES[i]);
@@ -242,7 +292,7 @@
             implementationStage.getSorter().addEdge(SYSTEM_IMPLEMENTATION_PHASES[i - 1],
                                                     SYSTEM_IMPLEMENTATION_PHASES[i]);
         }
-        implementationStage.getLastSet().add(Phase.IMPLEMENTATION);
+        implementationStage.getLastSet().add(IMPLEMENTATION);
         stages.put(implementationStage.getName(), implementationStage);
     }
 }

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java Tue Nov 18 21:27:58 2008
@@ -47,7 +47,7 @@
 /**
  * @version $Rev$ $Date$
  */
-public class RuntimeWireInvoker {
+public class RuntimeWireInvoker implements Invoker{
     protected ConversationManager conversationManager;
     protected boolean conversational;
     protected ExtendedConversation conversation;
@@ -74,6 +74,25 @@
             this.conversational = contract.getInterface().isConversational();
         }
     }
+    
+    /*
+     * TODO - Introduced to allow the RuntimeWireInvoker to sit on the end of the 
+     *        service binding chain. Runtime wire invoke needs splitting up into 
+     *        separate conversation, callback interceptors etc.
+     */
+    public Message invoke(Message msg) {
+                
+        try {
+            Object response = invoke(msg.getOperation(),msg);
+            // Hack to put the response back in a message. 
+            // shouldn't take it out of the response message in the first place
+            msg.setBody(response);
+        } catch (InvocationTargetException e) {
+            throw new ServiceRuntimeException(e);
+        }
+        
+        return msg;
+    }
 
     public Object invoke(Operation operation, Message msg) throws InvocationTargetException {
         return invoke(wire, operation, msg);

Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/work/Jsr237WorkScheduler.java Tue Nov 18 21:27:58 2008
@@ -65,7 +65,7 @@
         try {
             InitialContext ctx = new InitialContext();
             jsr237WorkManager = (WorkManager)ctx.lookup("java:comp/env/wm/TuscanyWorkManager");
-        } catch (NamingException e) {
+        } catch (Throwable e) {
             // ignore
         }
         if (jsr237WorkManager == null) {

Modified: tuscany/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest (original)
+++ tuscany/java/sca/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest Tue Nov 18 21:27:58 2008
@@ -18,5 +18,7 @@
 name=implementation.last, stage=implementation, after=*
 name=reference.first, stage=reference, before=*
 name=reference.transaction, stage=reference, after=reference.interface
+name=reference.binding.header, stage=reference.binding, after=reference.binding.transport
+name=service.binding.header, stage=service.binding, after=service.binding.transport
 name=service.transaction, stage=service, after=service.binding, before=component.service
-name=implementation.transaction, stage=implementation, before=implementation.policy
\ No newline at end of file
+name=implementation.transaction, stage=implementation, before=implementation.policy

Modified: tuscany/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java (original)
+++ tuscany/java/sca/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java Tue Nov 18 21:27:58 2008
@@ -33,10 +33,9 @@
 public class AxiomDataBinding extends BaseDataBinding {
     
     public static final String NAME = OMElement.class.getName();
-    public static final String[] ALIASES = new String[] {"axiom"};
 
     public AxiomDataBinding() {
-        super(NAME, ALIASES, OMElement.class);
+        super(NAME, OMElement.class);
     }
 
     /**

Modified: tuscany/java/sca/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding?rev=718858&r1=718857&r2=718858&view=diff
==============================================================================
--- tuscany/java/sca/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding (original)
+++ tuscany/java/sca/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding Tue Nov 18 21:27:58 2008
@@ -16,5 +16,5 @@
 # under the License.
 
 # implementation classes for the databindings
-org.apache.tuscany.sca.databinding.axiom.AxiomDataBinding;type=org.apache.axiom.om.OMElement,name=axiom
+org.apache.tuscany.sca.databinding.axiom.AxiomDataBinding;name=org.apache.axiom.om.OMElement
 



Mime
View raw message