public abstract class AbstractRepositoryServlet
extends javax.servlet.http.HttpServlet
getRepository()
method that returns the actual content repository.
The Repository
instance bound to the servlet context is actually
a ProxyRepository
for late binding of the underlying content repository.
The default name of the repository attribute is
"javax.jcr.Repository
", but it can be changed by specifying
an init parameter with the same name:
<servlet> <init-param> <param-name>javax.jcr.Repository</param-name> <param-value>my.repository.attribute</param-value> <description> This init parameter causes the repository to be looked up from the "my.repository.attribute" attribute instead of the default "javax.jcr.Repository". </description> </init-param> </servlet>
A repository servlet can also be mapped to the URL space. See the
doGet(HttpServletRequest, HttpServletResponse)
method for
the details of the default behavior.
Constructor and Description |
---|
AbstractRepositoryServlet() |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Removes the repository attribute from the servlet context.
|
protected void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Outputs the repository descriptors either as a collection of properties
(see
Properties.store(java.io.OutputStream, String) or
individually addressable text/plain resources based on the request URI. |
protected String |
getAttributeName()
Returns the name of the repository attribute.
|
protected String |
getInitParameter(String name,
String def)
Utility method that returns the named init parameter or the given
default value if the parameter does not exist.
|
protected abstract Repository |
getRepository()
Returns the repository that will be used by the
ProxyRepository bound to the servlet context. |
void |
init()
Binds a
ProxyRepository with the repository returned by
getRepository() in the configured servlet context attribute. |
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
public void init() throws javax.servlet.ServletException
ProxyRepository
with the repository returned by
getRepository()
in the configured servlet context attribute.init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class javax.servlet.GenericServlet
protected abstract Repository getRepository() throws RepositoryException
ProxyRepository
bound to the servlet context.RepositoryException
- if the repository could not be createdprotected String getAttributeName()
javax.jcr.Repository
" or
the value of the "javax.jcr.Repository
" init parameter.
A subclass can override this method to customize the attribute name, but for consistency it is generally better not to do that.
protected String getInitParameter(String name, String def)
name
- name of the init parameterdef
- default valueprotected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
Properties.store(java.io.OutputStream, String)
or
individually addressable text/plain resources based on the request URI.
A typical mapping for a repository servlet would be:
<servlet-mapping> <servlet-name>Repository</servlet-name> <url-pattern>/repository/*</url-pattern> </servlet-mapping>
This mapping would allow clients to retrieve all repository descriptors
from http://server/context/repository/
and to address
individual descriptors by key with URIs like
http://server/context/repository/key
.
For example, the name of the repository vendor could be retrieved from
http://server/context/repository/jcr.repository.vendor
.
Likewise, a 404 (not found) response from
http://server/context/repository/level.2.supported
would
indicate that the repository does not support Level 2 features.
Note that mapping a repository servlet to the URL space is optional, as the main purpose of the servlet is to make a repository available in the servlet context, not to expose repository information to web clients.
doGet
in class javax.servlet.http.HttpServlet
request
- HTTP requestresponse
- HTTP responseIOException
- on IO errorsjavax.servlet.ServletException
- on servlet errorsCopyright © 2004–2024 The Apache Software Foundation. All rights reserved.