[jboss-cvs] system2/src/main/org/jboss/deployers/plugins/classloading ...

Scott Stark scott.stark at jboss.com
Mon Jul 17 15:19:20 EDT 2006


  User: starksm 
  Date: 06/07/17 15:19:20

  Modified:    src/main/org/jboss/deployers/plugins/classloading 
                        ClassLoadingDeployer.java
  Log:
  Parse the deployment context manifest for Class-Path entries
  
  Revision  Changes    Path
  1.6       +42 -6     system2/src/main/org/jboss/deployers/plugins/classloading/ClassLoadingDeployer.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ClassLoadingDeployer.java
  ===================================================================
  RCS file: /cvsroot/jboss/system2/src/main/org/jboss/deployers/plugins/classloading/ClassLoadingDeployer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- ClassLoadingDeployer.java	12 Jul 2006 09:13:32 -0000	1.5
  +++ ClassLoadingDeployer.java	17 Jul 2006 19:19:20 -0000	1.6
  @@ -21,15 +21,22 @@
    */
   package org.jboss.deployers.plugins.classloading;
   
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.jar.Attributes;
  +import java.util.jar.Manifest;
  +
   import org.jboss.deployers.plugins.AbstractAspectDeployer;
   import org.jboss.deployers.plugins.DeployerConstants;
   import org.jboss.deployers.spi.DeploymentContext;
   import org.jboss.deployers.spi.DeploymentException;
  +import org.jboss.vfs.spi.VirtualFile;
  +
   /**
    * ClassLoadingDeployer
    * 
    * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class ClassLoadingDeployer extends AbstractAspectDeployer
   {
  @@ -53,21 +60,50 @@
      }
   
      /**
  -    * Never analyze a deployment - leave this for the other deployers
  -    * TODO: analyze could be done for class loader metadata
  +    * Look for META-INF/MANIFEST.MF Class-Path header and add these entries
  +    * to the ctx.
       */
      public boolean analyze(DeploymentContext ctx) throws DeploymentException
      {
  -      return false;
  +      boolean hasManifest = false;
  +      VirtualFile vf = ctx.getFile();
  +      try
  +      {
  +         vf.findChild("META-INF/MANIFEST.MF");
  +         InputStream is = vf.openStream();
  +         Manifest mf = new Manifest(is);
  +         String path = mf.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
  +         is.close();
  +         if( path != null )
  +         {
  +            String[] cp = path.split("\\s");
  +            for(int n = 0; n < cp.length; n ++)
  +            {
  +               String entry = cp[n];
  +               ctx.addClasspathEntry(entry);
  +            }
  +            hasManifest = true;
  +         }
  +      }
  +      catch (IOException e)
  +      {
  +         // Ignore
  +      }
  +      return hasManifest;
      }
      public Object getManagedObject(DeploymentContext ctx)
      {
         return null;
      }
   
  -   public void deploy(DeploymentContext comp) throws DeploymentException
  +   /**
  +    * Add any classpath entries to the ctx classloader. Current impl 
  +    * @param ctx - the deployment ctx to process
  +    * TODO: How to combine deployment class loaders; parent/child, repository, etc.
  +    */
  +   public void deploy(DeploymentContext ctx) throws DeploymentException
      {
  -      // TODO Auto-generated method stub      
  +      
      }
   
      public void redeploy(DeploymentContext comp) throws DeploymentException
  
  
  



More information about the jboss-cvs-commits mailing list