cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Michels <step...@apache.org>
Subject Re: Defining Source Interfaces
Date Mon, 06 Jan 2003 18:57:40 GMT


On Mon, 6 Jan 2003, Sylvain Wallez wrote:

> Stephan Michels wrote:
>
> >On Mon, 6 Jan 2003, Sylvain Wallez wrote:
> >
> >>Stephan Michels wrote:
> >>
> >>
> >>>>>   /** Return the parent source. Returns null if the source hasn't
a
> >>>>>parent. */
> >>>>>   public Source getParentSource() throws ProcessingException,
> >>>>>IOException;
> >>>>>}
> >>>>>
> >>>I don't return Sources, because Sources can be Components, which
> >>>must be resolved/released by the SourceResolver.
> >>>So I think returning the URI instead of the Sources is a must-have.
> >>>
> >>I disagree : the SourceResolver is used to get a Source from its URL,
> >>but a Source is not a component : the component is the SourceFactory
> >>that creates Source instances. A source itself is not managed by a
> >>ServiceManager.
> >>
> >>
> >
> >But can managed by the SourceResolver.
> >
>
> Can you elaborate ? I was meaning that a source has no defined
> lifecycle. Even the release that is managed by the factory and not the
> source itself.
>
> >>Also, having to hop through the SourceResolver to get parents or
> >>children of a Source *really hits performance*, as each call to
> >>resolve() looks up/releases the factory, asks it to create the source,
> >>etc, etc.
> >>
> >>
> >
> >But if the creation of the Sources is expensive, is is easier to create
> >a SourceResolver, which holds a pool of the sources.
> >
> >
>
> Can you elaborate again ? You can only manage a pool of equivalent
> objects that can be reused. Sources don't fall in this category, as a
> Source is intimately tied to its URI and the range of URIs is infinite.

URI can be infinite, be most of the computer does have an infinite
filesystem, especially cocoon webapps ;-)

> >>So, considering that the SourceResolver is one of the most used
> >>components, removing release() from this interface may lead to a
> >>significant performance increase.
> >>
> >>
> >
> >That can be, but a resolve/release has much cleaner lifecycle. For
> >example, if the Source lookup for a component using the componentmanager,
> >which got the Source by the Composable contract, the component must
> >release the component, if the Source were disposed.
> >
> >
>
> Sorry, I don't understand what you mean above :-/

class MySource implements Source,Composable,Disposable
{
 private Component used;

 public compose(ComponentManager cm)
 {
  used = cm.lookup("whatever");
 }

 public dispose()
 {
  cm.release(used);
 }
}

Something like that ;-) Of cause, you can write

class MySource implements Source,Composable,Disposable
{
 private ComponentManager cm;

 public compose(ComponentManager cm)
 {
  this.cm = cm;
 }

 public using()
 {
   used = cm.lookup("whatever");
   used.using();
   cm.release(used);
 }
}

But in the essence, there are examples, which need a lifecycle for a
source object. :-/

Stephan Michels.


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message