Thanks for shedding light on this!! makes much more sense now.
lasitha wrote:
I'd like to clarify something (just in case i've led you astray):
The only way, AFAIK, that you should be defining ASOs in your registry
is via a contribution to the ApplicationStateManager as described at
the end of the first article i mentioned.
Just binding an ASO in the registry - as you would a regular service -
could lead to unexpected behavior !
Generally, an ASO is _not_ a 'service' and vice verca. In particular,
services have two possible lifecycles out of the box: singleton and
per-thread. Neither of these matches the lifespan of an ASO[1].
So, to summarize, i think your options are:
* Don't bind UserData if its to be an ASO,
* If you really want it in the registry, define it as a contribution to the ASM,
* I guess if you're adventurous, you could contribute your own service
lifecycle [1].
Apologies if all that was obvious - just wanted to be sure.
Cheers, lasitha.
[1] http://tapestry.apache.org/tapestry5/tapestry-ioc/apidocs/
On 10/9/07, Peter Stavrinides <[EMAIL PROTECTED]> wrote:
Thanks for your responses guys, this is awesome!! much improved over the
Hivemind approach, though I think I will stick with two steps, I like a
self documenting registry, just so I know what services I have implemented.
lasitha wrote:
Hi Peter,
If you just want UserData to be an ASO, there's only one step (in your
page/component class):
@ApplicationState
private UserData userData;
You don't need to bind anything. So its actually easier than 'too
easy to be true' :).
Here's a good starting point:
http://tapestry.apache.org/tapestry5/tapestry-core/guide/appstate.html
The 'scope' Kristian mentioned, i believe, is a reference to different
persistence strategies for ASOs, the default of which is to store it
in the http session.
In fact i wouldn't use the word scope in that context since it's
easily confused with service scopes in tapestry-ioc, which is an
altogether different concept:
http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html
(see section 'Defining Service Scope')
Cheers,
lasitha.
On 10/8/07, Peter Stavrinides <[EMAIL PROTECTED]> wrote:
Okay so let me get this straight:
Step1 bind (it has a default scope of session):
binder.bind(UserData.class).withId("DataService")
Step2:
@Inject
private UserData userData_;
And that's it?? that seems almost too easy to be true!
Kristian Marinkovic wrote:
and you can also have services withouth an interface
binder.bind(UserData.class).withId("DataService")
will also work :)
Kristian Marinkovic <[EMAIL PROTECTED]>
08.10.2007 14:29
Bitte antworten an
"Tapestry users" <users@tapestry.apache.org>
An
"Tapestry users" <users@tapestry.apache.org>
Kopie
Thema
Antwort: Re: Tapestry 5 IoC container
in T5 you don't have to define ASOs as in T4
if you want to define and use a ASO you just have
to use the @ApplicationState annotation:
@ApplicationState
private UserData userData;
the first access will force the object instantiation with
a no-arg constructor. default scope of ASOs (and the only
possible at the moment) is "session".
if you need global ASOs you can define a service in your
AppModule and inject it as you did below.
g,
kris
Peter Stavrinides <[EMAIL PROTECTED]>
08.10.2007 14:20
Bitte antworten an
"Tapestry users" <users@tapestry.apache.org>
An
Tapestry users <users@tapestry.apache.org>
Kopie
Thema
Re: Tapestry 5 IoC container
Actually I am migrating a lot of code from T4
Typically I have many Pojos used as services like this one:
public class UserData implements Serializable {
....
public UserData() {
}
}
This is an ASO session scoped in T4. In T5 in AppModule.java I have
added a binder entry:
binder.bind(UserData.class, UserDataImpl.class).withId("DataService");
UserData is expected as an interface though in T5, how do I convert
them, do have to write wrappers for all my services? what is the
efficient approach here?
I am injecting services in T5 like this, I don't know if this is correct
though?
@Inject
private RequestGlobals globals_;
@Inject
private UserData userData_;
Thanks
Peter
Robin Helgelin wrote:
On 10/8/07, Peter Stavrinides <[EMAIL PROTECTED]> wrote:
Hi All,
Sorry if this is a trivial question, I am looking for samples or a
tutorial explaining how to use Tapestry 5 IoC. I have been through the
documentation on site and there are some details I can't figure out.
It's easier to help you if you tell us the details :)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]