Hi Jeff,

Thank you for calling me out on this. Yeah looking into Dagger a bit more 
(I must admit to being a newbie with that framework), my answer should be 
completely disregarded. I gave a way to share DATA, not objects :P.

Jeff seems to be in the right here, While you possibly CAN create some 
cross-instance, using a LOT of work, a backend permanent instance for it to 
reside, and creating endpoints to get it and update it... it's a LOT of 
work for something you can simply declare locally as static and your app 
won't really change it's behavior (be careful about testing, as Jeff points 
out, as this will definitely be special, testing a "fake" singleton as a 
real one will be misleading). 

Cheers!

On Monday, July 6, 2015 at 12:28:46 AM UTC-4, Jeff Schnitzer wrote:
>
> Patrice: Dagger is a dependency injection framework like Guice. He's 
> asking how you create a singleton object in Java webland.
>
> Zak: There are lots of ways of doing this. First of all, you do not want 
> to try to create some sort of cross-instance object graph; each instance 
> should instantiate the ObjectGraph at instance start. Any other way lies 
> madness.
>
> The most "natural" place to do this is in a ServletContextListener you 
> configure in web.xml. Then put the ObjectGraph in the 
> ServletContext.get/setAttribute collection. However, you're going to 
> quickly figure out that all of this feels a little inside-out because 
> really, things like servlets or JAXRS endpoints or whatnot should be 
> instantiated by Dagger, not the other way around.
>
> Another option is to simply save the ObjectGraph as a static field 
> somewhere, instantiated as a singleton statically. This suffers from 
> testability issues but if you want easy, that's the simplest solution.
>
> FWIW, Dagger has some catching up to do before it's ready to replace Guice 
> on the server-side. You might want to switch to Guice; it will feel less 
> like swimming upstream but for the most part the API is pretty similar.
>
> Jeff
>
> On Thu, Jul 2, 2015 at 7:40 AM, Patrice (Cloud Platform Support) <
> pvoutsi...@google.com> wrote:
>
>> Hi Zack,
>>
>> I could see saving data in the datastore (as a blob, possibly), and 
>> retrieving it when needed from there to be a solution.
>>
>> If I get it correctly, you want to be able to have a single point of 
>> access for your object graphs? to me, I'd say the best would be datastore 
>> as a blob. Maybe your precise use-case doesn't warrant that though, so if 
>> you could expand, it would be great so we can discuss an answer more 
>> tailored to your question :)
>>
>> Cheers!
>>
>> On Wednesday, July 1, 2015 at 4:58:25 PM UTC-4, Zak Taccardi wrote:
>>>
>>> I am using dagger for dependency injection, and I don't want to create a 
>>> new object graph for every endpoint.
>>>
>>> Android lets us extend `Application`, which is a great place to store 
>>> our singletons so they can be easily reused throughout different pages 
>>> (actiivities) in the app.
>>>
>>> What is Google App-Engine's equivalent of this?
>>>
>>>
>>> note: I am okay with this being a per-instance thing.
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Google App Engine" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to google-appengine+unsubscr...@googlegroups.com.
>> To post to this group, send email to google-appengine@googlegroups.com.
>> Visit this group at http://groups.google.com/group/google-appengine.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/google-appengine/165b1007-c4f4-4bc1-9069-74c5c2561f2e%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/google-appengine/165b1007-c4f4-4bc1-9069-74c5c2561f2e%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/51488f87-36cf-44f6-b566-796513743f88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to