Services are ordinary java classes,

difference is only that some objects you will instantiate
by hand, like StringBuffer or File...

Service is a class for which you let tapestry-ioc to
generate instances. You configure which services
are available in your AppModule and define there
how they are created. If you use bind method
then you supply only the Class and let tapestry fill
in dependancies (through constructor).
If you use buildMyService methods then you require
dependacies by liting them as method parameters
and manualy construct your service.

this is how I can explain it, say if it makes any sense,

Davor Hrg



On 9/10/07, Erik Vullings <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I've read the manual about services, but don't get it: It's like seeing
> the
> puzzle pieces, but not the whole. Can someone explain it to me please,
> especially:
>
>    1. How can I use a service to connect to my database? Or should I use
>    Hibernate?
>    2. How can I use a service to access the file system? In the demos,
>    Howard uses a service to access his CD library, and it seems really
> cool,
>    but I have no idea how he does it...
>
> More specifically, I had a struts2 MVC webapp which I'm porting to T5. It
> had three layers: JSP, which maps nicely to HTML templates, Controllers,
> which are myTapestry components and pages, and my DAL, which is still
> there.
> So for every serious class that I need to persist, it has a DAO that does
> it
> for me e.g.:
>
>     public WhateverDAO() {
>         dataSource = new DriverManagerDataSource();
>         dataSource.setDriverClassName(Globals.dbDriver);
>         dataSource.setUrl(Globals.dbURL);
>         dataSource.setUsername(Globals.dbUsername);
>         dataSource.setPassword(Globals.dbPassword);
> ...
> }
>     public List<QandA> retrieve(long poId) throws SQLException {
>         JdbcTemplate jt = new JdbcTemplate(dataSource);
> ...
> }
>
> This does not seem to be the Tapestry way, but can someone show me the
> true
> path :-) A service seems to be the answer... or Hibernate, but I'm not
> sure
> whether that will save me a lot of time.
>
> Thanks,
> Erik
>

Reply via email to