jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guo Du <mrdu...@gmail.com>
Subject Re: Jackrabbit Session inside Stateless Session EJB
Date Thu, 15 Oct 2009 09:28:39 GMT
On Thu, Oct 15, 2009 at 7:41 AM, Jaco Prinsloo <jacolists@gmail.com> wrote:
> Thanks for clarifying.
> Perhaps I can clarify the difference with two pseudo-ish code examples:
>
> (1)
> @Stateless
> public class RepositoryEJB {
>  @Resource private Repository repository;
>
>  public String getMimeType(String path) {
>    Session session = repository.login( .. );
>    String mimeType =
> (String)session.getRootNode().getNode(path).getProperties().get( .. );
>    session.logout();
>    return mimeType;
>  }

>1) Every request (method) opens a session, performs the work and then closes
> the session again.

Sorry, I was missed the keywords "method" at first place. Open session
COULD be expensive operation. I was never thought such a way to
process request :(

So the second is the right approach. Just make sure you closed the
session properly at the end.

-Guo

Mime
View raw message