tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r674139 - in /tuscany/java/sca: itest/builder/ itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/ modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ modules/assembly/src/main/java/org/apache/tuscany/sca/a...
Date Fri, 04 Jul 2008 23:20:37 GMT
Author: slaws
Date: Fri Jul  4 16:20:36 2008
New Revision: 674139

URL: http://svn.apache.org/viewvc?rev=674139&view=rev
Log:
TUSCANY-2352 - upgrade the fix for promoted binding overriding as the automatically created
sca bindings were causing the top level to always override.

Added:
    tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
  (with props)
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java
  (with props)
Modified:
    tuscany/java/sca/itest/builder/   (props changed)
    tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
    tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java

Propchange: tuscany/java/sca/itest/builder/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jul  4 16:20:36 2008
@@ -0,0 +1,4 @@
+.classpath
+.project
+.settings
+target

Added: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java?rev=674139&view=auto
==============================================================================
--- tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
(added)
+++ tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
Fri Jul  4 16:20:36 2008
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.itest.builder;
+
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.DefaultEndpointFactory;
+import org.apache.tuscany.sca.assembly.EndpointFactory;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.SCADefinitions;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.IntentAttachPointTypeFactory;
+
+/**
+ * A builder that handles the configuration of the components inside a composite
+ * and the wiring of component references to component services.
+ * 
+ * @version $Rev$ $Date$
+ */
+public class CompositeBuilderNonWiringImpl implements CompositeBuilder {
+    private static final Logger logger = Logger.getLogger(CompositeBuilderNonWiringImpl.class.getName());
+    private CompositeBuilder compositeIncludeBuilder;
+    private CompositeBuilder componentWireBuilder;
+    private CompositeBuilder compositeReferenceWireBuilder;
+    private CompositeBuilder compositeCloneBuilder;
+    private CompositeBuilder componentConfigurationBuilder;
+    private CompositeBuilder compositeServiceConfigurationBuilder;
+    private CompositeBuilder compositePromotionBuilder;
+    private CompositeBuilder compositePolicyBuilder;
+    private CompositeBuilder componentServiceBindingBuilder;
+    private CompositeBuilder compositeServiceBindingBuilder;
+    private CompositeBuilder componentReferenceBindingBuilder;
+    
+    /**
+     * Constructs a new composite builder.
+     * 
+     * @param assemblyFactory
+     * @param scaBindingFactory
+     * @param intentAttachPointTypeFactory
+     * @param interfaceContractMapper
+     * @param monitor
+     */
+    public CompositeBuilderNonWiringImpl(AssemblyFactory assemblyFactory,
+                                SCABindingFactory scaBindingFactory,
+                                IntentAttachPointTypeFactory  intentAttachPointTypeFactory,
+                                InterfaceContractMapper interfaceContractMapper,
+                                Monitor monitor) {
+        this(assemblyFactory, null, scaBindingFactory,  intentAttachPointTypeFactory, interfaceContractMapper,
null, monitor);
+    }
+    
+    /**
+     * Constructs a new composite builder.
+     * 
+     * @param assemblyFactory
+     * @param scaBindingFactory
+     * @param endpointFactory
+     * @param intentAttachPointTypeFactory
+     * @param interfaceContractMapper
+     * @param policyDefinitions
+     * @param monitor
+     */
+    public CompositeBuilderNonWiringImpl(AssemblyFactory assemblyFactory,
+                                EndpointFactory endpointFactory,
+                                SCABindingFactory scaBindingFactory,
+                                IntentAttachPointTypeFactory  intentAttachPointTypeFactory,
+                                InterfaceContractMapper interfaceContractMapper,
+                                SCADefinitions policyDefinitions,
+                                Monitor monitor) {
+        
+        if (endpointFactory == null){
+            endpointFactory = new DefaultEndpointFactory();
+        }       
+        
+        compositeIncludeBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeIncludeBuilderImpl(monitor);

+        componentWireBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentReferenceWireBuilderImpl(assemblyFactory,
endpointFactory, interfaceContractMapper, monitor);
+        compositeReferenceWireBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeReferenceWireBuilderImpl(assemblyFactory,
endpointFactory, interfaceContractMapper, monitor);
+        compositeCloneBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeCloneBuilderImpl(monitor);
+        componentConfigurationBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentConfigurationBuilderImpl(assemblyFactory,
scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+        compositeServiceConfigurationBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeServiceConfigurationBuilderImpl(assemblyFactory,
scaBindingFactory, interfaceContractMapper, policyDefinitions, monitor);
+        compositePromotionBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositePromotionBuilderImpl(assemblyFactory,
endpointFactory, interfaceContractMapper, monitor);
+        compositePolicyBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositePolicyBuilderImpl(assemblyFactory,
endpointFactory, interfaceContractMapper, monitor);
+        componentServiceBindingBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentServiceBindingBuilderImpl(monitor);
+        compositeServiceBindingBuilder = new org.apache.tuscany.sca.assembly.builder.impl.CompositeServiceBindingBuilderImpl(monitor);
+        componentReferenceBindingBuilder = new org.apache.tuscany.sca.assembly.builder.impl.ComponentReferenceBindingBuilderImpl(monitor);
+    }
+
+    public void build(Composite composite) throws CompositeBuilderException {
+
+        // Collect and fuse includes
+        compositeIncludeBuilder.build(composite);
+
+        // Expand nested composites
+        compositeCloneBuilder.build(composite);
+
+        // Configure all components
+        componentConfigurationBuilder.build(composite);
+
+        // Connect composite services/references to promoted services/references
+        compositePromotionBuilder.build(composite);
+        
+        // Compute the policies across the model hierarchy
+        compositePolicyBuilder.build(composite);
+
+        // Build component service binding-related information
+        componentServiceBindingBuilder.build(composite);
+
+        // Build composite service binding-related information
+//        compositeServiceBindingBuilder.build(composite);
+        
+        // Configure composite services
+//        compositeServiceConfigurationBuilder.build(composite);
+        
+        // Wire the components
+//        componentWireBuilder.build(composite);
+
+        // Wire the composite references
+//        compositeReferenceWireBuilder.build(composite);
+
+        // Build component reference binding-related information
+        componentReferenceBindingBuilder.build(composite);
+        
+        // Fuse nested composites
+        //FIXME do this later
+        //cloneBuilder.fuseCompositeImplementations(composite);
+    }
+
+}

Propchange: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CompositeBuilderNonWiringImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java?rev=674139&r1=674138&r2=674139&view=diff
==============================================================================
--- tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
(original)
+++ tuscany/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
Fri Jul  4 16:20:36 2008
@@ -121,6 +121,7 @@
         IntentAttachPointTypeFactory attachPointTypeFactory = modelFactories.getFactory(IntentAttachPointTypeFactory.class);
         InterfaceContractMapper contractMapper = utilities.getUtility(InterfaceContractMapper.class);
         domainCompositeBuilder = new CompositeBuilderImpl(assemblyFactory, scaBindingFactory,
attachPointTypeFactory, contractMapper, monitor);
+        //domainCompositeBuilder = new CompositeBuilderNonWiringImpl(assemblyFactory, scaBindingFactory,
attachPointTypeFactory, contractMapper, monitor);
     }
     
     public void loadContribution(String compositeURL, String sourceURI, String sourceURL)
throws Exception {

Added: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java?rev=674139&view=auto
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java
(added)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java
Fri Jul  4 16:20:36 2008
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.assembly.builder;
+
+/**
+ * Represent a binding that has been added automatically to the model rather 
+ * than being specified by the user through the composite file
+ * 
+ * @version $Rev$ $Date$
+ * 
+ */
+public interface AutomaticBinding extends Cloneable  {
+
+    /**
+     * @param isAutomatic
+     */
+    void setIsAutomatic(boolean isAutomatic);
+    
+    /**
+     * @return isAutomatic
+     */
+    boolean getIsAutomatic();
+}

Propchange: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/AutomaticBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java?rev=674139&r1=674138&r2=674139&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
(original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseConfigurationBuilderImpl.java
Fri Jul  4 16:20:36 2008
@@ -41,6 +41,7 @@
 import org.apache.tuscany.sca.assembly.SCABinding;
 import org.apache.tuscany.sca.assembly.SCABindingFactory;
 import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.AutomaticBinding;
 import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor;
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
 import org.apache.tuscany.sca.definitions.SCADefinitions;
@@ -827,25 +828,35 @@
                 newComponentService.setService(promotedService.getService());
                 // set the bindings using the top level bindings to override the 
                 // lower level bindings
-                if (compositeService.getBindings().size() > 0){
+                if (bindingsSpecifiedManually(compositeService.getBindings())){
                     newComponentService.getBindings()
                         .addAll(compositeService.getBindings());
                 } else {
-                    newComponentService.getBindings()
-                    .addAll(promotedService.getBindings());
+                    for (Binding binding : promotedService.getBindings()){
+                        try {
+                            newComponentService.getBindings().add((Binding)binding.clone());
+                        } catch(CloneNotSupportedException ex){
+                            // this binding can't be used in the promoted service
+                        }
+                    }                    
                 }
                 newComponentService.setInterfaceContract(compositeService.getInterfaceContract());
                 if (compositeService.getInterfaceContract() != null && compositeService
                     .getInterfaceContract().getCallbackInterface() != null) {
                     newComponentService.setCallback(assemblyFactory.createCallback());
                     if ((compositeService.getCallback() != null) &&
-                            (compositeService.getCallback().getBindings().size() > 0)){
+                        (bindingsSpecifiedManually(compositeService.getCallback().getBindings()))){
                         newComponentService.getCallback().getBindings()
                             .addAll(compositeService.getCallback().getBindings());
                     } else if ((promotedService.getCallback() != null) &&
-                            (promotedService.getCallback().getBindings().size() > 0)){
-                        newComponentService.getBindings()
-                            .addAll(promotedService.getBindings());
+                               (bindingsSpecifiedManually(promotedService.getCallback().getBindings()))){
+                        for (Binding binding : promotedService.getCallback().getBindings()){
+                            try {
+                                newComponentService.getCallback().getBindings().add((Binding)binding.clone());
+                            } catch(CloneNotSupportedException ex){
+                                // this binding can't be used in the promoted service
+                            }
+                        }                          
                     }
                 }
 
@@ -904,20 +915,28 @@
                             newComponentService.setName("$promoted$." + componentService.getName());
                             promotedComponent.getServices().add(newComponentService);
                             newComponentService.setService(promotedService.getService());
+                            
                             // set the bindings using the top level bindings to override
the 
                             // lower level bindings
-                            if (componentService.getBindings().size() > 0){
+                            if (bindingsSpecifiedManually(componentService.getBindings())){
                                 newComponentService.getBindings()
                                     .addAll(componentService.getBindings());
-                            } else if (compositeService.getBindings().size() > 0){
+                            } else if (bindingsSpecifiedManually(compositeService.getBindings())){
                                 newComponentService.getBindings()
                                     .addAll(compositeService.getBindings());
                             } else {
-                                newComponentService.getBindings()
-                                .addAll(promotedService.getBindings());
+                                for (Binding binding : promotedService.getBindings()){
+                                    try {
+                                        newComponentService.getBindings().add((Binding)binding.clone());
+                                    } catch(CloneNotSupportedException ex){
+                                        // this binding can't be used in the promoted service
+                                    }
+                                }
                             }
+                            
                             newComponentService.setInterfaceContract(componentService
                                 .getInterfaceContract());
+                            
                             if (componentService.getInterfaceContract() != null &&

                                 componentService.getInterfaceContract().getCallbackInterface()
!= null) {
                                 
@@ -926,17 +945,22 @@
                                 // set the bindings using the top level bindings to override
the 
                                 // lower level bindings
                                 if ((componentService.getCallback() != null) &&
-                                    (componentService.getCallback().getBindings().size()
> 0)){
+                                    (bindingsSpecifiedManually(componentService.getCallback().getBindings()))){
                                     newComponentService.getCallback().getBindings()
                                         .addAll(componentService.getCallback().getBindings());
                                 } else if ((compositeService.getCallback() != null) &&
-                                           (compositeService.getCallback().getBindings().size()
> 0)){
+                                           (bindingsSpecifiedManually(compositeService.getCallback().getBindings()))){
                                     newComponentService.getCallback().getBindings()
                                         .addAll(compositeService.getCallback().getBindings());
                                 } else if ((promotedService.getCallback() != null) &&
-                                           (promotedService.getCallback().getBindings().size()
> 0)){
-                                    newComponentService.getBindings()
-                                        .addAll(promotedService.getBindings());
+                                           (bindingsSpecifiedManually(promotedService.getCallback().getBindings()))){
+                                    for (Binding binding : promotedService.getCallback().getBindings()){
+                                        try {
+                                            newComponentService.getCallback().getBindings().add((Binding)binding.clone());
+                                        } catch(CloneNotSupportedException ex){
+                                            // this binding can't be used in the promoted
service
+                                        }
+                                    }                                    
                                 }
                             }
 
@@ -952,6 +976,28 @@
     }
 
     /**
+     * If the bindings are specified in the composite file return true as they should 
+     * otherwise return false
+     *  
+     * @param bindings
+     * @return true if the bindings were specified manually
+     */
+    private boolean bindingsSpecifiedManually(List<Binding> bindings){
+
+        if (bindings.size() > 1){
+            return true;
+        } else if ((bindings.size() == 1) &&
+                   (bindings.get(0) instanceof AutomaticBinding) &&
+                   (((AutomaticBinding)bindings.get(0)).getIsAutomatic() == true )){
+            return false;
+        } else if (bindings.size() == 1) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+    
+    /**
      * @param composite
      */
     private void configureSourcedProperties(Composite composite, List<ComponentProperty>
propertySettings) {
@@ -1023,6 +1069,12 @@
     private SCABinding createSCABinding() {
         SCABinding scaBinding = scaBindingFactory.createSCABinding();
         
+        // mark the bindings that are added automatically so that theu can 
+        // can be disregarded for overriding purposes
+        if (scaBinding instanceof AutomaticBinding){
+            ((AutomaticBinding)scaBinding).setIsAutomatic(true);
+        }
+        
         if ( policyDefinitions != null ) {
             for ( IntentAttachPointType attachPointType : policyDefinitions.getBindingTypes()
) {
                 if ( attachPointType.getName().equals(BINDING_SCA_QNAME)) {

Modified: tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java?rev=674139&r1=674138&r2=674139&view=diff
==============================================================================
--- tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
(original)
+++ tuscany/java/sca/modules/binding-sca/src/main/java/org/apache/tuscany/sca/binding/sca/impl/SCABindingImpl.java
Fri Jul  4 16:20:36 2008
@@ -27,6 +27,7 @@
 import org.apache.tuscany.sca.assembly.Extensible;
 import org.apache.tuscany.sca.assembly.OptimizableBinding;
 import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.builder.AutomaticBinding;
 import org.apache.tuscany.sca.policy.Intent;
 import org.apache.tuscany.sca.policy.IntentAttachPointType;
 import org.apache.tuscany.sca.policy.PolicySet;
@@ -37,7 +38,7 @@
  * 
  * @version $Rev$ $Date$
  */
-public class SCABindingImpl implements SCABinding, Extensible, PolicySetAttachPoint, OptimizableBinding
{
+public class SCABindingImpl implements SCABinding, Extensible, PolicySetAttachPoint, OptimizableBinding,
AutomaticBinding {
     private String name;
     private String uri;
     private List<Object> extensions = new ArrayList<Object>();
@@ -50,6 +51,8 @@
     private Binding targetBinding;
     private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
     
+    private boolean isAutomatic = false;
+    
     public List<PolicySet> getApplicablePolicySets() {
         return applicablePolicySets;
     }
@@ -208,4 +211,13 @@
     public void setRequiredIntents(List<Intent> intents) {
         this.requiredIntents = intents;
     }
+    
+
+    public void setIsAutomatic(boolean isAutomatic){
+        this.isAutomatic = isAutomatic;
+    }
+    
+    public boolean getIsAutomatic(){
+        return this.isAutomatic;
+    }
 }



Mime
View raw message