avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly TypeManager.java
Date Thu, 22 Aug 2002 10:13:39 GMT
mcconnell    2002/08/22 03:13:39

  Modified:    assembly/src/java/org/apache/excalibur/merlin/assembly
                        TypeManager.java
  Log:
  checkstyle ok
  
  Revision  Changes    Path
  1.15      +59 -24    jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java
  
  Index: TypeManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TypeManager.java	21 Aug 2002 17:00:51 -0000	1.14
  +++ TypeManager.java	22 Aug 2002 10:13:39 -0000	1.15
  @@ -11,30 +11,24 @@
   import java.io.IOException;
   import java.util.jar.Attributes;
   import java.util.jar.Manifest;
  -import java.util.Dictionary;
   import java.util.Hashtable;
   import java.util.Enumeration;
   import java.util.Vector;
   import java.util.ArrayList;
  -import java.util.Arrays;
   import java.util.Iterator;
   import java.util.Map;
   import java.util.List;
  -import java.util.LinkedList;
   import java.net.URLClassLoader;
   import java.net.URL;
   import java.net.JarURLConnection;
   
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.avalon.framework.logger.LogEnabled;
  -import org.apache.avalon.framework.CascadingRuntimeException;
  -import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.excalibur.extension.Extension;
  @@ -44,13 +38,10 @@
   import org.apache.avalon.excalibur.packagemanager.impl.DefaultExtensionManager;
   import org.apache.excalibur.meta.info.Type;
   import org.apache.excalibur.meta.info.ReferenceDescriptor;
  -import org.apache.excalibur.meta.info.StageDescriptor;
   import org.apache.excalibur.merlin.model.IncludeDescriptor;
   import org.apache.excalibur.merlin.model.LibraryDescriptor;
   import org.apache.excalibur.merlin.model.ClasspathDescriptor;
   import org.apache.excalibur.merlin.model.FilesetDescriptor;
  -import org.apache.excalibur.merlin.model.IncludeDescriptor;
  -import org.apache.excalibur.merlin.model.LibraryDescriptor;
   
   /**
    * Abstract type manager.
  @@ -80,9 +71,15 @@
       */
       public static final String CLASSPATH_DESCRIPTOR_KEY = "classpath";
   
  +   /**
  +    * The default Merlin container implementation class name.
  +    */
       public static final String DEFAULT_CONTAINER_CLASS = 
         "org.apache.excalibur.merlin.container.DefaultContainer";
   
  +   /**
  +    * The default Merlin container structural extension class name.
  +    */
       public static final String DEFAULT_STRUCTURE_CLASS = 
         "org.apache.excalibur.merlin.container.StructuralExtension";
   
  @@ -138,17 +135,29 @@
       // LogEnabled
       //=======================================================================
   
  +   /**
  +    * Sets the logging channel to the supplied value.
  +    * @param logger the logging channel to assign
  +    */
       public void enableLogging( Logger logger )
       {
           m_logger = logger;
           m_localLogger = logger.getChildLogger("loader");
       }
   
  +   /**
  +    * Returns the assigned logging channel
  +    * @return the logging channel
  +    */
       protected Logger getLogger()
       {
           return m_logger;
       }
   
  +   /**
  +    * Returns the internal logging channel
  +    * @return the internal logging channel
  +    */
       protected Logger getLocalLogger()
       {
           return m_localLogger;
  @@ -162,7 +171,7 @@
      /**
       * Declaration of the extensions and classpath descriptors.
       * @param context the context object containing the inital parameters
  -    * @exception ContextException if the supplied does not contain a DESCRIPTOR_KEY value

  +    * @exception ContextException if a context related error occurs
       */
       public void contextualize( Context context ) throws ContextException
       {
  @@ -174,6 +183,7 @@
           {
               // ignore - optional context element
           }
  +
           try
           {
               m_classpath = (ClasspathDescriptor) context.get( CLASSPATH_DESCRIPTOR_KEY );
  @@ -188,6 +198,10 @@
       // Initializable
       //=======================================================================
   
  +   /**
  +    * Initialization of the manager.
  +    * @exception Exception if an error occurs during the intialization process
  +    */
       public void initialize() throws Exception
       {
   
  @@ -265,8 +279,9 @@
      /**
       * Register any components declared in the manifest.
       * @param url pointing to the jar file
  +    * @exception TypeRuntimeException if a type related error occurs
       */
  -    private void scan( URL url )
  +    private void scan( URL url ) throws TypeRuntimeException
       {
           try
           {
  @@ -286,14 +301,16 @@
                       {
                           if( attributes.get( entry ).equals( "true" ) )
                           {
  -                            final String path = name.substring( 0, name.indexOf( ".class"
) );
  +                            final String path = 
  +                              name.substring( 0, name.indexOf( ".class" ) );
                               try
                               {
                                   m_types.addBlock( path );
                               }
                               catch( ClassNotFoundException e )
                               {
  -                                final String warning = "Unresolved class: " + e.getMessage()

  +                                final String warning = 
  +                                  "Unresolved class: " + e.getMessage() 
                                     + " in block: " + path ;
                                   getLocalLogger().warn( warning );
                               }
  @@ -308,7 +325,8 @@
                       {
                           if( attributes.get( entry ).equals( "Type" ) )
                           {
  -                            final String path = name.substring( 0, name.indexOf( ".class"
) );
  +                            final String path = 
  +                              name.substring( 0, name.indexOf( ".class" ) );
                               try
                               {
                                   m_types.addType( path );
  @@ -325,7 +343,7 @@
           }
           catch( IOException e )
           {
  -            final String error = "IO exception while attempt to read block manifest.";
  +            final String error = "IO exception while attempt to read manifest.";
               throw new TypeRuntimeException( error, e );
           }
           catch( Throwable e )
  @@ -339,6 +357,9 @@
       // Disposable
       //===================================================================
   
  +   /**
  +    * Disposal of the type mnager.
  +    */
       public void dispose()
       {
           // need to complete this 
  @@ -408,8 +429,10 @@
        *
        * @param stack a <code>Vector</code> containing a sequence of jar files
        *   to be added to the classloader.
  +     * @exception RuntimeException if un unexpected error occurs during
  +     *  the loading of the stack
        */
  -    private void load( Vector stack )
  +    private void load( Vector stack ) throws RuntimeException
       {
           int size = stack.size();
           getLocalLogger().debug( "Stack size: " + stack.size() );
  @@ -427,7 +450,8 @@
               catch( Throwable error )
               {
                   getLocalLogger().warn(
  -                    "Encountered error while loading resource: " + file, error );
  +                  "Encountered error while loading resource: " 
  +                  + file, error );
                   errors.put( file, error );
               }
   
  @@ -448,8 +472,8 @@
               {
                   File key = (File)keys.nextElement();
                   getLocalLogger().error(
  -                    "Error while loading file."
  -                    + "\n\tfile: " + key.toString(), (Throwable)errors.get( key ) );
  +                  "Error while loading file."
  +                  + "\n\tfile: " + key.toString(), (Throwable)errors.get( key ) );
               }
               throw new RuntimeException( "Unable to load file stack - see trace for details."
);
           }
  @@ -470,6 +494,7 @@
       *
       * @param classname the component type
       * @return the type
  +    * @exception TypeException if the type is unknown
       */
       public Type getType( String classname ) throws TypeException
       {
  @@ -503,7 +528,8 @@
                   }
                   else
                   {
  -                    throw new TypeException("Type not found, classname: " + classname );
  +                    throw new TypeException(
  +                      "Type not found, classname: " + classname );
                   }
               }
           }
  @@ -521,6 +547,7 @@
      /**
       * Returns the set of component types know to the registry that are capable of 
       * supporting the supplied service.
  +    * @param service the service descriptor 
       * @return the set of candidate component types
       */
       public Type[] getTypes( ReferenceDescriptor service )
  @@ -528,6 +555,10 @@
           return m_types.getTypes( service );
       }
   
  +   /**
  +    * Test if a class is locally managed.
  +    * @return TRUE if the class is local to this manager
  +    */
       boolean isLocal( String classname )
       {
           return m_types.isLocal( classname );
  @@ -543,6 +574,7 @@
        *
        * @param classPath the Classpath array
        * @return the files that need to be added to ClassLoader
  +     * @exception Exception if a extension error occurs
        */
       protected File[] getOptionalPackagesFor( final String[] classPath )
           throws Exception
  @@ -616,14 +648,17 @@
                   try
                   {
                       final URL url = new URL( "jar:" + element + "!/" );
  -                    final JarURLConnection connection = (JarURLConnection)url.openConnection();
  +                    final JarURLConnection connection = 
  +                      (JarURLConnection)url.openConnection();
                       final Manifest manifest = connection.getManifest();
                       manifests.add( manifest );
                   }
                   catch( final IOException ioe )
                   {
  -                    final String message = REZ.getString( "bad-classpath-entry", element
);
  -                    throw new TypeException( message + ": " + element, ioe );
  +                    final String message = 
  +                      REZ.getString( "bad-classpath-entry", element );
  +                    throw new TypeException( 
  +                      message + ": " + element, ioe );
                   }
               }
           }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message