bloritsch 02/01/25 13:12:56
Modified: src/scratchpad/org/apache/avalon/excalibur/source
SourceResolver.java SourceResolverImpl.java
src/scratchpad/org/apache/avalon/excalibur/system
ContainerManager.java
Log:
make SourceResolver able to be ThreadSafe--baseURL always keyed off of
'container.rootDir'. Any new Container that uses this will have a new
container.rootDir to use.
Revision Changes Path
1.8 +1 -12
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/SourceResolver.java
Index: SourceResolver.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/SourceResolver.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SourceResolver.java 8 Jan 2002 13:43:48 -0000 1.7
+++ SourceResolver.java 25 Jan 2002 21:12:56 -0000 1.8
@@ -30,24 +30,13 @@
* like Composable, Initializable, Disposable etc.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
- * @version CVS $Revision: 1.7 $ $Date: 2002/01/08 13:43:48 $
+ * @version CVS $Revision: 1.8 $ $Date: 2002/01/25 21:12:56 $
*/
public interface SourceResolver
extends Component {
String ROLE = "org.apache.avalon.excalibur.source.SourceResolver";
-
- /**
- * Set the base URL. All relative references are resolved
- * according to this URL.
- */
- void setBaseURL(URL base);
-
- /**
- * Get the base URL
- */
- URL getBaseURL();
/**
* Get a <code>Source</code> object.
1.13 +25 -59
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/SourceResolverImpl.java
Index: SourceResolverImpl.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/source/SourceResolverImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SourceResolverImpl.java 18 Jan 2002 21:33:44 -0000 1.12
+++ SourceResolverImpl.java 25 Jan 2002 21:12:56 -0000 1.13
@@ -7,7 +7,6 @@
*/
package org.apache.avalon.excalibur.source;
-import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
@@ -22,6 +21,8 @@
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.avalon.excalibur.pool.Recyclable;
import java.io.File;
import java.io.IOException;
@@ -50,7 +51,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version $Id: SourceResolverImpl.java,v 1.12 2002/01/18 21:33:44
bloritsch Exp $
+ * @version $Id: SourceResolverImpl.java,v 1.13 2002/01/25 21:12:56
bloritsch Exp $
*/
public class SourceResolverImpl
extends AbstractLogEnabled
@@ -58,27 +59,22 @@
Contextualizable,
Disposable,
SourceResolver,
- Recyclable
+ ThreadSafe
{
/** The component manager */
- protected ComponentManager manager;
+ protected ComponentManager m_manager;
/** The special Source factories */
- protected ComponentSelector factorySelector;
+ protected ComponentSelector m_factorySelector;
/** The context */
- protected Context context;
+ protected Context m_context;
/**
* The base URL
*/
- protected URL baseURL;
-
- /**
- * The user directory
- */
- protected URL userDirectory;
+ protected URL m_baseURL;
/**
* Get the context
@@ -86,21 +82,21 @@
public void contextualize(Context context)
throws ContextException
{
- this.context = context;
+ m_context = context;
try
{
- this.userDirectory = ((File)
this.context.get("container.rootDir")).toURL();
+ m_baseURL = ((File) m_context.get("container.rootDir")).toURL();
}
catch (ContextException ce)
{
// set the base URL to the current directory
try
{
- this.userDirectory = new
File(System.getProperty("user.dir")).toURL();
+ m_baseURL = new File(System.getProperty("user.dir")).toURL();
if ( this.getLogger().isDebugEnabled() )
{
- this.getLogger().debug("SourceResolver: Using base
directory: " + this.userDirectory);
+ this.getLogger().debug("SourceResolver: Using base URL:
" + m_baseURL);
}
}
catch (MalformedURLException mue)
@@ -112,8 +108,6 @@
{
throw new ContextException("Malformed URL for
container.rootDir", mue);
}
-
- this.baseURL = this.userDirectory;
}
/**
@@ -123,8 +117,8 @@
public void compose(ComponentManager manager)
throws ComponentException
{
- this.manager = manager;
- this.factorySelector =
(ComponentSelector)this.manager.lookup(SourceFactory.ROLE + "Selector");
+ m_manager = manager;
+ m_factorySelector =
(ComponentSelector)m_manager.lookup(SourceFactory.ROLE + "Selector");
}
/**
@@ -132,48 +126,20 @@
*/
public void dispose()
{
- if (this.manager != null)
+ if (m_manager != null)
{
- this.manager.release(this.factorySelector);
- this.factorySelector = null;
+ m_manager.release(m_factorySelector);
+ m_factorySelector = null;
}
}
/**
- * Recycle: reset the base dir
- */
- public void recycle()
- {
- this.baseURL = this.userDirectory;
- }
-
- /**
- * Set the base URL. All relative references are resolved
- * according to this URL.
- */
- public void setBaseURL(URL base)
- {
- if ( this.getLogger().isDebugEnabled() ) {
- this.getLogger().debug("Changing baseURL to: " + base);
- }
- this.baseURL = base;
- }
-
- /**
- * Get the base URL
- */
- public URL getBaseURL()
- {
- return this.baseURL;
- }
-
- /**
* Get a <code>Source</code> object.
*/
public Source resolve(String location)
throws MalformedURLException, IOException, ComponentException
{
- return this.resolve(this.baseURL, location, null);
+ return this.resolve(m_baseURL, location, null);
}
/**
@@ -183,7 +149,7 @@
SourceParameters parameters)
throws MalformedURLException, IOException, ComponentException
{
- return this.resolve( this.baseURL, location, parameters );
+ return this.resolve( m_baseURL, location, parameters );
}
/**
@@ -211,7 +177,7 @@
// first step: create systemID
String systemID;
- if (base == null) base = this.baseURL;
+ if (base == null) base = m_baseURL;
if (location.length() == 0) {
systemID = base.toExternalForm();
@@ -262,17 +228,17 @@
if ( protocolPos != -1 )
{
final String protocol = systemID.substring(0, protocolPos);
- if ( this.factorySelector.hasComponent(protocol) )
+ if ( m_factorySelector.hasComponent(protocol) )
{
SourceFactory factory = null;
try
{
- factory = ( SourceFactory )this.factorySelector.select(
protocol );
+ factory = ( SourceFactory )m_factorySelector.select(
protocol );
source = factory.getSource( systemID, parameters );
}
finally
{
- this.factorySelector.release( factory );
+ m_factorySelector.release( factory );
}
}
}
@@ -306,7 +272,7 @@
{
if (source instanceof Contextualizable)
{
- ((Contextualizable) source).contextualize (this.context);
+ ((Contextualizable) source).contextualize (m_context);
}
}
catch (ContextException ce)
@@ -316,7 +282,7 @@
if (source instanceof Composable)
{
- ((Composable) source).compose(this.manager);
+ ((Composable) source).compose(m_manager);
}
return source;
}
1.8 +26 -4
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerManager.java
Index: ContainerManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system/ContainerManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ContainerManager.java 25 Jan 2002 20:48:34 -0000 1.7
+++ ContainerManager.java 25 Jan 2002 21:12:56 -0000 1.8
@@ -27,7 +27,6 @@
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
-import org.apache.avalon.excalibur.component.RoleManager;
import org.apache.avalon.excalibur.logger.LoggerManager;
import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
import org.apache.avalon.excalibur.util.ComponentStateValidator;
@@ -136,7 +135,7 @@
* </table>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Revision: 1.7 $ $Date: 2002/01/25 20:48:34 $
+ * @version CVS $Revision: 1.8 $ $Date: 2002/01/25 21:12:56 $
*/
public class ContainerManager
{
@@ -404,9 +403,13 @@
{
if ( null == m_componentManager )
{
- m_componentManager = new DefaultComponentManager();
+ DefaultComponentManager manager = new DefaultComponentManager();
String parser = m_initialParameters.getParameter(XML_PARSER,
"org.apache.avalon.excalibur.xml.JaxpParser");
//manager.put();
+
+ SourceResolver
+
+ m_componentManager = manager;
}
return m_componentManager;
@@ -421,7 +424,26 @@
{
if ( null == m_roleManager )
{
- m_roleManager = (RoleManager) new ExcaliburRoleManager();
+ if ( null == m_roleConfig )
+ {
+ m_roleManager = new ExcaliburRoleManager();
+ }
+ else
+ {
+ ExcaliburRoleManager erm = new ExcaliburRoleManager();
+ ConfigurableRoleManager crm = new ConfigurableRoleManager(
erm );
+
+ try
+ {
+ crm.configure( m_roleConfig );
+ m_roleManager = crm;
+ }
+ catch ( Exception e )
+ {
+ this.m_defaultLogger.warn("There was a problem with the
role configuration, defaulting to ExcaliburComponentManager.", e);
+ m_roleManager = erm;
+ }
+ }
}
return m_roleManager;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>