You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by do...@apache.org on 2002/05/12 14:39:26 UTC
cvs commit: jakarta-avalon-excalibur/merlin/src/java/org/apache/excalibur/merlin ServiceRegistry.java
donaldp 02/05/12 05:39:26
Modified: merlin/src/java/org/apache/excalibur/merlin
ServiceRegistry.java
Log:
Remove some unused variables
Revision Changes Path
1.2 +77 -83 jakarta-avalon-excalibur/merlin/src/java/org/apache/excalibur/merlin/ServiceRegistry.java
Index: ServiceRegistry.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/merlin/src/java/org/apache/excalibur/merlin/ServiceRegistry.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceRegistry.java 10 May 2002 17:53:09 -0000 1.1
+++ ServiceRegistry.java 12 May 2002 12:39:26 -0000 1.2
@@ -7,44 +7,39 @@
*
* Original contribution by OSM SARL, http://www.osm.net
*/
-
package org.apache.excalibur.merlin;
import java.io.File;
import java.io.IOException;
-import java.util.Vector;
+import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
-import java.util.Hashtable;
-import java.util.Enumeration;
-import java.util.jar.JarFile;
+import java.util.Vector;
import java.util.jar.Attributes;
-
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.CascadingRuntimeException;
+import java.util.jar.JarFile;
import org.apache.avalon.framework.CascadingException;
+import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
/**
- * Implementation class that provides support for the registration of
+ * Implementation class that provides support for the registration of
* meta information about available service implementations.
*/
-class ServiceRegistry extends AbstractLogEnabled implements Configurable
+class ServiceRegistry
+ extends AbstractLogEnabled
+ implements Configurable
{
-
- private Configuration m_config;
+ private Configuration m_config;
private Vector m_repository = new Vector();
- private UnitInfo[] m_blockInfoSet;
- private Hashtable m_table;
- private Hashtable m_lookup;
private boolean m_verbose = false;
private File m_root;
- /**
- * Creation of a new <code>ServiceRegistry</code>
- * @param verbose if TRUE, enable DEBUG message priority logging
- */
+ /**
+ * Creation of a new <code>ServiceRegistry</code>
+ * @param verbose if TRUE, enable DEBUG message priority logging
+ */
public ServiceRegistry( File root, boolean verbose )
{
m_verbose = verbose;
@@ -56,67 +51,66 @@
m_config = config;
}
- /**
- * Initialize the registry.
- */
+ /**
+ * Initialize the registry.
+ */
public void initialize() throws Exception
{
- if( getLogger() == null )
- {
- throw new IllegalStateException(
- "Factory logging has not been enabled.");
- }
- if( m_config == null )
- {
- throw new IllegalStateException(
- "Factory has not been configured.");
- }
- }
-
- /**
- * Populates the set of available services based on a supplied
- * vector of jar files.
- * @param list a list of jar files
- */
- public void register( Vector list ) throws PipelineException
+ if( getLogger() == null )
+ {
+ throw new IllegalStateException(
+ "Factory logging has not been enabled." );
+ }
+ if( m_config == null )
+ {
+ throw new IllegalStateException(
+ "Factory has not been configured." );
+ }
+ }
+
+ /**
+ * Populates the set of available services based on a supplied
+ * vector of jar files.
+ * @param list a list of jar files
+ */
+ public void register( final Vector list ) throws PipelineException
{
- Vector registry = new Vector();
- Enumeration enum = list.elements();
+ final Enumeration enum = list.elements();
while( enum.hasMoreElements() )
{
- File target = (File) enum.nextElement();
+ File target = (File)enum.nextElement();
register( target );
}
}
- /**
- * Register a jar file with the registry.
- * @param file the jar file to register
- */
+ /**
+ * Register a jar file with the registry.
+ * @param target the jar file to register
+ */
public void register( File target ) throws PipelineException
{
- UnitInfo[] blocks = getUnitInfo( target );
- for( int i=0; i<blocks.length; i++ )
+ final UnitInfo[] blocks = getUnitInfo( target );
+ for( int i = 0; i < blocks.length; i++ )
{
- UnitInfo info = blocks[i];
+ final UnitInfo info = blocks[ i ];
m_repository.add( info );
}
}
- /**
- * Lookup the meta info for an implementation based
- * on a supplied service requirement.
- * @param info meta info describing the required implemenation info
- (return null if no implementation info matches the request)
- * @return UnitInfo meta information about an available implementation
- */
+ /**
+ * Lookup the meta info for an implementation based
+ * on a supplied service requirement.
+ * @param info meta info describing the required implemenation info
+ (return null if no implementation info matches the request)
+ * @return UnitInfo meta information about an available implementation
+ */
public UnitInfo lookup( DependencyInfo info )
{
Enumeration enum = m_repository.elements();
while( enum.hasMoreElements() )
{
- UnitInfo blockInfo = (UnitInfo) enum.nextElement();
- if( blockInfo.provides( info.getService() ) )
+ UnitInfo blockInfo = (UnitInfo)enum.nextElement();
+ if( blockInfo.provides( info.getService() ) )
{
Configuration config = info.getConfiguration();
return new UnitInfo( blockInfo, config );
@@ -125,11 +119,11 @@
return null;
}
- /**
- * Returns an array of block infos provided by a supplied jar file.
- * @param file a jar file
- * @return a <code>UnitInfo[]<code> provided by the jar file
- */
+ /**
+ * Returns an array of block infos provided by a supplied jar file.
+ * @param file a jar file
+ * @return a <code>UnitInfo[]<code> provided by the jar file
+ */
private UnitInfo[] getUnitInfo( File file ) throws PipelineException
{
Vector vector = new Vector();
@@ -137,14 +131,14 @@
{
//
// if the file contains block declarations, then pipeline and
- // blocks as a supporting service that will be provided to the
+ // blocks as a supporting service that will be provided to the
// target server
//
-
+
String[] blocks = getBlocks( file );
- for( int i=0; i<blocks.length; i++ )
+ for( int i = 0; i < blocks.length; i++ )
{
- final String path = blocks[i];
+ final String path = blocks[ i ];
try
{
vector.add( new UnitInfo( path, m_root ) );
@@ -165,9 +159,9 @@
catch( Throwable e )
{
throw new CascadingRuntimeException(
- "Unexpected error while attempting to load file: " + file, e );
+ "Unexpected error while attempting to load file: " + file, e );
}
- return (UnitInfo[]) vector.toArray( new UnitInfo[0] );
+ return (UnitInfo[])vector.toArray( new UnitInfo[ 0 ] );
}
@@ -175,14 +169,14 @@
// utilities
//===============================================================================
- /**
- * Returns an array of <code>String</code>s corresponding to the set of classnames
- * where each classname is a declared block within the supplied jar file.
- * @param file a jar file
- * @exception CascadingException if a general exception occurs
- */
+ /**
+ * Returns an array of <code>String</code>s corresponding to the set of classnames
+ * where each classname is a declared block within the supplied jar file.
+ * @param file a jar file
+ * @exception CascadingException if a general exception occurs
+ */
private String[] getBlocks( File file )
- throws CascadingException
+ throws CascadingException
{
final Vector vector = new Vector();
try
@@ -192,17 +186,17 @@
Iterator iterator = map.keySet().iterator();
while( iterator.hasNext() )
{
- String name = (String) iterator.next();
- Attributes attributes = (Attributes) map.get( name );
+ String name = (String)iterator.next();
+ Attributes attributes = (Attributes)map.get( name );
Iterator it = attributes.keySet().iterator();
while( it.hasNext() )
{
Object entry = it.next();
- if( entry.toString().equals("Avalon-Block") )
+ if( entry.toString().equals( "Avalon-Block" ) )
{
- if( attributes.get( entry ).equals("true") )
+ if( attributes.get( entry ).equals( "true" ) )
{
- vector.add( name.substring(0,name.indexOf(".class")));
+ vector.add( name.substring( 0, name.indexOf( ".class" ) ) );
}
}
}
@@ -220,7 +214,7 @@
}
finally
{
- return (String[]) vector.toArray( new String[0] );
+ return (String[])vector.toArray( new String[ 0 ] );
}
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>