diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-20 10:10:33 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-20 10:10:33 +0000 |
commit | df394ad8991792c90ee678ec18ca3d4fcf896e2e (patch) | |
tree | c7cc1ecd5d056b1261b193bb86c04b48b743bfbf /sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java | |
parent | aee4ccff94e790912b0230b244cc9e46ec62463b (diff) |
Copy trunk to test sanbox for release plugin testing
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@756399 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java')
-rw-r--r-- | sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java | 260 |
1 files changed, 260 insertions, 0 deletions
diff --git a/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java new file mode 100644 index 0000000000..6c8228d58a --- /dev/null +++ b/sandbox/ant/sca/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java @@ -0,0 +1,260 @@ +/* + * 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.impl; + +import java.util.logging.Logger; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.TransformerFactory; + +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.FactoryExtensionPoint; +import org.apache.tuscany.sca.definitions.Definitions; +import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.policy.PolicyFactory; + +/** + * 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 CompositeBuilderImpl implements CompositeBuilder { + private static final Logger logger = Logger.getLogger(CompositeBuilderImpl.class.getName()); + private CompositeBuilder compositeIncludeBuilder; + private CompositeBuilder componentReferenceWireBuilder; + //private CompositeBuilder componentReferencePromotionWireBuilder; + private CompositeBuilder componentReferencePromotionBuilder; + //private CompositeBuilder compositeReferenceWireBuilder; + private CompositeBuilder compositeCloneBuilder; + private CompositeBuilder componentConfigurationBuilder; + private CompositeBuilder compositeServiceConfigurationBuilder; + private CompositeBuilder compositeReferenceConfigurationBuilder; + private CompositeBuilder compositeBindingURIBuilder; + //private CompositeBuilder componentServicePromotionBuilder; + //private CompositeBuilder compositeServicePromotionBuilder; + private CompositeBuilder compositePromotionBuilder; + private CompositeBuilder compositePolicyBuilder; + private CompositeBuilder componentServiceBindingBuilder; + private CompositeBuilder componentReferenceBindingBuilder; + + private CompositeBuilder componentReferenceEndpointReferenceBuilder; + private CompositeBuilder componentServiceEndpointBuilder; + //private CompositeBuilder endpointReferenceBuilder; + + public CompositeBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) { + this(factories.getFactory(AssemblyFactory.class), + factories.getFactory(EndpointFactory.class), + factories.getFactory(SCABindingFactory.class), + factories.getFactory(PolicyFactory.class), + factories.getFactory(DocumentBuilderFactory.class), + factories.getFactory(TransformerFactory.class), + mapper); + } + + /** + * Constructs a new composite builder. + * + * @param assemblyFactory + * @param scaBindingFactory + * @param endpointFactory + * @param intentAttachPointTypeFactory + * @param interfaceContractMapper + * @param policyDefinitions + * @param monitor + */ + @Deprecated + public CompositeBuilderImpl(AssemblyFactory assemblyFactory, + EndpointFactory endpointFactory, + SCABindingFactory scaBindingFactory, + PolicyFactory intentAttachPointTypeFactory, + InterfaceContractMapper interfaceContractMapper) { + this(assemblyFactory, endpointFactory, scaBindingFactory, intentAttachPointTypeFactory, + null, null, interfaceContractMapper); + } + + /** + * Constructs a new composite builder. + * + * @param assemblyFactory + * @param scaBindingFactory + * @param endpointFactory + * @param intentAttachPointTypeFactory + * @param interfaceContractMapper + * @param policyDefinitions + * @param monitor + */ + @Deprecated + public CompositeBuilderImpl(AssemblyFactory assemblyFactory, + SCABindingFactory scaBindingFactory, + PolicyFactory intentAttachPointTypeFactory, + InterfaceContractMapper interfaceContractMapper) { + this(assemblyFactory, null, scaBindingFactory, intentAttachPointTypeFactory, + null, null, interfaceContractMapper); + } + + /** + * Constructs a new composite builder. + * + * @param assemblyFactory + * @param scaBindingFactory + * @param intentAttachPointTypeFactory + * @param documentBuilderFactory + * @param transformerFactory + * @param interfaceContractMapper + * @param monitor + */ + public CompositeBuilderImpl(AssemblyFactory assemblyFactory, + SCABindingFactory scaBindingFactory, + PolicyFactory intentAttachPointTypeFactory, + DocumentBuilderFactory documentBuilderFactory, + TransformerFactory transformerFactory, + InterfaceContractMapper interfaceContractMapper) { + this(assemblyFactory, null, scaBindingFactory, intentAttachPointTypeFactory, + documentBuilderFactory, transformerFactory, interfaceContractMapper); + } + + /** + * Constructs a new composite builder. + * + * @param assemblyFactory + * @param scaBindingFactory + * @param endpointFactory + * @param intentAttachPointTypeFactory + * @param interfaceContractMapper + * @param policyDefinitions + * @param monitor + */ + public CompositeBuilderImpl(AssemblyFactory assemblyFactory, + EndpointFactory endpointFactory, + SCABindingFactory scaBindingFactory, + PolicyFactory intentAttachPointTypeFactory, + DocumentBuilderFactory documentBuilderFactory, + TransformerFactory transformerFactory, + InterfaceContractMapper interfaceContractMapper) { + + if (endpointFactory == null){ + endpointFactory = new DefaultEndpointFactory(); + } + + compositeIncludeBuilder = new CompositeIncludeBuilderImpl(); + componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper); + //componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory); + componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(assemblyFactory, endpointFactory); + //compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory); + compositeCloneBuilder = new CompositeCloneBuilderImpl(); + componentConfigurationBuilder = new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); + compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory); + compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(assemblyFactory); + compositeBindingURIBuilder = new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper); + //componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory); + //compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory); + compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper); + compositePolicyBuilder = new CompositePolicyBuilderImpl(assemblyFactory, endpointFactory, interfaceContractMapper); + componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl(); + componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl(); + + componentReferenceEndpointReferenceBuilder = new ComponentReferenceEndpointReferenceBuilderImpl(assemblyFactory, interfaceContractMapper); + componentServiceEndpointBuilder = new ComponentServiceEndpointBuilderImpl(assemblyFactory); + //endpointReferenceBuilder = new EndpointReference2BuilderImpl(assemblyFactory, interfaceContractMapper); + } + + public String getID() { + return "org.apache.tuscany.sca.assembly.builder.CompositeBuilder"; + } + + public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { + + // Collect and fuse includes + compositeIncludeBuilder.build(composite, definitions, monitor); + + // Expand nested composites + compositeCloneBuilder.build(composite, definitions, monitor); + + // Configure all components + componentConfigurationBuilder.build(composite, definitions, monitor); + + // Connect composite services/references to promoted services/references + compositePromotionBuilder.build(composite, definitions, monitor); + + // Compute the policies across the model hierarchy + compositePolicyBuilder.build(composite, definitions, monitor); + + // Configure composite services by copying bindings up the promotion + // hierarchy overwriting automatic bindings with those added manually + compositeServiceConfigurationBuilder.build(composite, definitions, monitor); + + // Configure composite references by copying bindings down promotion + // hierarchy overwriting automatic bindings with those added manually + compositeReferenceConfigurationBuilder.build(composite, definitions, monitor); + + // Configure service binding URIs and names. Creates an SCA defined URI based + // on the scheme base URI, the component name and the binding name + compositeBindingURIBuilder.build(composite, definitions, monitor); + + // Create $promoted$ component services on bottom level components + // to represent promoted services + // TODO - EPR replaced by endpoints on the promoted services + //componentServicePromotionBuilder.build(composite, definitions, monitor); + + // Create $promoted$ component services on bottom level components + // to represent promoted composite services + // TODO - EPR OASIS doesn't deploy top level composite services + // if it did it would be replaced by endpoints + //compositeServicePromotionBuilder.build(composite, definitions, monitor); + + // Perform and service binding related build activities. The binding + // will provide the builder. + componentServiceBindingBuilder.build(composite, definitions, monitor); + + // create endpoints on component services. + componentServiceEndpointBuilder.build(composite, definitions, monitor); + + // Apply any wires in the composite to create new component reference targets + componentReferenceWireBuilder.build(composite, definitions, monitor); + + // create reference endpoint reference models + componentReferenceEndpointReferenceBuilder.build(composite, definitions, monitor); + + // Push down configuration from promoted references to the + // references they promote + componentReferencePromotionBuilder.build(composite, definitions, monitor); + + // Push down configuration from promoted references to the + // references they promote + // TODO - EPR Seems to be a repeat of compositeReferenceConfigurationBuilder + // componentReferencePromotionWireBuilder.build(composite, definitions, monitor); + + // Wire the composite references + // TODO - EPR OASIS doesn't deploy top level composite references + // compositeReferenceWireBuilder.build(composite, definitions, monitor); + + // Perform and reference binding related build activities. The binding + // will provide the builder. + componentReferenceBindingBuilder.build(composite, definitions, monitor); + } + +} |