summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/implementation-ejb/src/main/java
diff options
context:
space:
mode:
authorvamsic007 <vamsic007@13f79535-47bb-0310-9956-ffa450edef68>2008-11-26 13:58:31 +0000
committervamsic007 <vamsic007@13f79535-47bb-0310-9956-ffa450edef68>2008-11-26 13:58:31 +0000
commit6b2f0faadffa62059874b5c7557904a0c0b5176d (patch)
treee8e212473af1516c85da5d39ef63393534e2fbf6 /branches/sca-java-1.x/modules/implementation-ejb/src/main/java
parent2ee92a412cc393b38fbd8dc9241909f7e71100f4 (diff)
Add ComponentPreProcessor to EJBImplementationImpl.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@720856 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/implementation-ejb/src/main/java')
-rw-r--r--branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/impl/EJBImplementationImpl.java65
1 files changed, 64 insertions, 1 deletions
diff --git a/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/impl/EJBImplementationImpl.java b/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/impl/EJBImplementationImpl.java
index bf2e6354d5..c9bfaea00b 100644
--- a/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/impl/EJBImplementationImpl.java
+++ b/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/impl/EJBImplementationImpl.java
@@ -21,11 +21,14 @@ package org.apache.tuscany.sca.implementation.ejb.impl;
import java.util.ArrayList;
import java.util.List;
+import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ConstrainingType;
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.assembly.builder.ComponentPreProcessor;
import org.apache.tuscany.sca.implementation.ejb.EJBImplementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
/**
@@ -33,7 +36,7 @@ import org.apache.tuscany.sca.implementation.ejb.EJBImplementation;
*
* @version $Rev$ $Date$
*/
-class EJBImplementationImpl implements EJBImplementation {
+class EJBImplementationImpl implements EJBImplementation, ComponentPreProcessor {
private List<Property> properties = new ArrayList<Property>();
private List<Service> services = new ArrayList<Service>();
@@ -92,4 +95,64 @@ class EJBImplementationImpl implements EJBImplementation {
public void setUnresolved(boolean unresolved) {
this.unresolved = unresolved;
}
+
+ /**
+ * Use preProcess to add any references and properties dynamically
+ */
+ public void preProcess(Component component) {
+ if (!(component instanceof RuntimeComponent)) {
+ return;
+ }
+ RuntimeComponent rtc = (RuntimeComponent) component;
+
+ for (Reference reference : rtc.getReferences()) {
+ if (getReference(reference.getName()) == null) {
+ getReferences().add(createReference(reference));
+ }
+ }
+
+ for (Property property : rtc.getProperties()) {
+ if (getProperty(property.getName()) == null) {
+ getProperties().add(createProperty(property));
+ }
+ }
+ }
+
+ 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;
+ }
+
+ protected Property getProperty(String name) {
+ for (Property property : getProperties()) {
+ if (property.getName().equals(name)) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ protected Property createProperty(Property property) {
+ Property newProperty;
+ try {
+ newProperty = (Property)property.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new AssertionError(e); // should not ever happen
+ }
+ return newProperty;
+ }
}