Methods Summary |
---|
private synchronized com.sun.enterprise.admin.common.AdminResponse | callGetAttribute(com.sun.enterprise.admin.common.AdminRequest req)
Object invokeResult = null;
AdminResponse response = new AdminResponse();
AdminResponseConfigurator responseConfig = new
AdminResponseConfigurator(response);
AdminRequestConfigurator requestConfig = new
AdminRequestConfigurator(req);
ObjectName objName = requestConfig.getObjectName();
String attrName = requestConfig.getAttributeName();
try
{
invokeResult = mMBeanServer.getAttribute(objName, attrName);
responseConfig.setReturnValue((Serializable)invokeResult);
mLogger.log(Level.FINE, "comm.get_attr_ok", objName);
}
catch(Exception e)
{
mLogger.log(Level.WARNING, "comm.get_attr_failed", unwrapMBeanException(e));
responseConfig.setException(e);
}
return ( response );
|
private synchronized com.sun.enterprise.admin.common.AdminResponse | callGetAttributes(com.sun.enterprise.admin.common.AdminRequest req)
Object invokeResult = null;
AdminResponse response = new AdminResponse();
AdminResponseConfigurator responseConfig = new
AdminResponseConfigurator(response);
AdminRequestConfigurator requestConfig = new
AdminRequestConfigurator(req);
ObjectName mbeanName = requestConfig.getObjectName();
String[] attributes = requestConfig.getAttributeNames();
try
{
AttributeList values = mMBeanServer.getAttributes(mbeanName,
attributes);
responseConfig.setReturnValue(values);
mLogger.log(Level.FINE, "comm.get_attrs_ok", mbeanName);
}
catch(Exception t)
{
mLogger.log(Level.WARNING, "comm.get_attrs_failed", unwrapMBeanException(t));
responseConfig.setException(t);
}
return ( response );
|
private synchronized com.sun.enterprise.admin.common.AdminResponse | callInvoke(com.sun.enterprise.admin.common.AdminRequest req)
Object invokeResult = null;
AdminResponse response = new AdminResponse();
AdminResponseConfigurator responseConfig = new
AdminResponseConfigurator(response);
AdminRequestConfigurator requestConfig = new
AdminRequestConfigurator(req);
ObjectName objName = requestConfig.getObjectName();
String oprName = requestConfig.getOperationName();
Object[] params = requestConfig.getOperationParams();
String[] signature = requestConfig.getOperationSignature();
try
{
invokeResult =
mMBeanServer.invoke(objName, oprName, params, signature);
responseConfig.setReturnValue((Serializable)invokeResult);
mLogger.log(Level.FINE, "comm.remote_invoke_ok", objName);
}
catch(Exception e)
{
mLogger.log(Level.WARNING, "comm.remote_invoke_failed", unwrapMBeanException(e));
responseConfig.setException(e);
}
return ( response );
|
private synchronized com.sun.enterprise.admin.common.AdminResponse | callMBean(com.sun.enterprise.admin.common.AdminRequest req)
String type = req.getRequestType();
AdminResponse response = null;
if (type.equals(AdminRequestType.INVOKE))
{
response = callInvoke(req);
}
else if(type.equals(AdminRequestType.GET_ATTRIBUTE))
{
response = callGetAttribute(req);
}
else if(type.equals(AdminRequestType.SET_ATTRIBUTE))
{
response = callSetAttribute(req);
}
else if (type.equals(AdminRequestType.GET_ATTRIBUTES))
{
response = callGetAttributes(req);
}
else if (type.equals(AdminRequestType.SET_ATTRIBUTES))
{
response = callSetAttributes(req);
}
else
{
response = new AdminResponse();
AdminResponseConfigurator config = new
AdminResponseConfigurator(response);
config.setException(new Exception("No Such Type"));
}
return ( response );
|
private synchronized com.sun.enterprise.admin.common.AdminResponse | callSetAttribute(com.sun.enterprise.admin.common.AdminRequest req)
Object invokeResult = null;
AdminResponse response = new AdminResponse();
AdminResponseConfigurator responseConfig = new
AdminResponseConfigurator(response);
AdminRequestConfigurator requestConfig = new
AdminRequestConfigurator(req);
ObjectName objName = requestConfig.getObjectName();
Attribute attribute = requestConfig.getAttribute();
try
{
mMBeanServer.setAttribute(objName, attribute);
String setValue = "value set: " + attribute.getValue();
responseConfig.setReturnValue(setValue);
mLogger.log(Level.FINE, "comm.set_attr_ok", objName);
}
catch(Exception e)
{
mLogger.log(Level.WARNING, "comm.set_attr_failed", unwrapMBeanException(e));
responseConfig.setException(e);
}
return ( response );
|
private synchronized com.sun.enterprise.admin.common.AdminResponse | callSetAttributes(com.sun.enterprise.admin.common.AdminRequest req)
Object invokeResult = null;
AdminResponse response = new AdminResponse();
AdminResponseConfigurator responseConfig = new
AdminResponseConfigurator(response);
AdminRequestConfigurator requestConfig = new
AdminRequestConfigurator(req);
ObjectName mbeanName = requestConfig.getObjectName();
AttributeList attributes = requestConfig.getAttributeList();
try
{
AttributeList values = mMBeanServer.setAttributes(mbeanName,
attributes);
responseConfig.setReturnValue(values);
mLogger.log(Level.FINE, "comm.set_attrs_ok", mbeanName);
}
catch(Exception e)
{
mLogger.log(Level.WARNING, "comm.set_attrs_failed", unwrapMBeanException(e));
responseConfig.setException(e);
}
return ( response );
|
private com.sun.enterprise.admin.common.AdminResponse | clientVersionCheck(com.sun.enterprise.admin.common.AdminRequest req)
AdminRequestConfigurator requestConfig = new
AdminRequestConfigurator(req);
String clientVersion = null;
try
{
clientVersion = requestConfig.getClientVersion();
int dotIdx = clientVersion.indexOf('.");
int majorVersion = (Integer.valueOf(clientVersion.substring(0, dotIdx))).intValue();
int minorVersion = (Integer.valueOf(clientVersion.substring(dotIdx+1))).intValue();
if(majorVersion == SUPPORTED_CLIENT_MAJOR_VERSION &&
minorVersion <= SUPPORTED_CLIENT_MINOR_VERSION /* backward compartibility */)
return null;
}
catch (Exception e)
{
}
// here we are only in case of non-matching version
// prepare and wrap exception
AdminResponse response = new AdminResponse();
AdminResponseConfigurator config = new AdminResponseConfigurator(response);
String msg;
if(clientVersion == null)
msg = localStrings.getString( "admin.server.core.servlet.no_client_version" );
else
msg = localStrings.getString( "admin.server.core.servlet.nonsupported_client_version", clientVersion);
config.setException(new AFRuntimeException(msg));
return response;
|
public void | doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Serializable resultObject = "TEST";
try
{
mLogger.log(Level.FINE, "comm.recd_request");
ObjectInputStream inpStream = new ObjectInputStream (
new BufferedInputStream(
request.getInputStream()));
Object obj = inpStream.readObject();
AdminRequest adminRequest = (AdminRequest)obj;
resultObject = clientVersionCheck(adminRequest);
if(resultObject == null)
resultObject = callMBean(adminRequest);
ObjectOutputStream oos = new ObjectOutputStream (
new BufferedOutputStream (response.getOutputStream ()));
response.setHeader("Content-type", "application/octet-stream");
final int contentLength = getContentLength(resultObject);
response.setContentLength(contentLength);
response.setStatus(HttpServletResponse.SC_OK);
oos.writeObject(resultObject);
oos.flush();
}
catch(Exception e)
{
throw new ServletException(e.getMessage());
}
|
public void | doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
doGet(request, response);
|
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
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(baos);
oos.writeObject(serObject);
size = baos.size();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (oos != null)
{
oos.close();
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return size;
|
public void | init()Populates the recipients in the dispatcher. These are the recipients
to whom the admin request will be forwarded. This needs
to be done only when the Servlet is loaded by the servlet container.
super.init();
mMBeanServer = MBeanServerFactory.getMBeanServer();
mLogger.log(Level.FINE, "comm.init_ok");
|
private java.lang.Exception | unwrapMBeanException(java.lang.Exception e)
while(e instanceof MBeanException)
{
e = ((MBeanException)e).getTargetException();
}
return e;
|