summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-11 08:17:57 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-11 08:17:57 +0000
commitcc3266ac6526eb7e8740fdb2e5c37fff0363e751 (patch)
treebeac7b6a294e6537d486e416d34a664de5bfb9a8 /java/sca/modules
parent41e952751cd44e16b78d5083e1cc543ef22a47b5 (diff)
Start supporting referneces on implementation.web
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@684666 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java40
1 files changed, 38 insertions, 2 deletions
diff --git a/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java b/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
index 96b5b12137..f069e9788a 100644
--- a/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
+++ b/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
@@ -23,19 +23,21 @@ import java.util.Collections;
import java.util.List;
import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor;
+import org.apache.tuscany.sca.assembly.Component;
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.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
/**
* The model representing an Web implementation in an SCA assembly model.
*/
-class WebImplementationImpl implements WebImplementation {
+class WebImplementationImpl implements WebImplementation, ComponentPreProcessor {
private List<Property> properties = new ArrayList<Property>();
- // private List<Service> services = new ArrayList<Service>();
private List<Reference> references = new ArrayList<Reference>();
private String uri;
private boolean unresolved;
@@ -93,4 +95,38 @@ class WebImplementationImpl implements WebImplementation {
public void setWebURI(String webURI) {
this.webURI = webURI;
}
+
+ /**
+ * Use preProcess to add any references dynamically
+ * TODO: also support introspection and handle WEB-INF/web.componentType (spec line 503)
+ */
+ public void preProcess(Component component) {
+ RuntimeComponent rtc = (RuntimeComponent) component;
+
+ for (Reference reference : rtc.getReferences()) {
+ if (getReference(reference.getName()) == null) {
+ getReferences().add(createReference(reference));
+ }
+ }
+ }
+
+ protected Reference getReference(String name) {
+ for (Reference reference : getReferences()) {
+ if (reference.getName().equals(name)) {
+ return reference;
+ }
+ }
+ return null;
+ }
+
+ protected Reference createReference(Reference reference) {
+ Reference newReference;
+ try {
+ newReference = (Reference)reference.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError(e); // should not ever happen
+ }
+ return newReference;
+ }
+
}