aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1187305 - in /aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender: EJBExtender.java RunningApplication.java
Date Fri, 21 Oct 2011 11:39:06 GMT
Author: timothyjward
Date: Fri Oct 21 11:39:05 2011
New Revision: 1187305

URL: http://svn.apache.org/viewvc?rev=1187305&view=rev
Log:
ARIES-754: Try to get trunk building properly again - Fix ejb itests

Modified:
    aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBExtender.java
    aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/RunningApplication.java

Modified: aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBExtender.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBExtender.java?rev=1187305&r1=1187304&r2=1187305&view=diff
==============================================================================
--- aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBExtender.java
(original)
+++ aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/EJBExtender.java
Fri Oct 21 11:39:05 2011
@@ -34,7 +34,11 @@ import org.apache.aries.util.tracker.Rec
 import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.assembler.classic.Assembler;
 import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.openejb.assembler.classic.EnterpriseBeanInfo;
+import org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo;
+import org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo;
 import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
+import org.apache.openejb.assembler.classic.ReferenceLocationInfo;
 import org.apache.openejb.assembler.classic.SecurityServiceInfo;
 import org.apache.openejb.assembler.classic.TransactionServiceInfo;
 import org.apache.openejb.assembler.dynamic.PassthroughFactory;
@@ -230,6 +234,8 @@ public class EJBExtender implements Bund
         Thread.currentThread().setContextClassLoader(cl);
       }
       
+      processJPAMappings(ejbInfo);
+      
       
       Assembler assembler = (Assembler) SystemInstance.get().getComponent(Assembler.class);
       RunningApplication app = null;
@@ -266,6 +272,22 @@ public class EJBExtender implements Bund
     }
   }
 
+  private void processJPAMappings(EjbJarInfo ejbInfo) {
+    for(EnterpriseBeanInfo ebi : ejbInfo.enterpriseBeans){
+      
+      for(PersistenceUnitReferenceInfo pui : ebi.jndiEnc.persistenceUnitRefs) {
+        pui.location = new ReferenceLocationInfo();
+        pui.location.jndiName = "aries/integration/unit/" + pui.persistenceUnitName;
+      }
+      
+      for(PersistenceContextReferenceInfo pci : ebi.jndiEnc.persistenceContextRefs) {
+        pci.location = new ReferenceLocationInfo();
+        pci.location.jndiName = "aries/integration/context/" + pci.persistenceUnitName;
+      }
+    }
+    
+  }
+
   private void addAltDDs(EjbModule ejbModule, Bundle bundle) {
     
     Map<String, Object> altDDs = ejbModule.getAltDDs(); 

Modified: aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/RunningApplication.java
URL: http://svn.apache.org/viewvc/aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/RunningApplication.java?rev=1187305&r1=1187304&r2=1187305&view=diff
==============================================================================
--- aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/RunningApplication.java
(original)
+++ aries/trunk/ejb/openejb-extender/src/main/java/org/apache/aries/ejb/openejb/extender/RunningApplication.java
Fri Oct 21 11:39:05 2011
@@ -44,6 +44,7 @@ import org.apache.openejb.assembler.clas
 import org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo;
 import org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo;
 import org.apache.openejb.assembler.classic.ProxyInterfaceResolver;
+import org.apache.openejb.assembler.classic.ReferenceLocationInfo;
 import org.apache.openejb.jee.EnterpriseBean;
 import org.apache.openejb.persistence.JtaEntityManager;
 import org.osgi.framework.Bundle;
@@ -64,8 +65,8 @@ public class RunningApplication implemen
   
   private ServiceTracker tracker;
   
-  private final ConcurrentMap<String, ConcurrentMap<Context, String>> unitRegistrations
= 
-    new ConcurrentHashMap<String, ConcurrentMap<Context, String>>();
+  private final ConcurrentMap<String, ConcurrentMap<Context, PersistenceUnitReferenceInfo>>

+    unitRegistrations = new ConcurrentHashMap<String, ConcurrentMap<Context, PersistenceUnitReferenceInfo>>();
   
   private final ConcurrentMap<String, ConcurrentMap<Context, PersistenceContextReferenceInfo>>

     contextRegistrations = new ConcurrentHashMap<String, ConcurrentMap<Context, PersistenceContextReferenceInfo>>();
@@ -76,16 +77,17 @@ public class RunningApplication implemen
     
     for(EnterpriseBeanInfo bean : enterpriseBeans) {
       for(PersistenceUnitReferenceInfo pui : bean.jndiEnc.persistenceUnitRefs) {
-        ConcurrentMap<Context, String> map = unitRegistrations.get(pui.persistenceUnitName);
+        ConcurrentMap<Context, PersistenceUnitReferenceInfo> map = unitRegistrations.
+           get(pui.persistenceUnitName);
         
         if(map == null) {
-          map = new ConcurrentHashMap<Context, String>();
+          map = new ConcurrentHashMap<Context, PersistenceUnitReferenceInfo>();
           unitRegistrations.put(pui.persistenceUnitName, map);
         }
         
         for(BeanContext eb : ctx.getBeanContexts()) {
           if(eb.getEjbName().equals(bean.ejbName)){
-            map.put(eb.getJndiContext(), pui.referenceName);
+            map.put(eb.getJndiContext(), pui);
             continue;
           }
         }
@@ -223,13 +225,13 @@ public class RunningApplication implemen
     if(isTrue(reference, PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT) &&
        !!!isTrue(reference, PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE)) {
       
-      Map<Context, String> pUnitRefs = unitRegistrations.
+      Map<Context, PersistenceUnitReferenceInfo> pUnitRefs = unitRegistrations.
              get(reference.getProperty(PersistenceUnitConstants.OSGI_UNIT_NAME));
       Map<Context, PersistenceContextReferenceInfo> pCtxRefs = contextRegistrations.
              get(reference.getProperty(PersistenceUnitConstants.OSGI_UNIT_NAME));
       
       if(pUnitRefs == null) {
-        pUnitRefs = new HashMap<Context, String>();
+        pUnitRefs = new HashMap<Context, PersistenceUnitReferenceInfo>();
       }
       if(pCtxRefs == null) {
         pCtxRefs = new HashMap<Context, PersistenceContextReferenceInfo>();
@@ -239,9 +241,9 @@ public class RunningApplication implemen
       
         EntityManagerFactory emf = (EntityManagerFactory)bundle.getBundleContext().getService(reference);
         
-        for(Entry<Context, String> e : pUnitRefs.entrySet()) {
+        for(Entry<Context, PersistenceUnitReferenceInfo> e : pUnitRefs.entrySet())
{
           try {
-            e.getKey().bind(e.getValue(), emf);
+            e.getKey().bind(e.getValue().referenceName, emf);
           } catch (NamingException ex) {
             // TODO Auto-generated catch block
             ex.printStackTrace();
@@ -276,13 +278,13 @@ public class RunningApplication implemen
 
   public void removedService(ServiceReference reference, Object service) {
     
-    Map<Context, String> pUnitRefs = unitRegistrations.
+    Map<Context, PersistenceUnitReferenceInfo> pUnitRefs = unitRegistrations.
         get(reference.getProperty(PersistenceUnitConstants.OSGI_UNIT_NAME));
     Map<Context, PersistenceContextReferenceInfo> pCtxRefs = contextRegistrations.
         get(reference.getProperty(PersistenceUnitConstants.OSGI_UNIT_NAME));
 
     if(pUnitRefs == null) {
-      pUnitRefs = new HashMap<Context, String>();
+      pUnitRefs = new HashMap<Context, PersistenceUnitReferenceInfo>();
     }
     if(pCtxRefs == null) {
       pCtxRefs = new HashMap<Context, PersistenceContextReferenceInfo>();
@@ -290,9 +292,9 @@ public class RunningApplication implemen
     
     if(pUnitRefs.size() > 0 || pCtxRefs.size() > 0) {
     
-      for(Entry<Context, String> e : pUnitRefs.entrySet()) {
+      for(Entry<Context, PersistenceUnitReferenceInfo> e : pUnitRefs.entrySet()) {
         try {
-          e.getKey().unbind(e.getValue());
+          e.getKey().unbind(e.getValue().referenceName);
         } catch (NamingException ex) {
           // TODO Auto-generated catch block
           ex.printStackTrace();



Mime
View raw message