jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hendrik Beck \(camunda\)" <hendrik.b...@camunda.com>
Subject RE: Repository Lock Problem in JEE-Environment
Date Thu, 23 Aug 2007 16:00:25 GMT
Hi Dan!

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Daniel Br?uen
> Sent: Thursday, August 23, 2007 10:23 PM
> To: users@jackrabbit.apache.org
> Subject: Re: Repository Lock Problem in JEE-Environment
> Hi!
> Marcel May wrote:
> > Can you use |@PreDestroy annotated method ?
> Yes, that's worth a try, at least for stateful session beans
> (@PrePassivate, @PostPassivate).

Be aware, that you should not rely on that these methods are really called
in any case. One example would be a server crash, but in general you should
be careful with that. Just ask yourself the question how serious it would be
if your bean dies without having executed the code in here.

> How do other folks use Jackrabbit in a JEE Environment, especially in a
> session bean? Do you acquire the repository in every single method call
> via JNDI, or do you store the repository handle in a member variable of
> the bean?
> If I get it correctly there can be only one single bean accessing the
> repository, since the repository can talk to only one single
> application. As a consequence there would be a locking-problem if the
> container decides to create another bean to handle requests, which is odd.

I haven't tested it, but the @Resource annotation should work to access
anything that's in JNDI. For example if you hooked your Repository into JNDI
under "java:jcr/local" then you should be able to get the handle like that:

public class MyBean() {

  @Resource (name="jcr/local") private Repository repository;



The container now looks up the Repository in JNDI and injects it into the
bean when it's created. This should work with managed beans in EJB3 (i.e. SL
and SF beans), I doubt it's working e.g. for helper classes.

Hope it helps. Best regards

> cheers,
> Dan

View raw message