• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: WOInject and WOUnit co-operation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WOInject and WOUnit co-operation


  • Subject: Re: WOInject and WOUnit co-operation
  • From: Paul Hoadley <email@hidden>
  • Date: Thu, 7 Dec 2017 14:36:08 +1030

Hi Henrique,

On 6 Dec 2017, at 20:45, Paul Hoadley <email@hidden> 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      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >WOInject and WOUnit co-operation (From: Paul Hoadley <email@hidden>)
 >Re: WOInject and WOUnit co-operation (From: Henrique Prange <email@hidden>)
 >Re: WOInject and WOUnit co-operation (From: Paul Hoadley <email@hidden>)

  • Prev by Date: Re: WOInject and WOUnit co-operation
  • Next by Date: Webservice soap header
  • Previous by thread: Re: WOInject and WOUnit co-operation
  • Next by thread: Webservice soap header
  • Index(es):
    • Date
    • Thread