cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krzysztof Janowicz...@janowicz.de>
Subject Stateless server (GWT)
Date Wed, 27 Aug 2008 11:23:57 GMT
Hi,

I am playing around with GWT, trying to implement a stateful client with
a stateless server (IMO this is the paradigm shift proposed by the
google guys). While this is a very promising solution for massive Web
2.0 ajax applications, I am running into some trouble handling this with
cayenne (2.0.4).

Most of the application logic is handled by the GWT client. The servlet
(GWT RPCService) is only used if the users change their settings or have
to interact with each other. As there will be many users I don't want to
have a session and associated datacontext per user. This would be very
ineffective, since communication between client and server is reduced to
a minimum. In addition, the datacontext stores objects in the
objectstore to manage their states, this is not necessary in a stateless
server scenario. Moreover, there are several isolated RPC services the
users are interacting with.

Hence, I decided to bind the context to a thread (see 
http://cayenne.apache.org/doc20/obtaining-datacontext.html). Each
servlet handles a couple of threads automatically (in my case tomcat)
and each thread has an own datacontext. This seems to be a nice solution
as I don't face and tread-safety problems and don't need to care about
sessions.

The first thing when executing a method within a RPCService is to call a
getcontext() method which gets the datacontext bounded to the thread
(DataContext.getThreadDataContext()) or creates one
(DataContext.bindThreadDataContext(DataContext.createDataContext(false)))
if this is the first time this thread is executed by the servlet
container.  My only concern so far is the objectstore of the datacontext
which keeps collecting objects. I set cayenne.DataRowStore.snapshot.size
to 1 but this only affects the DataRowStore. I tried to use
context.getObjectStore().startTrackingNewObjects() and then
context.getObjectStore().unregisterNewObjects() every time i get the
context from the thread but this does not solve my problem. IMO i don't
need to track any objects in the objectStore. If a client calls a
RPCService to create/change/delete something, this is either directly
commited to the DB (context.commitChanges()) or rolled back in case of
an error (context.rollbackChanges()). As the datacontext is kept per
thread its objectstore will run full of data which will probably be
never used again. Is there a way to clear the objectstore (expect
calling unregisterNode() for each created object by hand)? Should I
create a new datacontext for a thread after a while?

Any ideas? Thanks in advance.
Krzysztof

Mime
View raw message