The named components seems like it might be a useful addition. The parameter
stuff I'm not so sure about. I can see it's useful in simple cases, but it
does lack flexibility, plus adds complexity to components.xml.

Coincidentally, I've just this minute written some code that configures my
LuceneIndexer equivalent, and the way I did it was the following:

    <component>
        <scope>application</scope>
        <class>com.blah.config.DefaultConfig</class>
        <enabler>com.blah.config.ConfigurationAware</enabler>
    </component>

    <component>
        <scope>application</scope>
        <class>com.blah.search.lucene.LuceneIndexStore</class>
        <enabler>com.blah.search.IndexerAware</enabler>
    </component>

DefaultConfig implements Config, and ConfigurationAware is just:

public interface ConfigurationAware {
    public void setConfig(Config config);
}

LuceneIndexStore implements ConfigurationAware, so it gets a copy of the
DefaultConfig object without any extra effort required. The DefaultConfig is
a generic piece of code that loads a properties file and makes the
properties available via Config.getStringProperty(key, default),
Config.getBooleanProperty(key, default) etc.

This works quite nicely, because anytime I add a new component that needs
some parameters passed, I just make it implement ConfigurationAware add the
params to my properties file and the component has access to them. Plus I
can of course plug in a JDBCConfiguration or whatever at a later date.

Hope this helps?

"BOGAERT Mathias" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Guys,
>
> I think it would be a good idea to extend the use of components.xml to
> include parameters (same way as interceptors accept parameters).
>
>     <component>
>         <scope>application</scope>
>         <class>com.intrasoft.search.lucene.LuceneIndexer</class>
>         <enabler>com.intrasoft.search.IndexerAware</enabler>
>         <param name="indexDir">lucene-index</param>
>     </component>
>
> Or in a new format:
>
>     <component name="indexer" scope="application">
>         <class>com.intrasoft.search.lucene.LuceneIndexer</class>
>         <enabler>com.intrasoft.search.IndexerAware</enabler>
>         <param name="indexDir">lucene-index</param>
>     </component>
>
> This will call setIndexDir on LuceneIndexer using Jakarta BeanUtils.
> Giving each component a unique name also has another advantage:
>
> ComponentManager cm = (ComponentManager)
> ServletActionContext.getRequest().getAttribute("DefaultComponentManager");
> Indexer indexer = (Indexer) cm.getComponent("indexer");
>
> Good idea?
>
> Cheers,
> Mathias
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php





-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to