Hi Henrique,

On 6 Dec 2017, at 20:45, Paul Hoadley <pa...@logicsquad.net> wrote:

>> Create a protected method to initialize the EO dependency:
>> 
>> class MyEO {
>>    private AnyObject object;
>> 
>>    @Inject
>>    protected void initMyObject(AnyObject object) {
>>       this.object = object;
>>    }
>> }
>> 
>> @Before
>> public void setup() {
>>    eo = new MyEO();
>> 
>>    eo.initMyObject(anObject);
>> 
>>    editingContext.insertObject(eo); // or insertSavedObject if you want to 
>> create a dummy EO.
>> }
> 
> In this first solution, there’s no @Inject annotation on 'AnyObject object' 
> now. Forgive my Guice ignorance here—does the @Inject on 
> initMyObject(AnyObject object) cause that method to be _called_ by Guice?

Sure does!

> If so, when?

Presumably at construction time.

>> It's not cool if you have to do it all the time, but it looks more polished 
>> than making your EO ask for a test version of the injected object. What do 
>> you think?
> 
> Great solutions—thanks. I’ll test them out tomorrow.

I’ve used the annotated init…() method example. Works great.


-- 
Paul Hoadley
https://logicsquad.net/
https://www.linkedin.com/company/logic-squad/


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to