Application code must retrieve a JCR Session via the JcrSessionFactoryUtils.getSession
method, to be able to detect a thread-bound Jcr Session. It is preferable to use getSession
with allowCreate=false, if the code relies on the interceptor to provide proper session handling. Typically, the code will look as follows:
public void doJcrAction() { Session session = JcrSessionFactoryUtils.getSession(this.jsf, false); try { ... } catch (RepositoryException ex) { throw JcrSessionFactoryUtils.convertJcrAccessException(ex); } }Note that the application must care about handling RepositoryExceptions itself, preferably via delegating to the
JcrSessionFactoryUtils.convertJcrAccessException
method that converts them to exceptions that are compatible with the org.springframework.dao
exception hierarchy (like JcrTemplate does). This class can be considered a declarative alternative to JcrTemplate's callback approach. The advantages are:
The drawbacks are:
|
|