Class RepositoryStartupServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.apache.jackrabbit.servlet.AbstractRepositoryServlet
-
- org.apache.jackrabbit.j2ee.RepositoryStartupServlet
-
- All Implemented Interfaces:
Serializable,javax.servlet.Servlet,javax.servlet.ServletConfig
public class RepositoryStartupServlet extends AbstractRepositoryServlet
The RepositoryStartupServlet starts a jackrabbit repository and registers it to the JNDI environment.Setup Wizard Functionality
When using the first time, the configuration can miss the relevant repository parameters in the web.xml. if so, it must contain abootstrap-configparameter that refers to a property file. This file must exist 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 prompts 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringINIT_PARAM_BOOTSTRAP_CONFIGinitial param name for the bootstrap config location
-
Constructor Summary
Constructors Constructor Description RepositoryStartupServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RepositorycreateRepository(InputSource is, File homedir)Creates the repository instance for the given config and homedir.voiddestroy()destroy the servletprotected voiddoGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Outputs the repository descriptors either as a collection of properties (seeProperties.store(java.io.OutputStream, String)or individually addressable text/plain resources based on the request URI.protected voiddoPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)BootstrapConfiggetBootstrapConfig()Returns the config that was used to bootstrap this servlet.static RepositoryStartupServletgetInstance(javax.servlet.ServletContext context)Returns an instance of this servlet.RepositorygetRepository()Returns the started repository ornullif not started yet.RepositoryFactorygetRepositoryFactory()Returns a repository factory that returns the repository if available or throws an exception if not.voidinit()Initializes the servlet.
Please note that only one repository startup servlet may exist per webapp.voidrestart()Restarts the repository.voidshutdown()Does a shutdown of the repository and deregisters it from the RMI registry and unbinds if from the JNDI context if so configured.voidstartup()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
-
-
-
-
Field Detail
-
INIT_PARAM_BOOTSTRAP_CONFIG
public static final String INIT_PARAM_BOOTSTRAP_CONFIG
initial param name for the bootstrap config location- See Also:
- Constant Field Values
-
-
Method Detail
-
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:
initin classAbstractRepositoryServlet- Throws:
javax.servlet.ServletException- if a same servlet is already registered or of another initialization error occurs.
-
getInstance
public static RepositoryStartupServlet getInstance(javax.servlet.ServletContext context)
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. It registers it then to the RMI registry and bind is to the JNDI context if so configured.- Throws:
javax.servlet.ServletException- if an error occurs.
-
shutdown
public void shutdown()
Does a shutdown of the repository and deregisters it from the RMI registry 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:
shutdown(),startup()
-
destroy
public void destroy()
destroy the servlet- Specified by:
destroyin interfacejavax.servlet.Servlet- Overrides:
destroyin classAbstractRepositoryServlet
-
getRepository
public Repository getRepository()
Returns the started repository ornullif not started yet.- Specified by:
getRepositoryin classAbstractRepositoryServlet- Returns:
- the JCR repository
-
getRepositoryFactory
public RepositoryFactory getRepositoryFactory()
Returns a repository factory that returns the repository if available or throws an exception if not.- Returns:
- repository factory
-
createRepository
protected Repository createRepository(InputSource is, File homedir) throws RepositoryException
Creates the repository instance for the given config and homedir. Subclasses may override this method of providing own implementations of aRepository.- Parameters:
is- input source of the repository confighomedir- the repository home directory- Returns:
- a new jcr repository.
- Throws:
RepositoryException- if an error during creation occurs.
-
getBootstrapConfig
public BootstrapConfig 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, IOExceptionOutputs the repository descriptors either as a collection of properties (seeProperties.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 likehttp://server/context/repository/key. For example, the name of the repository vendor could be retrieved fromhttp://server/context/repository/jcr.repository.vendor. Likewise, a 404 (not found) response fromhttp://server/context/repository/level.2.supportedwould 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.
- Overrides:
doGetin classAbstractRepositoryServlet- Parameters:
req- HTTP requestresp- HTTP response- Throws:
javax.servlet.ServletException- on servlet errorsIOException- on IO errors
-
doPost
protected void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException- Overrides:
doPostin classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionIOException
-
-