You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by richard head <du...@hotmail.com> on 2007/07/16 23:57:39 UTC

Chain of Responsibility Catalog, Adding Command Element Attributes

Hi,

I’ve been playing around with the Commons Chain of Responsibility 
implementation and have a question or two. Maybe a chain is not the right 
approach, I’d appreciate any suggestions.

	I’d like to make a Chain that retrieves an XML document, transforms it, and 
emails the results.  3 Commands as I see it. Each of these Commands requires 
information that is independent of the others. XML file’s URL, XSLT 
transformation’s output path, SMTP server etc…

I understand that the preferred method of retaining state is to use the 
Chain’s Context. Yet in this situation is seems inflexible, as the class 
instantiating the chain will be tightly bound to it because it would have to 
anticipate each link and what each link’s Context requirements are.

What I would like to do is use a catalog.xml file to store the chain, and 
add the appropriate attributes to the given command element.

i.e. <command name="EmailUser" className="com.bs.email.Emailer" 
smtpServer=”xyz.abc.com” .../>


In order to achieve such functionality, what would I have to do, set the 
appropriate rules in the ConfigParser’s Digester?

i.e. 
config.getDigester().addSetProperties(“/catalog/chain/command”,”smtpServer”,”smtpServer”)

I would prefer to do this via the Emailer’s constructor, but it appears that 
it’s not possible and one must use getters and setters.

Thank You.

_________________________________________________________________
http://imagine-windowslive.com/hotmail/?locale=en-us&ocid=TXT_TAGHM_migration_HM_mini_2G_0507


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Chain of Responsibility Catalog, Adding Command Element Attributes

Posted by Niall Pemberton <ni...@gmail.com>.
On 7/17/07, richard head <du...@hotmail.com> wrote:
>
> >>What I would like to do is use a catalog.xml file to store the chain, and
> >>add the appropriate attributes to the given command element.
> >>
> >>i.e. <command name="EmailUser" className="com.bs.email.Emailer"
> >>smtpServer="xyz.abc.com" .../>
> >>
> >>
> >>In order to achieve such functionality, what would I have to do, set the
> >>appropriate rules in the ConfigParser's Digester?
> >>
> >>i.e.
> >>config.getDigester().addSetProperties("/catalog/chain/command","smtpServer","smtpServer")
> >
> >You don't have to change the configured digester rules at all -  just
> >add getters/setters as appropriate - so in your case adding
> >setSmtpServer() and getSmtpServer() methods to your Emailer command
> >and when the xml is parsed they will get called with the values you've
> >specified in your xml.
>
> Ok, cool. Though is it possible for these attributes to be classes?

Not quite sure what you mean - do you want something like
setFooClass(Class fooClass)?

Anyway its not something I've tried by AFAIK the set properties rule
in Digester uses BeanUtils.populate() - which uses any registered
Converters - there is one for "Class" - so the above
setFooClass(Class) example should work with the String value specified
in your XML being converted to a Class.

Best way with these types of things is always to give it a go and see
what happens.

Niall

> Thanks

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Chain of Responsibility Catalog, Adding Command Element Attributes

Posted by richard head <du...@hotmail.com>.
>>What I would like to do is use a catalog.xml file to store the chain, and
>>add the appropriate attributes to the given command element.
>>
>>i.e. <command name="EmailUser" className="com.bs.email.Emailer"
>>smtpServer="xyz.abc.com" .../>
>>
>>
>>In order to achieve such functionality, what would I have to do, set the
>>appropriate rules in the ConfigParser's Digester?
>>
>>i.e.
>>config.getDigester().addSetProperties("/catalog/chain/command","smtpServer","smtpServer")
>
>You don't have to change the configured digester rules at all -  just
>add getters/setters as appropriate - so in your case adding
>setSmtpServer() and getSmtpServer() methods to your Emailer command
>and when the xml is parsed they will get called with the values you've
>specified in your xml.

Ok, cool. Though is it possible for these attributes to be classes?

Thanks

_________________________________________________________________
Need a brain boost? Recharge with a stimulating game. Play now!  
http://club.live.com/home.aspx?icid=club_hotmailtextlink1


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Chain of Responsibility Catalog, Adding Command Element Attributes

Posted by Niall Pemberton <ni...@gmail.com>.
On 7/16/07, richard head <du...@hotmail.com> wrote:
> Hi,
>
> I've been playing around with the Commons Chain of Responsibility
> implementation and have a question or two. Maybe a chain is not the right
> approach, I'd appreciate any suggestions.
>
>         I'd like to make a Chain that retrieves an XML document, transforms it, and
> emails the results.  3 Commands as I see it. Each of these Commands requires
> information that is independent of the others. XML file's URL, XSLT
> transformation's output path, SMTP server etc…
>
> I understand that the preferred method of retaining state is to use the
> Chain's Context. Yet in this situation is seems inflexible, as the class
> instantiating the chain will be tightly bound to it because it would have to
> anticipate each link and what each link's Context requirements are.
>
> What I would like to do is use a catalog.xml file to store the chain, and
> add the appropriate attributes to the given command element.
>
> i.e. <command name="EmailUser" className="com.bs.email.Emailer"
> smtpServer="xyz.abc.com" .../>
>
>
> In order to achieve such functionality, what would I have to do, set the
> appropriate rules in the ConfigParser's Digester?
>
> i.e.
> config.getDigester().addSetProperties("/catalog/chain/command","smtpServer","smtpServer")

You don't have to change the configured digester rules at all -  just
add getters/setters as appropriate - so in your case adding
setSmtpServer() and getSmtpServer() methods to your Emailer command
and when the xml is parsed they will get called with the values you've
specified in your xml.

> I would prefer to do this via the Emailer's constructor, but it appears that
> it's not possible and one must use getters and setters.

No its not possible with the XML/Digester configuration provided by
Commons Chain.

Niall

> Thank You.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org