mcconnell 02/03/03 15:08:26
Modified: enterprise/tools build.xml
enterprise/tools/lib merlin.jar
enterprise/tools/src/etc LICENSE.HTML
enterprise/tools/src/java/org/apache/avalon/excalibur/service
DefaultServiceManager.java ServiceFactory.java
ServiceLoader.java UnitInfo.java package.html
Log:
addition of support for mpool Pool interface and backward compatabily
for Composable targets
Revision Changes Path
1.2 +24 -1 jakarta-avalon-apps/enterprise/tools/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-apps/enterprise/tools/build.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- build.xml 3 Mar 2002 16:44:24 -0000 1.1
+++ build.xml 3 Mar 2002 23:08:26 -0000 1.2
@@ -37,6 +37,8 @@
<property name="enterprise" value=".." />
<property name="tools.path" value="${enterprise}/tools" />
<property name="tools.lib.path" value="${tools.path}/lib" />
+ <property name="excalibur.path" value="../jakarta-avalon-excalibur" />
+
<property name="merlin.jar" value="merlin.jar"/>
@@ -169,7 +171,7 @@
</fileset>
</copy>
<javadoc destdir="${javadoc.root.path}"
- doctitle="<h1>Enterprise Suite Tools Package</h1>"
+ doctitle="<h1>Merlin Service Management</h1>"
noindex="false" author="false"
use="true"
overview="${overview.html}"
@@ -229,6 +231,27 @@
</load>
+ </target>
+
+ <!--
+ Internal utility to update excalibur scratchpad with service package.
+ -->
+
+ <target name="excalibur.context">
+ <available file="${excalibur.path}" type="dir"
property="excalibur.present"/>
+ </target>
+
+ <target name="excalibur.check" depends="excalibur.context"
unless="excalibur.present">
+ <echo message="Excalibur not present under ${excalibur.path}"/>
+ </target>
+
+ <target name="export" depends="excalibur.check" if="excalibur.present">
+ <echo message="Exporting service package to Excalibur."/>
+ <copy toDir="${excalibur.path}/src/scratchpad"
preservelastmodified="true">
+ <fileset dir="${src}/java">
+ <include name="org/apache/avalon/excalibur/service/**"/>
+ </fileset>
+ </copy>
</target>
</project>
1.2 +63 -57 jakarta-avalon-apps/enterprise/tools/lib/merlin.jar
<<Binary file>>
1.2 +1 -1 jakarta-avalon-apps/enterprise/tools/src/etc/LICENSE.HTML
Index: LICENSE.HTML
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/etc/LICENSE.HTML,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LICENSE.HTML 3 Mar 2002 15:45:58 -0000 1.1
+++ LICENSE.HTML 3 Mar 2002 23:08:26 -0000 1.2
@@ -9,7 +9,7 @@
<BODY BGCOLOR="#ffffff">
- <p class="title">Persistent State Service (PSS) <br>Disclaimers,
Licenses and Due Credits</p>
+ <p class="title">License, Disclaimer, and Due Credits</p>
<hr>
1.2 +25 -88
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/DefaultServiceManager.java
Index: DefaultServiceManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/DefaultServiceManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultServiceManager.java 3 Mar 2002 15:45:58 -0000 1.1
+++ DefaultServiceManager.java 3 Mar 2002 23:08:26 -0000 1.2
@@ -14,110 +14,47 @@
/**
- * Internal helper class the implements the service manager interface and
- * is supplied to dynamically crerated componets during service lifecyle
- * pipeline processing.
+ * Internal helper class the implements the <code>ServiceManager</code>
interface and
+ * is supplied to dynamically created componets during lifecyle pipeline
processing.
*/
-class DefaultServiceManager implements ServiceManager
+class DefaultServiceManager extends AbstractManager implements ServiceManager
{
-
- /**
- * Hashtable containing service providers keyed by role name.
- * The manager use the providers in this table to aquire services
- * in response to <code>lookup</code> invocations. Provider
- * types fall into one of the following three catagories:
- *
- * <table>
- * <tr><td><b>Policy</b></td><td><b>Description</b></td><tr>
- * <tr><td>SINGLETON_LIFETIME_POLICY</td><td>
- * Service of the type singleton are distinguished by the fact
- * that they do not inherit from Pool or Transient. The singleton
- * provider object is a reference to the singleton service and is
- * return directly by the implemetation on invocation of lookup.
- * </td>
- * <tr><td>POOLED_LIFETIME_POLICY</td><td>
- * Pooled services implement the Pool interface. The service
- * resolves lookup aquires the pooled service by invoking
- * <code>checkout</code> on the pool implementation. Clients
- * using pooled services are required to release services using
- * the manager <code>release</code> method. The implemetation will
- * attempt to locate the issuing pool and release the object on
- * behalf of the client.
- * </td>
- * <tr><td>TRANSIENT_LIFETIME_POLICY</td><td>
- * A transient provider is factory from which new instances are
- * created and pipelined following a invocation of <code>lookup</code>.
- * The invocing client is totally responsible for service disposal.
- * </td>
- */
- private Hashtable m_providers = new Hashtable();
-
+ /**
+ * Construct ServiceManager.
+ */
public DefaultServiceManager( Hashtable providers ) throws Exception
{
- m_providers = providers;
+ super( providers );
}
+ /**
+ * Returns true if a provider exists for the supplied role.
+ * @param role the service identifier
+ * @return boolean TRUE if the service is available else FALSE
+ */
public boolean hasService( String role )
{
- return (m_providers.get( role ) != null );
+ return super.has( role );
}
+ /**
+ * Retrieve Object by role from ServiceManager.
+ * @param role the role
+ * @return the Object
+ * @exception ServiceException if an error occurs
+ */
public Object lookup( String role ) throws ServiceException
{
- Object provider = m_providers.get( role );
- if( provider == null ) throw new ServiceException(
- "Could not locate a provider for the role: " + role );
-
- if( provider instanceof TransientProvider )
- {
- //
- // return a transient instance
- //
-
- return ((TransientProvider)provider).create( );
- }
-/*
- else if( provider instanceof PooledProvider )
- {
- //
- // return a pooled service
- //
-
- return ((PooledProvider)provider).checkout( );
- }
-*/
- else
- {
- //
- // return a singleton service
- //
-
- return ((SingletonProvider)provider).provide( );
- }
+ return super.resolve( role );
}
+ /**
+ * Release a pooled object.
+ * @param object a pooled object
+ */
public void release( Object object )
{
- //
- // release a pooled service
- //
-/*
- Class c = object.getClass();
- Enumeration providers = m_providers.elements();
- while( providers.hasMoreElements())
- {
- Object provider = providers.nextElement();
- if( provider instanceof PooledProvider )
- {
- PooledProvider pool = (PooledProvider) provider;
- if( pool.getBaseClass().isAssignableFrom( c ) )
- {
- pool.release( object );
- break;
- }
- }
- }
-*/
+ super.disgard( object );
}
}
1.2 +15 -2
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceFactory.java
Index: ServiceFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceFactory.java 3 Mar 2002 15:45:58 -0000 1.1
+++ ServiceFactory.java 3 Mar 2002 23:08:26 -0000 1.2
@@ -46,6 +46,7 @@
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.excalibur.configuration.CascadingConfiguration;
+import org.apache.avalon.excalibur.mpool.Pool;
/**
*
@@ -164,8 +165,20 @@
case UnitInfo.POOLED_LIFETIME_POLICY :
- final String error = "Cannot provide a default provider for a
pool at this time.";
- throw new RuntimeException( error );
+ provider = m_pools.get( provider_class );
+ if( provider == null )
+ {
+ if( m_verbose ) if( getLogger().isDebugEnabled() )
getLogger().debug(
+ "Creating pooled provider for :" +
provider_class.getName());
+
+ // create and pipeline the singleton instance and
+ // add it to the list of singletons
+
+ Object object = pipeline( block_info, info.getRole() );
+ provider = new PooledProvider( (Pool) object,
info.getRole() );
+ m_pools.put( provider_class, provider );
+ }
+ return provider;
default :
1.2 +5 -5
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceLoader.java
Index: ServiceLoader.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/ServiceLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceLoader.java 3 Mar 2002 15:45:58 -0000 1.1
+++ ServiceLoader.java 3 Mar 2002 23:08:26 -0000 1.2
@@ -74,11 +74,11 @@
* <pre>
* <config>
*
- * <block class="com.magic.DirectoryBlock">
+ * <block class="org.apache.DirectoryBlock">
* <-- block specific content -->
* </block>
*
- * <block class="com.magic.ActivatorBlock">
+ * <block class="org.apache.ActivatorBlock">
* <-- block specific content -->
* </block>
*
@@ -208,8 +208,8 @@
* statement.</p>
* <p>An example command line is shown below:</p>
* <pre>
- * $ java -classpath
<strong>merlin.jar;avalon-framework.jar;logkit.jar</strong>
- * org.apache.avalon.excalibur.service.ServiceLoader
+ * $ java -classpath merlin.jar;avalon-framework.jar;logkit.jar
+ * <strong>org.apache.avalon.excalibur.service.ServiceLoader</strong>
* <supporting-jar-files> -target <class-name>
* </pre>
* </ul>
@@ -239,7 +239,7 @@
* <td>
* <p>A value of <code>true</code> will force debug level logging of the
actual pipeline
* processor. A value of <code>false</code> will disable pipeline debug
priority logging.
- * Visibility of logging inffomration is dependent on the level supplied
under the
+ * Visibility of logging infomration is dependent on the level supplied
under the
* <code>priority</code parameter.</p>
* </td></tr>
* <tr><td width="20%" valign="top"><code>-priority
<priority></code></td>
1.2 +12 -4
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/UnitInfo.java
Index: UnitInfo.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/UnitInfo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UnitInfo.java 3 Mar 2002 15:45:58 -0000 1.1
+++ UnitInfo.java 3 Mar 2002 23:08:26 -0000 1.2
@@ -10,6 +10,7 @@
import java.util.Vector;
import org.apache.avalon.framework.CascadingException;
import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.excalibur.mpool.Pool;
/**
* Meta information about a <code>Serviceable</code> component.
@@ -100,18 +101,25 @@
throw new CascadingException( "Could not construct dependency
information.", e );
}
- String policy =
xinfo.getChild("implementation").getAttribute("policy","TRANSIENT");
+ String policy =
xinfo.getChild("implementation").getAttribute("policy","OTHER");
if( policy.equalsIgnoreCase( "SINGLETON" ) )
{
m_policy = SINGLETON_LIFETIME_POLICY;
}
- else if( policy.equalsIgnoreCase( "POOLED" ) )
+ else if( policy.equalsIgnoreCase( "TRANSIENT" ) )
{
- m_policy = POOLED_LIFETIME_POLICY;
+ m_policy = TRANSIENT_LIFETIME_POLICY;
}
else
{
- m_policy = TRANSIENT_LIFETIME_POLICY;
+ if( Pool.class.isAssignableFrom( block ) )
+ {
+ m_policy = POOLED_LIFETIME_POLICY;
+ }
+ else
+ {
+ m_policy = TRANSIENT_LIFETIME_POLICY;
+ }
}
}
1.3 +11 -7
jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/package.html
Index: package.html
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/enterprise/tools/src/java/org/apache/avalon/excalibur/service/package.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- package.html 3 Mar 2002 16:44:24 -0000 1.2
+++ package.html 3 Mar 2002 23:08:26 -0000 1.3
@@ -73,7 +73,7 @@
<p>For each component declared in a manifest, the implementation establishes
the available services
and dependencies based on information contained in an <code>.xinfo</code>
file. Given a component
-implementation class
<strong><code>org/apache/DirectoryBlock.class</code></strong> the
<code>Pipeline</code> processor will attempt to locate a
<strong><code>org/apache/DirectoryBlock.xinfo</code></strong>
+implementation class
<strong><code>org/apache/ReferralBlock.class</code></strong> the
<code>ServiceLoader</code> will attempt to locate a
<strong><code>org/apache/ReferralBlock.xinfo</code></strong>
resource in the jar file.</P>
<pre>
@@ -122,7 +122,7 @@
establish and provide the dependencies via the component
Serviceable
implementation. The role name corresponds to the identifying
string
that the component implementation will use to lookup a service from
- a service manger during the serviceable lifecycle phase.
+ a service manager during the serviceable lifecycle phase.
--></i></font>
<dependency>
@@ -133,10 +133,14 @@
</dependencies>
<font color="blue"><i><!--
- Component implementation policy may one of the following:
+ Component implementation policy may be one of the following:
(a) SINGLETON, service is available for the lifetime of the manager
- (b) POOLED, the implementation implements Pool (implementation pending)
- (c) TRANSIENT, manager is a factory of transient service instances
+ (b) TRANSIENT, manager is a factory of transient service instances
+ (c) OTHER, (default) The container will check if the class implements
+ the org.apache.excalibur.mpool.Pool interface. If true,
<code>lookup</code>
+ and <code>release</code> invocations will be redirected to the pools
<code>aquire</code> and
+ <code>release</code> methods - otherwise, the class will be registered
under the
+ TRANSIENT policy.
--></i></font>
<implementation policy="SINGLETON" />
@@ -149,8 +153,8 @@
<p>The pipeline processor provides support for the automated retrieval of
default
configurations for a component. During lifecycle processing, the pipeline
processor
will attempt to locate a configuration resource with the same path and name
as
-the component implementation class. For example, for the component
<strong><code>org/apache/DirectoryBlock.class</code></strong>, the
implementation will look for
-a default configuration under the resource path
<strong><code>org/apache/DirectoryBlock.conf</code></strong>.
+the component implementation class. For example, for the component
<strong><code>org/apache/RefferalBlock.class</code></strong>, the
implementation will look for
+a default configuration under the resource path
<strong><code>org/apache/RefferalBlock.conf</code></strong>.
During the configuration stage, the pipeline processor will supply the
component with
a <code>CascadingConfiguration</code> where the primary configuration is
configuration
derived from the pipeline processor configuration, and a default
configuration corresponding
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>