Boolean returnValueAsAttribute = (Boolean) request.getAttribute("returnValueAsAttribute");
try
{
response.setContentType(RESPONSE_CONTENT_TYPE);
// See if the request already has the MarshalledInvocation
MarshalledInvocation mi = (MarshalledInvocation) request.getAttribute("MarshalledInvocation");
if( mi == null )
{
// Get the invocation from the post
ServletInputStream sis = request.getInputStream();
ObjectInputStream ois = new ObjectInputStream(sis);
mi = (MarshalledInvocation) ois.readObject();
ois.close();
}
/* If the invocation carries no auth context, look to to the auth
context of this servlet as seen in the SecurityAssocation. This allows
the web app authentication to transparently be used as the call
authentication.
*/
if (mi.getPrincipal() == null && mi.getCredential() == null)
{
mi.setPrincipal(GetPrincipalAction.getPrincipal());
mi.setCredential(GetCredentialAction.getCredential());
}
Object[] params = {mi};
String[] sig = {"org.jboss.invocation.Invocation"};
ObjectName invokerName = localInvokerName;
// If there is no associated invoker, get the name from the invocation
if( invokerName == null )
{
Integer nameHash = (Integer) mi.getObjectName();
invokerName = (ObjectName) Registry.lookup(nameHash);
if( invokerName == null )
throw new ServletException("Failed to find invoker name for hash("+nameHash+")");
}
// Forward the invocation onto the JMX invoker