You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by János Jarecsni <ja...@gmail.com> on 2008/04/25 19:49:25 UTC

accessing core services

Hi,

sorry for the newbie question again, but what is the canonic or suggested
way to access core services or facilities of the T5? I mean, from classes,
into which nothing gets injected (say, I'm writing a dispatcher, where I'd
like to resolve page names, component names). I'd like to have a
ComponentClassResolver for instance. Is that possible? (I hope so :))

thx & cu
janos

Re: accessing core services

Posted by Peter Beshai <pe...@gmail.com>.
You define your dispatcher as a service (with a build method) in your IoC
module and pass the services that you need injected into the constructor.

See:
http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html


Peter Beshai

On Fri, Apr 25, 2008 at 1:49 PM, János Jarecsni <ja...@gmail.com>
wrote:

> Hi,
>
> sorry for the newbie question again, but what is the canonic or suggested
> way to access core services or facilities of the T5? I mean, from classes,
> into which nothing gets injected (say, I'm writing a dispatcher, where I'd
> like to resolve page names, component names). I'd like to have a
> ComponentClassResolver for instance. Is that possible? (I hope so :))
>
> thx & cu
> janos
>

Re: accessing core services

Posted by Chris Lewis <ch...@bellsouth.net>.
Yeah that looks ok (at a glance). These wikis should help you:

http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher
http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher2
http://wiki.apache.org/tapestry/Tapestry5HowToControlAccess

They relate directly to what it seems like you are doing.

good luck

chris

János Jarecsni wrote:
> Hi, thx for the quick replies first of all,
>
> here is how I'm doing it now:
>
>     public void contributeMasterDispatcher(OrderedConfiguration<Dispatcher>
> configuration,
>
>             @InjectService("MyDispatcher") Dispatcher myDispatcher) {
>         configuration.add("MyDispatcher", myDispatcher,
> "before:RootPath");
>     }
>
> and
>
>     public static void bind(ServiceBinder binder) {
>         binder.bind(MyDispatcher.class).withId("MyDispatcher");
>     }
>
> Isn't it ok?
>
> thx again!
> janos
>
>
> 2008/4/25 Sven Homburg <ho...@googlemail.com>:
>
>   
>> i hope it helps you:
>>
>> put this code into your ApplicationModule
>>
>> public static buildMyDispachter(ComponentClassResolver resolver)
>> {
>>  return MyDispatcher(resolver);
>> }
>>
>> 2008/4/25, János Jarecsni <ja...@gmail.com>:
>>     
>>> Hi,
>>>
>>> sorry for the newbie question again, but what is the canonic or
>>>       
>> suggested
>>     
>>> way to access core services or facilities of the T5? I mean, from
>>>       
>> classes,
>>     
>>> into which nothing gets injected (say, I'm writing a dispatcher, where
>>>       
>> I'd
>>     
>>> like to resolve page names, component names). I'd like to have a
>>> ComponentClassResolver for instance. Is that possible? (I hope so :))
>>>
>>> thx & cu
>>> janos
>>>
>>>       
>>
>> --
>> with regards
>> Sven Homburg
>> http://tapestry5-components.googlecode.com
>>
>>     

-- 
http://thegodcode.net


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


Re: accessing core services

Posted by János Jarecsni <ja...@gmail.com>.
Hi, thx for the quick replies first of all,

here is how I'm doing it now:

    public void contributeMasterDispatcher(OrderedConfiguration<Dispatcher>
configuration,

            @InjectService("MyDispatcher") Dispatcher myDispatcher) {
        configuration.add("MyDispatcher", myDispatcher,
"before:RootPath");
    }

and

    public static void bind(ServiceBinder binder) {
        binder.bind(MyDispatcher.class).withId("MyDispatcher");
    }

Isn't it ok?

thx again!
janos


2008/4/25 Sven Homburg <ho...@googlemail.com>:

> i hope it helps you:
>
> put this code into your ApplicationModule
>
> public static buildMyDispachter(ComponentClassResolver resolver)
> {
>  return MyDispatcher(resolver);
> }
>
> 2008/4/25, János Jarecsni <ja...@gmail.com>:
> >
> > Hi,
> >
> > sorry for the newbie question again, but what is the canonic or
> suggested
> > way to access core services or facilities of the T5? I mean, from
> classes,
> > into which nothing gets injected (say, I'm writing a dispatcher, where
> I'd
> > like to resolve page names, component names). I'd like to have a
> > ComponentClassResolver for instance. Is that possible? (I hope so :))
> >
> > thx & cu
> > janos
> >
>
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
>

Re: T5-Components: DAO component issue

Posted by Sven Homburg <ho...@googlemail.com>.
findById is renamed to doRetrieve

2008/4/26 Andreas Pursian <dg...@gmx.net>:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi list, hi sven,
>
> i'm using the t5-contrib dao component in my project. While upgrading
> from t5c-contrib 5.0.10 to 5.0.11 i noticed that the findById() method
> seems not to be available anymore, is there a special reason for it?
>
> thanks in advance ...
>
> Andreas
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFIE0UiM14O/Esx/74RArM4AKCZfhAWfFIOPNzLPMEGP+QRWLZnZQCdFMqM
> XBc1GTnC+2BzVBh0XIPO3Xw=
> =QSB6
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
with regards
Sven Homburg
http://tapestry5-components.googlecode.com

T5-Components: DAO component issue

Posted by Andreas Pursian <dg...@gmx.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list, hi sven,

i'm using the t5-contrib dao component in my project. While upgrading
from t5c-contrib 5.0.10 to 5.0.11 i noticed that the findById() method
seems not to be available anymore, is there a special reason for it?

thanks in advance ...

Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIE0UiM14O/Esx/74RArM4AKCZfhAWfFIOPNzLPMEGP+QRWLZnZQCdFMqM
XBc1GTnC+2BzVBh0XIPO3Xw=
=QSB6
-----END PGP SIGNATURE-----

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


Re: accessing core services

Posted by Sven Homburg <ho...@googlemail.com>.
@InjectService is possible, if you must inject a service by his ID (if two
or more services implement the same interface)

2008/4/26 Chris Lewis <ch...@bellsouth.net>:

> Janos
>
> No, @Inject does not work in services. However injection still works on
> them, and is done via constructor arguments. You don't have to
> instantiate your service, just bind it in your module's bind() method
> and T5-ioc will sort out the details. To me that seems perfectly
> sensible and enforces encapsulation better than mutable properties
> (getters/setters), however if you prefer that then you can provide a
> buildMyService() method and build it manually.
>
> As far as using @Inject, I can't remember where this is documented but
> am quite sure you can only use it on page, component, and mixin classes
> (specifically NOT in services). Someone correct me if I'm mistaken.
>
> good luck
>
> chris
>
> János Jarecsni wrote:
> > However,
> >
> > @Inject Logger logger;
> >
> > does not work even now. It is a pity, because this way I have to list
> all
> > stuff I need in the constructor... I'd rather inject them. Is there some
> > rule in which kind of classes injection works?
> >
> > thx
> > janos
> >
> > 2008/4/26 János Jarecsni <ja...@gmail.com>:
> >
> >
> >> This helped!
> >> THX! :)
> >> Janos
> >>
> >> 2008/4/25 Sven Homburg <ho...@googlemail.com>:
> >>
> >>
> >>> i hope it helps you:
> >>>
> >>> put this code into your ApplicationModule
> >>>
> >>> public static buildMyDispachter(ComponentClassResolver resolver)
> >>> {
> >>>  return MyDispatcher(resolver);
> >>> }
> >>>
> >>> 2008/4/25, János Jarecsni <ja...@gmail.com>:
> >>>
> >>>> Hi,
> >>>>
> >>>> sorry for the newbie question again, but what is the canonic or
> >>>>
> >>> suggested
> >>>
> >>>> way to access core services or facilities of the T5? I mean, from
> >>>>
> >>> classes,
> >>>
> >>>> into which nothing gets injected (say, I'm writing a dispatcher,
> where
> >>>>
> >>> I'd
> >>>
> >>>> like to resolve page names, component names). I'd like to have a
> >>>> ComponentClassResolver for instance. Is that possible? (I hope so :))
> >>>>
> >>>> thx & cu
> >>>> janos
> >>>>
> >>>>
> >>>
> >>> --
> >>> with regards
> >>> Sven Homburg
> >>> http://tapestry5-components.googlecode.com
> >>>
> >>>
> >>
>
> --
> http://thegodcode.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
with regards
Sven Homburg
http://tapestry5-components.googlecode.com

Re: accessing core services

Posted by Chris Lewis <ch...@bellsouth.net>.
Janos

No, @Inject does not work in services. However injection still works on
them, and is done via constructor arguments. You don't have to
instantiate your service, just bind it in your module's bind() method
and T5-ioc will sort out the details. To me that seems perfectly
sensible and enforces encapsulation better than mutable properties
(getters/setters), however if you prefer that then you can provide a
buildMyService() method and build it manually.

As far as using @Inject, I can't remember where this is documented but
am quite sure you can only use it on page, component, and mixin classes
(specifically NOT in services). Someone correct me if I'm mistaken.

good luck

chris

János Jarecsni wrote:
> However,
>
> @Inject Logger logger;
>
> does not work even now. It is a pity, because this way I have to list all
> stuff I need in the constructor... I'd rather inject them. Is there some
> rule in which kind of classes injection works?
>
> thx
> janos
>
> 2008/4/26 János Jarecsni <ja...@gmail.com>:
>
>   
>> This helped!
>> THX! :)
>> Janos
>>
>> 2008/4/25 Sven Homburg <ho...@googlemail.com>:
>>
>>     
>>> i hope it helps you:
>>>
>>> put this code into your ApplicationModule
>>>
>>> public static buildMyDispachter(ComponentClassResolver resolver)
>>> {
>>>  return MyDispatcher(resolver);
>>> }
>>>
>>> 2008/4/25, János Jarecsni <ja...@gmail.com>:
>>>       
>>>> Hi,
>>>>
>>>> sorry for the newbie question again, but what is the canonic or
>>>>         
>>> suggested
>>>       
>>>> way to access core services or facilities of the T5? I mean, from
>>>>         
>>> classes,
>>>       
>>>> into which nothing gets injected (say, I'm writing a dispatcher, where
>>>>         
>>> I'd
>>>       
>>>> like to resolve page names, component names). I'd like to have a
>>>> ComponentClassResolver for instance. Is that possible? (I hope so :))
>>>>
>>>> thx & cu
>>>> janos
>>>>
>>>>         
>>>
>>> --
>>> with regards
>>> Sven Homburg
>>> http://tapestry5-components.googlecode.com
>>>
>>>       
>>     

-- 
http://thegodcode.net


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


Re: accessing core services

Posted by János Jarecsni <ja...@gmail.com>.
However,

@Inject Logger logger;

does not work even now. It is a pity, because this way I have to list all
stuff I need in the constructor... I'd rather inject them. Is there some
rule in which kind of classes injection works?

thx
janos

2008/4/26 János Jarecsni <ja...@gmail.com>:

> This helped!
> THX! :)
> Janos
>
> 2008/4/25 Sven Homburg <ho...@googlemail.com>:
>
> > i hope it helps you:
> >
> > put this code into your ApplicationModule
> >
> > public static buildMyDispachter(ComponentClassResolver resolver)
> > {
> >  return MyDispatcher(resolver);
> > }
> >
> > 2008/4/25, János Jarecsni <ja...@gmail.com>:
> > >
> > > Hi,
> > >
> > > sorry for the newbie question again, but what is the canonic or
> > suggested
> > > way to access core services or facilities of the T5? I mean, from
> > classes,
> > > into which nothing gets injected (say, I'm writing a dispatcher, where
> > I'd
> > > like to resolve page names, component names). I'd like to have a
> > > ComponentClassResolver for instance. Is that possible? (I hope so :))
> > >
> > > thx & cu
> > > janos
> > >
> >
> >
> >
> > --
> > with regards
> > Sven Homburg
> > http://tapestry5-components.googlecode.com
> >
>
>

Re: accessing core services

Posted by János Jarecsni <ja...@gmail.com>.
This helped!
THX! :)
Janos

2008/4/25 Sven Homburg <ho...@googlemail.com>:

> i hope it helps you:
>
> put this code into your ApplicationModule
>
> public static buildMyDispachter(ComponentClassResolver resolver)
> {
>  return MyDispatcher(resolver);
> }
>
> 2008/4/25, János Jarecsni <ja...@gmail.com>:
> >
> > Hi,
> >
> > sorry for the newbie question again, but what is the canonic or
> suggested
> > way to access core services or facilities of the T5? I mean, from
> classes,
> > into which nothing gets injected (say, I'm writing a dispatcher, where
> I'd
> > like to resolve page names, component names). I'd like to have a
> > ComponentClassResolver for instance. Is that possible? (I hope so :))
> >
> > thx & cu
> > janos
> >
>
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
>

Re: accessing core services

Posted by Sven Homburg <ho...@googlemail.com>.
i hope it helps you:

put this code into your ApplicationModule

public static buildMyDispachter(ComponentClassResolver resolver)
{
  return MyDispatcher(resolver);
}

2008/4/25, János Jarecsni <ja...@gmail.com>:
>
> Hi,
>
> sorry for the newbie question again, but what is the canonic or suggested
> way to access core services or facilities of the T5? I mean, from classes,
> into which nothing gets injected (say, I'm writing a dispatcher, where I'd
> like to resolve page names, component names). I'd like to have a
> ComponentClassResolver for instance. Is that possible? (I hope so :))
>
> thx & cu
> janos
>



-- 
with regards
Sven Homburg
http://tapestry5-components.googlecode.com