Why can't you use ObjectBuilder?

On the other hand you can subclass ApplicationServlet and make the Hivemind registry accessible to your application, so you can access services from anywhere and any way you want. Of course this is not as clean solution as injection...

Regards,
Norbi

----- Original Message ----- From: "Jun Tsai" <[EMAIL PROTECTED]>
To: "Tapestry users" <[email protected]>
Sent: Monday, February 06, 2006 6:51 AM
Subject: Re: How to get service?


Thank your reply.

My class is asset,not page ,not component,not service.How to inject service?

Thanks.

Jun Tsai

在 06-2-6,Raul Raja Martinez<[EMAIL PROTECTED]> 写道:
Hi Jun Tsai

If the class where you want your service to be injected is not a page or
a component you can't inject it using annotations.

If your class is another service you can get it injected declaring a
setter in your class that takes the interface of the service that you
want to inject as parameter:

private ServiceToInject serviceToInject;

public void setServiceToInject(ServiceToInject service) {
        serviceToInject = service;
}


On the other hand if you want to inject services into POJOS you can use
HiveUtils (formerly Hivetranse) for doing so.
http://hivetranse.sourceforge.net/quickstart.html#start.objectbuilder

best regards.

Raul Raja.

Jun Tsai wrote:
> Thank you.
> I want to inject the service in an asset class.
>
> Please look > tapestry\examples\Workbench\src\java\org\apache\tapestry\workbench\chart\ChartAsset.java
>
>
> Thanks
>
> Jun Tsai
>
>
> 2006/2/6, Shing Hing Man <[EMAIL PROTECTED]>:
>> You can inject a service into your page :
>>
>> @InjectObject("engine-service:chart")
>> public abstract IEngineService getChartService();
>>
>> where chart is a custom service defined in
>> hivemind.xml . Something like :
>>  <service-point id="chart"
>> interface="org.apache.tapestry.engine.IEngineService">
>>     <invoke-factory>
>>       <construct class="services.ChartService">
>>         <set-object property="exceptionReporter"
>> value="infrastructure:requestExceptionReporter"/>
>>         <set-object property="response"
>> value="infrastructure:response"/>
>>         <set-object property="linkFactory"
>> value="infrastructure:linkFactory"/>
>>                  <set-object property="daoFactory"
>> value="service:daoFactory"/>
>>        </construct>
>>     </invoke-factory>
>>   </service-point>
>>
>> InjectObject is documented here :
>> http://jakarta.apache.org/tapestry/UsersGuide/hivemind.html#hivemind.inject
>>
>>
>>
>> --- Jun Tsai <[EMAIL PROTECTED]> wrote:
>>
>>> hi all,
>>>     I find
>>>
>> cycle.getEngine().getService(BlobService.SERVICE_NAME);
>>> gerService method was deprected.I didn't find
>>> another method to get service?
>>>
>>> How to ?
>>>
>>> Thanks.
>>>
>>> Jun Tsai
>>> --
>>> Welcome to China Java Users Group(CNJUG).
>>> http://cnjug.dev.java.net
>>>
>>>
>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>>> [EMAIL PROTECTED]
>>> For additional commands, e-mail:
>>> [EMAIL PROTECTED]
>>>
>>>
>>
>> Home page :
>>   http://uk.geocities.com/matmsh/index.html
>>
>>
>>
>> ___________________________________________________________
>> Yahoo! Photos – NEW, now offering a quality print service from just 8p >> a photo http://uk.photos.yahoo.com
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> --
> Welcome to China Java Users Group(CNJUG).
> http://cnjug.dev.java.net


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net



--------------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.15.0/249 - Release Date: 2006. 02. 02.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to