org.apache.jackrabbit.servlet
Class ServletRepository

java.lang.Object
  extended by org.apache.jackrabbit.commons.AbstractRepository
      extended by org.apache.jackrabbit.commons.repository.ProxyRepository
          extended by org.apache.jackrabbit.servlet.ServletRepository
All Implemented Interfaces:
Repository

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 {
                  session.logout();
              }
          } catch (RepositoryException e) {
              throw new ServletException(e);
          }
      }

 }
 

Since:
1.4
See Also:
ServletRepositoryFactory

Field Summary
 
Fields inherited from interface javax.jcr.Repository
LEVEL_1_SUPPORTED, LEVEL_2_SUPPORTED, OPTION_LOCKING_SUPPORTED, OPTION_OBSERVATION_SUPPORTED, OPTION_QUERY_SQL_SUPPORTED, OPTION_TRANSACTIONS_SUPPORTED, OPTION_VERSIONING_SUPPORTED, QUERY_XPATH_DOC_ORDER, QUERY_XPATH_POS_INDEX, REP_NAME_DESC, REP_VENDOR_DESC, REP_VENDOR_URL_DESC, REP_VERSION_DESC, SPEC_NAME_DESC, SPEC_VERSION_DESC
 
Constructor Summary
ServletRepository(javax.servlet.GenericServlet servlet)
          Creates a proxy for a repository found in the context of the given servlet.
 
Method Summary
 
Methods inherited from class org.apache.jackrabbit.commons.repository.ProxyRepository
getDescriptor, getDescriptorKeys, login
 
Methods inherited from class org.apache.jackrabbit.commons.AbstractRepository
login, login, login
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletRepository

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

Parameters:
servlet - servlet


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.