[jboss-cvs] JBossAS SVN: r57946 - in trunk/ejb3/src/main/org/jboss: ejb3 ejb3/deployers ejb3/embedded ejb3/entity injection

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 31 13:31:52 EST 2006


Author: bill.burke at jboss.com
Date: 2006-10-31 13:31:19 -0500 (Tue, 31 Oct 2006)
New Revision: 57946

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/DeploymentUnit.java
   trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java
   trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java
   trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java
   trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
   trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBStage2Deployer.java
   trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java
   trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java
   trunk/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java
   trunk/ejb3/src/main/org/jboss/ejb3/entity/PersistenceUnitDeployment.java
   trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java
Log:
fix ear integration with JBoss5

Modified: trunk/ejb3/src/main/org/jboss/ejb3/DeploymentUnit.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/DeploymentUnit.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/DeploymentUnit.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -62,4 +62,6 @@
    Hashtable getJndiProperties();
 
    InterceptorInfoRepository getInterceptorInfoRepository();
+
+   URL getRelativeURL(String path);
 }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -22,10 +22,12 @@
 package org.jboss.ejb3;
 
 import java.net.URL;
+import java.net.MalformedURLException;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.io.IOException;
+import java.io.File;
 
 import org.jboss.deployment.DeploymentInfo;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
@@ -64,6 +66,47 @@
       }
    }
 
+
+   public URL getRelativeURL(String jar)
+   {
+      URL url = null;
+      try
+      {
+         url = new URL(jar);
+      }
+      catch (MalformedURLException e)
+      {
+         try
+         {
+            if (jar.startsWith(".."))
+            {
+               if (getUrl() == null)
+                  throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
+               String base = getUrl().toString();
+               jar = jar.replaceAll("\\.\\./", "+");
+               int idx = jar.lastIndexOf('+');
+               jar = jar.substring(idx + 1);
+               for (int i = 0; i < idx + 1; i++)
+               {
+                  int slash = base.lastIndexOf('/');
+                  base = base.substring(0, slash + 1);
+               }
+               url = new URL(base + jar.substring(idx));
+            }
+            else
+            {
+               File fp = new File(jar);
+               url = fp.toURL();
+            }
+         }
+         catch (MalformedURLException e1)
+         {
+            throw new RuntimeException("Unable to find relative url: " + jar, e1);
+         }
+      }
+      return url;
+   }
+
    URL extractDescriptorUrl(String resource)
    {
       String urlStr = deploymentInfo.url.getFile();
@@ -148,7 +191,7 @@
       try
       {
          EJB3DeployerMBean deployer = (EJB3DeployerMBean) MBeanProxyExt.create(EJB3DeployerMBean.class, EJB3DeployerMBean.OBJECT_NAME,
-                                                                         deploymentInfo.getServer());
+                 deploymentInfo.getServer());
 
          return deployer.getDefaultProperties();
       }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -34,11 +34,11 @@
  */
 public class MCDependencyPolicy implements DependencyPolicy
 {
-   protected HashSet<DemandMetaData> dependencies = new HashSet<DemandMetaData>();
+   protected HashSet<String> dependencies = new HashSet<String>();
 
    public void addDependency(String dependency)
    {
-      dependencies.add(new AbstractDemandMetaData(dependency));
+      dependencies.add(dependency);
    }
 
    public void addDatasource(String jndiName)
@@ -58,6 +58,11 @@
 
    public HashSet<DemandMetaData> getDependencies()
    {
-      return dependencies;
+      HashSet<DemandMetaData> set = new HashSet<DemandMetaData>();
+      for (String depends : dependencies)
+      {
+         set.add(new AbstractDemandMetaData(depends));
+      }
+      return set;
    }
 }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -34,6 +34,7 @@
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
 import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.spi.registry.KernelRegistryEntry;
 
@@ -118,7 +119,16 @@
       log.info("installing bean: " + name + " with dependencies:");
       for (Object obj : policy.getDependencies())
       {
-         log.info("\t" + obj);
+         String msg;
+         if (obj instanceof AbstractDemandMetaData)
+         {
+            msg = ((AbstractDemandMetaData)obj).getDemand().toString();
+         }
+         else
+         {
+            msg = obj.toString();
+         }
+         log.info("\t" + msg);
       }
       try
       {

Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -24,6 +24,7 @@
 import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
 import org.jboss.deployers.spi.deployer.DeploymentUnit;
 import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.DeploymentContext;
 import org.jboss.ejb3.DeploymentScope;
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.kernel.Kernel;
@@ -124,15 +125,22 @@
                }
             }
          }
-         log.trace("********* Begin Unit: " + unit.getName() + " jar: " + jar.getName());
+         log.debug("********* EJBRegistrationDepoyer Begin Unit: " + unit.getName() + " jar: " + jar.getName());
          DeploymentScope scope = null;
-         if (unit.getDeploymentContext().getParent() != null)
+         DeploymentContext parent = unit.getDeploymentContext().getParent();
+         if (parent != null && parent.getRoot().getName().endsWith(".ear")) // todo should look for metadata instead of ".ear"
          {
-            scope = new JBoss5DeploymentScope(unit.getDeploymentContext().getParent());
+            scope = parent.getTransientAttachments().getAttachment(DeploymentScope.class);
+            if (scope == null)
+            {
+               scope = new JBoss5DeploymentScope(unit.getDeploymentContext().getParent());
+               parent.getTransientAttachments().addAttachment(DeploymentScope.class, scope);
+            }
          }
          JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
          du.setDefaultPersistenceProperties(defaultPersistenceProperties);
          Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope);
+         if (scope != null) scope.register(deployment);
          // create() creates initial EJB containers and initializes metadata.
          deployment.create();
          if (deployment.getEjbContainers().size() == 0 && deployment.getPersistenceUnitDeployments().size() == 0)

Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBStage2Deployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBStage2Deployer.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBStage2Deployer.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -44,6 +44,7 @@
       if (deployment == null) return;
       try
       {
+         log.debug("********* EJBStage2 Begin Unit: " + unit.getName() + " jar: " + unit.getDeploymentContext().getRoot().getName());
          deployment.start();
       }
       catch (Exception e)

Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -88,6 +88,10 @@
 
    public Ejb3Deployment findRelativeDeployment(String relativeName)
    {
+      if (relativeName.startsWith("../"))
+      {
+         relativeName = relativeName.substring(3);
+      }
       return deployments.get(relativeName);
    }
 

Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -31,10 +31,13 @@
 import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
 
 import java.net.URL;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.io.IOException;
+import java.io.File;
 
 /**
  * Comment
@@ -53,6 +56,38 @@
       this.deploymentInfo = deploymentInfo;
    }
 
+
+   public URL getRelativeURL(String jar)
+   {
+      try
+      {
+         return new URL(jar);
+      }
+      catch (MalformedURLException e)
+      {
+         try
+         {
+            if (jar.startsWith(".."))
+            {
+               if (getUrl() == null)
+                  throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
+               String tmpjar = jar.substring(3);
+               VirtualFile vf = deploymentInfo.getDeploymentContext().getRoot().getParent().findChild(tmpjar);
+               return vf.toURL();
+            }
+            else
+            {
+               File fp = new File(jar);
+               return fp.toURL();
+            }
+         }
+         catch (Exception e1)
+         {
+            throw new RuntimeException("could not find relative path: " + jar, e1);
+         }
+      }
+   }
+
    URL extractDescriptorUrl(String resource)
    {
       try
@@ -150,7 +185,7 @@
       FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, va);
 
       List<VirtualFile> classpath = deploymentInfo.getDeploymentContext().getClassPath();
-      if( classpath != null )
+      if (classpath != null)
       {
          for (VirtualFile vf : classpath)
          {

Modified: trunk/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployer.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -28,6 +28,7 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLConnection;
+import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashSet;
@@ -104,6 +105,47 @@
          }
       }
 
+      public URL getRelativeURL(String jar)
+      {
+         URL url = null;
+         try
+         {
+            url = new URL(jar);
+         }
+         catch (MalformedURLException e)
+         {
+            try
+            {
+               if (jar.startsWith(".."))
+               {
+                  if (getUrl() == null)
+                     throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
+                  String base = getUrl().toString();
+                  jar = jar.replaceAll("\\.\\./", "+");
+                  int idx = jar.lastIndexOf('+');
+                  jar = jar.substring(idx + 1);
+                  for (int i = 0; i < idx + 1; i++)
+                  {
+                     int slash = base.lastIndexOf('/');
+                     base = base.substring(0, slash + 1);
+                  }
+                  url = new URL(base + jar.substring(idx));
+               }
+               else
+               {
+                  File fp = new File(jar);
+                  url = fp.toURL();
+               }
+            }
+            catch (MalformedURLException e1)
+            {
+               throw new RuntimeException("Unable to find relative url: " + jar, e1);
+            }
+         }
+         return url;
+      }
+      
+
       public List<VirtualFile> getResources(VirtualFileFilter filter)
       {
          VisitorAttributes va = new VisitorAttributes();

Modified: trunk/ejb3/src/main/org/jboss/ejb3/entity/PersistenceUnitDeployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/entity/PersistenceUnitDeployment.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/ejb3/entity/PersistenceUnitDeployment.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -196,37 +196,10 @@
 
       for (String jar : xml.getJarFiles())
       {
-         URL url = null;
-         try
-         {
-            url = new URL(jar);
-         }
-         catch (MalformedURLException e)
-         {
-            if (jar.startsWith(".."))
-            {
-               if (di.getUrl() == null)
-                  throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
-               String base = di.getUrl().toString();
-               jar = jar.replaceAll("\\.\\./", "+");
-               int idx = jar.lastIndexOf('+');
-               jar = jar.substring(idx + 1);
-               for (int i = 0; i < idx + 1; i++)
-               {
-                  int slash = base.lastIndexOf('/');
-                  base = base.substring(0, slash + 1);
-               }
-               url = new URL(base + jar.substring(idx));
-            }
-            else
-            {
-               File fp = new File(jar);
-               url = fp.toURL();
-            }
-         }
-         log.debug("adding JarFile URL: " + url.toString());
-         jarFiles.add(url);
+         jarFiles.add(deployment.getDeploymentUnit().getRelativeURL(jar));
       }
+
+
       if (xml.getProvider() != null) pi.setPersistenceProviderClassName(xml.getProvider());
       if (explicitEntityClasses.size() > 0)
       {

Modified: trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java	2006-10-31 14:17:29 UTC (rev 57945)
+++ trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java	2006-10-31 18:31:19 UTC (rev 57946)
@@ -122,10 +122,12 @@
       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.debug("******* could not find PU dependency so adding a default: " + PersistenceUnitDeployment.getDefaultKernelName(unitName));
       container.getDependencyPolicy().addDependency(PersistenceUnitDeployment.getDefaultKernelName(unitName));
    }
 




More information about the jboss-cvs-commits mailing list