You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2002/09/22 10:11:54 UTC
cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly ServiceRegistry.java
mcconnell 2002/09/22 01:11:54
Modified: assembly/src/java/org/apache/excalibur/merlin/assembly
ServiceRegistry.java
Log:
Updates to sync. with meta package changes.
Revision Changes Path
1.3 +49 -12 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ServiceRegistry.java
Index: ServiceRegistry.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ServiceRegistry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServiceRegistry.java 12 Sep 2002 11:05:52 -0000 1.2
+++ ServiceRegistry.java 22 Sep 2002 08:11:54 -0000 1.3
@@ -16,7 +16,7 @@
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.excalibur.meta.info.ReferenceDescriptor;
-import org.apache.excalibur.meta.info.Service;
+import org.apache.excalibur.meta.info.ServiceDefinition;
import org.apache.excalibur.meta.info.builder.ServiceBuilder;
import org.apache.excalibur.meta.verifier.VerifyException;
@@ -34,12 +34,18 @@
// state
//=======================================================================
+ /**
+ * The service builder.
+ */
private ServiceBuilder m_builder = new ServiceBuilder();
+ /**
+ * The classloader assigned to the registry.
+ */
private ClassLoader m_classloader;
/**
- * Service types keyed by classname.
+ * ServiceDefinition types keyed by classname.
*/
private Hashtable m_table = new Hashtable();
@@ -55,6 +61,16 @@
*/
public ServiceRegistry( ClassLoader loader, Logger logger )
{
+ if( loader == null )
+ {
+ throw new NullPointerException( "loader" );
+ }
+
+ if( logger == null )
+ {
+ throw new NullPointerException( "logger" );
+ }
+
m_classloader = loader;
super.enableLogging( logger );
m_builder.enableLogging( logger );
@@ -79,11 +95,16 @@
* @param classname the service class name
* @return the service descriptor
*/
- public Service addService( String path ) throws Exception
+ public ServiceDefinition addService( String path ) throws Exception
{
+ if( path == null )
+ {
+ throw new NullPointerException( "path" );
+ }
+
final String classname = path.replace('/','.');
- Service service = getService( classname );
+ ServiceDefinition service = getService( classname );
if( service == null )
{
service= m_builder.build( classname, m_classloader );
@@ -113,8 +134,12 @@
* @param type the service defintion
* @exception VerifyException if the service fails verification
*/
- protected Class getServiceClass( Service service ) throws Exception
+ protected Class getServiceClass( ServiceDefinition service ) throws Exception
{
+ if( service == null )
+ {
+ throw new NullPointerException( "service" );
+ }
return m_classloader.loadClass( service.getClassname() );
}
@@ -122,18 +147,30 @@
* Returns the set of services know to the registry.
* @return the services
*/
- public Service[] getServices()
+ public ServiceDefinition[] getServices()
{
- return (Service[]) m_table.values().toArray( new Service[0] );
+ return (ServiceDefinition[]) m_table.values().toArray( new ServiceDefinition[0] );
}
/**
* Returns the set of services matching a supplied phase.
* @return the set of types capable of supporting the stage.
*/
- public Service getService( ReferenceDescriptor reference )
+ public ServiceDefinition getService( ReferenceDescriptor reference )
{
- Service service = (Service) m_table.get( reference.getClassname() );
+ if( reference == null )
+ {
+ throw new NullPointerException( "reference" );
+ }
+
+ ServiceDefinition service =
+ (ServiceDefinition) m_table.get( reference.getClassname() );
+
+ if( service == null )
+ {
+ return null;
+ }
+
if( service.matches( reference ) )
{
return service;
@@ -145,9 +182,9 @@
* Returns a registered component type.
* @return the component type from the registry or null if the type is unknown
*/
- public Service getService( String classname )
+ public ServiceDefinition getService( String classname )
{
- return (Service) m_table.get( classname );
+ return (ServiceDefinition) m_table.get( classname );
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>