[appengine-java] Re: Understanding gwt-dispatch and Singletons/member variables

2010-12-30 Thread Sky
I switched to local variables and now it works perfectly.



On 23 Dez., 10:05, "l.denardo"  wrote:
> I don't fully understand your problem (maybe a few lines of code will
> help).
>
> Anyway:
> *Member variables in action handlers are usually created as they
> should, empty, for my experience
> *Memcache is shared across all application instances, so if you
> populate your map using the memcache value and then check for it, your
> map will always contain the same items once cache is populated.
>
> i.e. what is expected is something like
>
> private Map cacheMap = new HashMap Serializable>();
> //map will be empty
> cacheMap.put( memcacheServiceInstance.get(key) );
> //cacheMap will be populated always with the same value, if provided
> key results in a memcache hit
>
> Regards
> Lorenzo
>
> On Dec 22, 12:55 pm, Sky  wrote:
>
> > Hi all,
>
> > I use gwt-dispatch in a project and now I have a question concerning
> > the gwt-dispatch framework and member variables in ActionHandlers.
> > I use guice on server side and bind the ActionHandlers as follow:
> > bindHandler(GetXYHandler.class);  <- this is per definition no
> > singleton!
>
> > In GetXYHandler I have a member variable, which stores the data
> > retrieved from Googles MemCacheService:
> > private Map cacheMap = new HashMap > Serializable>();
>
> > When making a server request in the execute method of GetXYHandler the
> > cacheMap is filled with objects, when a cache hit in memcache occurs  -
>
> > > the cacheMap member variable is not empty anymore!
>
> > My understanding of member variables (in example "cacheMap") is, that
> > they should be created new in each serverCall if they are not static.
> > In my case the cacheMap should be empty each time when the execute
> > method is called.
> > In my local tests the behaviour is somewhat different. When I test it
> > in debug modus locally (different user calls), the cacheMap stays
> > always filled like a static variable. Is this the normal behaviour of
> > member variables of Actionhandlers? My understanding would say this is
> > very curious, because its not a singleton?
> > If this is normal behaviour, no member variables could be used,
> > because they would not be synchronized...
>
> > Thanks for your help!
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.



[appengine-java] Re: Understanding gwt-dispatch and Singletons/member variables

2010-12-23 Thread l.denardo
I don't fully understand your problem (maybe a few lines of code will
help).

Anyway:
*Member variables in action handlers are usually created as they
should, empty, for my experience
*Memcache is shared across all application instances, so if you
populate your map using the memcache value and then check for it, your
map will always contain the same items once cache is populated.

i.e. what is expected is something like

private Map cacheMap = new HashMap();
//map will be empty
cacheMap.put( memcacheServiceInstance.get(key) );
//cacheMap will be populated always with the same value, if provided
key results in a memcache hit

Regards
Lorenzo

On Dec 22, 12:55 pm, Sky  wrote:
> Hi all,
>
> I use gwt-dispatch in a project and now I have a question concerning
> the gwt-dispatch framework and member variables in ActionHandlers.
> I use guice on server side and bind the ActionHandlers as follow:
> bindHandler(GetXYHandler.class);  <- this is per definition no
> singleton!
>
> In GetXYHandler I have a member variable, which stores the data
> retrieved from Googles MemCacheService:
> private Map cacheMap = new HashMap Serializable>();
>
> When making a server request in the execute method of GetXYHandler the
> cacheMap is filled with objects, when a cache hit in memcache occurs  -
>
> > the cacheMap member variable is not empty anymore!
>
> My understanding of member variables (in example "cacheMap") is, that
> they should be created new in each serverCall if they are not static.
> In my case the cacheMap should be empty each time when the execute
> method is called.
> In my local tests the behaviour is somewhat different. When I test it
> in debug modus locally (different user calls), the cacheMap stays
> always filled like a static variable. Is this the normal behaviour of
> member variables of Actionhandlers? My understanding would say this is
> very curious, because its not a singleton?
> If this is normal behaviour, no member variables could be used,
> because they would not be synchronized...
>
> Thanks for your help!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.