Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » @Optional doesn't work as I expect
@Optional doesn't work as I expect [message #731600] Sat, 01 October 2011 20:03 Go to previous message
Missing name Missing name is currently offline Missing name Missing name
Messages: 18
Registered: September 2011
Junior Member
I've got a method:

class MyClass {

...

@Inject
void setSomething(@Optional Something something) {
// do something with something
}

}

I want this method to be called only if I've placed something in the context to be injected. Trouble is, when I construct a MyClass, a Something gets constructed to satisfy the injection. That's not what I want. How can I make this truly optional so that DI won't default construct something in order to call it? I'd settle for a call to setSomething(null).
 
Read Message
Read Message
Read Message
Previous Topic:When Processor method is called ?
Next Topic:Change Part size dynamically
Goto Forum:
  


Current Time: Wed May 22 11:50:37 EDT 2013

Powered by FUDForum. Page generated in 0.02393 seconds