You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@abdera.apache.org by James Abley <ja...@gmail.com> on 2008/08/01 11:44:40 UTC

request lifecycle for setting up and tearing down

Hi,

I'm trying to understand the idiomatic way to set up and teardown
resources during request processing.

In my case, I need a JCR session to store / retrieve data in the
underlying repository. I need to get an session from my session pool,
and then return my session to the session pool.

1. Use an Abdera Filter. This works for managing entries and media,
but fails for the service document. The session gets destroyed before
the output is created and an exception is thrown.

2. Use Transactional start / end, as per the example JCR Adapter in
the Abdera code. This works for managing entries and media, but fails
for the service document. start() is never called to create a session
for the request. The JcrCollectionAdapter sample within Abdera does
not suffer from this, since it only has a single workspace which is
programmatically configured with SimpleWorkspaceInfo

SimpleWorkspaceInfo wkspc = new SimpleWorkspaceInfo();
    wkspc.setTitle("JCR Workspace");
    wkspc.addCollection(cp);
    jcrProvider.addWorkspace(wkspc);

I need to be able to connect using a JCR session and enumerate the
available workspaces.

3. Use a Servlet Filter. This works, but duplicates some of the URI
parsing that Abdera does for me. If I manage JCR sessions within the
Abdera framework, I get to use the Target and parameters from the URI
path to determine which JCR workspace the request is for.

4. Use an Abdera filter to create the JCR session, and a Servlet
Filter to tear down the JCR session. This seems the best solution that
I have so far, but feels messy in terms of the asymmetry.

Does anyone have any suggestions as to what I'm missing?

Cheers,

James

Re: request lifecycle for setting up and tearing down

Posted by Christopher Elkins <ch...@esha.com>.
On Aug 1, 2008, at 2:44 AM, James Abley wrote:

> Does anyone have any suggestions as to what I'm missing?


5. Use a custom, JCR-backed WorkspaceManager implementation. What I do  
is obtain and release a JCR session within my getWorkspaces()  
implementation. This does mean that the same session is not used for  
subsequent JCR access within the same request, but that shouldn't be a  
problem as long as your implementation has no side-effects (i.e., just  
a read-only look at the repository).

-- 
Christopher Elkins