diff options
Diffstat (limited to 'java/sca')
6 files changed, 106 insertions, 15 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderTmp.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderTmp.java new file mode 100644 index 0000000000..cf3e62ab38 --- /dev/null +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderTmp.java @@ -0,0 +1,54 @@ +/* + * 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; + +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.definitions.Definitions; +import org.apache.tuscany.sca.monitor.Monitor; + +/** + * 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 interface CompositeBuilderTmp { + + /** + * Returns the ID of the builder. + * + * @return + */ + String getID(); + + /** + * Build a composite. + * + * @param composite + * @param definitions + * @param monitor + * @throws CompositeBuilderException + */ + void build(Composite composite, Definitions definitions, Map<Class<?>, List<String>> bindingMap, Monitor monitor) throws CompositeBuilderException; + +} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java index 32444349b2..4d6612979f 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java @@ -22,6 +22,7 @@ package org.apache.tuscany.sca.assembly.builder; import java.lang.reflect.Constructor; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.apache.tuscany.sca.assembly.Composite; @@ -96,7 +97,7 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx * A wrapper around a composite builder allowing lazy * loading and initialization of implementation providers. */ - private static class LazyCompositeBuilder implements CompositeBuilder { + private static class LazyCompositeBuilder implements CompositeBuilder, CompositeBuilderTmp { private ExtensionPointRegistry registry; private FactoryExtensionPoint factories; @@ -123,6 +124,11 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { getBuilder().build(composite, definitions, monitor); } + + public void build(Composite composite, Definitions definitions, Map<Class<?>, List<String>> bindingMap, Monitor monitor) + throws CompositeBuilderException { + ((CompositeBuilderTmp)getBuilder()).build(composite, definitions, bindingMap, monitor); + } private CompositeBuilder getBuilder() { if (builder == null) { diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java index d31a38c70b..d6757fd42b 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java @@ -70,7 +70,8 @@ public class CompositeBindingConfigurationBuilderImpl extends CompositeBindingUR defaultBindings = (List<Binding>)x; } } - configureBindingURIs(composite, definitions, defaultBindings, monitor); + // TODO - EPR - is this ever used? + //configureBindingURIs(composite, definitions, defaultBindings, monitor); } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java index 2daf8cbaf6..896d6d3540 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java @@ -44,6 +44,7 @@ import org.apache.tuscany.sca.assembly.SCABindingFactory; 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.CompositeBuilderTmp; import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.monitor.Monitor; @@ -53,7 +54,7 @@ import org.apache.tuscany.sca.monitor.Monitor; * * @version $Rev$ $Date$ */ -public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements CompositeBuilder { +public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements CompositeBuilder, CompositeBuilderTmp { @Deprecated public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory, @@ -80,6 +81,12 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { configureBindingURIsAndNames(composite, definitions, monitor); } + + public void build(Composite composite, Definitions definitions, Map<Class<?>, List<String>> bindingMap, Monitor monitor) + throws CompositeBuilderException { + configureBindingURIs(composite, null, definitions, bindingMap, monitor); + configureBindingNames(composite, monitor); + } /** * Called by CompositeBindingURIBuilderImpl @@ -100,7 +107,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * @param defaultBindings list of default binding configurations */ protected void configureBindingURIs(Composite composite, - Definitions definitions, List<Binding> defaultBindings, + Definitions definitions, Map<Class<?>, List<String>> defaultBindings, Monitor monitor) throws CompositeBuilderException { configureBindingURIs(composite, null, definitions, defaultBindings, monitor); } @@ -126,7 +133,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * @param defaultBindings list of default binding configurations */ private void configureBindingURIs(Composite composite, String uri, - Definitions definitions, List<Binding> defaultBindings, + Definitions definitions, Map<Class<?>, List<String>> defaultBindings, Monitor monitor) throws CompositeBuilderException { String parentComponentURI = uri; @@ -339,7 +346,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * @param defaultBindings */ private void constructBindingURI(String parentComponentURI, Composite composite, Service service, - Binding binding, List<Binding> defaultBindings, Monitor monitor) + Binding binding, Map<Class<?>, 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. @@ -358,7 +365,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * @param defaultBindings the list of default binding configurations */ private void constructBindingURI(Component component, Service service, - Binding binding, List<Binding> defaultBindings, Monitor monitor) + Binding binding, Map<Class<?>, List<String>> defaultBindings, Monitor monitor) throws CompositeBuilderException{ boolean includeBindingName = component.getServices().size() != 1; constructBindingURI(component.getURI(), service, binding, includeBindingName, defaultBindings, monitor); @@ -375,7 +382,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C * @throws CompositeBuilderException */ private void constructBindingURI(String componentURIString, Service service, Binding binding, - boolean includeBindingName, List<Binding> defaultBindings, Monitor monitor) + boolean includeBindingName, Map<Class<?>, List<String>> defaultBindings, Monitor monitor) throws CompositeBuilderException{ try { @@ -419,9 +426,13 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C // calculate the base URI URI baseURI = null; if (defaultBindings != null) { - for (Binding defaultBinding : defaultBindings){ - if (binding.getType().equals(defaultBinding.getType())){ - baseURI = new URI(addSlashToPath(defaultBinding.getURI())); + for (Class<?> bindingClass : defaultBindings.keySet()){ + if (bindingClass.isInstance(binding)){ + List<String> uris = defaultBindings.get(bindingClass); + if (uris.size() > 0){ + baseURI = new URI(addSlashToPath(uris.get(0))); + } + break; } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java index e54e805016..e1598bb75f 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.assembly.builder.impl; +import java.util.List; +import java.util.Map; import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilderFactory; @@ -28,6 +30,7 @@ import org.apache.tuscany.sca.assembly.Composite; 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.assembly.builder.CompositeBuilderTmp; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.definitions.Definitions; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; @@ -40,7 +43,7 @@ import org.apache.tuscany.sca.policy.PolicyFactory; * * @version $Rev$ $Date$ */ -public class CompositeBuilderImpl implements CompositeBuilder { +public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderTmp { private static final Logger logger = Logger.getLogger(CompositeBuilderImpl.class.getName()); private CompositeBuilder compositeIncludeBuilder; private CompositeBuilder componentReferenceWireBuilder; @@ -137,8 +140,12 @@ public class CompositeBuilderImpl implements CompositeBuilder { public String getID() { return "org.apache.tuscany.sca.assembly.builder.CompositeBuilder"; } - + public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { + build(composite, definitions, null, monitor); + } + + public void build(Composite composite, Definitions definitions, Map<Class<?>, List<String>> bindingMap, Monitor monitor) throws CompositeBuilderException { try { // Collect and fuse includes @@ -163,7 +170,7 @@ public class CompositeBuilderImpl implements CompositeBuilder { // 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); + ((CompositeBuilderTmp)compositeBindingURIBuilder).build(composite, definitions, bindingMap, monitor); // Create $promoted$ component services on bottom level components // to represent promoted services diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java index 8ce21bc375..66f6f0e090 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java @@ -34,6 +34,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -52,6 +53,7 @@ import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilderTmp; import org.apache.tuscany.sca.contribution.Artifact; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.contribution.ContributionFactory; @@ -90,6 +92,7 @@ import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.NodeFactory; +import org.apache.tuscany.sca.node.configuration.BindingConfiguration; import org.apache.tuscany.sca.node.configuration.ContributionConfiguration; import org.apache.tuscany.sca.node.configuration.DeploymentComposite; import org.apache.tuscany.sca.node.configuration.NodeConfiguration; @@ -596,8 +599,17 @@ public class NodeFactoryImpl extends NodeFactory { } } + // TODO - EPR - create a binding map to pass down into the builders + // for use during URI calculation. + Map<Class<?>, List<String>> bindingMap = new HashMap<Class<?>, List<String>>(); + for (BindingConfiguration config : configuration.getBindings()){ + StAXArtifactProcessor<?> processor = xmlProcessors.getProcessor(config.getBindingType()); + Class<?> bindingClass = processor.getModelType(); + bindingMap.put(bindingClass, config.getBaseURIs()); + } + // build the top level composite - compositeBuilder.build(tempComposite, systemDefinitions, monitor); + ((CompositeBuilderTmp)compositeBuilder).build(tempComposite, systemDefinitions, bindingMap, monitor); analyzeProblems(); endpointReferenceBuilder.build(tempComposite, systemDefinitions, monitor); |