Handle MBean invocation requests
330360
public Object handleOperation(String operation, Object[] params) throws IOException {
        if (OPERATION_DOWNLOAD.equals(operation)) {
            if (params.length == 2) {
                downloadFile((String) params[0], (String) params[1]);
            } else {
                //partial download
                return downloadFile((String) params[0], (String) params[1], (Long) params[2], (Long) params[3]);
            }
        } else if (OPERATION_UPLOAD.equals(operation)) {
            uploadFile((String) params[0], (String) params[1], (Boolean) params[2]);
        } else if (OPERATION_DELETE.equals(operation)) {
            deleteFile((String) params[0]);
        } else if (OPERATION_DELETE_ALL.equals(operation)) {
            deleteAll((List<String>) params[0]);
        } else {
            throw logUnsupportedOperationError("handleOperation", operation);
        }

        //currently all operations are void, so return null.
        return null;
    }
347226
public static OpResultInfo invokeOp(String name, int index, String[] args) throws JMException
   {
      MBeanServer server = getMBeanServer();
      ObjectName objName = new ObjectName(name);
      MBeanInfo info = server.getMBeanInfo(objName);
      MBeanOperationInfo[] opInfo = info.getOperations();
      MBeanOperationInfo op = opInfo[index];
      MBeanParameterInfo[] paramInfo = op.getSignature();
      String[] argTypes = new String[paramInfo.length];

      for (int p = 0; p < paramInfo.length; p++)
         argTypes[p] = paramInfo[p].getType();
 
      return invokeOpByName(name, op.getName(), argTypes, args);
   }
828985
@Override
	public final Object invoke(final String actionName, final Object[] params,
			final String[] signature) throws MBeanException,
			ReflectionException {
		// Get the JmxCommand
		JmxCommand curCmd = null;
		for (JmxCommand cmd : this.cmds) {
			if (cmd.getType().equals(actionName)) {
				curCmd = cmd;
				break;
			}
		}

		final boolean isSync = actionName.startsWith("sync");
		try {
			// initialize arguments for lunching (using Quartz)
			final Map<String, Object> jobDataMap = buildJobDataMap(curCmd, params);

			final Launch<?> launch = Launcher.getLauncher()
					.newLaunch((Class<?>) remoteProgram.getAdapterClass()).addParameters(jobDataMap);
			if (isSync) {
				// Launch and wait until terminated
				launch.synchLaunch();
				return LaunchingMessageKind.ILAUNCH0003.getFormatedMessage(
						remoteProgram.getAdapterClass().getCanonicalName(), launch.getLaunchId(),
						launch.getLaunchResult().getStatusCode(),
						launch.getLaunchResult().getReturnCode());
			} else {
				// Launch and continue
				launch.aSynchLaunch();
				return LaunchingMessageKind.ILAUNCH0002.getFormatedMessage(
						remoteProgram.getAdapterClass().getCanonicalName(), launch.getLaunchId());
			}
		} catch (LaunchException e) {
			LaunchingMessageKind.ELAUNCH0003.format(actionName, e);
		}
		
		return null;
	}
1337505
private void initMBean()  {
        try {
            registerMBean(this,getObjectName());
        } catch (InstanceAlreadyExistsException exp) {
            // This is no problem, since this MBeanServerHandlerMBean holds only global information
            // with no special state (so all instances of this MBean behave similar)
            // This exception can happen, when multiple servlets get registered within the same JVM
        } catch (MalformedObjectNameException e) {
            // Cannot happen, otherwise this is a bug. We should be always provide our own name in correct
            // form.
            throw new IllegalStateException("Internal Error: Own ObjectName " + getObjectName() + " is malformed",e);
        } catch (NotCompliantMBeanException e) {
            // Same here
            throw new IllegalStateException("Internal Error: " + this.getClass().getName() + " is not a compliant MBean",e);
        }
    }
456012
@Override
    protected Long callInternal() throws Exception {
        return portletRenderer.doServeResource(
                portletWindowId, request, response, new ResourcePortletOutputHandler(response));
    }
405970
@Override
  public Object invoke(Object[] argv) throws Throwable {
    if (handle == null) {
      throw new IllegalStateException(
          "Default method handler invoked before proxy has been bound.");
    }
    return handle.invokeWithArguments(argv);
  }
66200
protected void handleRequest(final HttpString method, HttpServerExchange exchange) throws Exception {
        final RequestData requestData = parseFormData(exchange);
        boolean persistent = exchange.isPersistent();
        exchange.setPersistent(false); //UNDERTOW-947 MCMP should not use persistent connections
        if (CONFIG.equals(method)) {
            processConfig(exchange, requestData);
        } else if (ENABLE_APP.equals(method)) {
            processCommand(exchange, requestData, MCMPAction.ENABLE);
        } else if (DISABLE_APP.equals(method)) {
            processCommand(exchange, requestData, MCMPAction.DISABLE);
        } else if (STOP_APP.equals(method)) {
            processCommand(exchange, requestData, MCMPAction.STOP);
        } else if (REMOVE_APP.equals(method)) {
            processCommand(exchange, requestData, MCMPAction.REMOVE);
        } else if (STATUS.equals(method)) {
            processStatus(exchange, requestData);
        } else if (INFO.equals(method)) {
            processInfo(exchange);
        } else if (DUMP.equals(method)) {
            processDump(exchange);
        } else if (PING.equals(method)) {
            processPing(exchange, requestData);
        } else {
            exchange.setPersistent(persistent);
            next.handleRequest(exchange);
        }
    }
291571
public void invocationCallbackPostInvoke() {
        if (ivEJBMethodCallback != null) {
            int n = ivEJBMethodCallback.size();
            for (int i = 0; i < n; i++) {
                try {
                    InvocationCallback callback = ivEJBMethodCallback.get(i);
                    callback.postInvoke(ivEJBMethodCallbackCookie.get(i));
                } catch (Throwable t) {
                    FFDCFilter.processException(t, CLASS_NAME +
                                                   ".ejbMethodCallbackPostInvoke",
                                                "332", this);
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc,
                                 "ignoring exception thrown by EJBMethodCallback.postInvoke",
                                 t);
                    }
                }
            }
        }
    }
876745
def _call(self, method_proxy, *args):
        
        request = self._gw.addRequest(method_proxy, *args)

        if self._auto_execute:
            response = self._gw.execute_single(request)

            if response.status == remoting.STATUS_ERROR:
                if hasattr(response.body, 'raiseException'):
                    try:
                        response.body.raiseException()
                    except:
                        raise
                else:
                    raise remoting.RemotingError

            return response.body

        return request
607842
@SuppressWarnings("unchecked")
  public static void registerMBean(final ManagementContext context,
                                   final Object object,
                                   final ObjectName objectName)
    throws Exception {

    String mbeanName = object.getClass().getName() + "MBean";

    for (Class c : object.getClass().getInterfaces()) {
      if (mbeanName.equals(c.getName())) {
        context.registerMBean(new AnnotatedMBean(object, c), objectName);
        return;
      }
    }

    context.registerMBean(object, objectName);
  }
899202
public void handleSuccess ()
    {
        if (_listener instanceof InvocationService.ConfirmListener) {
            reportRequestProcessed();
        } else if (_listener instanceof InvocationService.ResultListener && _resultSet) {
            reportRequestProcessed(_result);
        }
    }
362191
private void displayMBeans(HttpServletRequest request, HttpServletResponse response) 
      throws ServletException, IOException
   {
      Iterator mbeans;

      try
      {
         mbeans = getDomainData();
      }
      catch (Exception e)
      {
         throw new ServletException("Failed to get MBeans", e);
      }

      request.setAttribute("mbeans", mbeans);
      RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/displaymbeans.jsp");
      rd.forward(request, response);
   }
1362638
public static Object[] call(Method method, Object[][] params,
                              InetSocketAddress[] addrs,
                              UserGroupInformation ticket, Configuration conf)
    throws IOException {

    Invocation[] invocations = new Invocation[params.length];
    for (int i = 0; i < params.length; i++)
      invocations[i] = new Invocation(method, null, params[i]);
    Client client = CLIENTS.getClient(conf);
    try {
    Writable[] wrappedValues =
      client.call(invocations, addrs, method.getDeclaringClass(), ticket);

    if (method.getReturnType() == Void.TYPE) {
      return null;
    }

    Object[] values =
      (Object[])Array.newInstance(method.getReturnType(), wrappedValues.length);
    for (int i = 0; i < values.length; i++)
      if (wrappedValues[i] != null)
        values[i] = ((ObjectWritable)wrappedValues[i]).get();
    
    return values;
    } finally {
      CLIENTS.stopClient(client);
    }
  }
70917
private void handleListMechsResponse(final ChannelHandlerContext ctx, final ByteBuf msg) throws Exception {
    String remote = ctx.channel().remoteAddress().toString();
    String[] supportedMechanisms = SaslListMechsResponse.supportedMechs(msg);
    if (supportedMechanisms.length == 0) {
      throw new AuthenticationException("Received empty SASL mechanisms list from server: " + remote);
    }

    saslClient = Sasl.createSaslClient(supportedMechanisms, null, "couchbase", remote, null, this);
    selectedMechanism = saslClient.getMechanismName();

    byte[] bytePayload = saslClient.hasInitialResponse() ? saslClient.evaluateChallenge(new byte[]{}) : null;
    ByteBuf payload = bytePayload != null ? ctx.alloc().buffer().writeBytes(bytePayload) : Unpooled.EMPTY_BUFFER;

    ByteBuf request = ctx.alloc().buffer();
    SaslAuthRequest.init(request);
    SaslAuthRequest.mechanism(selectedMechanism, request);
    SaslAuthRequest.challengeResponse(payload, request);
    payload.release();

    ChannelFuture future = ctx.writeAndFlush(request);
    future.addListener(new GenericFutureListener<Future<Void>>() {
      @Override
      public void operationComplete(Future<Void> future) throws Exception {
        if (!future.isSuccess()) {
          LOGGER.warn("Error during SASL Auth negotiation phase.", future);
          originalPromise().setFailure(future.cause());
        }
      }
    });
  }
1341909
protected void handleInvocationNotification (int receiverId, int methodId, Object[] args)
    {
        // look up the decoder registered for this receiver
        InvocationDecoder decoder = _receivers.get(receiverId);
        if (decoder == null) {
            log.warning("Received notification for which we have no registered receiver",
                        "recvId", receiverId, "methodId", methodId, "args", args);
            return;
        }

//         log.info("Dispatching invocation notification", "receiver", decoder.receiver,
//                  "methodId", methodId, "args", args);

        try {
            decoder.dispatchNotification(methodId, args);
        } catch (Throwable t) {
            log.warning("Invocation notification receiver choked", "receiver", decoder.receiver,
                        "methId", methodId, "args", args, t);
        }
    }
1237405
public static void registerMbean(Object mbean, ObjectName name) {
        registerMbean(ManagementFactory.getPlatformMBeanServer(),
                      JmxUtils.createModelMBean(mbean),
                      name);
    }
175971
public void invoke(HttpServletRequest req, HttpServletResponse rsp, Object root, String url) throws IOException, ServletException {
        RequestImpl sreq = new RequestImpl(this, req, new ArrayList<AncestorImpl>(), new TokenList(url));
        RequestImpl oreq = CURRENT_REQUEST.get();
        CURRENT_REQUEST.set(sreq);

        ResponseImpl srsp = new ResponseImpl(this, rsp);
        ResponseImpl orsp = CURRENT_RESPONSE.get();
        CURRENT_RESPONSE.set(srsp);

        try {
            invoke(sreq,srsp,root);
        } finally {
            CURRENT_REQUEST.set(oreq);
            CURRENT_RESPONSE.set(orsp);
        }
    }