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
