summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-11-06 10:56:44 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-11-06 10:56:44 +0000
commitb9806981ec7becc5aca1fe3f56b8216903206709 (patch)
treecf2ed0f7ec04dbb0a579c787535a2737a1abd27f /java
parent77d412bf962815decfe73bdfecc3946fd83df411 (diff)
remove more cruft from the builders
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@833341 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java14
-rw-r--r--java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java9
-rw-r--r--java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java29
-rw-r--r--java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java88
-rw-r--r--java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java115
5 files changed, 31 insertions, 224 deletions
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
index 205a3157de..aad07dd704 100644
--- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
+++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
@@ -94,20 +94,10 @@ public class BindingURIBuilderImpl implements CompositeBuilder {
try {
// Process nested composites recursively
for (Component component : composite.getComponents()) {
-
- // Initialize component URI
- String componentURI;
- if (parentComponentURI == null) {
- componentURI = component.getName();
- } else {
- componentURI = URI.create(parentComponentURI + '/').resolve(component.getName()).toString();
- }
- component.setURI(componentURI);
-
Implementation implementation = component.getImplementation();
if (implementation instanceof Composite) {
// Process nested composite
- configureBindingURIs((Composite)implementation, componentURI, definitions, defaultBindings, monitor);
+ configureBindingURIs((Composite)implementation, component.getURI(), definitions, defaultBindings, monitor);
}
}
@@ -125,9 +115,7 @@ public class BindingURIBuilderImpl implements CompositeBuilder {
for (Component component : composite.getComponents()) {
monitor.pushContext("Component: " + component.getName());
-
try {
-
for (ComponentService service : component.getServices()) {
// Initialize binding names and URIs
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
index 85fa783451..77a460e7d9 100644
--- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
+++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
@@ -301,15 +301,6 @@ public class ComponentBuilderImpl {
if (componentReference.getAutowire() == null) {
componentReference.setAutowire(component.getAutowire());
}
-
- // TODO - we shouldn't do this as targets must be resolved in the
- // context in which they are defined. Leaving here as a reminder
- // for the time being
- // Reconcile targets copying them up the promotion hierarchy
- //if (componentReference.getTargets().isEmpty()) {
- // componentReference.getTargets().addAll(componentTypeReference.getTargets());
- //}
-
}
}
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
index 471c5ef216..35d5dabd87 100644
--- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
+++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
@@ -97,9 +97,12 @@ public class ModelBuilderImpl implements CompositeBuilder {
composite = compositeIncludeBuilder.build(composite, context);
// Set up the structural URIs for components (services/references/bindings)
+ // TODO does this need to happen before policy attachment
composite = structuralURIBuilder.build(composite, context);
- // need to apply policy external attachment
+ // Apply policy external attachment. Happens before the composite type
+ // is created so that suitable promotion and structural processing is
+ // applied to the attached policies
composite = policyAttachmentBuilder.build(composite, context);
// Process the implementation hierarchy by calculating the component type
@@ -108,24 +111,22 @@ public class ModelBuilderImpl implements CompositeBuilder {
// components that depend on them
compositeComponentTypeBuilder.createComponentType(null, composite, context);
- // create the runtime model by updating the static model we have just
- // created. This involves things like creating
- // component URIs
- // binding URIs
- // binding specific build processing
- // callback references - currently done in static pass
- // callback services - currently done in static pass
- // Endpoints
- // Endoint References
- // 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
+ // Calculate the URI associated with service bindings
composite = bindingURIBuilder.build(composite, context);
+
+ // perform any binding specific build processing
composite = componentServiceBindingBuilder.build(composite, context); // binding specific build
composite = componentReferenceBindingBuilder.build(composite, context); // binding specific build
+
+ // compute all the service endpoints
endpointBuilder.build(composite, context);
+
+ // compute all the reference endpoint references
endpointReferenceBuilder.build(composite, context);
- composite = compositePolicyBuilder.build(composite, context); // the rest of the policy processing?
+
+ // calculate intents and policy sets across the model hierarchy
+ // relies on the endpoints and endpoint references having been calculated
+ composite = compositePolicyBuilder.build(composite, context);
// For debugging - in success cases
//System.out.println(dumpBuiltComposite(composite));
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java
deleted file mode 100644
index ef03344131..0000000000
--- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.builder.impl;
-
-import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.ComponentService;
-import org.apache.tuscany.sca.assembly.CompositeService;
-import org.apache.tuscany.sca.assembly.Service;
-
-/**
- * This class encapsulates utility methods to deal with service definitions.
- *
- * @version $Rev$ $Date$
- */
-abstract class ServiceConfigurationUtil {
-
- /**
- * Follow a service promotion chain down to the inner most (non composite)
- * component service.
- *
- * @param topCompositeService
- * @return
- */
- static ComponentService getPromotedComponentService(CompositeService compositeService) {
- ComponentService componentService = compositeService.getPromotedService();
- if (componentService != null) {
- Service service = componentService.getService();
- if (componentService.getName() != null && service instanceof CompositeService) {
-
- // Continue to follow the service promotion chain
- return getPromotedComponentService((CompositeService)service);
-
- } else {
-
- // Found a non-composite service
- return componentService;
- }
- } else {
-
- // No promoted service
- return null;
- }
- }
-
- /**
- * Follow a service promotion chain down to the innermost (non-composite) component.
- *
- * @param compositeService
- * @return
- */
- static Component getPromotedComponent(CompositeService compositeService) {
- ComponentService componentService = compositeService.getPromotedService();
- if (componentService != null) {
- Service service = componentService.getService();
- if (componentService.getName() != null && service instanceof CompositeService) {
-
- // Continue to follow the service promotion chain
- return getPromotedComponent((CompositeService)service);
-
- } else {
-
- // Found a non-composite service
- return compositeService.getPromotedComponent();
- }
- } else {
-
- // No promoted service
- return null;
- }
- }
-
-}
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
index b543e3347d..7c2d86862b 100644
--- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
+++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
@@ -52,6 +52,21 @@ public class StructuralURIBuilderImpl implements CompositeBuilder {
public StructuralURIBuilderImpl(ExtensionPointRegistry registry) {
}
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.StructualURIBuilder";
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ configureStructuralURIs(composite,
+ null,
+ context.getDefinitions(),
+ context.getBindingBaseURIs(),
+ context.getMonitor());
+ return composite;
+ }
+
/**
* If a binding name is not provided by the user, construct it based on the service
@@ -117,99 +132,6 @@ public class StructuralURIBuilderImpl implements CompositeBuilder {
}
}
- /**
- * Concatenate binding URI parts together based on Assembly Specification section 1.7.2
- *
- * @param baseURI the base of the binding URI
- * @param componentURI the middle part of the binding URI derived from the component name
- * @param bindingURI the end part of the binding URI
- * @param includeBindingName when set true the binding name part should be used
- * @param bindingName the binding name
- * @return the resulting URI as a string
- */
- private static String constructBindingURI(URI baseURI,
- URI componentURI,
- URI bindingURI,
- String serviceName,
- boolean includeBindingName,
- String bindingName) {
- String name = includeBindingName ? serviceName + "/" + bindingName : serviceName;
- String uriString;
-
- if (baseURI == null) {
- if (componentURI == null) {
- if (bindingURI != null) {
- uriString = name + "/" + bindingURI.toString();
- } else {
- uriString = name;
- }
- } else {
- if (bindingURI != null) {
- if (bindingURI.toString().startsWith("/")) {
- uriString = componentURI.resolve(bindingURI).toString();
- } else {
- uriString = componentURI.resolve(name + "/" + bindingURI).toString();
- }
- } else {
- uriString = componentURI.resolve(name).toString();
- }
- }
- } else {
- if (componentURI == null) {
- if (bindingURI != null) {
- uriString = basedURI(baseURI, bindingURI).toString();
- } else {
- uriString = basedURI(baseURI, URI.create(name)).toString();
- }
- } else {
- if (bindingURI != null) {
- uriString = basedURI(baseURI, componentURI.resolve(bindingURI)).toString();
- } else {
- uriString = basedURI(baseURI, componentURI.resolve(name)).toString();
- }
- }
- }
-
- // tidy up by removing any trailing "/"
- if (uriString.endsWith("/")) {
- uriString = uriString.substring(0, uriString.length() - 1);
- }
-
- URI uri = URI.create(uriString);
- if (!uri.isAbsolute()) {
- uri = URI.create("/").resolve(uri);
- }
- return uri.toString();
- }
-
- /**
- * Combine a URI with a base URI.
- *
- * @param baseURI
- * @param uri
- * @return
- */
- private static URI basedURI(URI baseURI, URI uri) {
- if (uri.getScheme() != null) {
- return uri;
- }
- String str = uri.toString();
- if (str.startsWith("/")) {
- str = str.substring(1);
- }
- return URI.create(baseURI.toString() + str).normalize();
- }
-
- public Composite build(Composite composite, BuilderContext context)
- throws CompositeBuilderException {
- configureStructuralURIs(composite, null, context.getDefinitions(), context.getBindingBaseURIs(), context.getMonitor());
- return composite;
- }
-
- public String getID() {
- return "org.apache.tuscany.sca.assembly.builder.StructualURIBuilder";
- }
-
private void configureStructuralURIs(Composite composite,
String parentComponentURI,
Definitions definitions,
@@ -242,13 +164,6 @@ public class StructuralURIBuilderImpl implements CompositeBuilder {
try {
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);