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/11/29 17:05:34 UTC
cvs commit: avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition DefaultServiceManager.java AbstractManager.java
mcconnell 2002/11/29 08:05:34
Modified: assembly/src/java/org/apache/avalon/assembly/lifecycle/composition
DefaultServiceManager.java
Removed: assembly/src/java/org/apache/avalon/assembly/lifecycle/composition
AbstractManager.java
Log:
Merged abstract class into the default service manager and incorporated
component proxy classes from framework.
Revision Changes Path
1.2 +46 -10 avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/DefaultServiceManager.java
Index: DefaultServiceManager.java
===================================================================
RCS file: /home/cvs/avalon-sandbox/assembly/src/java/org/apache/avalon/assembly/lifecycle/composition/DefaultServiceManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultServiceManager.java 29 Nov 2002 13:04:54 -0000 1.1
+++ DefaultServiceManager.java 29 Nov 2002 16:05:34 -0000 1.2
@@ -57,25 +57,42 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.assembly.appliance.Appliance;
+import org.apache.avalon.meta.info.DependencyDescriptor;
/**
- * Internal helper class the implements the <code>ServiceManager</code> interface and
- * is supplied to dynamically created componets during lifecyle pipeline processing.
+ * Helper class the implements the <code>ServiceManager</code> interface and
+ * is supplied to componets during lifecyle processing.
* @author Stephen McConnell <mc...@osm.net>
*/
-class DefaultServiceManager
- extends AbstractManager
- implements ServiceManager
+public class DefaultServiceManager implements ServiceManager
{
+
+ //========================================================================
+ // state
+ //========================================================================
+
+ /**
+ * A map of resources keyed by lookup role.
+ */
+ private Appliance m_appliance;
+
+ //========================================================================
+ // constructor
+ //========================================================================
+
/**
* Construct a new ServiceManager.
* @param profile the component profile
*/
public DefaultServiceManager( Appliance appliance )
{
- super( appliance );
+ m_appliance = appliance;
}
+ //========================================================================
+ // ServiceManager
+ //========================================================================
+
/**
* Returns true if a provider exists for the supplied role.
* @param role the service identifier
@@ -83,7 +100,7 @@
*/
public boolean hasService( String role )
{
- return super.has( role );
+ return ( m_appliance.getServiceProvider( role ) != null );
}
/**
@@ -94,13 +111,32 @@
*/
public Object lookup( String role ) throws ServiceException
{
+ if( role == null )
+ {
+ throw new NullPointerException( "role" );
+ }
+
+ DependencyDescriptor dependency =
+ m_appliance.getProfile().getType().getDependency( role );
+ Appliance provider = m_appliance.getServiceProvider( role );
+ if( provider == null )
+ {
+ final String error =
+ "Internal error - incorrect assembly in appliance: " + m_appliance
+ + ". A null provider was retured for the dependency: " + dependency;
+ throw new ServiceException( role, error );
+ }
+
try
{
- return super.get( role );
+ return provider.access( dependency );
}
catch( Throwable e )
{
- final String error = "Service resolution failure for role: " + role;
+ final String error =
+ "Unexpected internal error while accessing a service provider in appliance: "
+ + m_appliance
+ + " for the role: " + role;
throw new ServiceException( role, error, e );
}
}
@@ -111,6 +147,6 @@
*/
public void release( Object object )
{
- super.put( object );
+ m_appliance.release( object );
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>