org.priha.j2ee
Class JNDIRegistrationServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.priha.j2ee.JNDIRegistrationServlet
- All Implemented Interfaces:
- java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
public class JNDIRegistrationServlet
- extends javax.servlet.http.HttpServlet
This is a small helper class which can be used to register Priha
to JNDI. To use this, just initialize it in any web.xml file, like thus:
<servlet>
<servlet-name>PrihaServlet</servlet-name>
<servlet-class>org.priha.j2ee.JNDIRegistrationServlet</servlet-class>
<load-on-startup>100</load-on-startup>
<!-- The following is optional. If there is no propertyfile parameter
stated, will attempt to find "priha.properties" from the classpath. -->
<init-param>
<param-name>propertyfile<param-name>
<param-value>/foo/bar/priha.properties<param-value>
</init-param>
</servlet>
Any servlet parameters which start with "java.naming." are added to the
InitialContext environment.
In order then to fetch it in your web application, you would use something like this:
Repository repository;
Properties environment = new Properties();
String lookupName = "priha.repository";
InitialContext initial = new InitialContext(environment);
Object obj = initial.lookup(lookupName);
repository = (Repository)PortableRemoteObject.narrow(obj, Repository.class);
- See Also:
- Serialized Form
Field Summary |
static java.lang.String |
JNDI_NAME
Value under which the Repository object is bound by default. |
static java.lang.String |
PARAM_PROPERTYFILE
Servlet initialization parameter name for stating the name of the
property file. |
Method Summary |
void |
init()
|
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, 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 |
JNDI_NAME
public static final java.lang.String JNDI_NAME
- Value under which the Repository object is bound by default. Value is "priha.repository".
- See Also:
- Constant Field Values
PARAM_PROPERTYFILE
public static final java.lang.String PARAM_PROPERTYFILE
- Servlet initialization parameter name for stating the name of the
property file. Value is "propertyfile".
- See Also:
- Constant Field Values
JNDIRegistrationServlet
public JNDIRegistrationServlet()
init
public void init()
throws javax.servlet.ServletException
- Overrides:
init
in class javax.servlet.GenericServlet
- Throws:
javax.servlet.ServletException