Home » Archived » Riena » Problem with annotated injection
Problem with annotated injection [message #468033] |
Mon, 03 August 2009 13:28  |
Eclipse User |
|
|
|
Hello,
in Riena I like to inject services with @InjectService.
Everything is easy in a SubModuleController class.
But in pojo's I have the problem, that bind won't be called.
The following code runs well from Activator.start
for pojo CurrentUser without annotation:
currentUser = new CurrentUser();
Inject.service(ISubjectHolderService.class.getName())
.into(currentUser)
.bind("bindSubjectHolderService")
.unbind("unbindSubjectHolderService")
.andStart(context);
Inject.service(IUserService.class.getName())
.into(currentUser)
.bind("bindUserService")
.unbind("unbindUserService")
.andStart(context);
If in Activator.start or any other place only
currentUser = new CurrentUser()
is called and CurrentUser is annotated like this the services are null.
public class CurrentUser {
private ISubjectHolderService subjectHolderService;
private IUserService userService;
@InjectService(service= IUserService.class ,unbind = "unbindUserService")
public void bindUserService(IUserService srv) {
this.userService = srv;
}
@InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
public void bindSubjectHolderService(ISubjectHolderService srv)
{
this.subjectHolderService = srv;
}
If tried to change @InjectService or use @WireWith but I can't get it run.
What goes wrong.
Rüdiger
|
|
| | | |
Re: Problem with annotated injection [message #468154 is a reply to message #468144] |
Tue, 04 August 2009 08:07   |
Eclipse User |
|
|
|
Stefan Liebig schrieb:
> Rüdiger Rensinghoff-Kranen wrote:
>> Stefan Liebig schrieb:
>>> Hi Rüdiger,
>>>
>>> When using annotations for injection something has to interpret those
>>> annotations and perform the necessary actions.
>>> In the case where classes are defined within extension points like
>>> your SubModuleController the ExtensionInjector takes care of the wiring.
>>> I you create a pojo yourself you have the choice of using either:
>>> -Inject.Service().into( pojo ). ..
>>> or
>>> - use annotations and do a Wire.instance( pojo ).andStart()
>>>
>>> HTH
>>> Stefan
>>>
>>> Rüdiger Rensinghoff-Kranen wrote:
>>>> Hello,
>>>>
>>>>
>>>> in Riena I like to inject services with @InjectService.
>>>> Everything is easy in a SubModuleController class.
>>>> But in pojo's I have the problem, that bind won't be called.
>>>>
>>>>
>>>> The following code runs well from Activator.start
>>>> for pojo CurrentUser without annotation:
>>>>
>>>> currentUser = new CurrentUser();
>>>> Inject.service(ISubjectHolderService.class.getName())
>>>> .into(currentUser)
>>>> .bind("bindSubjectHolderService")
>>>> .unbind("unbindSubjectHolderService")
>>>> .andStart(context);
>>>> Inject.service(IUserService.class.getName())
>>>> .into(currentUser)
>>>> .bind("bindUserService")
>>>> .unbind("unbindUserService")
>>>> .andStart(context);
>>>> If in Activator.start or any other place only
>>>> currentUser = new CurrentUser()
>>>> is called and CurrentUser is annotated like this the services are null.
>>>>
>>>>
>>>> public class CurrentUser {
>>>> private ISubjectHolderService subjectHolderService;
>>>> private IUserService userService;
>>>> @InjectService(service= IUserService.class ,unbind =
>>>> "unbindUserService")
>>>> public void bindUserService(IUserService srv) {
>>>> this.userService = srv;
>>>> }
>>>> @InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
>>>>
>>>> public void bindSubjectHolderService(ISubjectHolderService
>>>> srv) {
>>>> this.subjectHolderService = srv;
>>>> }
>>>>
>>>>
>>>> If tried to change @InjectService or use @WireWith but I can't get
>>>> it run.
>>>>
>>>> What goes wrong.
>>>>
>>>> Rüdiger
>>>>
>>>>
>>>>
>>
>> Hello Stefan,
>>
>>
>> thanks for your rapide response. I tried Wire.instance and it works
>> well and is more convenient to me.
>>
>>
>> Rüdiger
>>
>
> Hello Rüdiger,
>
> You can even simplify your pojo annotations:
>
> public class CurrentUser {
> private ISubjectHolderService subjectHolderService;
> private IUserService userService;
> @InjectService()
> public void bindUserService(IUserService srv) {
> this.userService = srv;
> }
> @InjectService()
> public void bindSubjectHolderService(ISubjectHolderService srv) {
> this.subjectHolderService = srv;
> }
>
> ..
>
> }
>
> The service class is now taken from the parameter type of the annotated
> bind method and the unbind method name is generated by prefixing the
> annotated bind method with with "un".
>
> Tschüß,
> Stefan
Hello Stefan,
thanks very much for your helpfull usage hint. It would be great to find
such information in a description for Riena. Now I have to learn it
the hard way. Spend hours, that I not really have, by try and error and
greping in inner classes of the framework. But Riena is worth it. Thanks
to the team.
Rüdiger
|
|
|
Re: Problem with annotated injection [message #468168 is a reply to message #468154] |
Tue, 04 August 2009 08:52   |
Eclipse User |
|
|
|
Rüdiger Rensinghoff-Kranen wrote:
> Stefan Liebig schrieb:
>> Rüdiger Rensinghoff-Kranen wrote:
>>> Stefan Liebig schrieb:
>>>> Hi Rüdiger,
>>>>
>>>> When using annotations for injection something has to interpret
>>>> those annotations and perform the necessary actions.
>>>> In the case where classes are defined within extension points like
>>>> your SubModuleController the ExtensionInjector takes care of the
>>>> wiring.
>>>> I you create a pojo yourself you have the choice of using either:
>>>> -Inject.Service().into( pojo ). ..
>>>> or
>>>> - use annotations and do a Wire.instance( pojo ).andStart()
>>>>
>>>> HTH
>>>> Stefan
>>>>
>>>> Rüdiger Rensinghoff-Kranen wrote:
>>>>> Hello,
>>>>>
>>>>>
>>>>> in Riena I like to inject services with @InjectService.
>>>>> Everything is easy in a SubModuleController class.
>>>>> But in pojo's I have the problem, that bind won't be called.
>>>>>
>>>>>
>>>>> The following code runs well from Activator.start
>>>>> for pojo CurrentUser without annotation:
>>>>>
>>>>> currentUser = new CurrentUser();
>>>>> Inject.service(ISubjectHolderService.class.getName())
>>>>> .into(currentUser)
>>>>> .bind("bindSubjectHolderService")
>>>>> .unbind("unbindSubjectHolderService")
>>>>> .andStart(context);
>>>>> Inject.service(IUserService.class.getName())
>>>>> .into(currentUser)
>>>>> .bind("bindUserService")
>>>>> .unbind("unbindUserService")
>>>>> .andStart(context); If in Activator.start or any other
>>>>> place only
>>>>> currentUser = new CurrentUser()
>>>>> is called and CurrentUser is annotated like this the services are
>>>>> null.
>>>>>
>>>>>
>>>>> public class CurrentUser {
>>>>> private ISubjectHolderService subjectHolderService;
>>>>> private IUserService userService;
>>>>> @InjectService(service= IUserService.class ,unbind =
>>>>> "unbindUserService")
>>>>> public void bindUserService(IUserService srv) {
>>>>> this.userService = srv;
>>>>> }
>>>>> @InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
>>>>>
>>>>> public void bindSubjectHolderService(ISubjectHolderService
>>>>> srv) {
>>>>> this.subjectHolderService = srv;
>>>>> }
>>>>>
>>>>>
>>>>> If tried to change @InjectService or use @WireWith but I can't get
>>>>> it run.
>>>>>
>>>>> What goes wrong.
>>>>>
>>>>> Rüdiger
>>>>>
>>>>>
>>>>>
>>>
>>> Hello Stefan,
>>>
>>>
>>> thanks for your rapide response. I tried Wire.instance and it works
>>> well and is more convenient to me.
>>>
>>>
>>> Rüdiger
>>>
>>
>> Hello Rüdiger,
>>
>> You can even simplify your pojo annotations:
>>
>> public class CurrentUser {
>> private ISubjectHolderService subjectHolderService;
>> private IUserService userService;
>> @InjectService()
>> public void bindUserService(IUserService srv) {
>> this.userService = srv;
>> }
>> @InjectService()
>> public void bindSubjectHolderService(ISubjectHolderService srv) {
>> this.subjectHolderService = srv;
>> }
>>
>> ..
>>
>> }
>>
>> The service class is now taken from the parameter type of the
>> annotated bind method and the unbind method name is generated by
>> prefixing the annotated bind method with with "un".
>>
>> Tschüß,
>> Stefan
>
> Hello Stefan,
>
> thanks very much for your helpfull usage hint. It would be great to find
> such information in a description for Riena. Now I have to learn it the
> hard way. Spend hours, that I not really have, by try and error and
> greping in inner classes of the framework. But Riena is worth it. Thanks
> to the team.
>
>
> Rüdiger
>
>
>
Hello Rüdiger,
You are right http://wiki.eclipse.org/Riena_Getting_Started_with_Wiring
needs some polishing. Thanks for the hint!
Keep posting your questions and comments! We will try hard.
Tschüß,
Stefan
|
|
|
Re: Problem with annotated injection [message #478778 is a reply to message #468168] |
Thu, 06 August 2009 15:37  |
Eclipse User |
|
|
|
Stefan Liebig schrieb:
> Rüdiger Rensinghoff-Kranen wrote:
>> Stefan Liebig schrieb:
>>> Rüdiger Rensinghoff-Kranen wrote:
>>>> Stefan Liebig schrieb:
>>>>> Hi Rüdiger,
>>>>>
>>>>> When using annotations for injection something has to interpret
>>>>> those annotations and perform the necessary actions.
>>>>> In the case where classes are defined within extension points like
>>>>> your SubModuleController the ExtensionInjector takes care of the
>>>>> wiring.
>>>>> I you create a pojo yourself you have the choice of using either:
>>>>> -Inject.Service().into( pojo ). ..
>>>>> or
>>>>> - use annotations and do a Wire.instance( pojo ).andStart()
>>>>>
>>>>> HTH
>>>>> Stefan
>>>>>
>>>>> Rüdiger Rensinghoff-Kranen wrote:
>>>>>> Hello,
>>>>>>
>>>>>>
>>>>>> in Riena I like to inject services with @InjectService.
>>>>>> Everything is easy in a SubModuleController class.
>>>>>> But in pojo's I have the problem, that bind won't be called.
>>>>>>
>>>>>>
>>>>>> The following code runs well from Activator.start
>>>>>> for pojo CurrentUser without annotation:
>>>>>>
>>>>>> currentUser = new CurrentUser();
>>>>>> Inject.service(ISubjectHolderService.class.getName())
>>>>>> .into(currentUser)
>>>>>> .bind("bindSubjectHolderService")
>>>>>> .unbind("unbindSubjectHolderService")
>>>>>> .andStart(context);
>>>>>> Inject.service(IUserService.class.getName())
>>>>>> .into(currentUser)
>>>>>> .bind("bindUserService")
>>>>>> .unbind("unbindUserService")
>>>>>> .andStart(context); If in Activator.start or any other
>>>>>> place only
>>>>>> currentUser = new CurrentUser()
>>>>>> is called and CurrentUser is annotated like this the services are
>>>>>> null.
>>>>>>
>>>>>>
>>>>>> public class CurrentUser {
>>>>>> private ISubjectHolderService subjectHolderService;
>>>>>> private IUserService userService;
>>>>>> @InjectService(service= IUserService.class ,unbind =
>>>>>> "unbindUserService")
>>>>>> public void bindUserService(IUserService srv) {
>>>>>> this.userService = srv;
>>>>>> }
>>>>>> @InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
>>>>>>
>>>>>> public void bindSubjectHolderService(ISubjectHolderService
>>>>>> srv) {
>>>>>> this.subjectHolderService = srv;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> If tried to change @InjectService or use @WireWith but I can't get
>>>>>> it run.
>>>>>>
>>>>>> What goes wrong.
>>>>>>
>>>>>> Rüdiger
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>> Hello Stefan,
>>>>
>>>>
>>>> thanks for your rapide response. I tried Wire.instance and it works
>>>> well and is more convenient to me.
>>>>
>>>>
>>>> Rüdiger
>>>>
>>>
>>> Hello Rüdiger,
>>>
>>> You can even simplify your pojo annotations:
>>>
>>> public class CurrentUser {
>>> private ISubjectHolderService subjectHolderService;
>>> private IUserService userService;
>>> @InjectService()
>>> public void bindUserService(IUserService srv) {
>>> this.userService = srv;
>>> }
>>> @InjectService()
>>> public void bindSubjectHolderService(ISubjectHolderService srv) {
>>> this.subjectHolderService = srv;
>>> }
>>>
>>> ..
>>>
>>> }
>>>
>>> The service class is now taken from the parameter type of the
>>> annotated bind method and the unbind method name is generated by
>>> prefixing the annotated bind method with with "un".
>>>
>>> Tschüß,
>>> Stefan
>>
>> Hello Stefan,
>>
>> thanks very much for your helpfull usage hint. It would be great to
>> find such information in a description for Riena. Now I have to learn
>> it the hard way. Spend hours, that I not really have, by try and error
>> and greping in inner classes of the framework. But Riena is worth it.
>> Thanks to the team.
>>
>>
>> Rüdiger
>>
>>
>>
>
> Hello Rüdiger,
>
> You are right http://wiki.eclipse.org/Riena_Getting_Started_with_Wiring
> needs some polishing. Thanks for the hint!
> Keep posting your questions and comments! We will try hard.
>
> Tschüß,
> Stefan
Hi Rüdiger,
I know you said you had no time but still wanted our documentation in Riena to be better. Help us to help us and write a
little paragraph in the wiki page that Stefan mentioned and add the things you were missing. Add a little documentation,
which I guess you can copy in parts from this thread to help others to be faster in understanding the concepts....
thanks
christian
|
|
|
Re: Problem with annotated injection [message #583111 is a reply to message #468033] |
Tue, 04 August 2009 01:03  |
Eclipse User |
|
|
|
Hi Rüdiger,
When using annotations for injection something has to interpret those
annotations and perform the necessary actions.
In the case where classes are defined within extension points like your
SubModuleController the ExtensionInjector takes care of the wiring.
I you create a pojo yourself you have the choice of using either:
-Inject.Service().into( pojo ). ..
or
- use annotations and do a Wire.instance( pojo ).andStart()
HTH
Stefan
Rüdiger Rensinghoff-Kranen wrote:
> Hello,
>
>
> in Riena I like to inject services with @InjectService.
> Everything is easy in a SubModuleController class.
> But in pojo's I have the problem, that bind won't be called.
>
>
> The following code runs well from Activator.start
> for pojo CurrentUser without annotation:
>
> currentUser = new CurrentUser();
> Inject.service(ISubjectHolderService.class.getName())
> .into(currentUser)
> .bind("bindSubjectHolderService")
> .unbind("unbindSubjectHolderService")
> .andStart(context);
> Inject.service(IUserService.class.getName())
> .into(currentUser)
> .bind("bindUserService")
> .unbind("unbindUserService")
> .andStart(context);
>
>
>
> If in Activator.start or any other place only
> currentUser = new CurrentUser()
> is called and CurrentUser is annotated like this the services are null.
>
>
> public class CurrentUser {
> private ISubjectHolderService subjectHolderService;
> private IUserService userService;
> @InjectService(service= IUserService.class ,unbind = "unbindUserService")
> public void bindUserService(IUserService srv) {
> this.userService = srv;
> }
> @InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
>
> public void bindSubjectHolderService(ISubjectHolderService srv) {
> this.subjectHolderService = srv;
> }
>
>
> If tried to change @InjectService or use @WireWith but I can't get it run.
>
> What goes wrong.
>
> Rüdiger
>
>
>
|
|
|
Re: Problem with annotated injection [message #583124 is a reply to message #468089] |
Tue, 04 August 2009 06:16  |
Eclipse User |
|
|
|
Stefan Liebig schrieb:
> Hi Rüdiger,
>
> When using annotations for injection something has to interpret those
> annotations and perform the necessary actions.
> In the case where classes are defined within extension points like your
> SubModuleController the ExtensionInjector takes care of the wiring.
> I you create a pojo yourself you have the choice of using either:
> -Inject.Service().into( pojo ). ..
> or
> - use annotations and do a Wire.instance( pojo ).andStart()
>
> HTH
> Stefan
>
> Rüdiger Rensinghoff-Kranen wrote:
>> Hello,
>>
>>
>> in Riena I like to inject services with @InjectService.
>> Everything is easy in a SubModuleController class.
>> But in pojo's I have the problem, that bind won't be called.
>>
>>
>> The following code runs well from Activator.start
>> for pojo CurrentUser without annotation:
>>
>> currentUser = new CurrentUser();
>> Inject.service(ISubjectHolderService.class.getName())
>> .into(currentUser)
>> .bind("bindSubjectHolderService")
>> .unbind("unbindSubjectHolderService")
>> .andStart(context);
>> Inject.service(IUserService.class.getName())
>> .into(currentUser)
>> .bind("bindUserService")
>> .unbind("unbindUserService")
>> .andStart(context);
>>
>>
>> If in Activator.start or any other place only
>> currentUser = new CurrentUser()
>> is called and CurrentUser is annotated like this the services are null.
>>
>>
>> public class CurrentUser {
>> private ISubjectHolderService subjectHolderService;
>> private IUserService userService;
>> @InjectService(service= IUserService.class ,unbind = "unbindUserService")
>> public void bindUserService(IUserService srv) {
>> this.userService = srv;
>> }
>> @InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
>>
>> public void bindSubjectHolderService(ISubjectHolderService srv) {
>> this.subjectHolderService = srv;
>> }
>>
>>
>> If tried to change @InjectService or use @WireWith but I can't get it
>> run.
>>
>> What goes wrong.
>>
>> Rüdiger
>>
>>
>>
Hello Stefan,
thanks for your rapide response. I tried Wire.instance and it works well
and is more convenient to me.
Rüdiger
|
|
|
Re: Problem with annotated injection [message #583137 is a reply to message #468130] |
Tue, 04 August 2009 06:52  |
Eclipse User |
|
|
|
Rüdiger Rensinghoff-Kranen wrote:
> Stefan Liebig schrieb:
>> Hi Rüdiger,
>>
>> When using annotations for injection something has to interpret those
>> annotations and perform the necessary actions.
>> In the case where classes are defined within extension points like
>> your SubModuleController the ExtensionInjector takes care of the wiring.
>> I you create a pojo yourself you have the choice of using either:
>> -Inject.Service().into( pojo ). ..
>> or
>> - use annotations and do a Wire.instance( pojo ).andStart()
>>
>> HTH
>> Stefan
>>
>> Rüdiger Rensinghoff-Kranen wrote:
>>> Hello,
>>>
>>>
>>> in Riena I like to inject services with @InjectService.
>>> Everything is easy in a SubModuleController class.
>>> But in pojo's I have the problem, that bind won't be called.
>>>
>>>
>>> The following code runs well from Activator.start
>>> for pojo CurrentUser without annotation:
>>>
>>> currentUser = new CurrentUser();
>>> Inject.service(ISubjectHolderService.class.getName())
>>> .into(currentUser)
>>> .bind("bindSubjectHolderService")
>>> .unbind("unbindSubjectHolderService")
>>> .andStart(context);
>>> Inject.service(IUserService.class.getName())
>>> .into(currentUser)
>>> .bind("bindUserService")
>>> .unbind("unbindUserService")
>>> .andStart(context);
>>>
>>> If in Activator.start or any other place only
>>> currentUser = new CurrentUser()
>>> is called and CurrentUser is annotated like this the services are null.
>>>
>>>
>>> public class CurrentUser {
>>> private ISubjectHolderService subjectHolderService;
>>> private IUserService userService;
>>> @InjectService(service= IUserService.class ,unbind =
>>> "unbindUserService")
>>> public void bindUserService(IUserService srv) {
>>> this.userService = srv;
>>> }
>>> @InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
>>>
>>> public void bindSubjectHolderService(ISubjectHolderService
>>> srv) {
>>> this.subjectHolderService = srv;
>>> }
>>>
>>>
>>> If tried to change @InjectService or use @WireWith but I can't get it
>>> run.
>>>
>>> What goes wrong.
>>>
>>> Rüdiger
>>>
>>>
>>>
>
> Hello Stefan,
>
>
> thanks for your rapide response. I tried Wire.instance and it works well
> and is more convenient to me.
>
>
> Rüdiger
>
Hello Rüdiger,
You can even simplify your pojo annotations:
public class CurrentUser {
private ISubjectHolderService subjectHolderService;
private IUserService userService;
@InjectService()
public void bindUserService(IUserService srv) {
this.userService = srv;
}
@InjectService()
public void bindSubjectHolderService(ISubjectHolderService srv) {
this.subjectHolderService = srv;
}
..
}
The service class is now taken from the parameter type of the annotated
bind method and the unbind method name is generated by prefixing the
annotated bind method with with "un".
Tschüß,
Stefan
|
|
|
Re: Problem with annotated injection [message #583150 is a reply to message #468144] |
Tue, 04 August 2009 08:07  |
Eclipse User |
|
|
|
Stefan Liebig schrieb:
> Rüdiger Rensinghoff-Kranen wrote:
>> Stefan Liebig schrieb:
>>> Hi Rüdiger,
>>>
>>> When using annotations for injection something has to interpret those
>>> annotations and perform the necessary actions.
>>> In the case where classes are defined within extension points like
>>> your SubModuleController the ExtensionInjector takes care of the wiring.
>>> I you create a pojo yourself you have the choice of using either:
>>> -Inject.Service().into( pojo ). ..
>>> or
>>> - use annotations and do a Wire.instance( pojo ).andStart()
>>>
>>> HTH
>>> Stefan
>>>
>>> Rüdiger Rensinghoff-Kranen wrote:
>>>> Hello,
>>>>
>>>>
>>>> in Riena I like to inject services with @InjectService.
>>>> Everything is easy in a SubModuleController class.
>>>> But in pojo's I have the problem, that bind won't be called.
>>>>
>>>>
>>>> The following code runs well from Activator.start
>>>> for pojo CurrentUser without annotation:
>>>>
>>>> currentUser = new CurrentUser();
>>>> Inject.service(ISubjectHolderService.class.getName())
>>>> .into(currentUser)
>>>> .bind("bindSubjectHolderService")
>>>> .unbind("unbindSubjectHolderService")
>>>> .andStart(context);
>>>> Inject.service(IUserService.class.getName())
>>>> .into(currentUser)
>>>> .bind("bindUserService")
>>>> .unbind("unbindUserService")
>>>> .andStart(context);
>>>> If in Activator.start or any other place only
>>>> currentUser = new CurrentUser()
>>>> is called and CurrentUser is annotated like this the services are null.
>>>>
>>>>
>>>> public class CurrentUser {
>>>> private ISubjectHolderService subjectHolderService;
>>>> private IUserService userService;
>>>> @InjectService(service= IUserService.class ,unbind =
>>>> "unbindUserService")
>>>> public void bindUserService(IUserService srv) {
>>>> this.userService = srv;
>>>> }
>>>> @InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
>>>>
>>>> public void bindSubjectHolderService(ISubjectHolderService
>>>> srv) {
>>>> this.subjectHolderService = srv;
>>>> }
>>>>
>>>>
>>>> If tried to change @InjectService or use @WireWith but I can't get
>>>> it run.
>>>>
>>>> What goes wrong.
>>>>
>>>> Rüdiger
>>>>
>>>>
>>>>
>>
>> Hello Stefan,
>>
>>
>> thanks for your rapide response. I tried Wire.instance and it works
>> well and is more convenient to me.
>>
>>
>> Rüdiger
>>
>
> Hello Rüdiger,
>
> You can even simplify your pojo annotations:
>
> public class CurrentUser {
> private ISubjectHolderService subjectHolderService;
> private IUserService userService;
> @InjectService()
> public void bindUserService(IUserService srv) {
> this.userService = srv;
> }
> @InjectService()
> public void bindSubjectHolderService(ISubjectHolderService srv) {
> this.subjectHolderService = srv;
> }
>
> ..
>
> }
>
> The service class is now taken from the parameter type of the annotated
> bind method and the unbind method name is generated by prefixing the
> annotated bind method with with "un".
>
> Tschüß,
> Stefan
Hello Stefan,
thanks very much for your helpfull usage hint. It would be great to find
such information in a description for Riena. Now I have to learn it
the hard way. Spend hours, that I not really have, by try and error and
greping in inner classes of the framework. But Riena is worth it. Thanks
to the team.
Rüdiger
|
|
|
Re: Problem with annotated injection [message #583159 is a reply to message #468154] |
Tue, 04 August 2009 08:52  |
Eclipse User |
|
|
|
Rüdiger Rensinghoff-Kranen wrote:
> Stefan Liebig schrieb:
>> Rüdiger Rensinghoff-Kranen wrote:
>>> Stefan Liebig schrieb:
>>>> Hi Rüdiger,
>>>>
>>>> When using annotations for injection something has to interpret
>>>> those annotations and perform the necessary actions.
>>>> In the case where classes are defined within extension points like
>>>> your SubModuleController the ExtensionInjector takes care of the
>>>> wiring.
>>>> I you create a pojo yourself you have the choice of using either:
>>>> -Inject.Service().into( pojo ). ..
>>>> or
>>>> - use annotations and do a Wire.instance( pojo ).andStart()
>>>>
>>>> HTH
>>>> Stefan
>>>>
>>>> Rüdiger Rensinghoff-Kranen wrote:
>>>>> Hello,
>>>>>
>>>>>
>>>>> in Riena I like to inject services with @InjectService.
>>>>> Everything is easy in a SubModuleController class.
>>>>> But in pojo's I have the problem, that bind won't be called.
>>>>>
>>>>>
>>>>> The following code runs well from Activator.start
>>>>> for pojo CurrentUser without annotation:
>>>>>
>>>>> currentUser = new CurrentUser();
>>>>> Inject.service(ISubjectHolderService.class.getName())
>>>>> .into(currentUser)
>>>>> .bind("bindSubjectHolderService")
>>>>> .unbind("unbindSubjectHolderService")
>>>>> .andStart(context);
>>>>> Inject.service(IUserService.class.getName())
>>>>> .into(currentUser)
>>>>> .bind("bindUserService")
>>>>> .unbind("unbindUserService")
>>>>> .andStart(context); If in Activator.start or any other
>>>>> place only
>>>>> currentUser = new CurrentUser()
>>>>> is called and CurrentUser is annotated like this the services are
>>>>> null.
>>>>>
>>>>>
>>>>> public class CurrentUser {
>>>>> private ISubjectHolderService subjectHolderService;
>>>>> private IUserService userService;
>>>>> @InjectService(service= IUserService.class ,unbind =
>>>>> "unbindUserService")
>>>>> public void bindUserService(IUserService srv) {
>>>>> this.userService = srv;
>>>>> }
>>>>> @InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
>>>>>
>>>>> public void bindSubjectHolderService(ISubjectHolderService
>>>>> srv) {
>>>>> this.subjectHolderService = srv;
>>>>> }
>>>>>
>>>>>
>>>>> If tried to change @InjectService or use @WireWith but I can't get
>>>>> it run.
>>>>>
>>>>> What goes wrong.
>>>>>
>>>>> Rüdiger
>>>>>
>>>>>
>>>>>
>>>
>>> Hello Stefan,
>>>
>>>
>>> thanks for your rapide response. I tried Wire.instance and it works
>>> well and is more convenient to me.
>>>
>>>
>>> Rüdiger
>>>
>>
>> Hello Rüdiger,
>>
>> You can even simplify your pojo annotations:
>>
>> public class CurrentUser {
>> private ISubjectHolderService subjectHolderService;
>> private IUserService userService;
>> @InjectService()
>> public void bindUserService(IUserService srv) {
>> this.userService = srv;
>> }
>> @InjectService()
>> public void bindSubjectHolderService(ISubjectHolderService srv) {
>> this.subjectHolderService = srv;
>> }
>>
>> ..
>>
>> }
>>
>> The service class is now taken from the parameter type of the
>> annotated bind method and the unbind method name is generated by
>> prefixing the annotated bind method with with "un".
>>
>> Tschüß,
>> Stefan
>
> Hello Stefan,
>
> thanks very much for your helpfull usage hint. It would be great to find
> such information in a description for Riena. Now I have to learn it the
> hard way. Spend hours, that I not really have, by try and error and
> greping in inner classes of the framework. But Riena is worth it. Thanks
> to the team.
>
>
> Rüdiger
>
>
>
Hello Rüdiger,
You are right http://wiki.eclipse.org/Riena_Getting_Started_with_Wiring
needs some polishing. Thanks for the hint!
Keep posting your questions and comments! We will try hard.
Tschüß,
Stefan
|
|
|
Re: Problem with annotated injection [message #583174 is a reply to message #468168] |
Thu, 06 August 2009 15:37  |
Eclipse User |
|
|
|
Stefan Liebig schrieb:
> Rüdiger Rensinghoff-Kranen wrote:
>> Stefan Liebig schrieb:
>>> Rüdiger Rensinghoff-Kranen wrote:
>>>> Stefan Liebig schrieb:
>>>>> Hi Rüdiger,
>>>>>
>>>>> When using annotations for injection something has to interpret
>>>>> those annotations and perform the necessary actions.
>>>>> In the case where classes are defined within extension points like
>>>>> your SubModuleController the ExtensionInjector takes care of the
>>>>> wiring.
>>>>> I you create a pojo yourself you have the choice of using either:
>>>>> -Inject.Service().into( pojo ). ..
>>>>> or
>>>>> - use annotations and do a Wire.instance( pojo ).andStart()
>>>>>
>>>>> HTH
>>>>> Stefan
>>>>>
>>>>> Rüdiger Rensinghoff-Kranen wrote:
>>>>>> Hello,
>>>>>>
>>>>>>
>>>>>> in Riena I like to inject services with @InjectService.
>>>>>> Everything is easy in a SubModuleController class.
>>>>>> But in pojo's I have the problem, that bind won't be called.
>>>>>>
>>>>>>
>>>>>> The following code runs well from Activator.start
>>>>>> for pojo CurrentUser without annotation:
>>>>>>
>>>>>> currentUser = new CurrentUser();
>>>>>> Inject.service(ISubjectHolderService.class.getName())
>>>>>> .into(currentUser)
>>>>>> .bind("bindSubjectHolderService")
>>>>>> .unbind("unbindSubjectHolderService")
>>>>>> .andStart(context);
>>>>>> Inject.service(IUserService.class.getName())
>>>>>> .into(currentUser)
>>>>>> .bind("bindUserService")
>>>>>> .unbind("unbindUserService")
>>>>>> .andStart(context); If in Activator.start or any other
>>>>>> place only
>>>>>> currentUser = new CurrentUser()
>>>>>> is called and CurrentUser is annotated like this the services are
>>>>>> null.
>>>>>>
>>>>>>
>>>>>> public class CurrentUser {
>>>>>> private ISubjectHolderService subjectHolderService;
>>>>>> private IUserService userService;
>>>>>> @InjectService(service= IUserService.class ,unbind =
>>>>>> "unbindUserService")
>>>>>> public void bindUserService(IUserService srv) {
>>>>>> this.userService = srv;
>>>>>> }
>>>>>> @InjectService(service=ISubjectHolderService.class,unbind="unbindSubjectHolderService ")
>>>>>>
>>>>>> public void bindSubjectHolderService(ISubjectHolderService
>>>>>> srv) {
>>>>>> this.subjectHolderService = srv;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> If tried to change @InjectService or use @WireWith but I can't get
>>>>>> it run.
>>>>>>
>>>>>> What goes wrong.
>>>>>>
>>>>>> Rüdiger
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>> Hello Stefan,
>>>>
>>>>
>>>> thanks for your rapide response. I tried Wire.instance and it works
>>>> well and is more convenient to me.
>>>>
>>>>
>>>> Rüdiger
>>>>
>>>
>>> Hello Rüdiger,
>>>
>>> You can even simplify your pojo annotations:
>>>
>>> public class CurrentUser {
>>> private ISubjectHolderService subjectHolderService;
>>> private IUserService userService;
>>> @InjectService()
>>> public void bindUserService(IUserService srv) {
>>> this.userService = srv;
>>> }
>>> @InjectService()
>>> public void bindSubjectHolderService(ISubjectHolderService srv) {
>>> this.subjectHolderService = srv;
>>> }
>>>
>>> ..
>>>
>>> }
>>>
>>> The service class is now taken from the parameter type of the
>>> annotated bind method and the unbind method name is generated by
>>> prefixing the annotated bind method with with "un".
>>>
>>> Tschüß,
>>> Stefan
>>
>> Hello Stefan,
>>
>> thanks very much for your helpfull usage hint. It would be great to
>> find such information in a description for Riena. Now I have to learn
>> it the hard way. Spend hours, that I not really have, by try and error
>> and greping in inner classes of the framework. But Riena is worth it.
>> Thanks to the team.
>>
>>
>> Rüdiger
>>
>>
>>
>
> Hello Rüdiger,
>
> You are right http://wiki.eclipse.org/Riena_Getting_Started_with_Wiring
> needs some polishing. Thanks for the hint!
> Keep posting your questions and comments! We will try hard.
>
> Tschüß,
> Stefan
Hi Rüdiger,
I know you said you had no time but still wanted our documentation in Riena to be better. Help us to help us and write a
little paragraph in the wiki page that Stefan mentioned and add the things you were missing. Add a little documentation,
which I guess you can copy in parts from this thread to help others to be faster in understanding the concepts....
thanks
christian
|
|
|
Goto Forum:
Current Time: Mon May 12 10:54:37 EDT 2025
Powered by FUDForum. Page generated in 0.08632 seconds
|