Thanks, so I assume there isn't any problem with reusing a session (as
subsequent requests to the EJB could be made by different users)?

On Thu, Oct 15, 2009 at 11:28 AM, Guo Du <[email protected]> wrote:

> On Thu, Oct 15, 2009 at 7:41 AM, Jaco Prinsloo <[email protected]>
> 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
>

Reply via email to