import javax.jcr.Session;
import javax.security.auth.Subject;
+import org.argeo.jcr.JcrException;
import org.argeo.jcr.JcrUtils;
/** Manages JCR {@link Session} in an ACR context. */
private boolean closed = false;
+ private Thread lastRetrievingThread = null;
+
public JcrSessionAdapter(Repository repository, Subject subject) {
this.repository = repository;
this.subject = subject;
throw new IllegalStateException("JCR session adapter is closed.");
Thread currentThread = Thread.currentThread();
+ if (lastRetrievingThread == null)
+ lastRetrievingThread = currentThread;
Map<String, Session> threadSession = threadSessions.get(currentThread);
if (threadSession == null) {
});
threadSession.put(workspace, session);
}
+
+ if (lastRetrievingThread != currentThread) {
+ try {
+ session.refresh(true);
+ } catch (RepositoryException e) {
+ throw new JcrException("Cannot refresh JCR session " + session, e);
+ }
+ }
+ lastRetrievingThread = currentThread;
return session;
}