Methods Summary |
---|
private void | configureResponse(javax.servlet.http.HttpServletResponse response, javax.management.remote.message.Message message)
response.setContentType(BINARY_DATA_TYPE);
/* BEGIN -- S1WS_MOD */
int reslen = getContentLength(message);
if (JMXInbandStream.getOutgoingStream() != null) {
int len = (int) JMXInbandStream.getOutgoingStreamLength();
int chunks = (int) ((len/8192) + 2);
reslen += len + (chunks * 4);
}
response.setContentLength(reslen /*getContentLength(message)*/);
/* END -- S1WS_MOD */
response.setHeader("Connection", "Keep-Alive");
response.setStatus(HttpServletResponse.SC_OK);
|
public void | destroy()Destroys the servlet.
/* BEGIN -- S1WS_MOD */
requestHandler.getNotificationManager().close();
/* END -- S1WS_MOD */
|
protected void | doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Handles the HTTP GET method.
processRequest(request, response);
|
protected void | doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Handles the HTTP POST method.
processRequest(request, response);
|
private void | drainInputStream()
InputStream in = JMXInbandStream.getInputStream();
if (in != null) {
byte[] bytes = new byte[8192];
try {
while (in.read(bytes) != -1)
;
} catch (IOException ignore) {
// XXX: Log it
}
}
|
private int | getContentLength(java.io.Serializable serObject)Returns the size of given seialized object in bytes.
The size is calculated from the underlying ByteArrayOutputStream
backing an ObjectStream, onto which the Object is written.
int size = 0;
ObjectOutputStream oos = null;
try {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(serObject);
size = baos.size();
}
catch (Exception e) {
e.printStackTrace();
}
finally {
/* BEGIN -- S1WS_MOD */
/*
try {
if (oos != null) {
oos.close();
}
}
catch (Exception e){}
*/
/* END -- S1WS_MOD */
}
return size;
|
public void | init(javax.servlet.ServletConfig config)Initializes the servlet./*,
DefaultConfiguration.LOGGER_RESOURCE_BUNDLE_NAME );*/
/* END -- S1WS_MOD */
super.init(config);
/* BEGIN -- S1WS_MOD */
// requestHandler = new MBeanServerRequestHandler();
requestHandler = new MBeanServerRequestHandler(config);
/* END -- S1WS_MOD */
|
protected void | processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Processes requests for both HTTP GET and POST methods.
try {
/* BEGIN -- S1WS_MOD */
String pathInfo = request.getPathInfo();
if (pathInfo != null && pathInfo.trim().equals(DefaultConfiguration.NOTIF_MGR_PATHINFO)) {
requestHandler.getNotificationManager().getNotifications(request, response);
return;
}
/* END -- S1WS_MOD */
final Message requestMessage = readRequestMessage(request);
final Message responseMessage = requestHandler.handle
((MBeanServerRequestMessage)requestMessage);
/* BEGIN -- S1WS_MOD */
drainInputStream(); // Since, in.close only reads byte by byte.
JMXInbandStream.setIncomingStream(null);
MBeanServerResponseMessage tempMsg =
(MBeanServerResponseMessage) responseMessage;
StreamMBeanServerResponseMessage resmsg =
new StreamMBeanServerResponseMessage(
tempMsg.getMessageId(),
tempMsg.getWrappedResult(),
tempMsg.isException());
InputStream in = JMXInbandStream.getOutgoingStream();
if (in != null) {
resmsg.setStreamAvailable(true);
}
OutputStream out = response.getOutputStream();
sendResponseMessage(response, resmsg, out);
if (in != null)
sendStream(in, out, getContentLength(resmsg));
/* END -- S1WS_MOD */
}
catch (ClassNotFoundException ce) {
final String message = "Detailed Message: Error in calling in Servlet:processRequest, actual exception is attached";
throw new ServletException (message, ce);
}
|
private javax.management.remote.message.Message | readRequestMessage(javax.servlet.http.HttpServletRequest request)
/* BEGIN -- S1WS_MOD */
JMXInbandStream.setOutputStream(null, 0);
InputStream in = request.getInputStream();
// final ObjectInputStream ois = new ObjectInputStream(
// new BufferedInputStream(request.getInputStream()));
final ObjectInputStream ois = new ObjectInputStream(in);
// new BufferedInputStream(in));
/* END -- S1WS_MOD */
final MBeanServerRequestMessage m =
(MBeanServerRequestMessage) ois.readObject();
/* BEGIN -- S1WS_MOD */
StreamMBeanServerRequestMessage streamm =
(StreamMBeanServerRequestMessage) m;
if (streamm.isStreamAvailable()) {
JMXInbandStream.setIncomingStream(
new JMXChunkedInputStream(in));
}
/* END -- S1WS_MOD */
logger.fine("Method id is: " + m.getMethodId());
return ( m );
|
private void | sendResponseMessage(javax.servlet.http.HttpServletResponse response, javax.management.remote.message.Message message, java.io.OutputStream out)
/* END -- S1WS_MOD */
configureResponse(response, message);
/* BEGIN -- S1WS_MOD */
// final ObjectOutputStream oos = new ObjectOutputStream(
// new BufferedOutputStream(response.getOutputStream()));
final ObjectOutputStream oos = new ObjectOutputStream(
new BufferedOutputStream(out));
/* END -- S1WS_MOD */
oos.writeObject(message);
oos.flush();
//oos.close();
|
private void | sendStream(java.io.InputStream in, java.io.OutputStream out, int padLen)
OutputStream o = new JMXChunkedOutputStream(out);
byte[] bytes = new byte[8192];
int len = 0;
while ( (len = in.read(bytes)) != -1) {
o.write(bytes, 0, len);
}
JMXInbandStream.setOutputStream(null, 0);
o.flush();
((JMXChunkedOutputStream)o).writeEOF(padLen);
|