tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1152756 - in /openejb/trunk/openejb3/container: openejb-api/src/main/java/org/apache/openejb/api/ openejb-core/src/main/java/org/apache/openejb/assembler/classic/ openejb-core/src/main/java/org/apache/openejb/cdi/ openejb-core/src/main/jav...
Date Mon, 01 Aug 2011 13:13:55 GMT
Author: rmannibucau
Date: Mon Aug  1 13:13:52 2011
New Revision: 1152756

URL: http://svn.apache.org/viewvc?rev=1152756&view=rev
Log:
allowing to inject repository into session beans

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/RepositoryReferenceInfo.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/RepositoryRef.java
Modified:
    openejb/trunk/openejb3/container/openejb-api/src/main/java/org/apache/openejb/api/Repository.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InjectionBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBeanInfo.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Application.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ApplicationClient.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JndiConsumer.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MessageDrivenBean.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebApp.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebFragment.java

Modified: openejb/trunk/openejb3/container/openejb-api/src/main/java/org/apache/openejb/api/Repository.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-api/src/main/java/org/apache/openejb/api/Repository.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-api/src/main/java/org/apache/openejb/api/Repository.java
(original)
+++ openejb/trunk/openejb3/container/openejb-api/src/main/java/org/apache/openejb/api/Repository.java
Mon Aug  1 13:13:52 2011
@@ -9,7 +9,7 @@ import java.lang.annotation.Target;
 /**
  * @author rmannibucau
  */
-@Target({ ElementType.TYPE })
+@Target({ ElementType.TYPE, ElementType.FIELD })
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Repository {
     PersistenceContext context() default @PersistenceContext;

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
Mon Aug  1 13:13:52 2011
@@ -127,9 +127,12 @@ public class Assembler extends Assembler
     public static final String VALIDATOR_FACTORY_NAMING_CONTEXT = JAVA_OPENEJB_NAMING_CONTEXT
+ "ValidatorFactory/";
     public static final String VALIDATOR_NAMING_CONTEXT = JAVA_OPENEJB_NAMING_CONTEXT + "Validator/";
 
+    public static final String REPOSITORY_NAMING_CONTEXT = JAVA_OPENEJB_NAMING_CONTEXT +
"Repository/";
+
     private static final String OPENEJB_URL_PKG_PREFIX = "org.apache.openejb.core.ivm.naming";
 
     public static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP, Assembler.class);
+
     Messages messages = new Messages(Assembler.class.getPackage().getName());
 
     private final CoreContainerSystem containerSystem;
@@ -694,7 +697,6 @@ public class Assembler extends Assembler
                     try {
                         Class<?> proxied = classLoader.loadClass(repository);
 
-                        // TODO: move it in config?
                         Repository annotation = proxied.getAnnotation(Repository.class);
                         PersistenceContext pc = annotation.context();
                         String unitName = pc.unitName();
@@ -727,7 +729,7 @@ public class Assembler extends Assembler
 
                         String jndi = annotation.jndiName();
                         if (jndi == null || jndi.isEmpty()) {
-                            jndi = "openejb/Repository/" + repository;
+                            jndi = REPOSITORY_NAMING_CONTEXT + repository;
                         }
 
                         // TODO in a better way

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InjectionBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InjectionBuilder.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InjectionBuilder.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/InjectionBuilder.java
Mon Aug  1 13:13:52 2011
@@ -95,6 +95,15 @@ public class InjectionBuilder {
                 injections.add(injection);
             }
         }
+
+        for (RepositoryReferenceInfo info : jndiEnc.repositoryRefs) {
+            for (InjectionInfo target : info.targets) {
+                Class targetClass = loadClass(target.className);
+                Injection injection = new Injection(info.referenceName, target.propertyName,
targetClass);
+                injections.add(injection);
+            }
+        }
+
         return injections;
     }
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncBuilder.java
Mon Aug  1 13:13:52 2011
@@ -449,6 +449,12 @@ public class JndiEncBuilder {
                 bindings.put(normalize(referenceInfo.referenceName), serviceRefData);
             }
         }
+
+        for (RepositoryReferenceInfo repositoryInfo : jndiEnc.repositoryRefs) {
+            Reference reference = new IntraVmJndiReference(Assembler.REPOSITORY_NAMING_CONTEXT
+ repositoryInfo.repository);
+            bindings.put(normalize(repositoryInfo.referenceName), reference);
+        }
+
         return bindings;
     }
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncInfo.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncInfo.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiEncInfo.java
Mon Aug  1 13:13:52 2011
@@ -34,4 +34,5 @@ public class JndiEncInfo extends InfoObj
     public final List<PersistenceContextReferenceInfo> persistenceContextRefs = new
ArrayList<PersistenceContextReferenceInfo>();
     public final List<ResourceEnvReferenceInfo> resourceEnvRefs = new ArrayList<ResourceEnvReferenceInfo>();
     public final List<ServiceReferenceInfo> serviceRefs = new ArrayList<ServiceReferenceInfo>();
+    public final List<RepositoryReferenceInfo> repositoryRefs = new ArrayList<RepositoryReferenceInfo>();
 }

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/RepositoryReferenceInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/RepositoryReferenceInfo.java?rev=1152756&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/RepositoryReferenceInfo.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/RepositoryReferenceInfo.java
Mon Aug  1 13:13:52 2011
@@ -0,0 +1,8 @@
+package org.apache.openejb.assembler.classic;
+
+/**
+ * @author rmannibucau
+ */
+public class RepositoryReferenceInfo extends InjectableInfo {
+    public String repository;
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBeanInfo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBeanInfo.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBeanInfo.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBeanInfo.java
Mon Aug  1 13:13:52 2011
@@ -17,22 +17,9 @@
 package org.apache.openejb.cdi;
 
 import org.apache.openejb.Injection;
-import org.apache.openejb.jee.DataSource;
-import org.apache.openejb.jee.EjbLocalRef;
-import org.apache.openejb.jee.EjbRef;
-import org.apache.openejb.jee.EnvEntry;
-import org.apache.openejb.jee.JndiConsumer;
-import org.apache.openejb.jee.KeyedCollection;
-import org.apache.openejb.jee.LifecycleCallback;
-import org.apache.openejb.jee.MessageDestinationRef;
-import org.apache.openejb.jee.PersistenceContextRef;
-import org.apache.openejb.jee.PersistenceUnitRef;
-import org.apache.openejb.jee.ResourceEnvRef;
-import org.apache.openejb.jee.ResourceRef;
-import org.apache.openejb.jee.SecurityIdentity;
-import org.apache.openejb.jee.SecurityRoleRef;
-import org.apache.openejb.jee.ServiceRef;
+import org.apache.openejb.jee.*;
 
+import javax.xml.bind.annotation.XmlTransient;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -59,6 +46,7 @@ public class CdiBeanInfo implements Jndi
     private String beanName;
     private ClassLoader classLoader;
     private List<Injection> injections;
+    protected KeyedCollection<String, RepositoryRef> repositoryRefs;
 
     public String getBeanName() {
         return beanName;
@@ -288,4 +276,20 @@ public class CdiBeanInfo implements Jndi
     public Class<?> getBeanClass() {
         return this.beanClass;
     }
+
+    @Override
+    public Collection<RepositoryRef> getRepositoryRef() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs;
+    }
+
+    @Override
+    public Map<String, RepositoryRef> getRepositoryRefMap() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs.toMap();
+    }
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Mon Aug  1 13:13:52 2011
@@ -132,91 +132,7 @@ import org.apache.openejb.api.RemoteClie
 import org.apache.openejb.api.Repository;
 import org.apache.openejb.cdi.CdiBeanInfo;
 import org.apache.openejb.core.webservices.JaxWsUtils;
-import org.apache.openejb.jee.ActivationConfig;
-import org.apache.openejb.jee.ActivationSpec;
-import org.apache.openejb.jee.AdminObject;
-import org.apache.openejb.jee.ApplicationClient;
-import org.apache.openejb.jee.AroundInvoke;
-import org.apache.openejb.jee.AroundTimeout;
-import org.apache.openejb.jee.AssemblyDescriptor;
-import org.apache.openejb.jee.AsyncMethod;
-import org.apache.openejb.jee.AuthenticationMechanism;
-import org.apache.openejb.jee.Beans;
-import org.apache.openejb.jee.ConcurrencyManagementType;
-import org.apache.openejb.jee.ConcurrentLockType;
-import org.apache.openejb.jee.ConcurrentMethod;
-import org.apache.openejb.jee.ConfigProperty;
-import org.apache.openejb.jee.ContainerConcurrency;
-import org.apache.openejb.jee.ContainerTransaction;
-import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.jee.EjbLocalRef;
-import org.apache.openejb.jee.EjbRef;
-import org.apache.openejb.jee.EjbReference;
-import org.apache.openejb.jee.Empty;
-import org.apache.openejb.jee.EnterpriseBean;
-import org.apache.openejb.jee.EnvEntry;
-import org.apache.openejb.jee.ExcludeList;
-import org.apache.openejb.jee.FacesConfig;
-import org.apache.openejb.jee.FacesManagedBean;
-import org.apache.openejb.jee.Filter;
-import org.apache.openejb.jee.Handler;
-import org.apache.openejb.jee.HandlerChains;
-import org.apache.openejb.jee.Icon;
-import org.apache.openejb.jee.InboundResourceadapter;
-import org.apache.openejb.jee.InitMethod;
-import org.apache.openejb.jee.Injectable;
-import org.apache.openejb.jee.InjectionTarget;
-import org.apache.openejb.jee.Interceptor;
-import org.apache.openejb.jee.InterceptorBinding;
-import org.apache.openejb.jee.Invokable;
-import org.apache.openejb.jee.JndiConsumer;
-import org.apache.openejb.jee.JndiReference;
-import org.apache.openejb.jee.License;
-import org.apache.openejb.jee.Lifecycle;
-import org.apache.openejb.jee.LifecycleCallback;
-import org.apache.openejb.jee.Listener;
-import org.apache.openejb.jee.MessageAdapter;
-import org.apache.openejb.jee.MessageDrivenBean;
-import org.apache.openejb.jee.MessageListener;
-import org.apache.openejb.jee.MethodAttribute;
-import org.apache.openejb.jee.MethodParams;
-import org.apache.openejb.jee.MethodPermission;
-import org.apache.openejb.jee.NamedMethod;
-import org.apache.openejb.jee.OutboundResourceAdapter;
-import org.apache.openejb.jee.ParamValue;
-import org.apache.openejb.jee.PersistenceContextRef;
-import org.apache.openejb.jee.PersistenceContextType;
-import org.apache.openejb.jee.PersistenceUnitRef;
-import org.apache.openejb.jee.PortComponent;
-import org.apache.openejb.jee.Property;
-import org.apache.openejb.jee.RemoteBean;
-import org.apache.openejb.jee.RemoveMethod;
-import org.apache.openejb.jee.ResAuth;
-import org.apache.openejb.jee.ResSharingScope;
-import org.apache.openejb.jee.ResourceAdapter;
-import org.apache.openejb.jee.ResourceEnvRef;
-import org.apache.openejb.jee.ResourceRef;
-import org.apache.openejb.jee.SecurityIdentity;
-import org.apache.openejb.jee.SecurityRoleRef;
-import org.apache.openejb.jee.ServiceRef;
-import org.apache.openejb.jee.Servlet;
-import org.apache.openejb.jee.SessionBean;
-import org.apache.openejb.jee.SessionType;
-import org.apache.openejb.jee.SingletonBean;
-import org.apache.openejb.jee.StatefulBean;
-import org.apache.openejb.jee.StatelessBean;
-import org.apache.openejb.jee.Tag;
-import org.apache.openejb.jee.Text;
-import org.apache.openejb.jee.Timeout;
-import org.apache.openejb.jee.Timer;
-import org.apache.openejb.jee.TimerConsumer;
-import org.apache.openejb.jee.TimerSchedule;
-import org.apache.openejb.jee.TldTaglib;
-import org.apache.openejb.jee.TransAttribute;
-import org.apache.openejb.jee.TransactionSupportType;
-import org.apache.openejb.jee.TransactionType;
-import org.apache.openejb.jee.WebApp;
-import org.apache.openejb.jee.WebserviceDescription;
+import org.apache.openejb.jee.*;
 import org.apache.openejb.jee.oejb3.OpenejbJar;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.util.Join;
@@ -3251,6 +3167,15 @@ public class AnnotationDeployer implemen
                 buildPersistenceContext(consumer, pcFactory.create(pCtx, member), member);
             }
 
+            //
+            // @Repository
+            //
+            for (Annotated<Field> field : annotationFinder.findMetaAnnotatedFields(Repository.class))
{
+                Repository repo = field.getAnnotation(Repository.class);
+                Member member = new FieldMember(field.get());
+                buildRepository(consumer, repo, member);
+            }
+
         }
 
         private void buildContext(JndiConsumer consumer, Member member) {
@@ -3500,6 +3425,34 @@ public class AnnotationDeployer implemen
             getValidationContext().fail(component, key, details);
         }
 
+        private void buildRepository(JndiConsumer consumer, Repository repo, Member member)
{
+            String refName = member.getDeclaringClass().getName() + "/" + member.getName();
+            refName = normalize(refName);
+
+            RepositoryRef reference = consumer.getRepositoryRefMap().get(refName);
+            if (reference == null && member != null) {
+                reference = new RepositoryRef();
+                reference.setRepository(member.getType().getName());
+                reference.setName(refName);
+                consumer.getRepositoryRef().add(reference);
+            }
+
+            if (member != null) {
+                InjectionTarget target = new InjectionTarget();
+                target.setInjectionTargetClass(member.getDeclaringClass().getName());
+                target.setInjectionTargetName(member.getName());
+                reference.getInjectionTarget().add(target);
+            }
+
+            // Override the lookup name if not set
+            if (reference.getLookupName() == null) {
+                String lookupName = repo.jndiName();
+                if (!lookupName.equals("")) {
+                    reference.setLookupName(lookupName);
+                }
+            }
+        }
+
         /**
          * Process @Resource into either <resource-ref> or <resource-env-ref>
for the given member (field or method) or class
          *

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/JndiEncInfoBuilder.java
Mon Aug  1 13:13:52 2011
@@ -19,43 +19,9 @@ package org.apache.openejb.config;
 import static org.apache.openejb.assembler.classic.EjbResolver.Scope.EJBJAR;
 import static org.apache.openejb.assembler.classic.EjbResolver.Scope.EAR;
 import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.assembler.classic.InjectableInfo;
+import org.apache.openejb.assembler.classic.*;
+import org.apache.openejb.jee.*;
 import org.apache.openejb.loader.SystemInstance;
-import org.apache.openejb.assembler.classic.AppInfo;
-import org.apache.openejb.assembler.classic.EjbLocalReferenceInfo;
-import org.apache.openejb.assembler.classic.EjbReferenceInfo;
-import org.apache.openejb.assembler.classic.EnterpriseBeanInfo;
-import org.apache.openejb.assembler.classic.EnvEntryInfo;
-import org.apache.openejb.assembler.classic.InjectionInfo;
-import org.apache.openejb.assembler.classic.JndiEncInfo;
-import org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo;
-import org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo;
-import org.apache.openejb.assembler.classic.PortRefInfo;
-import org.apache.openejb.assembler.classic.ReferenceLocationInfo;
-import org.apache.openejb.assembler.classic.ResourceEnvReferenceInfo;
-import org.apache.openejb.assembler.classic.ResourceReferenceInfo;
-import org.apache.openejb.assembler.classic.ServiceReferenceInfo;
-import org.apache.openejb.assembler.classic.EjbResolver;
-import org.apache.openejb.assembler.classic.EjbJarInfo;
-import org.apache.openejb.jee.EjbLocalRef;
-import org.apache.openejb.jee.EnvEntry;
-import org.apache.openejb.jee.Injectable;
-import org.apache.openejb.jee.InjectionTarget;
-import org.apache.openejb.jee.JndiConsumer;
-import org.apache.openejb.jee.JndiReference;
-import org.apache.openejb.jee.MessageDestinationRef;
-import org.apache.openejb.jee.PersistenceContextRef;
-import org.apache.openejb.jee.PersistenceContextType;
-import org.apache.openejb.jee.PersistenceUnitRef;
-import org.apache.openejb.jee.PortComponentRef;
-import org.apache.openejb.jee.Property;
-import org.apache.openejb.jee.ResAuth;
-import org.apache.openejb.jee.ResourceEnvRef;
-import org.apache.openejb.jee.ResourceRef;
-import org.apache.openejb.jee.ServiceRef;
-import org.apache.openejb.jee.EjbReference;
-import org.apache.openejb.jee.SessionBean;
-import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
 import org.apache.openejb.util.Messages;
@@ -132,6 +98,22 @@ public class JndiEncInfoBuilder {
 
         buildServiceRefInfos(jndiConsumer, moduleJndiEnc, compJndiEnc);
 
+        buildRepositoryRefInfos(jndiConsumer, compJndiEnc);
+
+    }
+
+    private void buildRepositoryRefInfos(JndiConsumer jndiConsumer, JndiEncInfo comp) {
+        for (RepositoryRef repoRef : jndiConsumer.getRepositoryRef()) {
+            RepositoryReferenceInfo info = new RepositoryReferenceInfo();
+            info.repository = repoRef.getRepository();
+            info.referenceName = repoRef.getName();
+            if (!info.referenceName.startsWith("java:")) {
+                info.referenceName = "comp/env/" + info.referenceName;
+            }
+            info.targets.addAll(buildInjectionInfos(repoRef));
+
+            comp.repositoryRefs.add(info);
+        }
     }
 
     private void buildEjbRefs(JndiConsumer jndiConsumer, URI moduleUri, String moduleId,
String ejbName, JndiEncInfo moduleJndiEnc, JndiEncInfo compJndiEnc) throws OpenEJBException
{

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Application.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Application.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Application.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Application.java
Mon Aug  1 13:13:52 2011
@@ -147,6 +147,9 @@ public class Application implements Jndi
     @XmlSchemaType(name = "ID")
     protected java.lang.String id;
 
+    @XmlTransient
+    protected KeyedCollection<String, RepositoryRef> repositoryRefs;
+
     public Application() {
     }
 
@@ -418,4 +421,19 @@ public class Application implements Jndi
         this.id = value;
     }
 
+    @Override
+    public Collection<RepositoryRef> getRepositoryRef() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs;
+    }
+
+    @Override
+    public Map<String, RepositoryRef> getRepositoryRefMap() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs.toMap();
+    }
 }

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ApplicationClient.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ApplicationClient.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ApplicationClient.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/ApplicationClient.java
Mon Aug  1 13:13:52 2011
@@ -147,6 +147,9 @@ public class ApplicationClient implement
     @XmlTransient
     protected String mainClass;
 
+    @XmlTransient
+    protected KeyedCollection<String, RepositoryRef> repositoryRefs;
+
     public ApplicationClient() {
     }
 
@@ -425,4 +428,19 @@ public class ApplicationClient implement
         this.mainClass = mainClass;
     }
 
+    @Override
+    public Collection<RepositoryRef> getRepositoryRef() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs;
+    }
+
+    @Override
+    public Map<String, RepositoryRef> getRepositoryRefMap() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs.toMap();
+    }
 }

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/EntityBean.java
Mon Aug  1 13:13:52 2011
@@ -180,6 +180,9 @@ public class EntityBean implements Remot
     @XmlID
     protected String id;
 
+    @XmlTransient
+    protected KeyedCollection<String, RepositoryRef> repositoryRefs;
+
     public EntityBean() {
         Set<String> publicIds = JaxbJavaee.currentPublicId.get();
         if (publicIds != null && publicIds.contains("-//Sun Microsystems, Inc.//DTD
Enterprise JavaBeans 1.1//EN")) {
@@ -603,4 +606,19 @@ public class EntityBean implements Remot
     public void setTransactionType(TransactionType type){
     }
 
+    @Override
+    public Collection<RepositoryRef> getRepositoryRef() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs;
+    }
+
+    @Override
+    public Map<String, RepositoryRef> getRepositoryRefMap() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs.toMap();
+    }
 }

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/Interceptor.java
Mon Aug  1 13:13:52 2011
@@ -133,6 +133,8 @@ public class Interceptor implements Jndi
     @XmlID
     protected String id;
 
+    protected KeyedCollection<String, RepositoryRef> repositoryRefs;
+
     public Interceptor() {
     }
 
@@ -333,6 +335,22 @@ public class Interceptor implements Jndi
         return this.dataSource.toMap();
     }
 
+    @Override
+    public Collection<RepositoryRef> getRepositoryRef() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs;
+    }
+
+    @Override
+    public Map<String, RepositoryRef> getRepositoryRefMap() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs.toMap();
+    }
+
     public List<LifecycleCallback> getPostConstruct() {
         if (postConstruct == null) {
             postConstruct = new ArrayList<LifecycleCallback>();
@@ -437,4 +455,6 @@ public class Interceptor implements Jndi
         assert interceptorClass != null : "Set the interceptorClass before calling this method";
         getAroundTimeout().add(new AroundTimeout(interceptorClass, method));
     }
+
+
 }

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JndiConsumer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JndiConsumer.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JndiConsumer.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/JndiConsumer.java
Mon Aug  1 13:13:52 2011
@@ -60,4 +60,7 @@ public interface JndiConsumer {
 
     Collection<DataSource> getDataSource();
     Map<String,DataSource> getDataSourceMap();
+
+    Collection<RepositoryRef> getRepositoryRef();
+    Map<String, RepositoryRef> getRepositoryRefMap();
 }

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MessageDrivenBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MessageDrivenBean.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MessageDrivenBean.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/MessageDrivenBean.java
Mon Aug  1 13:13:52 2011
@@ -170,6 +170,9 @@ public class MessageDrivenBean implement
     @XmlID
     protected String id;
 
+    @XmlTransient
+    protected KeyedCollection<String, RepositoryRef> repositoryRefs;
+
     public MessageDrivenBean() {
     }
 
@@ -619,4 +622,20 @@ public class MessageDrivenBean implement
     public String getTimerConsumerName() {
         return ejbName;
     }
+
+    @Override
+    public Collection<RepositoryRef> getRepositoryRef() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs;
+    }
+
+    @Override
+    public Map<String, RepositoryRef> getRepositoryRefMap() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs.toMap();
+    }
 }

Added: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/RepositoryRef.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/RepositoryRef.java?rev=1152756&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/RepositoryRef.java
(added)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/RepositoryRef.java
Mon Aug  1 13:13:52 2011
@@ -0,0 +1,90 @@
+/**
+ *
+ * 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.openejb.jee;
+
+import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.ArrayList;
+import java.util.List;
+
+public class RepositoryRef implements JndiReference {
+    protected List<InjectionTarget> injectionTarget;
+    protected String repository;
+    protected String name;
+    protected String lookup;
+
+    public RepositoryRef() {
+    }
+
+    public RepositoryRef(String repositoryName) {
+        this.repository = repositoryName;
+    }
+
+    public List<InjectionTarget> getInjectionTarget() {
+        if (injectionTarget == null) {
+            injectionTarget = new ArrayList<InjectionTarget>();
+        }
+        return this.injectionTarget;
+    }
+
+    public String getRepository() {
+        return repository;
+    }
+
+    public void setRepository(String repository) {
+        this.repository = repository;
+    }
+
+    public String getLookupName() {
+        return lookup;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getType() {
+        return repository;
+    }
+
+    public void setType(String type) {
+        repository = type;
+    }
+
+    public String getMappedName() {
+        return null;
+    }
+
+    public void setMappedName(String mappedName) {
+        // no-op
+    }
+
+    public void setLookupName(String lookupName) {
+        lookup = lookupName;
+    }
+
+    @Override public String getKey() {
+        return "java:openejb/Repository/" + repository;
+    }
+}

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/SessionBean.java
Mon Aug  1 13:13:52 2011
@@ -256,6 +256,9 @@ public class SessionBean implements Remo
     @XmlTransient
     private boolean restService = false;
 
+    @XmlTransient
+    protected KeyedCollection<String, RepositoryRef> repositoryRefs;
+
     public SessionBean() {
     }
 
@@ -895,4 +898,20 @@ public class SessionBean implements Remo
     public void setRestService(boolean restService) {
         this.restService = restService;
     }
+
+    @Override
+    public Collection<RepositoryRef> getRepositoryRef() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs;
+    }
+
+    @Override
+    public Map<String, RepositoryRef> getRepositoryRefMap() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs.toMap();
+    }
 }

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebApp.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebApp.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebApp.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebApp.java
Mon Aug  1 13:13:52 2011
@@ -186,7 +186,8 @@ public class WebApp implements WebCommon
     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
     protected String version = "3.0";
 
-
+    @XmlTransient
+    protected KeyedCollection<String, RepositoryRef> repositoryRefs;
 
 
     @Override
@@ -587,6 +588,22 @@ public class WebApp implements WebCommon
         return this.dataSource.toMap();
     }
 
+    @Override
+    public Collection<RepositoryRef> getRepositoryRef() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs;
+    }
+
+    @Override
+    public Map<String, RepositoryRef> getRepositoryRefMap() {
+        if (repositoryRefs == null) {
+            repositoryRefs = new KeyedCollection<String,RepositoryRef>();
+        }
+        return repositoryRefs.toMap();
+    }
+
     public AbsoluteOrdering getAbsoluteOrdering() {
         return absoluteOrdering;
     }

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebFragment.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebFragment.java?rev=1152756&r1=1152755&r2=1152756&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebFragment.java
(original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/WebFragment.java
Mon Aug  1 13:13:52 2011
@@ -185,7 +185,8 @@ public class WebFragment implements WebC
     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
     protected String version;
 
-
+    @XmlTransient
+    protected KeyedCollection<String, RepositoryRef> repositoryRefs;
 
 
     @Override
@@ -613,4 +614,15 @@ public class WebFragment implements WebC
     public void setName(String name) {
         this.name = name;
     }
+
+    @Override
+    public Collection<RepositoryRef> getRepositoryRef() {
+        return repositoryRefs;
+    }
+
+    @Override
+    public Map<String, RepositoryRef> getRepositoryRefMap() {
+        return repositoryRefs.toMap();
+    }
+
 }
\ No newline at end of file



Mime
View raw message