You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Domenico Fiorilli <do...@gmail.com> on 2014/02/13 17:43:46 UTC

Services on Tapestry

Hi,
I'm developing on application in Tapestry and I have this problem:

I have some classes in java that they need to use a HibernateSession. I
read that to do that, those classes must be execute as well as Services.
But those classes have to start automatically after Tapestry bootstrap, and
this doesn't happend.

E.g. One of those classes, ApplicationManager, start the whole application,
it starts some observable object and it uses the HibernateSession.

How can I do that?


-- 
*Domenico Fiorilli*
*Dottore in Ingegneria Informatica*



*via Marconi 33Pontecagnano (SA)**3932855726*

*domenicofiorilli@gmail.com <do...@gmail.com>*
*http://domenicofiorilli.jimdo.com/* <http://domenicofiorilli.jimdo.com/>

Re: Services on Tapestry

Posted by Domenico Fiorilli <do...@gmail.com>.
Hi,
finally I understood that .eagerLoad() execute the constructor class. But I
have another problem now:
I want to use anotclass ApplicationManager, that now is a Service, also as
an Observer. I use also another Service ElaboratorManager that must observ
ApplicationManager. But when I do
elaboratorManager.addObserver(applicationManager), the program crash
because elaboratorManager is null, because it doesn't yet start!

I would to know how to connect the observers after the Services started.

Thank you very much.


2014-02-14 10:11 GMT+01:00 Domenico Fiorilli <do...@gmail.com>:

> Sorry if I reply on dev-list. If you can help me because I don't
> understand. I have
>
> In class AppModule I added binder.bind(ApplicationManager.class), and I
> want it as Service.
> I added, as you tell me, the method eagerLoad(), but it nothing happens.
> In class ApplicationManager there is a method init() that initializes the
> whole application, such as the structures, the observer etc... and starts
> it.
> But I think I'm getting something wrong, because it nothing happens.
>
> Thank you very much.
>
>
> 2014-02-13 19:11 GMT+01:00 Thiago H de Paula Figueiredo <
> thiagohp@gmail.com>:
>
> On Thu, 13 Feb 2014 14:43:46 -0200, Domenico Fiorilli <
>> domenicofiorilli@gmail.com> wrote:
>>
>>  Hi,
>>>
>>
>> Hi!
>>
>> This question should have been posted in the users mailing list, not the
>> dev one, so I'm answering in the users one. :)
>>
>>
>>  I'm developing on application in Tapestry and I have this problem:
>>> I have some classes in java that they need to use a HibernateSession. I
>>> read that to do that, those classes must be execute as well as Services.
>>> But those classes have to start automatically after Tapestry bootstrap,
>>> and this doesn't happend.
>>>
>>
>> That's expected. All Tapestry-IoC services are lazy initialized by
>> default, and that's a blessing. :)
>>
>> If you're using autobinding, just add .eagerLoad():
>> binder.bind(Service.class, ServiceImpl.class).eagerLoad();
>>
>> If you're not, just add @EagerLoad to the method that builds your service:
>>
>> @EagerLoad
>> public static Service buildService(...) { ... }
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>>
>
>
>
> --
> *Domenico Fiorilli*
> *Dottore in Ingegneria Informatica*
>
>
>
> * via Marconi 33Pontecagnano (SA)**3932855726*
>
> *domenicofiorilli@gmail.com <do...@gmail.com> *
> *http://domenicofiorilli.jimdo.com/* <http://domenicofiorilli.jimdo.com/>
>
>
>


-- 
*Domenico Fiorilli*
*Dottore in Ingegneria Informatica*



*via Marconi 33Pontecagnano (SA)**3932855726*

*domenicofiorilli@gmail.com <do...@gmail.com>*
*http://domenicofiorilli.jimdo.com/* <http://domenicofiorilli.jimdo.com/>

Re: Services on Tapestry

Posted by Domenico Fiorilli <do...@gmail.com>.
Sorry if I reply on dev-list. If you can help me because I don't
understand. I have

In class AppModule I added binder.bind(ApplicationManager.class), and I
want it as Service.
I added, as you tell me, the method eagerLoad(), but it nothing happens.
In class ApplicationManager there is a method init() that initializes the
whole application, such as the structures, the observer etc... and starts
it.
But I think I'm getting something wrong, because it nothing happens.

Thank you very much.


2014-02-13 19:11 GMT+01:00 Thiago H de Paula Figueiredo <th...@gmail.com>
:

> On Thu, 13 Feb 2014 14:43:46 -0200, Domenico Fiorilli <
> domenicofiorilli@gmail.com> wrote:
>
>  Hi,
>>
>
> Hi!
>
> This question should have been posted in the users mailing list, not the
> dev one, so I'm answering in the users one. :)
>
>
>  I'm developing on application in Tapestry and I have this problem:
>> I have some classes in java that they need to use a HibernateSession. I
>> read that to do that, those classes must be execute as well as Services.
>> But those classes have to start automatically after Tapestry bootstrap,
>> and this doesn't happend.
>>
>
> That's expected. All Tapestry-IoC services are lazy initialized by
> default, and that's a blessing. :)
>
> If you're using autobinding, just add .eagerLoad():
> binder.bind(Service.class, ServiceImpl.class).eagerLoad();
>
> If you're not, just add @EagerLoad to the method that builds your service:
>
> @EagerLoad
> public static Service buildService(...) { ... }
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>



-- 
*Domenico Fiorilli*
*Dottore in Ingegneria Informatica*



*via Marconi 33Pontecagnano (SA)**3932855726*

*domenicofiorilli@gmail.com <do...@gmail.com>*
*http://domenicofiorilli.jimdo.com/* <http://domenicofiorilli.jimdo.com/>

Re: Services on Tapestry

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 13 Feb 2014 14:43:46 -0200, Domenico Fiorilli  
<do...@gmail.com> wrote:

> Hi,

Hi!

This question should have been posted in the users mailing list, not the  
dev one, so I'm answering in the users one. :)

> I'm developing on application in Tapestry and I have this problem:
> I have some classes in java that they need to use a HibernateSession. I
> read that to do that, those classes must be execute as well as Services.
> But those classes have to start automatically after Tapestry bootstrap,  
> and this doesn't happend.

That's expected. All Tapestry-IoC services are lazy initialized by  
default, and that's a blessing. :)

If you're using autobinding, just add .eagerLoad():  
binder.bind(Service.class, ServiceImpl.class).eagerLoad();

If you're not, just add @EagerLoad to the method that builds your service:

@EagerLoad
public static Service buildService(...) { ... }

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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