[jboss-cvs] JBossAS SVN: r70241 - trunk/ejb3/src/main/org/jboss/ejb3/deployers.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 28 23:45:53 EST 2008


Author: scott.stark at jboss.org
Date: 2008-02-28 23:45:53 -0500 (Thu, 28 Feb 2008)
New Revision: 70241

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
Log:
Add has30EjbJarXml(InputStream) util method

Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java	2008-02-29 04:42:10 UTC (rev 70240)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java	2008-02-29 04:45:53 UTC (rev 70241)
@@ -21,7 +21,9 @@
 */
 package org.jboss.ejb3.deployers;
 
+import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Properties;
@@ -33,7 +35,6 @@
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
 import org.jboss.deployment.security.JaccPolicyUtil;
 import org.jboss.ejb3.DeploymentScope;
-import org.jboss.ejb3.EJB3Deployer;
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.kernel.Kernel;
 import org.jboss.logging.Logger;
@@ -60,6 +61,53 @@
    private List<String> allowedSuffixes;
    private boolean requireDeploymentDescriptor;
 
+   public static boolean has30EjbJarXml(InputStream ddStream)
+   {
+      try
+      {
+         // look for version="3.0" in the file
+         byte[] stringToFind = "version=\"3.0\"".getBytes();
+         InputStreamReader reader = new InputStreamReader(ddStream);
+         try
+         {
+            int idx = 0;
+            int len = stringToFind.length;
+            while (reader.ready())
+            {
+               int read = reader.read();
+               if (read == stringToFind[idx])
+               {
+                  idx++;
+                  if (idx == len)
+                  {
+                     return true;
+                  }
+               }
+               else
+               {
+                  idx = 0;
+               }
+            }
+
+         }
+         finally
+         {
+            try
+            {
+               reader.close();
+               ddStream.close();
+            }
+            catch (IOException ignored)
+            {
+            }
+         }
+      }
+      catch (Exception ignore)
+      {
+      }
+      return false;
+   }
+
    /**
     * Create a new EJBRegistrationDeployer.
     */
@@ -154,7 +202,7 @@
          if (ejbjar != null)
          {
             InputStream is = ejbjar.openStream();
-            boolean has30EjbJarXml = EJB3Deployer.has30EjbJarXml(is);
+            boolean has30EjbJarXml = has30EjbJarXml(is);
             is.close();
             if (!has30EjbJarXml) {
                return;




More information about the jboss-cvs-commits mailing list