Create a Naming interface proxy that uses HTTP to communicate with the
JBoss JNDI naming service. Any request to this servlet receives a
serialized object stream containing a MarshalledValue with the Naming proxy
as its content. The proxy is obtained from the MBean named by the
namingProxyMBean init-param.
| Method from org.jboss.invocation.http.servlet.NamingFactoryServlet Detail: |
public void destroy() {
}
|
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
processRequest(request, response);
}
Handles the HTTP GET method. |
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
processRequest(request, response);
}
Handles the HTTP POST method. |
public String getServletInfo() {
return "A factory servlet for Naming proxies";
}
Returns a short description of the servlet. |
public void init(ServletConfig config) throws ServletException {
super.init(config);
String category = getClass().getName() + '." + config.getServletName();
log = Logger.getLogger(category);
// Get the name of the MBean that provides the Naming proxy
String name = config.getInitParameter("namingProxyMBean");
if( name == null )
throw new ServletException("An namingProxyMBean must be specified");
proxyAttribute = config.getInitParameter("proxyAttribute");
if( proxyAttribute == null )
proxyAttribute = "Proxy";
try
{
namingProxyMBean = new ObjectName(name);
}
catch (MalformedObjectNameException e)
{
throw new ServletException("Failed to create object name: "+name, e);
}
}
|
protected void processRequest(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
boolean trace = log.isTraceEnabled();
if( trace )
log.trace("processRequest");
// Lazy load of the proxy
lookupNamingProxy();
try
{
response.setContentType(RESPONSE_CONTENT_TYPE);
MarshalledValue mv = new MarshalledValue(namingProxy);
if( trace )
log.trace("Serialized Naming proxy, size="+mv.size());
//response.setContentLength(mv.size());
ServletOutputStream sos = response.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(sos);
oos.writeObject(mv);
oos.flush();
oos.close();
}
catch(Throwable t)
{
log.debug("Invoke failed", t);
// Marshall the exception
response.resetBuffer();
MarshalledValue mv = new MarshalledValue(t);
ServletOutputStream sos = response.getOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(sos);
oos.writeObject(mv);
oos.close();
}
}
Return a Naming service proxy for any GET/POST made against this servlet |