You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Davor Hrg <hr...@gmail.com> on 2007/04/12 15:02:40 UTC

t5 - tapestry-ioc auto-wiring

I started converting a small project from hivemind to tapestry-ioc,

this was just to compare experiences...

most of it went fine, but when it came to auto-wiring, it got
overcomplicated.

auto-wiring works for parameters in module's build-methods,
but this still means that I have to manually construct the service
and set the dependencies provided in build method parameters.

for example:
   public ICronService buildCron(
      RegistryShutdownHub hub,
      UserService userService,
      Log log,
   ){
        CronService cron = new CronService(hub, userService, log);
        cron.start();
        return cron;
   }

this could be shorter (provided that container creates instance nad
autowires properties)

   public ICronService buildCron(CronService cron){
        cron.start();
        return cron;
   }


the problem here is not in ammout of writing
(the latter code is little confusing also)
the problem lies in the fact that if I add another dependancy:
 - create field
 - create setter
this was enough in hivemind, but in tapestry-ioc
I have to change the build method:
 - add an extra parameter
 - call the setter

any thoughts on this ?
any plans ?

Davor Hrg

Re: t5 - tapestry-ioc auto-wiring

Posted by Davor Hrg <hr...@gmail.com>.
that's a nice and clean approach for simple services,
less code...
but builder methods should have access to auto-wiring also,
...

Davor Hrg

On 4/13/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>
> Yep, I'm in the middle of changes where you'll be able to specify a
> class as a service and T5 IoC will perform injections o n the class'
> constructor. It's inspired by Guice.  So for a simple service, it will
> look like:
>
> public class MyModule {
>
>   public void bind(ServiceBinder binder) {
>    binder.bind(MyService.class, MyServiceImpl.class);
>   }
>
> Your example, though, is one that will continue to operate the
> traditional way (when there's more involved than dependency injection
> via constructor).
>
>
>
> On 4/12/07, Davor Hrg <hr...@gmail.com> wrote:
> > I started converting a small project from hivemind to tapestry-ioc,
> >
> > this was just to compare experiences...
> >
> > most of it went fine, but when it came to auto-wiring, it got
> > overcomplicated.
> >
> > auto-wiring works for parameters in module's build-methods,
> > but this still means that I have to manually construct the service
> > and set the dependencies provided in build method parameters.
> >
> > for example:
> >    public ICronService buildCron(
> >       RegistryShutdownHub hub,
> >       UserService userService,
> >       Log log,
> >    ){
> >         CronService cron = new CronService(hub, userService, log);
> >         cron.start();
> >         return cron;
> >    }
> >
> > this could be shorter (provided that container creates instance nad
> > autowires properties)
> >
> >    public ICronService buildCron(CronService cron){
> >         cron.start();
> >         return cron;
> >    }
> >
> >
> > the problem here is not in ammout of writing
> > (the latter code is little confusing also)
> > the problem lies in the fact that if I add another dependancy:
> >  - create field
> >  - create setter
> > this was enough in hivemind, but in tapestry-ioc
> > I have to change the build method:
> >  - add an extra parameter
> >  - call the setter
> >
> > any thoughts on this ?
> > any plans ?
> >
> > Davor Hrg
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: t5 - tapestry-ioc auto-wiring

Posted by Howard Lewis Ship <hl...@gmail.com>.
Yep, I'm in the middle of changes where you'll be able to specify a
class as a service and T5 IoC will perform injections o n the class'
constructor. It's inspired by Guice.  So for a simple service, it will
look like:

public class MyModule {

  public void bind(ServiceBinder binder) {
   binder.bind(MyService.class, MyServiceImpl.class);
  }

Your example, though, is one that will continue to operate the
traditional way (when there's more involved than dependency injection
via constructor).



On 4/12/07, Davor Hrg <hr...@gmail.com> wrote:
> I started converting a small project from hivemind to tapestry-ioc,
>
> this was just to compare experiences...
>
> most of it went fine, but when it came to auto-wiring, it got
> overcomplicated.
>
> auto-wiring works for parameters in module's build-methods,
> but this still means that I have to manually construct the service
> and set the dependencies provided in build method parameters.
>
> for example:
>    public ICronService buildCron(
>       RegistryShutdownHub hub,
>       UserService userService,
>       Log log,
>    ){
>         CronService cron = new CronService(hub, userService, log);
>         cron.start();
>         return cron;
>    }
>
> this could be shorter (provided that container creates instance nad
> autowires properties)
>
>    public ICronService buildCron(CronService cron){
>         cron.start();
>         return cron;
>    }
>
>
> the problem here is not in ammout of writing
> (the latter code is little confusing also)
> the problem lies in the fact that if I add another dependancy:
>  - create field
>  - create setter
> this was enough in hivemind, but in tapestry-ioc
> I have to change the build method:
>  - add an extra parameter
>  - call the setter
>
> any thoughts on this ?
> any plans ?
>
> Davor Hrg
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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