You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ZedroS Schwart <ze...@gmail.com> on 2006/05/01 16:41:47 UTC

Injecting services and static method

Hi

I was reading some doc regarding another issue and I just ran into this
example of service injection :

<page-specification class=". . .">

  <inject property="mailSender" object="service:mymodule.MailSender"/>

</page-specification>

I'm wondering what the difference with an old fashioned "static method"
called let's say "sendMail".

What are the benefits of the service injection ?

It may be a stupid question, I apologize in advance, I'm just curious...

Thanks in advance
ZedroS

RE: Injecting services and static method

Posted by James Carman <ja...@carmanconsulting.com>.
Dependency injection allows you to easily unit test your logic.  If you use
a static method, you can't substitute a "dummy" implementation of the mail
sending logic during unit testing.

-----Original Message-----
From: ZedroS Schwart [mailto:zedros.schwartz@gmail.com] 
Sent: Monday, May 01, 2006 10:42 AM
To: Tapestry users
Subject: Injecting services and static method

Hi

I was reading some doc regarding another issue and I just ran into this
example of service injection :

<page-specification class=". . .">

  <inject property="mailSender" object="service:mymodule.MailSender"/>

</page-specification>

I'm wondering what the difference with an old fashioned "static method"
called let's say "sendMail".

What are the benefits of the service injection ?

It may be a stupid question, I apologize in advance, I'm just curious...

Thanks in advance
ZedroS



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