Class RepositoryStartupServlet
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
Note: if a bootstrap-config
init parameter is specified the
servlet tries to read the respective resource, either as context resource or
as file. The properties specified in this file override the init params
specified in the web.xml
.
Setup Wizard Functionality
When using the first time, the configuraition can miss the relevant
repository parameters in the web.xml. if so, it must contain a
bootstrap-config
parameter that referrs to a propertiy file.
This file must exsit for proper working. If not, the repository is not
started.
If the servlet is not configured correctly and accessed via http, it will
provide a simple wizard for the first time configuration. It propmpts for
a new (or existing) repository home and will copy the templates of the
repository.xml and bootstrap.properties to the respective location.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
initial param name for the bootstrap config location -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Repository
createRepository
(File configJson, File homedir) Creates the repository instance for the given config and homedir.void
destroy()
destroy the servletprotected void
doGet
(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) protected void
doPost
(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) Returns the config that was used to bootstrap this servlet.static RepositoryStartupServlet
getInstance
(javax.servlet.ServletContext context) Returns an instance of this servlet.Returns the started repository ornull
if not started yet.Returns a repository factory that returns the repository if available or throws an exception if not.void
init()
Initializes the servlet.
Please note that only one repository startup servlet may exist per webapp.void
restart()
Restarts the repository.void
shutdown()
Does a shutdown of the repository and unbinds if from the JNDI context if so configured.void
startup()
Configures and starts the repository.Methods inherited from class org.apache.jackrabbit.servlet.AbstractRepositoryServlet
getAttributeName, getInitParameter
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
INIT_PARAM_BOOTSTRAP_CONFIG
initial param name for the bootstrap config location- See Also:
-
-
Constructor Details
-
RepositoryStartupServlet
public RepositoryStartupServlet()
-
-
Method Details
-
init
public void init() throws javax.servlet.ServletExceptionInitializes the servlet.
Please note that only one repository startup servlet may exist per webapp. it registers itself as context attribute and acts as singleton.- Overrides:
init
in classAbstractRepositoryServlet
- Throws:
javax.servlet.ServletException
- if a same servlet is already registered or of another initialization error occurs.
-
getInstance
Returns an instance of this servlet. Please note, that only 1 repository startup servlet can exist per webapp.- Parameters:
context
- the servlet context- Returns:
- this servlet
-
startup
public void startup() throws javax.servlet.ServletExceptionConfigures and starts the repository.- Throws:
javax.servlet.ServletException
- if an error occurs.
-
shutdown
public void shutdown()Does a shutdown of the repository and unbinds if from the JNDI context if so configured. -
restart
public void restart() throws javax.servlet.ServletExceptionRestarts the repository.- Throws:
javax.servlet.ServletException
- if an error occurs.- See Also:
-
destroy
public void destroy()destroy the servlet- Specified by:
destroy
in interfacejavax.servlet.Servlet
- Overrides:
destroy
in classAbstractRepositoryServlet
-
getRepository
Returns the started repository ornull
if not started yet.- Specified by:
getRepository
in classAbstractRepositoryServlet
- Returns:
- the JCR repository
-
getRepositoryFactory
Returns a repository factory that returns the repository if available or throws an exception if not.- Returns:
- repository factory
-
createRepository
Creates the repository instance for the given config and homedir. Subclasses may override this method of providing own implementations of aRepository
.- Parameters:
configJson
- input source of the repository confighomedir
- the repository home directory- Returns:
- a new jcr repository.
- Throws:
RepositoryException
- if an error during creation occurs.
-
getBootstrapConfig
Returns the config that was used to bootstrap this servlet.- Returns:
- the bootstrap config or
null
.
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException - Overrides:
doGet
in classAbstractRepositoryServlet
- Throws:
javax.servlet.ServletException
IOException
-
doPost
protected void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException - Overrides:
doPost
in classjavax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
IOException
-