Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Riena » Problem with annotated injection
Problem with annotated injection [message #468033] Mon, 03 August 2009 17:28 Go to next message
RRK is currently offline RRKFriend
Messages: 21
Registered: July 2009
Junior Member
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 #468089 is a reply to message #468033] Tue, 04 August 2009 05:03 Go to previous messageGo to next message
Stefan Liebig is currently offline Stefan LiebigFriend
Messages: 124
Registered: July 2009
Senior Member
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 #468130 is a reply to message #468089] Tue, 04 August 2009 10:16 Go to previous messageGo to next message
RRK is currently offline RRKFriend
Messages: 21
Registered: July 2009
Junior Member
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 #468144 is a reply to message #468130] Tue, 04 August 2009 10:52 Go to previous messageGo to next message
Stefan Liebig is currently offline Stefan LiebigFriend
Messages: 124
Registered: July 2009
Senior Member
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 #468154 is a reply to message #468144] Tue, 04 August 2009 12:07 Go to previous messageGo to next message
RRK is currently offline RRKFriend
Messages: 21
Registered: July 2009
Junior Member
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 12:52 Go to previous messageGo to next message
Stefan Liebig is currently offline Stefan LiebigFriend
Messages: 124
Registered: July 2009
Senior Member
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 19:37 Go to previous message
Christian Campo is currently offline Christian CampoFriend
Messages: 597
Registered: July 2009
Senior Member
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 05:03 Go to previous message
Stefan Liebig is currently offline Stefan LiebigFriend
Messages: 124
Registered: July 2009
Senior Member
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 10:16 Go to previous message
RRK is currently offline RRKFriend
Messages: 21
Registered: July 2009
Junior Member
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 10:52 Go to previous message
Stefan Liebig is currently offline Stefan LiebigFriend
Messages: 124
Registered: July 2009
Senior Member
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 12:07 Go to previous message
RRK is currently offline RRKFriend
Messages: 21
Registered: July 2009
Junior Member
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 12:52 Go to previous message
Stefan Liebig is currently offline Stefan LiebigFriend
Messages: 124
Registered: July 2009
Senior Member
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 19:37 Go to previous message
Christian Campo is currently offline Christian CampoFriend
Messages: 597
Registered: July 2009
Senior Member
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
Previous Topic:Problem with annotated injection
Next Topic:Riena milestone 1.2.0.M1
Goto Forum:
  


Current Time: Thu Apr 18 07:11:59 GMT 2024

Powered by FUDForum. Page generated in 0.03382 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top