[jboss-cvs] JBossAS SVN: r78954 - in projects/ejb3/trunk/core/src: main/java/org/jboss/ejb3/enc and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 30 09:45:29 EDT 2008


Author: wolfc
Date: 2008-09-30 09:45:29 -0400 (Tue, 30 Sep 2008)
New Revision: 78954

Removed:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/EjbModuleEjbResolver.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/EjbModulePersistenceUnitResolver.java
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/DeploymentScope.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/DeploymentEjbResolver.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/injection/ExtendedInjectionContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/injection/InjectionContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/injection/PersistenceUnitHandler.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MockEjb3Deployment.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/injection/test/common/DummyInjectionContainer.java
Log:
EJBTHREE-1508: removed persistence unit deployment functions

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/DeploymentScope.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/DeploymentScope.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/DeploymentScope.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -29,10 +29,12 @@
 
 /**
  * Abstraction for accessing contents of an EAR
- *
+ * 
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
+ * @deprecated looking up stuff should happen through resolvers 
  */
+ at Deprecated
 public interface DeploymentScope extends JavaEEApplication
 {
    public Collection<Ejb3Deployment> getEjbDeployments();

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -72,7 +72,6 @@
 import org.jboss.ejb3.annotation.defaults.PoolDefaults;
 import org.jboss.ejb3.aop.BeanContainer;
 import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
 import org.jboss.ejb3.injection.InjectionInvocation;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
 import org.jboss.ejb3.interceptor.InterceptorInjector;
@@ -1494,11 +1493,6 @@
       return "ejb-jar.xml";
    }
 
-   public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
-   {
-      return deployment.getPersistenceUnitDeployment(unitName);
-   }
-
    public String getEjbJndiName(Class businessInterface) throws NameNotFoundException
    {
       return deployment.getEjbJndiName(businessInterface);

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -26,6 +26,7 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -47,9 +48,6 @@
 import org.jboss.ejb3.cache.CacheFactoryRegistry;
 import org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry;
 import org.jboss.ejb3.common.lang.ClassHelper;
-import org.jboss.ejb3.enc.EjbModulePersistenceUnitResolver;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-import org.jboss.ejb3.entity.SecondLevelCacheUtil;
 import org.jboss.ejb3.javaee.JavaEEApplication;
 import org.jboss.ejb3.javaee.JavaEEComponent;
 import org.jboss.ejb3.javaee.JavaEEComponentHelper;
@@ -71,8 +69,6 @@
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 import org.jboss.metadata.javaee.spec.Environment;
 import org.jboss.metadata.javaee.spec.MessageDestinationsMetaData;
-import org.jboss.metadata.jpa.spec.PersistenceMetaData;
-import org.jboss.metadata.jpa.spec.PersistenceUnitMetaData;
 import org.jboss.system.ServiceMBeanSupport;
 import org.jboss.virtual.VirtualFile;
 
@@ -94,19 +90,14 @@
 
    private JBossMetaData metaData;
    
-   private PersistenceMetaData persistenceUnitsMetaData;
-
    protected DeploymentUnit unit;
 
    protected LinkedHashMap<ObjectName, Container> ejbContainers = new LinkedHashMap<ObjectName, Container>();
 
-   private boolean processPersistenceUnits = true;
    protected boolean hasEntities;
 
    protected List<String> explicitEntityClasses = new ArrayList<String>();
 
-   protected List<PersistenceUnitDeployment> persistenceUnitDeployments = new ArrayList<PersistenceUnitDeployment>();
-
    protected String defaultSLSBDomain = "Stateless Bean";
 
    protected String defaultSFSBDomain = "Stateful Bean";
@@ -126,8 +117,6 @@
 
    protected DeploymentScope deploymentScope;
 
-   protected EjbModulePersistenceUnitResolver persistenceUnitResolver;
-
    // For backwards compatibility initialize to the default.
    private MessageDestinationReferenceResolver messageDestinationReferenceResolver = new DefaultMessageDestinationReferenceResolver();
    
@@ -144,15 +133,22 @@
    
    private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
 
-   @Deprecated
-   public Ejb3Deployment(DeploymentUnit unit, DeploymentScope deploymentScope, JBossMetaData metaData, PersistenceMetaData persistenceUnitsMetaData)
+   /**
+    * Do not deploy persistence unit anymore.
+    * 
+    * @param deploymentUnit
+    * @param unit
+    * @param deploymentScope
+    * @param metaData
+    */
+   public Ejb3Deployment(org.jboss.deployers.structure.spi.DeploymentUnit deploymentUnit, DeploymentUnit unit, DeploymentScope deploymentScope, JBossMetaData metaData)
    {
       assert unit != null : "unit is null";
+      assert deploymentUnit != null : "deploymentUnit is null";
       
       this.unit = unit;
       this.deploymentScope = deploymentScope;
       this.metaData = metaData;
-      this.persistenceUnitsMetaData = persistenceUnitsMetaData;
       try
       {
          initialContext = InitialContextFactory.getInitialContext(unit.getJndiProperties());
@@ -161,26 +157,9 @@
       {
          throw new RuntimeException(e);
       }
-      persistenceUnitResolver = new EjbModulePersistenceUnitResolver(persistenceUnitDeployments, deploymentScope, ejbContainers);
       MessageDestinationsMetaData destinations = null;
       if (metaData != null && metaData.getAssemblyDescriptor() != null)
          destinations = metaData.getAssemblyDescriptor().getMessageDestinations();
-   }
-   
-   /**
-    * Do not deploy persistence unit anymore.
-    * 
-    * @param deploymentUnit
-    * @param unit
-    * @param deploymentScope
-    * @param metaData
-    */
-   public Ejb3Deployment(org.jboss.deployers.structure.spi.DeploymentUnit deploymentUnit, DeploymentUnit unit, DeploymentScope deploymentScope, JBossMetaData metaData)
-   {
-      this(unit, deploymentScope, metaData, null);
-      
-      assert deploymentUnit != null : "deploymentUnit is null";
-      
       this.deploymentUnit = deploymentUnit;
    }
 
@@ -268,9 +247,15 @@
       this.poolFactoryRegistry = poolFactoryRegistry;
    }
 
+   /**
+    * @deprecated processing persistence units is no longer supported, use jpa-deployers
+    * @param b
+    */
+   @Deprecated
    public void setProcessPersistenceUnits(boolean b)
    {
-      this.processPersistenceUnits = b;
+      if(b)
+         log.warn("EJBTHREE-1508: Processing persistence units is no longer supported");
    }
    
    /**
@@ -388,22 +373,13 @@
       return ejbContainers;
    }
 
-   public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
+   @Deprecated
+   public List<?> getPersistenceUnitDeployments()
    {
-      return persistenceUnitResolver.getPersistenceUnitDeployment(unitName);
+      log.warn("EJBTHREE-1508: Quering Ejb3Deployment for persistence unit deployments is no longer supported");
+      return Collections.EMPTY_LIST;
    }
 
-   public PersistenceUnitDeployment getPersistenceUnitDeploymentInternal(String unitName)
-   {
-      return persistenceUnitResolver.getPersistenceUnitDeploymentInternal(unitName);
-   }
-
-   public List<PersistenceUnitDeployment> getPersistenceUnitDeployments()
-   {
-      return persistenceUnitDeployments;
-   }
-
-
    public EJBContainer getEjbContainer(String ejbLink, Class businessIntf)
    {
       String relativePath = unit.getRelativePath();
@@ -511,8 +487,6 @@
 
          deploy();
 
-         initializePersistenceUnits();
-         
          registerDeployment();
 
          log.debug("EJB3 deployment time took: " + (System.currentTimeMillis() - start));
@@ -533,7 +507,6 @@
    
    protected void reinitialize() throws Exception
    {
-      initializePersistenceUnits();
       reinitialize = false;
    }
 
@@ -544,8 +517,6 @@
          if (reinitialize)
             reinitialize();
          
-         startPersistenceUnits();
-
          for (Object o : ejbContainers.values())
          {
             Container con = (Container) o;
@@ -588,7 +559,6 @@
             log.debug("error trying to stop ejb container", e);
          }
       }
-      stopPersistenceUnits();
       
       reinitialize = true;
    }
@@ -716,99 +686,8 @@
       }
    }
 
-   protected void initializePersistenceUnits() throws Exception
-   {
-      hasEntities = persistenceUnitsMetaData != null && processPersistenceUnits;
-
-      if (!hasEntities)
-         return;
-
-      if (unit.getClasses() != null)
-      {
-         for (Class<?> explicit : unit.getClasses())
-         {
-            if (explicit.isAnnotationPresent(Entity.class))
-            {
-               explicitEntityClasses.add(explicit.getName());
-            }
-         }
-      }
-
-      // scope the unitName if this is an ejb archive
-      // todo revert to this: List<PersistenceMetadata> persistenceMetadata = PersistenceXmlLoader.deploy(persistenceXmlUrl, new HashMap(), new EJB3DTDEntityResolver());
-      List<PersistenceUnitMetaData> pumds = persistenceUnitsMetaData.getPersistenceUnits();
-      for (PersistenceUnitMetaData metaData : pumds)
-      {
-         String earShortName = deploymentScope == null ? null : deploymentScope.getShortName();
-         boolean isScoped = ejbContainers.size() > 0;
-
-         Map<String, String> properties = metaData.getProperties();
-         if (properties == null)
-         {
-            properties = new HashMap<String, String>();
-            metaData.setProperties(properties);
-         }
-         // Ensure 2nd level cache entries are segregated from other deployments
-         String cache_prefix = properties.get(SecondLevelCacheUtil.HIBERNATE_CACHE_REGION_PREFIX);
-         if (cache_prefix == null)
-         {
-            // Create a region_prefix for the 2nd level cache to ensure
-            // deployments are segregated
-            String jarName = isScoped ? unit.getShortName() : null;
-            cache_prefix = SecondLevelCacheUtil.createCacheRegionPrefix(earShortName, jarName, metaData.getName());
-            properties.put(SecondLevelCacheUtil.HIBERNATE_CACHE_REGION_PREFIX, cache_prefix);
-         }
-         PersistenceUnitDeployment deployment = new PersistenceUnitDeployment(initialContext, this, explicitEntityClasses, metaData, earShortName, unit.getShortName(), isScoped);
-         PersistenceUnitRegistry.register(deployment);
-         persistenceUnitDeployments.add(deployment);
-      }
-   }
-
    public abstract DependencyPolicy createDependencyPolicy(JavaEEComponent component);
 
-   protected void startPersistenceUnits()
-   {
-      if (persistenceUnitDeployments == null)
-         return;
-
-      for (PersistenceUnitDeployment entityDeployment : persistenceUnitDeployments)
-      {
-         if (entityDeployment != null)
-         {
-            DependencyPolicy policy = createDependencyPolicy(entityDeployment);
-            entityDeployment.addDependencies(policy);
-            kernelAbstraction.install(entityDeployment.getKernelName(), policy, unit, entityDeployment);
-         }
-      }
-   }
-
-   protected void stopPersistenceUnits()
-   {
-      if (persistenceUnitDeployments == null)
-         return;
-
-      for (PersistenceUnitDeployment entityDeployment : persistenceUnitDeployments)
-      {
-         try
-         {
-            PersistenceUnitRegistry.unregister(entityDeployment);
-            if (entityDeployment != null)
-            {
-               kernelAbstraction.uninstall(entityDeployment.getKernelName());
-            }
-         }
-         catch (Exception e)
-         {
-            log.debug("error trying to shut down persistence unit", e);
-         }
-      }
-      
-      persistenceUnitDeployments = new ArrayList<PersistenceUnitDeployment>();
-
-   }
-
-   
-
    public void destroy() //throws Exception
    {
       try

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/DeploymentEjbResolver.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/DeploymentEjbResolver.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/DeploymentEjbResolver.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -21,17 +21,18 @@
  */
 package org.jboss.ejb3.enc;
 
+import java.util.Iterator;
+
+import javax.naming.NameNotFoundException;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DeploymentScope;
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.Ejb3Registry;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.DeploymentScope;
 import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
 import org.jboss.logging.Logger;
 
-import javax.naming.NameNotFoundException;
-import java.util.Iterator;
-
 /**
  * Class to resolve EJB containers from ejb-ref or @EJB metadata
  * This class is overriden for specific behaviors, specifically whether or not
@@ -42,6 +43,7 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
+ at Deprecated
 public abstract class DeploymentEjbResolver
 {
    private static final Logger log = Logger.getLogger(DeploymentEjbResolver.class);

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/DeploymentPersistenceUnitResolver.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.enc;
-
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-import org.jboss.ejb3.PersistenceUnitRegistry;
-import org.jboss.ejb3.DeploymentScope;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.logging.Logger;
-
-import javax.naming.NameNotFoundException;
-import java.util.Collection;
-import java.util.List;
-import java.util.LinkedHashMap;
-
-/**
- * Resolves persistence units for @PersistenceContext and @PersistenceUnit
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class DeploymentPersistenceUnitResolver
-{
-   private static final Logger log = Logger.getLogger(DeploymentPersistenceUnitResolver.class);
-   
-   protected List<PersistenceUnitDeployment> persistenceUnitDeployments;
-   protected DeploymentScope deploymentScope;
-   protected LinkedHashMap ejbContainers;
-
-   public DeploymentPersistenceUnitResolver(List<PersistenceUnitDeployment> persistenceUnitDeployments, DeploymentScope deploymentScope, LinkedHashMap ejbContainers)
-   {
-      this.persistenceUnitDeployments = persistenceUnitDeployments;
-      this.deploymentScope = deploymentScope;
-      this.ejbContainers = ejbContainers;
-   }
-
-   public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
-   {
-      if (unitName == null || "".equals(unitName))
-      {
-         if (persistenceUnitDeployments == null)
-         {
-            throw new NameNotFoundException("EMPTY STRING unitName but there is no deployments in scope");
-         }
-         if (persistenceUnitDeployments.size() == 1 && ejbContainers.size() > 0)
-         {
-            return persistenceUnitDeployments.get(0);
-         }
-         else if (persistenceUnitDeployments.size() > 1)
-         {
-            throw new NameNotFoundException("EMPTY STRING unitName and there is more than one scoped persistence unit");
-         }
-         else //check for persistence.xml outside of jar, but in ear scope
-         {
-            if (deploymentScope != null)
-            {
-               Collection<Ejb3Deployment> deployments = deploymentScope.getEjbDeployments();
-               if (deployments != null)
-               {
-                  for (Ejb3Deployment deployment : deployments)
-                  {
-                     if (deployment.getPersistenceUnitDeployments().size() == 1)
-                     {
-                        return deployment.getPersistenceUnitDeployments().get(0);
-                     }
-                  }
-               }
-            }
-            throw new NameNotFoundException("There is no default persistence unit in this deployment.");
-         }
-         
-      }
-      int hashIndex = unitName.indexOf('#');
-      if (hashIndex != -1)
-      {
-         String relativePath = unitName.substring(0, hashIndex);
-         String name = unitName.substring(hashIndex + 1);
-         if (deploymentScope == null)
-         {
-            String relativeJarName = relativePath.substring(3);
-            // look in global EJB jars.
-            for (PersistenceUnitDeployment pud : PersistenceUnitRegistry.getPersistenceUnits())
-            {
-               String jarName = pud.getDeployment().getDeploymentUnit().getShortName() + ".jar";
-               if (pud.getDeployment().getEar() == null
-                       && jarName.equals(relativeJarName)
-                       && pud.getEntityManagerName().equals(name)
-                       && pud.isScoped())
-               {
-                  return pud;
-               }
-            }
-            return null;
-         }
-         Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
-         if (dep == null)
-         {
-            return null;
-         }
-         PersistenceUnitDeployment rtn = dep.getPersistenceUnitDeploymentInternal(name);
-         return rtn;
-      }
-      PersistenceUnitDeployment rtn = getPersistenceUnitDeploymentInternal(unitName);
-      if (rtn != null) return rtn;
-
-      for (PersistenceUnitDeployment deployment : PersistenceUnitRegistry.getPersistenceUnits())
-      {
-         if (deployment.isScoped()) continue;
-         if (deployment.getEntityManagerName().equals(unitName))
-         {
-            if (deploymentScope == null || deploymentScope.getBaseName() == null || deployment.getKernelName().contains(deploymentScope.getBaseName())) return deployment; 
-         }
-      }
-      return rtn;
-   }
-
-   public PersistenceUnitDeployment getPersistenceUnitDeploymentInternal(String unitName)
-   {
-      if (persistenceUnitDeployments != null)
-      {
-         for (PersistenceUnitDeployment deployment : persistenceUnitDeployments)
-         {
-            if (deployment.getEntityManagerName().equals(unitName))
-            {
-               return deployment;
-            }
-         }
-      }
-      return null;
-   }
-}

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/EjbModuleEjbResolver.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/EjbModuleEjbResolver.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/EjbModuleEjbResolver.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.enc;
-
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.DeploymentScope;
-
-import javax.naming.NameNotFoundException;
-import java.util.LinkedHashMap;
-
-/**
- * Resolve EJBs.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EjbModuleEjbResolver extends DeploymentEjbResolver
-{
-   protected LinkedHashMap ejbContainers;
-   protected Ejb3Deployment deployment;
-
-   public EjbModuleEjbResolver(DeploymentScope deploymentScope, String errorName, LinkedHashMap ejbContainers, Ejb3Deployment deployment)
-   {
-      super(deploymentScope, errorName);
-      this.ejbContainers = ejbContainers;
-      this.deployment = deployment;
-   }
-
-   @Override
-   protected EJBContainer searchDeploymentInternally(String ejbLink, Class businessIntf)
-   {
-      for (Object obj : ejbContainers.values())
-      {
-         EJBContainer container = (EJBContainer) obj;
-         if (container.getEjbName().equals(ejbLink))
-         {
-            return container;
-         }
-      }
-      return null;
-   }
-
-   @Override
-   protected EJBContainer searchForEjbContainerInternally(Class businessIntf) throws NameNotFoundException
-   {
-      EJBContainer rtnContainer;
-      rtnContainer = getEjbContainer(deployment, businessIntf);
-      return rtnContainer;
-   }
-
-}

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/EjbModulePersistenceUnitResolver.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/EjbModulePersistenceUnitResolver.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/EjbModulePersistenceUnitResolver.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.enc;
-
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-import org.jboss.ejb3.DeploymentScope;
-
-import java.util.List;
-import java.util.LinkedHashMap;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EjbModulePersistenceUnitResolver extends DeploymentPersistenceUnitResolver
-{
-   public EjbModulePersistenceUnitResolver(List<PersistenceUnitDeployment> persistenceUnitDeployments, DeploymentScope deploymentScope, LinkedHashMap ejbContainers)
-   {
-      super(persistenceUnitDeployments, deploymentScope, ejbContainers);
-   }
-}

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/injection/ExtendedInjectionContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/injection/ExtendedInjectionContainer.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/injection/ExtendedInjectionContainer.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -27,5 +27,13 @@
  */
 public interface ExtendedInjectionContainer extends InjectionContainer
 {
+   /**
+    * Find the MC bean that supplies the specified persistence unit.
+    * 
+    * @param unitName the name of the persistence unit
+    * @return the name of the persistence unit supplier
+    * 
+    * TODO: this method should be on InjectionContainer
+    */
    String resolvePersistenceUnitSupplier(String unitName);
 }

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/injection/InjectionContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/injection/InjectionContainer.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/injection/InjectionContainer.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -33,7 +33,6 @@
 
 import org.jboss.ejb3.Container;
 import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
 import org.jboss.metadata.javaee.spec.RemoteEnvironment;
 import org.jboss.virtual.VirtualFile;
 
@@ -67,9 +66,6 @@
 
    Context getEnc();
 
-   @Deprecated
-   PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException;
-
    Container resolveEjbContainer(String link, Class<?> businessIntf);
    Container resolveEjbContainer(Class<?> businessIntf) throws NameNotFoundException;
    String getEjbJndiName(Class<?> businessInterface) throws NameNotFoundException;

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/injection/PersistenceUnitHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/injection/PersistenceUnitHandler.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/injection/PersistenceUnitHandler.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -35,7 +35,6 @@
 import org.jboss.ejb3.annotation.IgnoreDependency;
 import org.jboss.ejb3.entity.InjectedEntityManagerFactory;
 import org.jboss.ejb3.entity.InjectedSessionFactory;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
 import org.jboss.jpa.deployment.ManagedEntityManagerFactory;
 import org.jboss.jpa.spi.PersistenceUnitRegistry;
 import org.jboss.logging.Logger;
@@ -125,20 +124,7 @@
          container.getDependencyPolicy().addDependency(dependency);
          return;
       }
-      log.warn("Container " + container + " does not implement ExtendedInjectionContainer, doing old style PersistenceUnit resolving");
-      PersistenceUnitDeployment deployment = null;
-      // look in EAR first
-      deployment = container.getPersistenceUnitDeployment(unitName);
-      if (deployment != null)
-      {
-         container.getDependencyPolicy().addDependency(deployment.getKernelName());
-         log.debug("***** adding PU dependency from located persistence unit: " + deployment.getKernelName());
-         return;
-      }
-      // probably not deployed yet.
-      // todo not sure if we should do this in JBoss 5
-      log.warn("Could not find PU dependency for " + PersistenceUnitDeployment.getDefaultKernelName(unitName) + ". Waiting for dependency to resolve");
-      container.getDependencyPolicy().addDependency(PersistenceUnitDeployment.getDefaultKernelName(unitName));
+      throw new UnsupportedOperationException("Container " + container + " does not implement ExtendedInjectionContainer, can't resolve persistence unit " + unitName);
    }
 
    public static ManagedEntityManagerFactory getManagedEntityManagerFactory(InjectionContainer container, String unitName)
@@ -150,19 +136,9 @@
          String beanName = eic.resolvePersistenceUnitSupplier(unitName);
          return ((org.jboss.jpa.deployment.PersistenceUnitDeployment) PersistenceUnitRegistry.getPersistenceUnit(beanName)).getManagedFactory();
       }
-      log.warn("Container " + container + " does not implement ExtendedInjectionContainer");
-      PersistenceUnitDeployment deployment = container.getPersistenceUnitDeployment(unitName);
-      if (deployment != null)
-      {
-         return deployment.getManagedFactory();
-      }
-      else
-      {
-         throw new NameNotFoundException("Unable to find persistence unit: " + unitName + " for deployment: " + container.getIdentifier());
-      }
+      throw new UnsupportedOperationException("Container " + container + " does not implement ExtendedInjectionContainer, can't resolve persistence unit " + unitName);
    }
 
-
    public static EntityManagerFactory getEntityManagerFactory(PersistenceUnit ref, InjectionContainer container) throws NameNotFoundException
    {
       return getEntityManagerFactory(ref.unitName(), container);
@@ -184,17 +160,7 @@
          ManagedEntityManagerFactory managedFactory = ((org.jboss.jpa.deployment.PersistenceUnitDeployment) PersistenceUnitRegistry.getPersistenceUnit(beanName)).getManagedFactory();
          return new InjectedEntityManagerFactory(managedFactory);
       }
-      log.warn("Container " + container + " does not implement ExtendedInjectionContainer");
-      PersistenceUnitDeployment deployment = container.getPersistenceUnitDeployment(unitName);
-      if (deployment != null)
-      {
-         ManagedEntityManagerFactory managedFactory = deployment.getManagedFactory();
-         return new InjectedEntityManagerFactory(managedFactory);
-      }
-      else
-      {
-         return null;
-      }
+      throw new UnsupportedOperationException("Container " + container + " does not implement ExtendedInjectionContainer, can't resolve persistence unit " + unitName);
    }
 
 
@@ -207,17 +173,7 @@
          ManagedEntityManagerFactory managedFactory = ((org.jboss.jpa.deployment.PersistenceUnitDeployment) PersistenceUnitRegistry.getPersistenceUnit(beanName)).getManagedFactory();
          return new InjectedSessionFactory(managedFactory);
       }
-      log.warn("Container " + container + " does not implement ExtendedInjectionContainer");
-      PersistenceUnitDeployment deployment = container.getPersistenceUnitDeployment(ref);
-      if (deployment != null)
-      {
-         ManagedEntityManagerFactory managedFactory = deployment.getManagedFactory();
-         return new InjectedSessionFactory(managedFactory);
-      }
-      else
-      {
-         return null;
-      }
+      throw new UnsupportedOperationException("Container " + container + " does not implement ExtendedInjectionContainer, can't resolve persistence unit " + ref);
    }
 
    public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MockEjb3Deployment.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MockEjb3Deployment.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/common/MockEjb3Deployment.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -25,6 +25,7 @@
 
 import javax.security.jacc.PolicyConfiguration;
 
+import org.jboss.deployers.structure.spi.helpers.AbstractDeploymentUnit;
 import org.jboss.ejb3.DependencyPolicy;
 import org.jboss.ejb3.DeploymentScope;
 import org.jboss.ejb3.DeploymentUnit;
@@ -51,7 +52,7 @@
 {
    public MockEjb3Deployment(DeploymentUnit unit, DeploymentScope deploymentScope)
    {
-      super(unit, deploymentScope, null, null);
+      super(new AbstractDeploymentUnit(), unit, deploymentScope, null);
       PoolFactoryRegistry poolRegistry = new PoolFactoryRegistry();
       HashMap<String, Class<? extends PoolFactory>> poolFactories = new HashMap<String, Class<? extends PoolFactory>>();
       poolFactories.put("ThreadlocalPool", ThreadlocalPoolFactory.class);

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/injection/test/common/DummyInjectionContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/injection/test/common/DummyInjectionContainer.java	2008-09-30 13:38:00 UTC (rev 78953)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/injection/test/common/DummyInjectionContainer.java	2008-09-30 13:45:29 UTC (rev 78954)
@@ -166,4 +166,8 @@
       return null;
    }
 
+   public String resolvePersistenceUnitSupplier(String unitName)
+   {
+      throw new RuntimeException("NYI");
+   }
 }




More information about the jboss-cvs-commits mailing list