HAInvokerWrapperpublic class HAInvokerWrapper extends org.jboss.mx.util.DynamicMBeanSupport This is an invoker that delegates to the target invoker and handles the
wrapping of the response in an HARMIResponse with any updated HATarget info. |
Fields Summary |
---|
private static Logger | log | private MBeanServer | mbeanServer | private MBeanInfo | info | private ObjectName | targetName | private org.jboss.ha.framework.server.HATarget | target |
Constructors Summary |
---|
public HAInvokerWrapper(MBeanServer mbeanServer, ObjectName targetName, org.jboss.ha.framework.server.HATarget target)
this.mbeanServer = mbeanServer;
this.targetName = targetName;
this.target = target;
MBeanAttributeInfo[] attrInfo = null;
MBeanConstructorInfo[] ctorInfo = null;
MBeanParameterInfo[] sig = {
new MBeanParameterInfo("invocation", Invocation.class.getName(),
"The invocation content information")
};
MBeanOperationInfo[] opInfo = {
new MBeanOperationInfo("invoke", "The detached invoker entry point",
sig, "java.lang.Object", MBeanOperationInfo.ACTION)
};
MBeanNotificationInfo[] eventInfo = null;
this.info = new MBeanInfo(getClass().getName(),
"A wrapper inovker that delegates to the target invoker",
attrInfo,
ctorInfo,
opInfo,
eventInfo);
|
Methods Summary |
---|
public javax.management.MBeanInfo | getMBeanInfo()
return info;
| public java.lang.Object | invoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)The JMX DynamicMBean invoke entry point. This only handles the
invoke(Invocation) operation.
if( params == null || params.length != 1 ||
(params[0] instanceof Invocation) == false )
{
NoSuchMethodException e = new NoSuchMethodException(actionName);
throw new ReflectionException(e, actionName);
}
Invocation invocation = (Invocation) params[0];
try
{
Object value = invoke(invocation);
return value;
}
catch(Exception e)
{
throw new ReflectionException(e, "Invoke failure");
}
| public java.lang.Object | invoke(org.jboss.invocation.Invocation invocation)The invoker entry point.
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
try
{
// The cl on the thread should be set in another interceptor
Object[] args = {invocation};
String[] sig = {"org.jboss.invocation.Invocation"};
Object rtn = mbeanServer.invoke(targetName, "invoke", args, sig);
// Update the targets list if the client view is out of date
Long clientViewId = (Long) invocation.getValue("CLUSTER_VIEW_ID");
HARMIResponse rsp = new HARMIResponse();
if (clientViewId.longValue() != target.getCurrentViewId())
{
rsp.newReplicants = new ArrayList(target.getReplicants());
rsp.currentViewId = target.getCurrentViewId();
}
rsp.response = rtn;
// Return the raw object and let the http layer marshall it
return rsp;
}
catch (Exception e)
{
// Unwrap any JMX exceptions
e = (Exception) JMXExceptionDecoder.decode(e);
// Don't send JMX exception back to client to avoid needing jmx
if( e instanceof JMException )
e = new GenericClusteringException (GenericClusteringException.COMPLETED_NO, e.getMessage());
// Only log errors if trace is enabled
if( log.isTraceEnabled() )
log.trace("operation failed", e);
throw e;
}
finally
{
Thread.currentThread().setContextClassLoader(oldCl);
}
|
|