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/09/24 14:16:56 UTC
cvs commit: jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/store Repository.java Store.java
donaldp 2002/09/24 05:16:56
Modified: src/java/org/apache/avalon/cornerstone/blocks/masterstore
AbstractFileRepository.java RepositoryManager.java
src/java/org/apache/avalon/cornerstone/services/store
Repository.java Store.java
Log:
Moved Cornerstone to Serviceable rather than Composable.
Submitted by: "Steve Short" <ss...@postx.com>
Revision Changes Path
1.8 +18 -18 jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFileRepository.java
Index: AbstractFileRepository.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/masterstore/AbstractFileRepository.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AbstractFileRepository.java 18 May 2002 09:50:38 -0000 1.7
+++ AbstractFileRepository.java 24 Sep 2002 12:16:56 -0000 1.8
@@ -19,9 +19,9 @@
import org.apache.avalon.cornerstone.services.store.Repository;
import org.apache.avalon.excalibur.io.ExtensionFileFilter;
import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.component.Composable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -38,16 +38,16 @@
*/
public abstract class AbstractFileRepository
extends AbstractLogEnabled
- implements Repository, Contextualizable, Composable, Configurable, Initializable
+ implements Repository, Contextualizable, Serviceable, Configurable, Initializable
{
protected static final boolean DEBUG = false;
protected static final String HANDLED_URL = "file://";
protected static final int BYTE_MASK = 0x0f;
- protected static final char[] HEX_DIGITS =
- {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
- };
+ protected static final char[] HEX_DIGITS = new char[]
+ {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
+ };
protected String m_path;
protected String m_destination;
@@ -56,21 +56,21 @@
protected FilenameFilter m_filter;
protected File m_baseDirectory;
- protected ComponentManager m_componentManager;
+ protected ServiceManager m_serviceManager;
protected BlockContext m_context;
protected abstract String getExtensionDecorator();
public void contextualize( final Context context )
{
- final BlockContext blockContext = (BlockContext)context;
+ final BlockContext blockContext = (BlockContext) context;
m_baseDirectory = blockContext.getBaseDirectory();
}
- public void compose( final ComponentManager componentManager )
- throws ComponentException
+ public void service( final ServiceManager serviceManager )
+ throws ServiceException
{
- m_componentManager = componentManager;
+ m_serviceManager = serviceManager;
}
public void configure( final Configuration configuration )
@@ -113,7 +113,7 @@
// Check for absolute path
if( m_path.startsWith( "/" ) )
{
- directory = new File ( m_path );
+ directory = new File( m_path );
}
else
{
@@ -138,7 +138,7 @@
protected AbstractFileRepository createChildRepository()
throws Exception
{
- return (AbstractFileRepository)getClass().newInstance();
+ return (AbstractFileRepository) getClass().newInstance();
}
public Repository getChildRepository( final String childName )
@@ -157,11 +157,11 @@
try
{
- child.compose( m_componentManager );
+ child.service( m_serviceManager );
}
- catch( final ComponentException cme )
+ catch( final ServiceException cme )
{
- throw new RuntimeException( "Cannot compose child " +
+ throw new RuntimeException( "Cannot service child " +
"repository " + childName +
" : " + cme );
}
1.11 +33 -50 jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/masterstore/RepositoryManager.java
Index: RepositoryManager.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/masterstore/RepositoryManager.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- RepositoryManager.java 17 Aug 2002 02:24:24 -0000 1.10
+++ RepositoryManager.java 24 Sep 2002 12:16:56 -0000 1.11
@@ -13,16 +13,16 @@
import org.apache.avalon.cornerstone.services.store.Repository;
import org.apache.avalon.cornerstone.services.store.Store;
import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.component.Component;
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.component.ComponentManager;
-import org.apache.avalon.framework.component.Composable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.container.ContainerUtil;
/**
* @phoenix:block
@@ -32,7 +32,7 @@
*/
public class RepositoryManager
extends AbstractLogEnabled
- implements Store, Contextualizable, Composable, Configurable
+ implements Store, Contextualizable, Serviceable, Configurable
{
private static final String REPOSITORY_NAME = "Repository";
private static long id = 0;
@@ -40,7 +40,7 @@
protected HashMap m_repositories = new HashMap();
protected HashMap m_models = new HashMap();
protected HashMap m_classes = new HashMap();
- protected ComponentManager m_componentManager;
+ protected ServiceManager m_serviceManager;
protected Context m_context;
public void contextualize( final Context context )
@@ -48,10 +48,10 @@
m_context = context;
}
- public void compose( final ComponentManager componentManager )
- throws ComponentException
+ public void service( final ServiceManager serviceManager )
+ throws ServiceException
{
- m_componentManager = componentManager;
+ m_serviceManager = serviceManager;
}
public void configure( final Configuration configuration )
@@ -96,30 +96,27 @@
}
}
- public void release( final Component component )
+ public void release( final Object service )
{
}
- public boolean hasComponent( final Object hint )
+ public boolean isSelectable( final Object policy )
{
- if( hint instanceof Configuration )
- return true;
- else
- return false;
+ return ( policy instanceof Configuration );
}
- public Component select( final Object hint )
- throws ComponentException
+ public Object select( final Object policy )
+ throws ServiceException
{
Configuration repConf = null;
try
{
- repConf = (Configuration)hint;
+ repConf = (Configuration) policy;
}
catch( final ClassCastException cce )
{
- throw new ComponentException( "Hint is of the wrong type. " +
- "Must be a Configuration", cce );
+ throw new ServiceException( "Hint is of the wrong type. " +
+ "Must be a Configuration", cce );
}
URL destination = null;
@@ -129,21 +126,21 @@
}
catch( final ConfigurationException ce )
{
- throw new ComponentException( "Malformed configuration has no " +
- "destinationURL attribute", ce );
+ throw new ServiceException( "Malformed configuration has no " +
+ "destinationURL attribute", ce );
}
catch( final MalformedURLException mue )
{
- throw new ComponentException( "destination is malformed. " +
- "Must be a valid URL", mue );
+ throw new ServiceException( "destination is malformed. " +
+ "Must be a valid URL", mue );
}
try
{
final String type = repConf.getAttribute( "type" );
final String repID = destination + type;
- Repository reply = (Repository)m_repositories.get( repID );
- final String model = (String)repConf.getAttribute( "model" );
+ Repository reply = (Repository) m_repositories.get( repID );
+ final String model = (String) repConf.getAttribute( "model" );
if( null != reply )
{
@@ -155,41 +152,27 @@
{
final String message = "There is already another repository with the " +
"same destination and type but with different model";
- throw new ComponentException( message );
+ throw new ServiceException( message );
}
}
else
{
final String protocol = destination.getProtocol();
- final String repClass = (String)m_classes.get( protocol + type + model );
+ final String repClass = (String) m_classes.get( protocol + type + model );
getLogger().debug( "Need instance of " + repClass + " to handle: " +
protocol + type + model );
try
{
- reply = (Repository)Class.forName( repClass ).newInstance();
+ reply = (Repository) Class.forName( repClass ).newInstance();
+
setupLogger( reply, "repository" );
- if( reply instanceof Contextualizable )
- {
- ( (Contextualizable)reply ).contextualize( m_context );
- }
-
- if( reply instanceof Composable )
- {
- ( (Composable)reply ).compose( m_componentManager );
- }
-
- if( reply instanceof Configurable )
- {
- ( (Configurable)reply ).configure( repConf );
- }
-
- if( reply instanceof Initializable )
- {
- ( (Initializable)reply ).initialize();
- }
+ ContainerUtil.contextualize( reply, m_context );
+ ContainerUtil.service( reply, m_serviceManager );
+ ContainerUtil.configure( reply, repConf );
+ ContainerUtil.initialize( reply );
m_repositories.put( repID, reply );
m_models.put( repID, model );
@@ -202,13 +185,13 @@
final String message = "Cannot find or init repository: " + e.getMessage();
getLogger().warn( message, e );
- throw new ComponentException( message, e );
+ throw new ServiceException( message, e );
}
}
}
catch( final ConfigurationException ce )
{
- throw new ComponentException( "Malformed configuration", ce );
+ throw new ServiceException( "Malformed configuration", ce );
}
}
1.3 +0 -3 jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/store/Repository.java
Index: Repository.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/store/Repository.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Repository.java 11 Dec 2001 10:49:21 -0000 1.2
+++ Repository.java 24 Sep 2002 12:16:56 -0000 1.3
@@ -7,15 +7,12 @@
*/
package org.apache.avalon.cornerstone.services.store;
-import org.apache.avalon.framework.component.Component;
-
/**
* Generic Repository interface
*
* @author <a href="mailto:fede@apache.org">Federico Barbieri</a>
*/
public interface Repository
- extends Component
{
Repository getChildRepository( String childName );
}
1.7 +6 -7 jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/store/Store.java
Index: Store.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/services/store/Store.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Store.java 16 Mar 2002 00:18:36 -0000 1.6
+++ Store.java 24 Sep 2002 12:16:56 -0000 1.7
@@ -7,20 +7,19 @@
*/
package org.apache.avalon.cornerstone.services.store;
-import org.apache.avalon.framework.component.Component;
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.component.ComponentSelector;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceSelector;
/**
* @author Federico Barbieri <fe...@apache.org>
*/
public interface Store
- extends ComponentSelector
+ extends ServiceSelector
{
String ROLE = Store.class.getName();
/**
- * This method accept a Configuration object as hint and return the
+ * This method accept a Configuration object as policy and returns the
* corresponding Repository.
* The Configuration must be in the form of:
* <repository destinationURL="[URL of this repository]"
@@ -29,6 +28,6 @@
* [addition configuration]
* </repository>
*/
- Component select( Object hint )
- throws ComponentException;
+ Object select( Object policy )
+ throws ServiceException;
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>