cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Sutic" <leo.su...@inspireinfrastructure.com>
Subject [Propsal][C2/2.1] Cocoon2 component manager hierarchy
Date Mon, 27 Aug 2001 11:01:48 GMT
(I'm posting this both to Cocoon-dev and Avalon-dev, as the subject touches
on both of them.)

The Problem: The sitemap components I write need access to components
besides those available in the default Cocoon2 configuration.

Solution: Define some roles and point user-roles to them.

Why this isn't optimal: This means that every instance of Cocoon will
re-load these roles as there is no system-wide component manager. Thus,
assuming two cocoon webapps in the same Tomcat instance, if both instances
have a threadsafe component there will be two instances of that component.
(For example). Also, one can not easily add a component or reconfigure *all*
C2 webapps from a single file.

What I'd like to have: A way to specify a parent component manager for
Cocoon and generally for servlets. I'll discuss Cocoon here, as an example.
I'm leaning towards letting Cocoon implement Composable, with the option of
letting the ComponentManager parameter be the empty (non null) component
manager.

The CocoonServlet would use this pattern to retrieve the parent component
manager:

<init-param>
	<name>parent-component-manager</name>
	<value>MyComponentManager</value>
</init-param>

.
.
.

String parentComponentManagerClass =
conf.getInitParameter("parent-component-manager");
ComponentManager parentComponentManager = null;
if (parentComponentManagerClass != null)
	parentComponentManager = (ComponentManager) ClassUtils.newInstance
(parentComponentManagerClass);
} else {
	parentComponentManager = new ExcaliburComponentManager ();
}

if (parentComponentManager instanceof Initializable) {
	parentComponentManager.initialize ();
}

.
.
.

this.cocoon.compose (parentComponentManager);

.
.
.

Now for the Avalon parts: This would be even clearer if one could implement
the Factory pattern here by having a parent component manager Factory
instead of a parent component manager:

<init-param>
	<name>parent-component-manager-factory</name>
	<value>MyComponentManagerFactory</value>
</init-param>

.
.
.

String parentComponentManagerFactoryClass =
conf.getInitParameter("parent-component-manager-factory");
ComponentManager parentComponentManager = null;
if (parentComponentManagerFactoryClass != null)
	parentComponentManagerFactory = (ComponentManagerFactory)
ClassUtils.newInstance (parentComponentManagerFactoryClass);
}

.
.
.

if (parentComponentManagerFactory != null) {
	this.cocoon.compose (parentComponentManagerFactory.newComponentManager ());
} else {
      ExcaliburComponentManager empty = new ExcaliburComponentManager ();
	empty.initialize ();
	this.cocoon.compose (empty);
}

SUMMARY:

What is needed:
 - (Avalon) A ComponentManagerFactory interface defined like this:

public interface ComponentManagerFactory {
	public ComponentManager newComponentManager ();
}

 - (Cocoon2) Let Cocoon implement composable. Let it use the CM passed to
compose as a parent component manager.

 - (Cocoon2) Let Cocoon load a ComponentManagerFactory based on the
parent-component-manager-factory parameter in web.xml.

BENEFITS:

 - (Avalon/Cocoon2) A standardized way of passing parent component managers
to servlets. Thus making configuration easier.

/LS


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


Mime
View raw message