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 15:08:47 UTC
cvs commit: jakarta-avalon-excalibur/merlin/src/java/org/apache/excalibur/merlin UnitInfo.java ServiceContext.java
donaldp 02/05/12 06:08:47
Modified: merlin/src/java/org/apache/excalibur/merlin UnitInfo.java
ServiceContext.java
Log:
Remove some unused variables from ServiceContext
Revision Changes Path
1.3 +228 -232 jakarta-avalon-excalibur/merlin/src/java/org/apache/excalibur/merlin/UnitInfo.java
Index: UnitInfo.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/merlin/src/java/org/apache/excalibur/merlin/UnitInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UnitInfo.java 12 May 2002 00:25:17 -0000 1.2
+++ UnitInfo.java 12 May 2002 13:08:47 -0000 1.3
@@ -7,44 +7,40 @@
*
* Original contribution by OSM SARL, http://www.osm.net
*/
-
package org.apache.excalibur.merlin;
import java.io.File;
import java.io.InputStream;
import java.util.Vector;
-
import org.apache.avalon.framework.CascadingException;
-import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.context.Context;
-
-import org.apache.excalibur.configuration.ConfigurationUtil;
import org.apache.excalibur.configuration.CascadingConfiguration;
+import org.apache.excalibur.configuration.ConfigurationUtil;
import org.apache.excalibur.context.ContextUtility;
/**
- * Meta information about a <code>Serviceable</code> component.
+ * Meta information about a <code>Serviceable</code> component.
* @author <a href="mailto:mcconnell@osm.net">Stephen McConnell</a>
*/
public class UnitInfo
{
-
- /**
- * A singleton service.
- */
+ /**
+ * A singleton service.
+ */
public static final int SINGLETON_LIFETIME_POLICY = 0;
- /**
- * A transient service.
- */
+ /**
+ * A transient service.
+ */
public static final int TRANSIENT_LIFETIME_POLICY = 2;
- /**
- * A singleton service (pending).
- */
+ /**
+ * A singleton service (pending).
+ */
//public static final int POOLED_LIFETIME_POLICY = 1;
private Class m_block;
@@ -55,118 +51,118 @@
private int m_policy = SINGLETON_LIFETIME_POLICY;
private String m_name;
- /**
- * Creation of a new UnitInfo based a xinfo configuration
- * derived from the supplied class name.
- * The UnitInfo recognises the the following structures within
- * the xinfo configuration:
- * <pre>
- * <blockinfo>
- *
- * <block>
- * <version>1.0</version>
- * </block>
- *
- * <!--
- * services that are offered by this block
- * -->
- *
- * <services>
- * <service name="hello.Hello" version="1.0"/>
- * </services>
- *
- * <!--
- * Implementation policy may one of the following enumerations:
- * (a) SINGLETON, service is available for the lifetime of the manager
- * (b) POOLED, the implementation implements Pool
- * (c) TRANSIENT, manager is a factory of transient service instances
- * -->
- *
- * <implementation policy="SINGLETON" />
- *
- * </blockinfo>
- * </pre>
- *
- * @param block the implementation class
- * @param xinfo the xinfo meta-information in the form of a Configuration
- * @exception Exception if an internal error occurs
- */
+ /**
+ * Creation of a new UnitInfo based a xinfo configuration
+ * derived from the supplied class name.
+ * The UnitInfo recognises the the following structures within
+ * the xinfo configuration:
+ * <pre>
+ * <blockinfo>
+ *
+ * <block>
+ * <version>1.0</version>
+ * </block>
+ *
+ * <!--
+ * services that are offered by this block
+ * -->
+ *
+ * <services>
+ * <service name="hello.Hello" version="1.0"/>
+ * </services>
+ *
+ * <!--
+ * Implementation policy may one of the following enumerations:
+ * (a) SINGLETON, service is available for the lifetime of the manager
+ * (b) POOLED, the implementation implements Pool
+ * (c) TRANSIENT, manager is a factory of transient service instances
+ * -->
+ *
+ * <implementation policy="SINGLETON" />
+ *
+ * </blockinfo>
+ * </pre>
+ *
+ * @param block the implementation class
+ * @param xinfo the xinfo meta-information in the form of a Configuration
+ * @exception Exception if an internal error occurs
+ */
public UnitInfo( Class block, Configuration xinfo ) throws Exception
{
- this( block, xinfo, new DefaultConfiguration("configuration",null) );
+ this( block, xinfo, new DefaultConfiguration( "configuration", null ) );
}
- /**
- * Creation of a new UnitInfo.
- * @param block the implementation class
- * @param xinfo the xinfo meta-information in the form of a Configuration
- * @param conf supplimentary configuration
- * @exception Exception if an internal error occurs
- */
- public UnitInfo( Class block, Configuration xinfo, Configuration conf )
- throws Exception
- {
- this( block, xinfo, conf, new File( System.getProperty("user.dir") ) );
- }
-
- /**
- * Creation of a new UnitInfo.
- * @param block the implementation class
- * @param xinfo the xinfo meta-information in the form of a Configuration
- * @param conf supplimentary configuration
- * @param root base directory
- * @exception Exception if an internal error occurs
- */
- public UnitInfo( Class block, Configuration xinfo, Configuration conf,
- File root )
- throws Exception
+ /**
+ * Creation of a new UnitInfo.
+ * @param block the implementation class
+ * @param xinfo the xinfo meta-information in the form of a Configuration
+ * @param conf supplimentary configuration
+ * @exception Exception if an internal error occurs
+ */
+ public UnitInfo( Class block, Configuration xinfo, Configuration conf )
+ throws Exception
+ {
+ this( block, xinfo, conf, new File( System.getProperty( "user.dir" ) ) );
+ }
+
+ /**
+ * Creation of a new UnitInfo.
+ * @param block the implementation class
+ * @param xinfo the xinfo meta-information in the form of a Configuration
+ * @param conf supplimentary configuration
+ * @param root base directory
+ * @exception Exception if an internal error occurs
+ */
+ public UnitInfo( Class block, Configuration xinfo, Configuration conf,
+ File root )
+ throws Exception
{
m_block = block;
-
+
// create the list of service provided by block implementation
try
{
- Configuration[] services =
- xinfo.getChild("services").getChildren("service");
+ Configuration[] services =
+ xinfo.getChild( "services" ).getChildren( "service" );
Vector vector = new Vector();
- for( int i=0; i<services.length; i++ )
+ for( int i = 0; i < services.length; i++ )
{
- vector.add( new ServiceInfo( services[i] ));
+ vector.add( new ServiceInfo( services[ i ] ) );
}
- m_services = (ServiceInfo[]) vector.toArray(
- new ServiceInfo[ vector.size() ] );
+ m_services = (ServiceInfo[])vector.toArray(
+ new ServiceInfo[ vector.size() ] );
}
catch( Throwable e )
{
- throw new CascadingException(
- "Could not construct service information.", e );
+ throw new CascadingException(
+ "Could not construct service information.", e );
}
// create the list of computational dependecies
try
{
- Configuration[] dependencies =
- xinfo.getChild("dependencies").getChildren("dependency");
+ Configuration[] dependencies =
+ xinfo.getChild( "dependencies" ).getChildren( "dependency" );
Vector vector = new Vector();
- for( int i=0; i<dependencies.length; i++ )
+ for( int i = 0; i < dependencies.length; i++ )
{
- vector.add( new DependencyInfo( dependencies[i] ));
+ vector.add( new DependencyInfo( dependencies[ i ] ) );
}
- m_dependencies = (DependencyInfo[])
- vector.toArray( new DependencyInfo[ vector.size() ] );
+ m_dependencies = (DependencyInfo[])
+ vector.toArray( new DependencyInfo[ vector.size() ] );
}
catch( Throwable e )
{
- throw new CascadingException(
- "Could not construct dependency information.", e );
+ throw new CascadingException(
+ "Could not construct dependency information.", e );
}
// resolve the implementation policy
- String policy = xinfo.getChild("implementation").getAttribute(
- "policy","SINGLETON");
+ String policy = xinfo.getChild( "implementation" ).getAttribute(
+ "policy", "SINGLETON" );
if( policy.equalsIgnoreCase( "SINGLETON" ) )
{
m_policy = SINGLETON_LIFETIME_POLICY;
@@ -177,7 +173,7 @@
}
else
{
- throw new ConfigurationException("Unsupported policy: " + policy );
+ throw new ConfigurationException( "Unsupported policy: " + policy );
// Pool support currently disabled (pending fortress finalization)
//if( Pool.class.isAssignableFrom( block ) )
//{
@@ -191,27 +187,27 @@
// get the default configuration
- Configuration configuration = xinfo.getChild("configuration");
- String base = configuration.getAttribute("extends", null );
+ Configuration configuration = xinfo.getChild( "configuration" );
+ String base = configuration.getAttribute( "extends", null );
if( base != null )
{
- configuration = new CascadingConfiguration(
- configuration, loadConfiguration( base ) );
+ configuration = new CascadingConfiguration(
+ configuration, loadConfiguration( base ) );
}
m_config = new CascadingConfiguration( conf, configuration );
// get the default name
- m_name = xinfo.getChild("block").getAttribute("name", getClassName() );
+ m_name = xinfo.getChild( "block" ).getAttribute( "name", getClassName() );
// get the default context
- Context context = new ServiceContext( new String[0], root, getName() );
- Configuration contextConfig = xinfo.getChild("context",false);
+ Context context = new ServiceContext( new String[ 0 ], root );
+ Configuration contextConfig = xinfo.getChild( "context", false );
if( contextConfig != null )
{
- m_context = ContextUtility.createContextFromConfiguration(
- context, contextConfig );
+ m_context = ContextUtility.createContextFromConfiguration(
+ context, contextConfig );
}
else
{
@@ -219,15 +215,15 @@
}
}
- /**
- * Creation of a new <code>UnitInfo</code> based on an existing
- * info and supplimentary configuration. The implementation will
- * assigns the supplied configuration as the primary configuration
- * backed by the info current configuration.
- * @param info the primary <code>UnitInfo</code>
- * @param config a configuration to assign as the primary
- * configuration for the created info
- */
+ /**
+ * Creation of a new <code>UnitInfo</code> based on an existing
+ * info and supplimentary configuration. The implementation will
+ * assigns the supplied configuration as the primary configuration
+ * backed by the info current configuration.
+ * @param info the primary <code>UnitInfo</code>
+ * @param config a configuration to assign as the primary
+ * configuration for the created info
+ */
public UnitInfo( UnitInfo info, Configuration config )
{
m_block = info.getBaseClass();
@@ -239,216 +235,216 @@
m_context = info.getContext();
}
- /**
- * Creation of a new <code>UnitInfo</code> from a .xinfo resource.
- * @param path the path to the .xinfo resource
- * @exception Exception if an error occurs
- */
+ /**
+ * Creation of a new <code>UnitInfo</code> from a .xinfo resource.
+ * @param path the path to the .xinfo resource
+ * @exception Exception if an error occurs
+ */
public UnitInfo( String path ) throws Exception
{
this( loadClass( path ), loadConfiguration( path + ".xinfo" ) );
}
- /**
- * Creation of a new <code>UnitInfo</code> form configuration given a supplied
- * path and base directory.
- * @param path the path to the configuration file
- * @param root the base directory
- * @exception Exception if an error occurs
- */
+ /**
+ * Creation of a new <code>UnitInfo</code> form configuration given a supplied
+ * path and base directory.
+ * @param path the path to the configuration file
+ * @param root the base directory
+ * @exception Exception if an error occurs
+ */
public UnitInfo( String path, File root ) throws Exception
{
- this( path, new DefaultConfiguration("configuration",null), root );
+ this( path, new DefaultConfiguration( "configuration", null ), root );
}
- /**
- * Creation of a new <code>UnitInfo</code> form configuration given a supplied
- * path, base directory and default configuration.
- * @param path the path to the configuration file
- * @param config the default configuration
- * @param root the base directory
- * @exception Exception if an error occurs
- */
- public UnitInfo( String path, Configuration config, File root )
- throws Exception
- {
- this( loadClass( path ), loadConfiguration( path + ".xinfo" ),
- config, root );
- }
-
- /**
- * Returns the name of the class implementing the service.
- * @return the class name
- */
+ /**
+ * Creation of a new <code>UnitInfo</code> form configuration given a supplied
+ * path, base directory and default configuration.
+ * @param path the path to the configuration file
+ * @param config the default configuration
+ * @param root the base directory
+ * @exception Exception if an error occurs
+ */
+ public UnitInfo( String path, Configuration config, File root )
+ throws Exception
+ {
+ this( loadClass( path ), loadConfiguration(
+ path + ".xinfo" ), config, root );
+ }
+
+ /**
+ * Returns the name of the class implementing the service.
+ * @return the class name
+ */
public String getClassName()
{
return m_block.getName();
}
- /**
- * Returns the set of services provided by the component.
- * @return an array of <code>ServiceInfo</code> instance
- */
+ /**
+ * Returns the set of services provided by the component.
+ * @return an array of <code>ServiceInfo</code> instance
+ */
public ServiceInfo[] getServices()
{
return m_services;
}
- /**
- * Returns a <code>ServiceInfo</code> from the <code>UnitInfo</code> matching
- * the supplied service descriptor.
- * @param info a <code>ServiceInfo</code> to locate with the <code>UnitInfo</code>
- * instance
- * @return ServiceInfo a <code>ServiceInfo</code> instance matching the supplied
- * service descriptor
- */
+ /**
+ * Returns a <code>ServiceInfo</code> from the <code>UnitInfo</code> matching
+ * the supplied service descriptor.
+ * @param info a <code>ServiceInfo</code> to locate with the <code>UnitInfo</code>
+ * instance
+ * @return ServiceInfo a <code>ServiceInfo</code> instance matching the supplied
+ * service descriptor
+ */
public ServiceInfo getService( ServiceInfo info )
{
ServiceInfo[] services = getServices();
- for( int i=0; i<services.length; i++ )
+ for( int i = 0; i < services.length; i++ )
{
- if( services[i].equals( info ))
+ if( services[ i ].equals( info ) )
{
- return services[i];
+ return services[ i ];
}
}
return null;
}
- /**
- * Returns a <code>TRUE</code> if the supplied <code>ServiceInfo</code> can be
- * provided by the implementation.
- * @param service the requested service
- * @return boolean TRUE if the service is available otherwise FALSE
- */
+ /**
+ * Returns a <code>TRUE</code> if the supplied <code>ServiceInfo</code> can be
+ * provided by the implementation.
+ * @param service the requested service
+ * @return boolean TRUE if the service is available otherwise FALSE
+ */
public boolean provides( ServiceInfo service )
{
return ( getService( service ) != null );
}
- /**
- * Returns a array of <code>DependencyInfo</code> descriptors that detail
- * the dependencies that this component has on other components.
- * @return component dependencies
- */
+ /**
+ * Returns a array of <code>DependencyInfo</code> descriptors that detail
+ * the dependencies that this component has on other components.
+ * @return component dependencies
+ */
public DependencyInfo[] getDependencies()
{
return m_dependencies;
}
- /**
- * Returns the implemetation policy. The value returned shall be one of
- * SINGLETON_LIFETIME_POLICY, or TRANSIENT_LIFETIME_POLICY.
- * @return implementation policy
- */
+ /**
+ * Returns the implemetation policy. The value returned shall be one of
+ * SINGLETON_LIFETIME_POLICY, or TRANSIENT_LIFETIME_POLICY.
+ * @return implementation policy
+ */
public int getPolicy()
{
return m_policy;
}
- /**
- * The component implementation class.
- * @return Class the component implementation class
- */
+ /**
+ * The component implementation class.
+ * @return Class the component implementation class
+ */
public Class getBaseClass()
{
return m_block;
}
- /**
- * Returns the default configuration.
- * @return Configuration the default configuration
- */
+ /**
+ * Returns the default configuration.
+ * @return Configuration the default configuration
+ */
public Configuration getConfiguration()
{
return m_config;
}
- /**
- * Returns the default service context.
- * @return Context the default service context
- */
+ /**
+ * Returns the default service context.
+ * @return Context the default service context
+ */
public Context getContext()
{
return m_context;
}
- /**
- * Returns the block name.
- * @return String the block name
- */
+ /**
+ * Returns the block name.
+ * @return String the block name
+ */
public String getName()
{
return m_name;
}
- /**
- * Returns a string representation of the descriptor.
- * @return String stringified representation
- */
+ /**
+ * Returns a string representation of the descriptor.
+ * @return String stringified representation
+ */
public String toString()
{
final StringBuffer buffer = new StringBuffer();
buffer.append( " name: " + getName() );
buffer.append( "\n class: " + getClassName() );
ServiceInfo[] services = getServices();
- for( int i=0; i<services.length; i++ )
+ for( int i = 0; i < services.length; i++ )
{
- buffer.append( "\n service: " + services[i].getInterface().getName()
- + ", version: " + services[i].getVersion() );
+ buffer.append( "\n service: " + services[ i ].getInterface().getName()
+ + ", version: " + services[ i ].getVersion() );
}
DependencyInfo[] dependencies = getDependencies();
- for( int i=0; i<dependencies.length; i++ )
+ for( int i = 0; i < dependencies.length; i++ )
{
- buffer.append( "\n dependency: "
- + "role: " + dependencies[i].getRole()
- + ", service: " + dependencies[i].getService().getInterface().getName()
- + ", version: " + dependencies[i].getService().getVersion() );
+ buffer.append( "\n dependency: "
+ + "role: " + dependencies[ i ].getRole()
+ + ", service: " + dependencies[ i ].getService().getInterface().getName()
+ + ", version: " + dependencies[ i ].getService().getVersion() );
}
- buffer.append("\n configuration\n");
- buffer.append( ConfigurationUtil.list( this.getConfiguration() ));
+ buffer.append( "\n configuration\n" );
+ buffer.append( ConfigurationUtil.list( this.getConfiguration() ) );
return buffer.toString();
}
- /**
- * Returns a configuration resource form a jar file.
- * @param path the package path to the resource e.g. net/osm/xinfo.xml
- * @exception ConfigurationException if there is a configuration load error
- */
- private static Configuration loadConfiguration( String path )
- throws ConfigurationException
+ /**
+ * Returns a configuration resource form a jar file.
+ * @param path the package path to the resource e.g. net/osm/xinfo.xml
+ * @exception ConfigurationException if there is a configuration load error
+ */
+ private static Configuration loadConfiguration( String path )
+ throws ConfigurationException
{
try
{
- DefaultConfigurationBuilder builder =
- new DefaultConfigurationBuilder( );
- InputStream is =
- Thread.currentThread().getContextClassLoader().
+ DefaultConfigurationBuilder builder =
+ new DefaultConfigurationBuilder();
+ InputStream is =
+ Thread.currentThread().getContextClassLoader().
getResourceAsStream( path );
- if( is != null )
+ if( is != null )
{
return builder.build( is );
}
- throw new ConfigurationException(
- "Could not locate configuration from path: " + path );
+ throw new ConfigurationException(
+ "Could not locate configuration from path: " + path );
}
catch( Throwable e )
{
- final String error =
- "Unexpected exception while attempting to load configuration from path: ";
- throw new ConfigurationException( error + path, e );
+ final String error =
+ "Unexpected exception while attempting to load configuration from path: ";
+ throw new ConfigurationException( error + path, e );
}
}
- /**
- * Loads a class given a path in the form <code>org/xyz/MyClass</code>.
- * @param path the resource path
- * @return Class the class loaded from the path
- * @exception Exception if there is a class loading error
- */
+ /**
+ * Loads a class given a path in the form <code>org/xyz/MyClass</code>.
+ * @param path the resource path
+ * @return Class the class loaded from the path
+ * @exception Exception if there is a class loading error
+ */
private static Class loadClass( final String path ) throws Exception
{
- return Thread.currentThread().getContextClassLoader().loadClass( path.replace('/','.'));
+ return Thread.currentThread().getContextClassLoader().loadClass( path.replace( '/', '.' ) );
}
}
1.2 +5 -11 jakarta-avalon-excalibur/merlin/src/java/org/apache/excalibur/merlin/ServiceContext.java
Index: ServiceContext.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/merlin/src/java/org/apache/excalibur/merlin/ServiceContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceContext.java 10 May 2002 17:53:09 -0000 1.1
+++ ServiceContext.java 12 May 2002 13:08:47 -0000 1.2
@@ -7,24 +7,21 @@
*
* Original contribution by OSM SARL, http://www.osm.net
*/
-
package org.apache.excalibur.merlin;
import java.io.File;
-import org.apache.avalon.framework.logger.Logger;
-
import org.apache.avalon.framework.context.DefaultContext;
/**
- * ServiceContext context object to hold command line arguments and
+ * ServiceContext context object to hold command line arguments and
* base directory that is supplied to a <code>Contextualizable</code>
* component.
* @author Stephen McConnell <mc...@osm.net>
*/
-public class ServiceContext extends DefaultContext
+public class ServiceContext
+ extends DefaultContext
{
-
/**
* Argument lookup key.
*/
@@ -37,20 +34,17 @@
private String[] m_args;
private File m_root;
- private String m_name;
- private Logger m_logger;
/**
* Creation of a new ServiceContext.
+ *
* @param args command line arguments
* @param base the base directory
- * @param name the name ??
*/
- public ServiceContext( String[] args, File base, String name )
+ public ServiceContext( String[] args, File base )
{
m_args = args;
m_root = base;
- m_name = name;
super.put( ARGS_KEY, m_args );
super.put( BASE_DIRECTORY_KEY, m_root );
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>