Class ServletRepository

  • All Implemented Interfaces:

    public class ServletRepository
    extends ProxyRepository
    Proxy for a repository bound in servlet context. The configured repository attribute is looked up from the servlet context during each method call. Thus the repository does not need to exist when this class is instantiated. The repository can also be replaced with another repository during the lifetime of an instance of this class.

    A typical way to use this class would be:

     public class MyServlet extends HttpServlet {
         private final Repository repository = new ServletRepository(this);
         protected void doGet(
                 HttpServletRequest request, HttpServletResponse response)
                 throws ServletException, IOException {
              try {
                  Session session = repository.login();
                  try {
                  } finally {
              } catch (RepositoryException e) {
                  throw new ServletException(e);

    Starting with version 1.6 this class can also be used by a servlet filter:

     public class MyFilter implements Filter {
         private Repository repository;
         public void init(FilterConfig config) {
             repository = new ServletRepository(config);
         // ...
    See Also:
    ServletRepositoryFactory, FilterRepositoryFactory
    • Constructor Detail

      • ServletRepository

        public ServletRepository​(javax.servlet.GenericServlet servlet)
        Creates a proxy for a repository found in the context of the given servlet.
        servlet - servlet
      • ServletRepository

        public ServletRepository​(javax.servlet.FilterConfig config)
        Creates a proxy for a repository found in the servlet context associated with the given filter configuration.
        config - filter configuration
        Apache Jackrabbit 1.6