Methods Summary |
---|
public void | close()
try {
mObjectInStream.close();
mObjectOutStream.close();
}
catch(Exception e) {
throw new RuntimeException (e);
}
|
private java.lang.String | createConnectExceptionMessage()
/* this is not internationalized yet -- this is because there is a
separate delivery of this code that cannot depend on other parts
of application server
*/
final String h = hca.getHost();
final int p = hca.getPort();
final String msg = "Unable to connect to admin-server at given host: [" + h + "] and port: [" + p + "].\nPlease check if this server is up and running and that the host and port provided are correct.";
return ( msg );
|
HttpConnectorAddress | getHttpConnectorAddress()Returns the URL to which Servlet Connection has been established
return hca;
|
public java.net.URL | getURL()Returns the URL to which Servlet Connection has been established
return mConnection.getURL();
|
private void | handleException(java.io.IOException e)
IOException exception = null;
if (e instanceof java.net.UnknownHostException) {
exception = new java.net.UnknownHostException(UNKNOWN_HOST +
e.getMessage());
}
else if (e instanceof java.net.ConnectException) {
exception = new java.net.ConnectException(createConnectExceptionMessage());
}
else {
int responseCode =
((HttpURLConnection)mConnection).getResponseCode();
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
exception = new IOException(UNAUTHORIZED_ACCESS);
}
else {
exception = e;
}
}
throw exception;
|
public java.lang.Object | receive()Read an incoming Object.
Object value = null;
try {
if (isRedirectionEnabled) {
int respCode = ((HttpURLConnection)mConnection).getResponseCode();
if (respCode == HttpURLConnection.HTTP_MOVED_TEMP) {
String redirectUrl =
mConnection.getHeaderFields().get("Location").get(0);
throw new RedirectException(redirectUrl,
"HTTP connection failed: 302 Moved Temporarily");
}
}
InputStream in = mConnection.getInputStream();
mObjectInStream = new ObjectInputStream(in);
value = mObjectInStream.readObject();
response_received = true;
JMXInbandStream.setOutputStream(null, 0);
StreamMBeanServerResponseMessage res =
(StreamMBeanServerResponseMessage) value;
if (res.isStreamAvailable()) {
JMXInbandStream.setIncomingStream(
new JMXChunkedInputStream(in));
}
} catch (IOException ioe) {
if (ioe instanceof RedirectException) throw ioe;
else handleException(ioe);
}
return value;
|
public void | run()
OutputStream out = null;
try {
out = new JMXChunkedOutputStream(mConnection.getOutputStream());
InputStream in = JMXInbandStream.getOutgoingStream();
byte[] bytes = new byte[8192];
int len = 0;
int prLen = 0;
int flBytes = 0;
while ((len = in.read(bytes)) != -1) {
out.write(bytes, 0, len);
}
JMXInbandStream.setOutputStream(null, 0);
out.flush();
((JMXChunkedOutputStream)out).writeEOF(reqSize);
} catch (Exception ex) {
ex.printStackTrace();
}
|
public void | send(java.io.Serializable req)Write an object to the connection
InputStream in = null;
if (req instanceof StreamMBeanServerRequestMessage) {
StreamMBeanServerRequestMessage reqm =
(StreamMBeanServerRequestMessage) req;
JMXInbandStream.setIncomingStream(null);
in = JMXInbandStream.getOutgoingStream();
if (in != null) {
reqm.setStreamAvailable(true);
int len = (int) JMXInbandStream.getOutgoingStreamLength();
ByteArrayOutputStream byO = new ByteArrayOutputStream();
ObjectOutputStream oO = new ObjectOutputStream(byO);
oO.writeObject(reqm);
reqSize = byO.size();
byO.reset();
int chunks = (len/8192) + 2;
streamSize = reqSize + len + (chunks * 4);
((HttpURLConnection)mConnection).setFixedLengthStreamingMode(streamSize);
mConnection.setRequestProperty("Connection", "Close");
}
}
sendReq(req);
if (in != null)
sendStream();
|
private void | sendReq(java.io.Serializable object)
response_received = false;
try {
mObjectOutStream = new ObjectOutputStream(
new BufferedOutputStream(mConnection.getOutputStream()));
mObjectOutStream.writeObject(object);
mObjectOutStream.flush();
//mObjectOutStream.close();
}
catch (IOException ioe) {
handleException(ioe);
}
|
private void | sendStream()
/* Thread thr = new Thread(this);
thr.start();
*/
run();
|