From 73f83aa2af6c25757ca8eee53d6d5ecb6fd7d6df Mon Sep 17 00:00:00 2001 From: vamsic007 Date: Thu, 5 Nov 2009 06:08:47 +0000 Subject: Obtain the injection points for ejb component from implementation.web git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@833009 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/implementation/ejb/EJBImplementation.java | 37 +++++++++++++++++++ .../ejb/impl/EJBImplementationImpl.java | 43 ++++++++++++++++++++++ .../ejb/xml/EJBImplementationProcessor.java | 38 +++++++++++++++++++ 3 files changed, 118 insertions(+) (limited to 'branches/sca-java-1.x/modules/implementation-ejb') diff --git a/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/EJBImplementation.java b/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/EJBImplementation.java index 0d3b05f0c9..3243c94aa7 100644 --- a/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/EJBImplementation.java +++ b/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/EJBImplementation.java @@ -18,7 +18,13 @@ */ package org.apache.tuscany.sca.implementation.ejb; +import java.util.Collection; +import java.util.Map; + import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.contribution.jee.InjectionTarget; +import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl; +import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl; @@ -41,4 +47,35 @@ public interface EJBImplementation extends Implementation { */ void setEJBLink(String ejbLink); + /** + * Returns the injection points for SCA references + * + * @return Map with injection points for SCA references + */ + Map getReferenceInjectionPoints(); + + /** + * Returns the injection points for SCA properties + * + * @return Map with injection points for SCA properties + */ + Map getPropertyInjectionPoints(); + + /** + * Returns the injection points for SCA resources like component context, component name, etc. + * + * @return Map with injection points for SCA resources + */ + Map getResourceInjectionPoints(); + + /** + * Returns the injection points for SCA callbacks + * + * @return Map with injection points for SCA callbacks + */ + Map> getCallbackInjectionPoints(); + + Map> getOptExtensionReferenceInjectionPoints(); + + Map getOptExtensionPropertyInjectionPoints(); } 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 8bcff6eb70..f912e4b36f 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 @@ -18,6 +18,10 @@ */ package org.apache.tuscany.sca.implementation.ejb.impl; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.ConstrainingType; import org.apache.tuscany.sca.assembly.Property; @@ -25,7 +29,10 @@ 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.assembly.impl.ImplementationImpl; +import org.apache.tuscany.sca.contribution.jee.InjectionTarget; import org.apache.tuscany.sca.implementation.ejb.EJBImplementation; +import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl; +import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl; import org.apache.tuscany.sca.runtime.RuntimeComponent; @@ -38,6 +45,18 @@ class EJBImplementationImpl extends ImplementationImpl implements EJBImplementat private String ejbLink; + private Map propertyInjectionPoints = new HashMap(); + + private Map referenceInjectionPoints = new HashMap(); + + private Map resourceInjectionPoints = new HashMap(); + + private final Map> callbackInjectionPoints = new HashMap>(); + + private Map> optExtReferenceInjectionPoints = new HashMap>(); + + private Map optExtPropertyInjectionPoints = new HashMap(); + /** * Constructs a new EJB implementation. */ @@ -64,6 +83,30 @@ class EJBImplementationImpl extends ImplementationImpl implements EJBImplementat this.ejbLink = ejbLink; } + public Map getPropertyInjectionPoints() { + return propertyInjectionPoints; + } + + public Map getReferenceInjectionPoints() { + return referenceInjectionPoints; + } + + public Map getResourceInjectionPoints() { + return resourceInjectionPoints; + } + + public Map> getCallbackInjectionPoints() { + return callbackInjectionPoints; + } + + public Map> getOptExtensionReferenceInjectionPoints() { + return optExtReferenceInjectionPoints; + } + + public Map getOptExtensionPropertyInjectionPoints() { + return optExtPropertyInjectionPoints; + } + /** * Use preProcess to add any references and properties dynamically */ diff --git a/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java b/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java index cfbad6c0f2..30c42f47a8 100644 --- a/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java +++ b/branches/sca-java-1.x/modules/implementation-ejb/src/main/java/org/apache/tuscany/sca/implementation/ejb/xml/EJBImplementationProcessor.java @@ -21,6 +21,10 @@ package org.apache.tuscany.sca.implementation.ejb.xml; import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; import java.util.logging.Logger; import javax.xml.namespace.QName; @@ -30,10 +34,13 @@ import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Property; import org.apache.tuscany.sca.assembly.xml.Constants; import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.jee.EjbInfo; import org.apache.tuscany.sca.contribution.jee.EjbModuleInfo; +import org.apache.tuscany.sca.contribution.jee.EjbReferenceInfo; +import org.apache.tuscany.sca.contribution.jee.EnvEntryInfo; import org.apache.tuscany.sca.contribution.jee.JavaEEExtension; import org.apache.tuscany.sca.contribution.jee.JavaEEOptionalExtension; import org.apache.tuscany.sca.contribution.jee.impl.EjbModuleInfoImpl; @@ -49,6 +56,8 @@ import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFacto import org.apache.tuscany.sca.implementation.java.IntrospectionException; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; +import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl; +import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl; import org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor; @@ -175,6 +184,23 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem if (ct != null){ implementation.getReferences().addAll(ct.getReferences()); implementation.getProperties().addAll(ct.getProperties()); + + // Injection points + List propertyNames = new ArrayList(); + for(Property prop : ct.getProperties()) { + propertyNames.add(prop.getName()); + } + EjbInfo ejbInfo = ejbModuleInfo.getEjbInfo(uri); + for(Map.Entry entry : ejbInfo.ejbReferences.entrySet()) { + EjbReferenceInfo ejbRef = entry.getValue(); + implementation.getOptExtensionReferenceInjectionPoints().put(ejbRef.injectionTarget, ejbRef.businessInterface); + } + for(Map.Entry entry : ejbInfo.envEntries.entrySet()) { + EnvEntryInfo envEntry = entry.getValue(); + if(propertyNames.contains(envEntry.name.replace("/", "_"))) { + implementation.getOptExtensionPropertyInjectionPoints().put(envEntry.name, envEntry.type); + } + } } } @@ -191,6 +217,18 @@ public class EJBImplementationProcessor extends BaseStAXArtifactProcessor implem implementation.getReferences().addAll(ji.getReferences()); implementation.getProperties().addAll(ji.getProperties()); implementation.getServices().addAll(ji.getServices()); + for(Map.Entry entry : ji.getReferenceMembers().entrySet()) { + implementation.getReferenceInjectionPoints().put(entry.getKey(), entry.getValue()); + } + for(Map.Entry entry : ji.getPropertyMembers().entrySet()) { + implementation.getPropertyInjectionPoints().put(entry.getKey(), entry.getValue()); + } + for(Map.Entry entry : ji.getResources().entrySet()) { + implementation.getResourceInjectionPoints().put(entry.getKey(), entry.getValue()); + } + for(Map.Entry> entry : ji.getCallbackMembers().entrySet()) { + implementation.getCallbackInjectionPoints().put(entry.getKey(), entry.getValue()); + } } catch (IntrospectionException e) { // TODO Auto-generated catch block e.printStackTrace(); -- cgit v1.2.3