|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.servlet.GenericServlet javax.servlet.http.HttpServlet org.apache.jackrabbit.servlet.AbstractRepositoryServlet org.apache.jackrabbit.j2ee.RepositoryStartupServlet
public class RepositoryStartupServlet
The RepositoryStartupServlet starts a jackrabbit repository and registers it to the JNDI environment and optional to the RMI registry.
Registration with RMI
Upon successfull creation of the repository in theinit()
method,
the repository is registered with an RMI registry if the web application is
so configured. To register with RMI, the following web application
init-params
are considered: rmi-port
designating
the port on which the RMI registry is listening, rmi-host
designating the interface on the local host on which the RMI registry is
active, repository-name
designating the name to which the
repository is to be bound in the registry, and rmi-uri
designating an RMI URI complete with host, optional port and name to which
the object is bound.
If the rmi-uri
parameter is configured with a non-empty value,
the rmi-port
and rmi-host
parameters are ignored.
The repository-name
parameter is only considered if a non-empty
rmi-uri
parameter is configured if the latter does not contain
a name to which to bind the repository.
This is the algorithm used to find out the host, port and name for RMI
registration:
rmi-uri
nor a rmi-host
nor a
rmi-port
parameter is configured, the repository is not
registered with any RMI registry.
rmi-uri
parameter is configured extract the
host name (or IP address), port number and name to bind to from the
URI. If the URI is not valid, host defaults to 0.0.0.0
meaning all interfaces on the local host, port defaults to the RMI
default port (1099
) and the name defaults to the value
of the repository-name
parameter.
rmi-uri
is not configured, the host is taken
from the rmi-host
parameter, the port from the
rmi-port
parameter and the name to bind the repository to
from the repository-name
parameter. If the
rmi-host
parameter is empty or not configured, the host
defaults to 0.0.0.0
meaning all interfaces on the local
host. If the rmi-port
parameter is empty, not configured,
zero or a negative value, the default port for the RMI registry
(1099
) is used.
LocateRegistry.createRegistry
method is
called to create a registry on the local host listening on the host and port
configured. If creation fails, the LocateRegistry.getRegistry
method is called to get a remote instance of the registry. Note, that
getRegistry
does not create an actual registry on the given
host/port nor does it check, whether an RMI registry is active.
When the registry has been retrieved, either by creation or by just creating
a remote instance, the repository is bound to the configured name in the
registry.
Possible causes for registration failures include:
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 Functionalitybootstrap-config
parameter that referrs to a propertiy file.
This file must exsit for proper working. If not, the repository is not
started.
Nested Class Summary | |
---|---|
protected static class |
RepositoryStartupServlet.RemoteFactoryDelegater
optional class for RMI, will only be used, if RMI server is present |
protected static class |
RepositoryStartupServlet.RMIRemoteFactoryDelegater
optional class for RMI, will only be used, if RMI server is present |
Field Summary | |
---|---|
static String |
INIT_PARAM_BOOTSTRAP_CONFIG
initial param name for the bootstrap config location |
Constructor Summary | |
---|---|
RepositoryStartupServlet()
|
Method Summary | |
---|---|
protected Repository |
createRepository(InputSource is,
File homedir)
Creates the repository instance for the given config and homedir. |
void |
destroy()
destroy the servlet |
protected void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
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 void |
doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
|
BootstrapConfig |
getBootstrapConfig()
Returns the config that was used to bootstrap this servlet. |
static RepositoryStartupServlet |
getInstance(javax.servlet.ServletContext context)
Returns an instance of this servlet. |
protected String |
getRemoteFactoryDelegaterClass()
Return the fully qualified name of the class providing the remote repository. |
Repository |
getRepository()
Returns the started repository or null if not started
yet. |
RepositoryFactory |
getRepositoryFactory()
Returns a repository factory that returns the repository if available or throws an exception if not. |
protected RMIServerSocketFactory |
getRMIServerSocketFactory(InetAddress hostAddress)
Returns an RMIServerSocketFactory used to create the server
socket for a locally created RMI registry. |
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 deregisters it from the RMI registry 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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String INIT_PARAM_BOOTSTRAP_CONFIG
Constructor Detail |
---|
public RepositoryStartupServlet()
Method Detail |
---|
public void init() throws javax.servlet.ServletException
init
in class AbstractRepositoryServlet
javax.servlet.ServletException
- if a same servlet is already registered or of
another initialization error occurs.public static RepositoryStartupServlet getInstance(javax.servlet.ServletContext context)
context
- the servlet context
public void startup() throws javax.servlet.ServletException
javax.servlet.ServletException
- if an error occurs.public void shutdown()
public void restart() throws javax.servlet.ServletException
javax.servlet.ServletException
- if an error occurs.shutdown()
,
startup()
public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class AbstractRepositoryServlet
public Repository getRepository()
null
if not started
yet.
getRepository
in class AbstractRepositoryServlet
public RepositoryFactory getRepositoryFactory()
protected Repository createRepository(InputSource is, File homedir) throws RepositoryException
Repository
.
is
- input source of the repository confighomedir
- the repository home directory
RepositoryException
- if an error during creation occurs.public BootstrapConfig getBootstrapConfig()
null
.protected String getRemoteFactoryDelegaterClass()
RepositoryStartupServlet.RemoteFactoryDelegater
interface.
Subclasses may override this method for providing a name of a own
implementation.
protected RMIServerSocketFactory getRMIServerSocketFactory(InetAddress hostAddress)
RMIServerSocketFactory
used to create the server
socket for a locally created RMI registry.
This implementation returns a new instance of a simple
RMIServerSocketFactory
which just creates instances of
the java.net.ServerSocket
class bound to the given
hostAddress
. Implementations may overwrite this method to
provide factory instances, which provide more elaborate server socket
creation, such as SSL server sockets.
hostAddress
- The InetAddress
instance representing the
the interface on the local host to which the server sockets are
bound.
RMIServerSocketFactory
creating java.net.ServerSocket
instances bound to
the rmiHost
.protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException
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 AbstractRepositoryServlet
req
- HTTP requestresp
- HTTP response
javax.servlet.ServletException
- on servlet errors
IOException
- on IO errorsprotected void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, IOException
doPost
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |