You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Carsten Ziegeler <cz...@s-und-n.de> on 2002/01/28 08:26:50 UTC

RE: cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system ContainerManager.java

Hi Berin,

I'm not so happy with this change!
If you think of Cocoon with having different sitemaps which are located
in different directories, you have actually different base directories
for resolving relative to the sitemap in question.
Or going one thing further, if you thing of a servlet engine having
several context directories, one for each web application, then you need
perhaps a SourceResolver for each application.

What do you think?

Carsten

> -----Original Message-----
> From: bloritsch@apache.org [mailto:bloritsch@apache.org]
> Sent: Friday, January 25, 2002 10:13 PM
> To: jakarta-avalon-excalibur-cvs@apache.org
> Subject: cvs commit:
> jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/syst
> em ContainerManager.java
>
>
> 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/excalibu
> r/source/SourceResolver.java
>
>   Index: SourceResolver.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalo
> n/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:cziegeler@apache.org">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/excalibu
> r/source/SourceResolverImpl.java
>
>   Index: SourceResolverImpl.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalo
> n/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:cziegeler@apache.org">Carsten Ziegeler</a>
>     * @author <a href="mailto:bloritsch@apache.org">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/excalibu
> r/system/ContainerManager.java
>
>   Index: ContainerManager.java
>   ===================================================================
>   RCS file:
> /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalo
> n/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:bloritsch@apache.org">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:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system ContainerManager.java

Posted by Berin Loritsch <bl...@apache.org>.
Carsten Ziegeler wrote:

> 
>>We need to start thinking of the Sitemap as a Container as well
>>as the root
>>Cocoon object.
>>
>>
> Oh, sorry, I didn't look into the Container concept, so if it is possible
> to have a different threadsafe component for a container (which makes sense,
> I think), it's great!


It absolutely is.  In fact, this is what Peter argues for when trying to
get rid of the ComponentSelector interface.  In this case, it makes more
sense than one component for the whole system.


-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system ContainerManager.java

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Berin Loritsch  wrote:
>
> Carsten Ziegeler wrote:
>
> > Hi Berin,
> >
> > I'm not so happy with this change!
> > If you think of Cocoon with having different sitemaps which are located
> > in different directories, you have actually different base directories
> > for resolving relative to the sitemap in question.
>
>
> This is where the concept of a Container comes in.  More below.
>
>
> > Or going one thing further, if you thing of a servlet engine having
> > several context directories, one for each web application, then you need
> > perhaps a SourceResolver for each application.
> >
> > What do you think?
>
>
> I understand your concerns, and I have addressed it in this way:
>
> Each Servlet Context is a separate and distinct "container".  In Cocoon,
> Each Sitemap is it's own container.  Therefore, if each Container has
> its own Resolver, they all resolve properly.
>
> You just have to make sure that the "container.root" context entry is
> set uniquely for each Container.
>
> If you want to make it one Resolver for an entire environment, you either
> pass the context with the request, or use the manual base URI entries.
>
Yes, this is the door I left open...:)

> We need to start thinking of the Sitemap as a Container as well
> as the root
> Cocoon object.
>
Oh, sorry, I didn't look into the Container concept, so if it is possible
to have a different threadsafe component for a container (which makes sense,
I think), it's great!

Thanks,
Carsten


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/system ContainerManager.java

Posted by Berin Loritsch <bl...@apache.org>.
Carsten Ziegeler wrote:

> Hi Berin,
> 
> I'm not so happy with this change!
> If you think of Cocoon with having different sitemaps which are located
> in different directories, you have actually different base directories
> for resolving relative to the sitemap in question.


This is where the concept of a Container comes in.  More below.


> Or going one thing further, if you thing of a servlet engine having
> several context directories, one for each web application, then you need
> perhaps a SourceResolver for each application.
> 
> What do you think?


I understand your concerns, and I have addressed it in this way:

Each Servlet Context is a separate and distinct "container".  In Cocoon,
Each Sitemap is it's own container.  Therefore, if each Container has
its own Resolver, they all resolve properly.

You just have to make sure that the "container.root" context entry is
set uniquely for each Container.

If you want to make it one Resolver for an entire environment, you either
pass the context with the request, or use the manual base URI entries.

We need to start thinking of the Sitemap as a Container as well as the root
Cocoon object.




-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>