tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r820125 - in /tuscany/java/sca: itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/ itest/policies/src/main/resources/META-INF/ modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ modules/assembly/src/main/java/org...
Date Tue, 29 Sep 2009 23:41:26 GMT
Author: rfeng
Date: Tue Sep 29 23:41:25 2009
New Revision: 820125

URL: http://svn.apache.org/viewvc?rev=820125&view=rev
Log:
Start to integrate the policy attachment builder

Modified:
    tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
    tuscany/java/sca/itest/policies/src/main/resources/META-INF/definitions.xml
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
    tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
    tuscany/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java
    tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java
    tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java
    tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java

Modified: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java (original)
+++ tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java Tue Sep 29 23:41:25 2009
@@ -25,20 +25,11 @@
 import junit.framework.Assert;
 
 import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.ComponentReference;
 import org.apache.tuscany.sca.assembly.ComponentService;
 import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.Reference;
-import org.apache.tuscany.sca.assembly.Service;
 import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
-import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -191,7 +182,7 @@
         "  Endpoint:  URI = ComponentB/ComponentD#service-binding(Service3/Service3) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n" +
         "  Endpoint:  URI = ComponentB/ComponentD#service-binding(Service3a/Service3a) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n" +
         "Endpoint:  URI = ComponentB#service-binding(Service2/Service2) org.apache.tuscany.sca.binding.ws.impl.WebServiceBindingImpl\n" +
-        "Endpoint:  URI = ComponentB#service-binding(Service2a/Service2a) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n";
+        "Endpoint:  URI = ComponentB#service-binding(Service2a/Service3a) org.apache.tuscany.sca.assembly.impl.SCABindingImpl\n";
 
         Assert.assertEquals(expectedStructure, structure);
         

Modified: tuscany/java/sca/itest/policies/src/main/resources/META-INF/definitions.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/policies/src/main/resources/META-INF/definitions.xml?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/itest/policies/src/main/resources/META-INF/definitions.xml (original)
+++ tuscany/java/sca/itest/policies/src/main/resources/META-INF/definitions.xml Tue Sep 29 23:41:25 2009
@@ -18,6 +18,7 @@
  * under the License.    
 -->
 <definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+            xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
             targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
             xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
 
@@ -31,4 +32,15 @@
 
     </policySet>
     
+    <policySet name="JDKLoggingImplPolicy" 
+               provides="tuscany:logging" 
+               appliesTo="//implementation.java"
+               attachTo="//sca:component[@name='CreditCardPayment']">
+        <tuscany:jdkLogger name="test.logger">
+            <tuscany:logLevel>INFO</tuscany:logLevel>
+            <tuscany:resourceBundle>LoggingMessages.properties</tuscany:resourceBundle>
+        </tuscany:jdkLogger>
+
+    </policySet>
+    
 </definitions>
\ No newline at end of file

Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java Tue Sep 29 23:41:25 2009
@@ -85,7 +85,7 @@
      * @param name the reference name
      * @return reference the reference
      */
-    Reference getReference(String name);    
+    ComponentReference getReference(String name);    
 
     /**
      * Returns a list of services exposed by the component.
@@ -100,7 +100,7 @@
      * @param name the service name
      * @return service the service
      */
-    Service getService(String name);    
+    ComponentService getService(String name);    
 
     /**
      * Returns a list of properties for the component.
@@ -115,7 +115,7 @@
      * @param name the property name
      * @return property the property
      */
-    Property getProperty(String name);    
+    ComponentProperty getProperty(String name);    
 
     /**
      * Returns a constraining type defining the shape of the component.

Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java Tue Sep 29 23:41:25 2009
@@ -28,9 +28,6 @@
 import org.apache.tuscany.sca.assembly.Composite;
 import org.apache.tuscany.sca.assembly.ConstrainingType;
 import org.apache.tuscany.sca.assembly.Implementation;
-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.policy.ExtensionType;
 import org.apache.tuscany.sca.policy.Intent;
 import org.apache.tuscany.sca.policy.PolicySet;
@@ -112,52 +109,40 @@
         return properties;
     }
     
-    public Property getProperty(String name){
-        Property property = null;
-        
-        for (Property tmp : getProperties()){
-            if (tmp.getName().equals(name)){
-                property = tmp;
-                break;
+    public ComponentProperty getProperty(String name) {
+        for (ComponentProperty property : getProperties()) {
+            if (property.getName().equals(name)) {
+                return property;
             }
         }
-        
-        return property;
-    }    
+        return null;
+    }
 
     public List<ComponentReference> getReferences() {
         return references;
     }
     
-    public Reference getReference(String name){
-        Reference reference = null;
-        
-        for (Reference tmp : getReferences()){
-            if (tmp.getName().equals(name)){
-                reference = tmp;
-                break;
+    public ComponentReference getReference(String name){
+        for (ComponentReference ref : getReferences()){
+            if (ref.getName().equals(name)){
+                return ref;
             }
         }
-        
-        return reference;
+        return null;
     }      
 
     public List<ComponentService> getServices() {
         return services;
     }
     
-    public Service getService(String name){
-        Service service = null;
-        
-        for (Service tmp : getServices()){
-            if (tmp.getName().equals(name)){
-                service = tmp;
-                break;
+    public ComponentService getService(String name) {
+        for (ComponentService service : getServices()) {
+            if (service.getName().equals(name)) {
+                return service;
             }
         }
-        
-        return service;
-    }    
+        return null;
+    }
 
     public void setConstrainingType(ConstrainingType constrainingType) {
         this.constrainingType = constrainingType;

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java Tue Sep 29 23:41:25 2009
@@ -691,6 +691,7 @@
         }
         */
         SCABinding scaBinding = scaBindingFactory.createSCABinding();
+        scaBinding.setName(contract.getName());
 
         if (definitions != null) {
             for (ExtensionType attachPointType : definitions.getBindingTypes()) {

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java Tue Sep 29 23:41:25 2009
@@ -21,7 +21,6 @@
 
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -29,33 +28,25 @@
 
 import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.ComponentReference;
 import org.apache.tuscany.sca.assembly.ComponentService;
 import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.Contract;
 import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.Reference;
 import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.DeployedCompositeBuilder;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
 import org.apache.tuscany.sca.definitions.Definitions;
 import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.MonitorFactory;
 
 /**
  * Configuration of binding URIs.
  *
  * @version $Rev$ $Date$
  */
-public class BindingURIBuilderImpl {
-
-    private Monitor monitor;
+public class BindingURIBuilderImpl implements CompositeBuilder, DeployedCompositeBuilder {
 
     public BindingURIBuilderImpl(ExtensionPointRegistry registry) {
-        UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
-        MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
-        monitor = monitorFactory.createMonitor();
     }
 
     /**
@@ -63,10 +54,10 @@
      *
      * @param composite the composite to be configured
      */
-    protected void configureBindingURIsAndNames(Composite composite, Definitions definitions, Monitor monitor)
+    public Composite build(Composite composite, Definitions definitions, Monitor monitor)
         throws CompositeBuilderException {
         configureBindingURIs(composite, null, definitions, null, monitor);
-        configureBindingNames(composite, monitor);
+        return composite;
     }
 
     /**
@@ -77,11 +68,12 @@
      * @param composite the composite to be configured
      * @param defaultBindings list of default binding configurations
      */
-    protected void configureBindingURIs(Composite composite,
-                                        Definitions definitions,
-                                        Map<QName, List<String>> defaultBindings,
-                                        Monitor monitor) throws CompositeBuilderException {
+    public Composite build(Composite composite,
+                           Definitions definitions,
+                           Map<QName, List<String>> defaultBindings,
+                           Monitor monitor) throws CompositeBuilderException {
         configureBindingURIs(composite, null, definitions, defaultBindings, monitor);
+        return composite;
     }
 
     /**
@@ -137,8 +129,6 @@
             List<Service> compositeServices = composite.getServices();
             for (Service service : compositeServices) {
 
-                constructBindingNames(service, monitor);
-
                 // Initialize binding names and URIs
                 for (Binding binding : service.getBindings()) {
                     constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings, monitor);
@@ -154,8 +144,6 @@
 
                     for (ComponentService service : component.getServices()) {
 
-                        constructBindingNames(service, monitor);
-
                         // Initialize binding names and URIs
                         for (Binding binding : service.getBindings()) {
                             constructBindingURI(component, service, binding, defaultBindings, monitor);
@@ -171,114 +159,6 @@
     }
 
     /**
-     * Add default names for callback bindings and reference bindings.  Needs to be
-     * separate from configureBindingURIs() because configureBindingURIs() is called
-     * by NodeConfigurationServiceImpl as well as by CompositeBuilderImpl.
-     */
-    private void configureBindingNames(Composite composite, Monitor monitor) {
-
-        // Process nested composites recursively
-        for (Component component : composite.getComponents()) {
-
-            Implementation implementation = component.getImplementation();
-            if (implementation instanceof Composite) {
-
-                // Process nested composite
-                configureBindingNames((Composite)implementation, monitor);
-            }
-        }
-
-        // Initialize composite service callback binding names
-        for (Service service : composite.getServices()) {
-            constructBindingNames(service, monitor);
-        }
-
-        // Initialize composite reference binding names
-        for (Reference reference : composite.getReferences()) {
-            constructBindingNames(reference, monitor);
-        }
-
-        // Initialize component service and reference binding names
-        for (Component component : composite.getComponents()) {
-
-            // Initialize component service callback binding names
-            for (ComponentService service : component.getServices()) {
-                constructBindingNames(service, monitor);
-            }
-
-            // Initialize component reference binding names
-            for (ComponentReference reference : component.getReferences()) {
-                // Initialize binding names
-                constructBindingNames(reference, monitor);
-            }
-        }
-    }
-
-    /**
-     * If a binding name is not provided by the user, construct it based on the service
-     * or reference name
-     *
-     * @param contract the service or reference
-     */
-    private void constructBindingNames(Contract contract, Monitor monitor) {
-        List<Binding> bindings = contract.getBindings();
-        Map<String, Binding> bindingMap = new HashMap<String, Binding>();
-        for (Binding binding : bindings) {
-            // set the default binding name if one is required
-            // if there is no name on the binding then set it to the service or reference name
-            if (binding.getName() == null) {
-                binding.setName(contract.getName());
-            }
-            Binding existed = bindingMap.put(binding.getName(), binding);
-            // Check that multiple bindings do not have the same name
-            if (existed != null && existed != binding) {
-                if (contract instanceof Service) {
-                    Monitor.error(monitor, this, "assembly-validation-messages", "MultipleBindingsForService", contract
-                        .getName(), binding.getName());
-                } else {
-                    Monitor.error(monitor,
-                                  this,
-                                  "assembly-validation-messages",
-                                  "MultipleBindingsForReference",
-                                  contract.getName(),
-                                  binding.getName());
-                }
-            }
-        }
-
-        if (contract.getCallback() != null) {
-            bindings = contract.getCallback().getBindings();
-            bindingMap.clear();
-            for (Binding binding : bindings) {
-                // set the default binding name if one is required
-                // if there is no name on the binding then set it to the service or reference name
-                if (binding.getName() == null) {
-                    binding.setName(contract.getName());
-                }
-                Binding existed = bindingMap.put(binding.getName(), binding);
-                // Check that multiple bindings do not have the same name
-                if (existed != null && existed != binding) {
-                    if (contract instanceof Service) {
-                        Monitor.error(monitor,
-                                      this,
-                                      "assembly-validation-messages",
-                                      "MultipleBindingsForServiceCallback",
-                                      contract.getName(),
-                                      binding.getName());
-                    } else {
-                        Monitor.error(monitor,
-                                      this,
-                                      "assembly-validation-messages",
-                                      "MultipleBindingsForReferenceCallback",
-                                      contract.getName(),
-                                      binding.getName());
-                    }
-                }
-            }
-        }
-    }
-
-    /**
      * URI construction for composite bindings based on Assembly Specification section 1.7.2, This method
      * assumes that the component URI part of the binding URI is formed from the part to the
      * composite in question and just calls the generic constructBindingURI method with this
@@ -506,4 +386,8 @@
         return URI.create(baseURI.toString() + str).normalize();
     }
 
+    public String getID() {
+        return "org.apache.tuscany.sca.assembly.builder.BindingURIBuilder";
+    }
+
 }

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java Tue Sep 29 23:41:25 2009
@@ -872,6 +872,7 @@
     protected void createSCABinding(Contract contract, Definitions definitions) {
 
         SCABinding scaBinding = scaBindingFactory.createSCABinding();
+        scaBinding.setName(contract.getName());
 
         if (definitions != null) {
             for (ExtensionType attachPointType : definitions.getBindingTypes()) {

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java Tue Sep 29 23:41:25 2009
@@ -386,6 +386,7 @@
     protected void createSCABinding(Contract contract, Definitions definitions) {
 
         SCABinding scaBinding = scaBindingFactory.createSCABinding();
+        scaBinding.setName(contract.getName());
 
         if (definitions != null) {
             for (ExtensionType attachPointType : definitions.getBindingTypes()) {

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java Tue Sep 29 23:41:25 2009
@@ -37,12 +37,15 @@
     private CompositeComponentTypeBuilderImpl compositeComponentTypeBuilder;
     private ComponentBuilderImpl componentBuilder;
 
+    private CompositeBuilder structuralURIBuilder;
     private BindingURIBuilderImpl bindingURIBuilder;
     private ComponentServiceBindingBuilderImpl componentServiceBindingBuilder;
     private ComponentReferenceBindingBuilderImpl componentReferenceBindingBuilder;
     private EndpointBuilderImpl endpointBuilder;
     private EndpointReferenceBuilderImpl endpointReferenceBuilder;
     private ComponentReferencePromotionBuilderImpl componentReferencePromotionBuilder;
+    
+    private CompositeBuilder policyAttachmentBuilder;
     private CompositePolicyBuilderImpl compositePolicyBuilder;
 
     /**
@@ -61,14 +64,16 @@
         compositeComponentTypeBuilder.setComponentBuilder(componentBuilder);
         componentBuilder.setComponentTypeBuilder(compositeComponentTypeBuilder);
 
+        structuralURIBuilder = new StructuralURIBuilderImpl(registry);
         bindingURIBuilder = new BindingURIBuilderImpl(registry);
         componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl(registry);
         componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl(registry);
         endpointBuilder = new EndpointBuilderImpl(registry);
         endpointReferenceBuilder = new EndpointReferenceBuilderImpl(registry);
         componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(registry);
-        compositePolicyBuilder = new CompositePolicyBuilderImpl(registry);
 
+        policyAttachmentBuilder = new PolicyAttachmentBuilderImpl(registry);
+        compositePolicyBuilder = new CompositePolicyBuilderImpl(registry);
     }
 
     public String getID() {
@@ -94,8 +99,11 @@
             // and discards the included composite
             composite = compositeIncludeBuilder.build(composite, definitions, monitor);
 
+            // Set up the structural URIs for components (services/references/bindings?)
+            composite = structuralURIBuilder.build(composite, definitions, monitor);
+            
             // need to apply policy external attachment
-
+            composite = policyAttachmentBuilder.build(composite, definitions, monitor);
 
             // Process the implementation hierarchy by calculating the component type 
             // for the top level implementation (composite). This has the effect of
@@ -115,7 +123,7 @@
             //  Policies
             // TODO - called here at the moment but we could have a separate build phase 
             //        to call these. Also we need to re-org these builders 
-            bindingURIBuilder.configureBindingURIsAndNames(composite, definitions, monitor);
+            composite = bindingURIBuilder.build(composite, definitions, monitor);
             composite = componentServiceBindingBuilder.build(composite, definitions, monitor); // binding specific build
             composite = componentReferenceBindingBuilder.build(composite, definitions, monitor); // binding specific build
             endpointBuilder.build(composite, definitions, monitor);

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java Tue Sep 29 23:41:25 2009
@@ -23,34 +23,43 @@
 import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE;
 import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
 
+import java.io.IOException;
 import java.io.StringWriter;
 import java.util.Set;
 import java.util.StringTokenizer;
 
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
 
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
 import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
 import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
 import org.apache.tuscany.sca.assembly.Implementation;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
 import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
 import org.apache.tuscany.sca.common.xml.stax.StAXHelper;
+import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.definitions.Definitions;
 import org.apache.tuscany.sca.monitor.Monitor;
 import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
 
 /**
  * A builder that attaches policy sets to the domain composite using the xpath defined by
@@ -77,7 +86,8 @@
         return "org.apache.tuscany.sca.policy.builder.PolicyAttachmentBuilder";
     }
 
-    public Composite build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
+    public Composite build(Composite composite, Definitions definitions, Monitor monitor)
+        throws CompositeBuilderException {
         try {
             Composite patched = applyXPath(composite, definitions, monitor);
             return patched;
@@ -95,6 +105,9 @@
      * @throws Exception
      */
     private Composite applyXPath(Composite composite, Definitions definitions, Monitor monitor) throws Exception {
+        if (definitions == null || definitions.getPolicySets().isEmpty()) {
+            return composite;
+        }
         // Recursively apply the xpath against the composites referenced by <implementation.composite>
         for (Component component : composite.getComponents()) {
             Implementation impl = component.getImplementation();
@@ -105,16 +118,8 @@
                 }
             }
         }
-        // First write the composite into a DOM document so that we can apply the xpath
-        StringWriter sw = new StringWriter();
-        XMLStreamWriter writer = staxHelper.createXMLStreamWriter(sw);
-        // Write the composite into a DOM document
-        processor.write(composite, writer);
-        writer.close();
-
-        Document document = domHelper.load(sw.toString());
+        Document document = saveAsDOM(composite);
 
-        boolean changed = false;
         for (PolicySet ps : definitions.getPolicySets()) {
             // First calculate the applicable nodes
             Set<Node> applicableNodes = null;
@@ -135,22 +140,156 @@
                     Node node = nodes.item(i);
                     if (applicableNodes == null || applicableNodes.contains(node)) {
                         // The node can be a component, service, reference or binding
-                        if (attach(node, ps) && !changed) {
-                            changed = true;
+                        String index = getStructuralURI(node);
+                        PolicySubject subject = lookup(composite, index);
+                        if (subject != null) {
+                            subject.getPolicySets().add(ps);
                         }
                     }
                 }
             }
         }
 
-        if (changed) {
-            XMLStreamReader reader = staxHelper.createXMLStreamReader(document);
-            reader.nextTag();
-            Composite patchedComposite = (Composite)processor.read(reader);
-            return patchedComposite;
-        } else {
-            return composite;
+        return composite;
+    }
+
+    private Document saveAsDOM(Composite composite) throws XMLStreamException, ContributionWriteException, IOException,
+        SAXException {
+        // First write the composite into a DOM document so that we can apply the xpath
+        StringWriter sw = new StringWriter();
+        XMLStreamWriter writer = staxHelper.createXMLStreamWriter(sw);
+        // Write the composite into a DOM document
+        processor.write(composite, writer);
+        writer.close();
+
+        Document document = domHelper.load(sw.toString());
+        return document;
+    }
+
+    private static final QName COMPONENT = new QName(Base.SCA11_NS, "component");
+    private static final QName SERVICE = new QName(Base.SCA11_NS, "service");
+    private static final QName REFERENCE = new QName(Base.SCA11_NS, "reference");
+
+    private static String getStructuralURI(Node node) {
+        if (node != null) {
+            QName name = new QName(node.getNamespaceURI(), node.getLocalName());
+            if (COMPONENT.equals(name)) {
+                Element element = (Element)node;
+                return element.getAttributeNS(null, "uri");
+            } else if (SERVICE.equals(name)) {
+                Element component = (Element)node.getParentNode();
+                String uri = component.getAttributeNS(null, "uri");
+                String service = ((Element)node).getAttributeNS(null, "name");
+                return uri + "#service(" + service + ")";
+            } else if (REFERENCE.equals(name)) {
+                Element component = (Element)node.getParentNode();
+                String uri = component.getAttributeNS(null, "uri");
+                String reference = ((Element)node).getAttributeNS(null, "name");
+                return uri + "#reference(" + reference + ")";
+            } else {
+                String localName = node.getLocalName();
+                if (localName.startsWith("binding.")) {
+                    String bindingName = ((Element)node).getAttributeNS(null, "name");
+                    Element contract = (Element)node.getParentNode();
+                    String contractName = contract.getAttributeNS(null, "name");
+                    Element component = (Element)node.getParentNode().getParentNode();
+                    String uri = component.getAttributeNS(null, "uri");
+                    return uri + "#" + contract.getLocalName() + "(" + contractName + "/" + bindingName + ")";
+                } else if (localName.startsWith("implementation.")) {
+                    Element component = (Element)node.getParentNode();
+                    String uri = component.getAttributeNS(null, "uri");
+                    return uri + "#implementation()";
+                }
+            }
+        }
+        return null;
+    }
+
+    private Binding getBinding(Contract contract, String name) {
+        for (Binding binding : contract.getBindings()) {
+            if (name.equals(binding.getName())) {
+                return binding;
+            }
+        }
+        return null;
+    }
+
+    private PolicySubject lookup(Composite composite, String structuralURI) {
+        if (structuralURI == null) {
+            return null;
+        }
+        int index = structuralURI.indexOf('#');
+        String componentURI = structuralURI;
+        String service = null;
+        String reference = null;
+        String binding = null;
+        boolean impl = false;
+
+        if (index != -1) {
+            componentURI = structuralURI.substring(0, index);
+            String fragment = structuralURI.substring(index + 1);
+            int begin = fragment.indexOf('(');
+            int end = fragment.indexOf(')');
+            if (begin != -1 && end != -1) {
+                String path = fragment.substring(begin + 1, end).trim();
+                String prefix = fragment.substring(0, begin).trim();
+                if (prefix.equals("implementation")) {
+                    impl = true;
+                } else {
+                    int pos = path.indexOf('/');
+                    if (pos != -1) {
+                        binding = path.substring(pos + 1);
+                        path = path.substring(0, index);
+                        if ("service-binding".equals(prefix)) {
+                            service = path;
+                        } else if ("reference-binding".equals(prefix)) {
+                            reference = path;
+                        }
+                    }
+                    if ("service".equals(prefix)) {
+                        service = path;
+                    } else if ("reference".equals(prefix)) {
+                        reference = path;
+                    }
+                }
+            }
+        }
+        for (Component component : composite.getComponents()) {
+            if (component.getURI().equals(componentURI)) {
+                if (service != null) {
+                    ComponentService componentService = component.getService(service);
+                    if (binding != null) {
+                        Binding b = getBinding(componentService, binding);
+                        if (b instanceof PolicySubject) {
+                            return (PolicySubject)b;
+                        }
+                    } else {
+                        return componentService;
+                    }
+                } else if (reference != null) {
+                    ComponentReference componentReference = component.getReference(reference);
+                    if (binding != null) {
+                        Binding b = getBinding(componentReference, binding);
+                        if (b instanceof PolicySubject) {
+                            return (PolicySubject)b;
+                        }
+                    } else {
+                        return componentReference;
+                    }
+                } else if (impl) {
+                    return component.getImplementation();
+                }
+                return component;
+            } else if (structuralURI.startsWith(component.getURI() + "/")) {
+                Implementation implementation = component.getImplementation();
+                if (implementation instanceof Composite) {
+                    return lookup((Composite)implementation, structuralURI);
+                } else {
+                    return null;
+                }
+            }
         }
+        return null;
     }
 
     /**

Modified: tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java (original)
+++ tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java Tue Sep 29 23:41:25 2009
@@ -54,160 +54,6 @@
     }
 
     /**
-     * Called by CompositeBindingURIBuilderImpl
-     *
-     * @param composite the composite to be configured
-     */
-    protected void configureBindingURIsAndNames(Composite composite, Definitions definitions, Monitor monitor)
-        throws CompositeBuilderException {
-        configureBindingURIs(composite, null, definitions, null, monitor);
-        configureBindingNames(composite, monitor);
-    }
-
-    /**
-     * Fully resolve the binding URIs based on available information. This includes information
-     * from the ".composite" files, from resources associated with the binding, e.g. WSDL files,
-     * from any associated policies and from the default information for each binding type.
-     *
-     * @param composite the composite to be configured
-     * @param bindingBaseURIs list of default binding configurations
-     */
-    private void configureBindingURIs(Composite composite,
-                                      Definitions definitions,
-                                      Map<QName, List<String>> bindingBaseURIs,
-                                      Monitor monitor) throws CompositeBuilderException {
-        configureBindingURIs(composite, null, definitions, bindingBaseURIs, monitor);
-    }
-
-    /**
-     * Fully resolve the binding URIs based on available information. This includes information
-     * from the ".composite" files, from resources associated with the binding, e.g. WSDL files,
-     * from any associated policies and from the default information for each binding type.
-     *
-     * NOTE: This method repeats some of the processing performed by the configureComponents()
-     *       method above.  The duplication is needed because NodeConfigurationServiceImpl
-     *       calls this method without previously calling configureComponents().  In the
-     *       normal builder sequence used by CompositeBuilderImpl, both of these methods
-     *       are called.
-     *
-     * TODO: Share the URL calculation algorithm with the configureComponents() method above
-     *       although keeping the configureComponents() methods signature as is because when
-     *       a composite is actually build in a node the node default information is currently
-     *       available
-     *
-     * @param composite the composite to be configured
-     * @param uri the path to the composite provided through any nested composite component implementations
-     * @param defaultBindings list of default binding configurations
-     */
-    private void configureBindingURIs(Composite composite,
-                                      String parentComponentURI,
-                                      Definitions definitions,
-                                      Map<QName, List<String>> defaultBindings,
-                                      Monitor monitor) throws CompositeBuilderException {
-
-        monitor.pushContext("Composite: " + composite.getName().toString());
-        try {
-            // Process nested composites recursively
-            for (Component component : composite.getComponents()) {
-
-                // Initialize component URI
-                String componentURI;
-                if (parentComponentURI == null) {
-                    componentURI = component.getName();
-                } else {
-                    componentURI = parentComponentURI + '/' + component.getName();
-                }
-                component.setURI(componentURI);
-
-                Implementation implementation = component.getImplementation();
-                if (implementation instanceof Composite) {
-                    // Process nested composite
-                    configureBindingURIs((Composite)implementation, componentURI, definitions, defaultBindings, monitor);
-                }
-            }
-
-            // Initialize composite service binding URIs
-            List<Service> compositeServices = composite.getServices();
-            for (Service service : compositeServices) {
-
-                constructBindingNames(service, monitor);
-
-                // Initialize binding names and URIs
-                for (Binding binding : service.getBindings()) {
-                    constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings, monitor);
-                }
-            }
-
-            // Initialize component service binding URIs
-            for (Component component : composite.getComponents()) {
-
-                monitor.pushContext("Component: " + component.getName());
-
-                try {
-
-                    for (ComponentService service : component.getServices()) {
-
-                        constructBindingNames(service, monitor);
-
-                        // Initialize binding names and URIs
-                        for (Binding binding : service.getBindings()) {
-                            constructBindingURI(component.getURI(), service, binding, defaultBindings, monitor);
-                        }
-                    }
-                } finally {
-                    monitor.popContext();
-                }
-            }
-        } finally {
-            monitor.popContext();
-        }
-    }
-
-    /**
-     * Add default names for callback bindings and reference bindings.  Needs to be
-     * separate from configureBindingURIs() because configureBindingURIs() is called
-     * by NodeConfigurationServiceImpl as well as by CompositeBuilderImpl.
-     */
-    private void configureBindingNames(Composite composite, Monitor monitor) {
-
-        // Process nested composites recursively
-        for (Component component : composite.getComponents()) {
-
-            Implementation implementation = component.getImplementation();
-            if (implementation instanceof Composite) {
-
-                // Process nested composite
-                configureBindingNames((Composite)implementation, monitor);
-            }
-        }
-
-        // Initialize composite service callback binding names
-        for (Service service : composite.getServices()) {
-            constructBindingNames(service, monitor);
-        }
-
-        // Initialize composite reference binding names
-        for (Reference reference : composite.getReferences()) {
-            constructBindingNames(reference, monitor);
-        }
-
-        // Initialize component service and reference binding names
-        for (Component component : composite.getComponents()) {
-
-            // Initialize component service callback binding names
-            for (ComponentService service : component.getServices()) {
-                constructBindingNames(service, monitor);
-            }
-
-            // Initialize component reference binding names
-            for (ComponentReference reference : component.getReferences()) {
-                // Initialize binding names
-                constructBindingNames(reference, monitor);
-            }
-        }
-    }
-
-    /**
      * If a binding name is not provided by the user, construct it based on the service
      * or reference name
      *
@@ -272,29 +118,6 @@
     }
 
     /**
-     * URI construction for composite bindings based on Assembly Specification section 1.7.2, This method
-     * assumes that the component URI part of the binding URI is formed from the part to the
-     * composite in question and just calls the generic constructBindingURI method with this
-     * information
-     *
-     * @param parentComponentURI
-     * @param composite
-     * @param service
-     * @param binding
-     * @param defaultBindings
-     */
-    private void constructBindingURI(String parentComponentURI,
-                                     Composite composite,
-                                     Service service,
-                                     Binding binding,
-                                     Map<QName, List<String>> defaultBindings,
-                                     Monitor monitor) throws CompositeBuilderException {
-        // This is a composite service so there is no component to provide a component URI
-        // The path to this composite (through nested composites) is used.
-        constructBindingURI(parentComponentURI, service, binding, defaultBindings, monitor);
-    }
-
-    /**
      * Generic URI construction for bindings based on Assembly Specification section 1.7.2
      *
      * @param componentURIString the string version of the URI part that comes from the component name
@@ -494,7 +317,7 @@
                            Definitions definitions,
                            Map<QName, List<String>> bindingBaseURIs,
                            Monitor monitor) throws CompositeBuilderException {
-        configureBindingURIs(composite, definitions, bindingBaseURIs, monitor);
+        configureStructuralURIs(composite, null, definitions, bindingBaseURIs, monitor);
         return composite;
     }
 
@@ -531,10 +354,12 @@
                     for (ComponentService service : component.getServices()) {
                         constructBindingNames(service, monitor);
 
+                        /*
                         // Initialize binding names and URIs
                         for (Binding binding : service.getBindings()) {
                             constructBindingURI(componentURI, service, binding, defaultBindings, monitor);
                         }
+                        */
                     }
                     for (ComponentReference service : component.getReferences()) {
                         constructBindingNames(service, monitor);

Modified: tuscany/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java (original)
+++ tuscany/java/sca/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java Tue Sep 29 23:41:25 2009
@@ -33,10 +33,6 @@
 import org.apache.tuscany.sca.assembly.Composite;
 import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
-import org.apache.tuscany.sca.builder.impl.CompositeCloneBuilderImpl;
-import org.apache.tuscany.sca.builder.impl.CompositeIncludeBuilderImpl;
-import org.apache.tuscany.sca.builder.impl.PolicyAttachmentBuilderImpl;
-import org.apache.tuscany.sca.builder.impl.StructuralURIBuilderImpl;
 import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
 import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor;
 import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -92,7 +88,10 @@
     public void testBuild() throws Exception {
         Definitions definitions = load("test_definitions.xml");
         Composite composite = load("Calculator.composite");
+        
+        CompositeBuilder uriBuilder = new StructuralURIBuilderImpl(extensionPoints);
 
+        composite = uriBuilder.build(composite, definitions, monitor);
         PolicyAttachmentBuilderImpl builder = new PolicyAttachmentBuilderImpl(extensionPoints);
         builder.build(composite, definitions, monitor);
     }
@@ -131,13 +130,6 @@
         CompositeBuilder cloneBuilder = new CompositeCloneBuilderImpl();
         CompositeBuilder uriBuilder = new StructuralURIBuilderImpl(extensionPoints);
 
-        /*
-        CompositeBuilder includeBuilder =
-            builders.getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeIncludeBuilder");
-        CompositeBuilder cloneBuilder =
-            builders.getCompositeBuilder("org.apache.tuscany.sca.assembly.builder.CompositeCloneBuilder");
-            */
-
         domainComposite = cloneBuilder.build(domainComposite, definitions, monitor);
         domainComposite = includeBuilder.build(domainComposite, definitions, monitor);
         domainComposite = uriBuilder.build(domainComposite, definitions, monitor);

Modified: tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java (original)
+++ tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java Tue Sep 29 23:41:25 2009
@@ -22,6 +22,7 @@
 import static javax.xml.XMLConstants.DEFAULT_NS_PREFIX;
 import static javax.xml.XMLConstants.NULL_NS_URI;
 
+import javax.xml.XMLConstants;
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
@@ -120,10 +121,10 @@
     }
 
     public String writeAttribute(XMLStreamWriter writer,
-                                String prefix,
-                                String localName,
-                                String namespaceURI,
-                                String value) throws XMLStreamException {
+                                 String prefix,
+                                 String localName,
+                                 String namespaceURI,
+                                 String value) throws XMLStreamException {
         String writerPrefix;
         /*
          * Due to parser implementations returning null as the namespace URI (for the empty namespace) we need to
@@ -231,17 +232,17 @@
     public void writeStartElement(XMLStreamWriter writer, QName name) throws XMLStreamException {
         writeStartElement(writer, name.getPrefix(), name.getLocalPart(), name.getNamespaceURI());
     }
-    
+
     public void writeStartElement(XMLStreamWriter writer, String prefix, String localName, String namespaceURI)
         throws XMLStreamException {
-        
+
         if (namespaceURI == null) {
             namespaceURI = NULL_NS_URI;
         }
         if (prefix == null) {
             prefix = DEFAULT_NS_PREFIX;
         }
-        
+
         if (isRepairingNamespaces) {
             writer.writeStartElement(prefix, localName, namespaceURI);
             return;
@@ -298,6 +299,12 @@
             if (prefix == null) {
                 prefix = DEFAULT_NS_PREFIX;
             }
+            if (DEFAULT_NS_PREFIX.equals(prefix) && !XMLConstants.NULL_NS_URI.equals(uri)) {
+                String ns = writer.getNamespaceContext().getNamespaceURI(prefix);
+                if (ns != null) {
+                    prefix = generateUniquePrefix(writer.getNamespaceContext());
+                }
+            }
             writer.writeNamespace(prefix, uri);
             return prefix;
         } else {

Modified: tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java (original)
+++ tuscany/java/sca/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java Tue Sep 29 23:41:25 2009
@@ -102,6 +102,7 @@
      */
     private Collection<String> getPrefixes(String expression) {
         Collection<String> prefixes = new HashSet<String>();
+        prefixes.add(XMLConstants.DEFAULT_NS_PREFIX);
         Pattern pattern = Pattern.compile("([^:]+):([^:]+)");
         Matcher matcher = pattern.matcher(expression);
         while (matcher.find()) {

Modified: tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java?rev=820125&r1=820124&r2=820125&view=diff
==============================================================================
--- tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java (original)
+++ tuscany/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java Tue Sep 29 23:41:25 2009
@@ -479,7 +479,7 @@
                 }
                 str = String.valueOf(value);
             }
-            if (str.length() == 0) {
+            if (str.length() == 0 && (value instanceof Collection)) {
                 return;
             }
 



Mime
View raw message