Dispatch the command

@param pVm the virtual machine to attach to (typeless in order avoid direct references to the sun classes)
@param pHandler  handler for listing processes
@return the return code (0 or 1)
177735
public int dispatchCommand(Object pVm,VirtualMachineHandler pHandler) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
        String commandName = options.getCommand();
        AbstractBaseCommand command = COMMANDS.get(commandName);
        if (command == null) {
            throw new IllegalArgumentException("Unknown command '" + commandName + "'");
        }
        return command.execute(options,pVm,pHandler);
    }
363995
@Override
    public void dispatch(final KeyedMessage message, final boolean block) throws IllegalArgumentException, ContainerException {
        if(!isRunningLazy) {
            LOGGER.debug("Dispacth called on stopped container");
            statCollector.messageFailed(false);
        }

        if(message == null)
            return; // No. We didn't process the null message

        if(!inbound.doesMessageKeyBelongToNode(message.key)) {
            if(LOGGER.isDebugEnabled())
                LOGGER.debug("Message with key " + SafeString.objectDescription(message.key) + " sent to wrong container. ");
            statCollector.messageFailed(false);
            return;
        }

        boolean evictedAndBlocking;

        if(message == null || message.message == null)
            throw new IllegalArgumentException("the container for " + clusterId + " attempted to dispatch null message.");

        if(message.key == null)
            throw new ContainerException("Message " + objectDescription(message.message) + " contains no key.");

        try {
            numBeingWorked.incrementAndGet();

            do {
                evictedAndBlocking = false;

                final InstanceWrapper wrapper = getInstanceForKey(message.key);

                // wrapper will be null if the activate returns 'false'
                if(wrapper != null) {
                    final Object instance = wrapper.getExclusive(block);
                    if(instance != null) { // null indicates we didn't get the lock
                        final List<KeyedMessageWithType> response;
                        try {
                            if(wrapper.isEvicted()) {
                                response = null;
                                // if we're not blocking then we need to just return a failure. Otherwise we want to try again
                                // because eventually the current Mp will be passivated and removed from the container and
                                // a subsequent call to getInstanceForDispatch will create a new one.
                                if(block) {
                                    Thread.yield();
                                    evictedAndBlocking = true; // we're going to try again.
                                } else { // otherwise it's just like we couldn't get the lock. The Mp is busy being killed off.
                                    if(LOGGER.isTraceEnabled())
                                        LOGGER.trace("the container for " + clusterId + " failed handle message due to evicted Mp "
                                            + SafeString.valueOf(prototype));

                                    statCollector.messageCollision(message);
                                }
                            } else {
                                response = invokeOperation(wrapper.getInstance(), Operation.handle, message);
                            }
                        } finally {
                            wrapper.releaseLock();
                        }
                        if(response != null) {
                            try {
                                dispatcher.dispatch(response);
                            } catch(final Exception de) {
                                if(isRunning.get())
                                    LOGGER.warn("Failed on subsequent dispatch of " + response + ": " + de.getLocalizedMessage());
                            }
                        }
                    } else { // ... we didn't get the lock
                        if(LOGGER.isTraceEnabled())
                            LOGGER.trace("the container for " + clusterId + " failed to obtain lock on " + SafeString.valueOf(prototype));
                        statCollector.messageCollision(message);
                    }
                } else {
                    // if we got here then the activate on the Mp explicitly returned 'false'
                    if(LOGGER.isDebugEnabled())
                        LOGGER.debug("the container for " + clusterId + " failed to activate the Mp for " + SafeString.valueOf(prototype));
                    // we consider this "processed"
                    break; // leave the do/while loop
                }
            } while(evictedAndBlocking);

        } finally {
            numBeingWorked.decrementAndGet();
        }
    }
547276
public Object process(Object... params) throws APPErrorException {
        String command = (String) params[0];
        Object[] param = Arrays.copyOfRange(params, 1, params.length);
        Command comm = mCommands.get(command);
        if (null == comm) {
            throw new APPErrorException(mType + " 无法识别的命令；" + command);
        }
        return comm.excute(param);

    }
1099359
private static NotificationsHandler getHandler(final String queueName,
                                                 final Properties pr) throws NotificationException {
    if (handler != null) {
      return handler;
    }

    synchronized (synchit) {
      handler = new JmsNotificationsHandlerImpl(queueName, pr);
    }

    return handler;
  }
174382
public static VMInfo processNewVM(String pid, String jmxHostAndPort) {
		try {
			final JmxClient jmxClient = new JmxClient();
			jmxClient.connect(pid, jmxHostAndPort);

			// 注册JMXClient注销的钩子
			Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
				@Override
				public void run() {
					jmxClient.disconnect();
				}
			}));

			return new VMInfo(jmxClient, pid);
		} catch (Exception e) {
			e.printStackTrace(System.out);
		}

		return createDeadVM(pid, VMInfoState.ERROR_DURING_ATTACH);
	}
1158446
def getActionHandle(self, pchActionName):
        """"""

        fn = self.function_table.getActionHandle
        pHandle = VRActionHandle_t()
        result = fn(pchActionName, byref(pHandle))
        return result, pHandle
114065
public static synchronized AdHocCommandManager getAddHocCommandsManager(XMPPConnection connection) {
        AdHocCommandManager ahcm = instances.get(connection);
        if (ahcm == null) {
            ahcm = new AdHocCommandManager(connection);
            instances.put(connection, ahcm);
        }
        return ahcm;
    }
475624
public MultiMEProxyHandler getProxyHandler() {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled()) {
            SibTr.entry(tc, "getProxyHandler");
            SibTr.exit(tc, "getProxyHandler", _multiMEProxyHandler);
        }

        return _multiMEProxyHandler;
    }
978551
public JmxMessage parameter(Object arg, Class<?> argType) {
        if (mbeanInvocation == null) {
            throw new CitrusRuntimeException("Invalid access to operation parameter for JMX message");
        }

        if (mbeanInvocation.getOperation() == null) {
            throw new CitrusRuntimeException("Invalid access to operation parameter before operation was set for JMX message");
        }

        if (mbeanInvocation.getOperation().getParameter() == null) {
            mbeanInvocation.getOperation().setParameter(new ManagedBeanInvocation.Parameter());
        }

        OperationParam operationParam = new OperationParam();
        operationParam.setValueObject(arg);
        operationParam.setType(argType.getName());
        mbeanInvocation.getOperation().getParameter().getParameter().add(operationParam);
        return this;
    }
1325058
@Override
    public Handle getHandle() throws RemoteException
    {
        ComponentMetaDataAccessorImpl cmdAccessor = null; // p125735
        try {
            cmdAccessor = ComponentMetaDataAccessorImpl.getComponentMetaDataAccessor(); // p125735
            cmdAccessor.beginContext(bmd); // p125735
            return beanId.getHome().createHandle(beanId);
        } finally
        {
            if (cmdAccessor != null)
                cmdAccessor.endContext(); // p125735
        }
    }
1222291
function dispatch(methodName, inDocument, xpath, contextNode, namespaceResolver) {
        xpath = preprocess(xpath);

        if (! contextNode) {
            contextNode = inDocument;
        }

        var result = getEngineFor(inDocument)
            .setIgnoreAttributesWithoutValue(ignoreAttributesWithoutValue)
            [methodName](xpath, contextNode, namespaceResolver);

        return result;
    }
353007
public CommandResponse doVagrant(String vagrantVm, final String... vagrantCommand) {
        CommandResponse response = commandProcessor.run(
                aCommand("vagrant").withArguments(vagrantCommand).withOptions(vagrantVm)
        );

        if(!response.isSuccessful()) {
            throw new RuntimeException("Errors during vagrant execution: \n" + response.getErrors());
        }

        // Check for puppet errors. Not vagrant still returns 0 when puppet fails
        // May not be needed after this PR released: https://github.com/mitchellh/vagrant/pull/1175
        for (String line : response.getOutput().split("\n\u001B")) {
            if (line.startsWith("[1;35merr:")) {
                throw new RuntimeException("Error in puppet output: " + line);
            }
        }

        return response;
    }
768951
public final void dispatch( AbstractMessage message ) throws JMSException
    {
        // Security
        LocalConnection conn = (LocalConnection)getConnection();
        if (conn.isSecurityEnabled())
        {
            Destination destination = message.getJMSDestination();
            if (destination instanceof Queue)
            {
                String queueName = ((Queue)destination).getQueueName();
                if (conn.isRegisteredTemporaryQueue(queueName))
                {
                    // OK, temporary destination
                }
                else
                if (queueName.equals(FFMQConstants.ADM_REQUEST_QUEUE))
                {
                    conn.checkPermission(Resource.SERVER, Action.REMOTE_ADMIN);
                }
                else
                if (queueName.equals(FFMQConstants.ADM_REPLY_QUEUE))
                {
                    // Only the internal admin thread can produce on this queue
                    if (conn.getSecurityContext() != null)
                        throw new FFMQException("Access denied to administration queue "+queueName,"ACCESS_DENIED");
                }
                else
                {
                    // Standard queue
                    conn.checkPermission(destination,Action.PRODUCE);
                }
            }
            else
            if (destination instanceof Topic)
            {
                String topicName = ((Topic)destination).getTopicName();
                if (conn.isRegisteredTemporaryTopic(topicName))
                {
                    // OK, temporary destination
                }
                else
                {
                    // Standard topic
                    conn.checkPermission(destination,Action.PRODUCE);   
                }
            }
            else
                throw new InvalidDestinationException("Unsupported destination : "+destination);
        }
        
        if (debugEnabled)
            log.debug(this+" [PUT] in "+message.getJMSDestination()+" - "+message);
        
        externalAccessLock.readLock().lock();
    	try
        {
            checkNotClosed();
            
            pendingPuts.add(message);
            
        	if (!transacted)
        		commitUpdates(false, null, true); // FIXME Async commit ?
        }
    	finally
    	{
    		externalAccessLock.readLock().unlock();
    	}
    }
840667
@FFDCIgnore({ NoSuchElementException.class })
    protected Map<String, String> getMpConfig(MpConfigProxyService service, ClassLoader cl, String propertyName,  Map<String, String> map) {
        try {
            String value = service.getConfigValue(cl, propertyName, String.class).trim();
            if (!value.isEmpty()) {
                map.put(propertyName, value);
            } else {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, propertyName + " is empty. Ignore it.");
                }
            }
        } catch (NoSuchElementException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, propertyName + " is not in mpConfig.");
            }
        }
        return map;
    }
1093320
public BatchProcessServer getBatchProcessServer()
    {
        if (process_server_class != null)
        {
            try
            {
                return process_server_class.newInstance();
            }
            catch (Exception e)
            {
                throw new QueujException(e);
            }
        }

        if (parent_queue != null)
            return parent_queue.getBatchProcessServer();

        // else
        throw new QueujException("No BatchProcessServer exists for Queue");
    }
755565
public <V> V executeAndFetch(ResultSetHandler<V> handler) {
        try (ResultSet rs = executeQuery()) {
            return handler.apply(rs);
        } catch (SQLException ex) {
            throw new ApplicationException(Code.BACKEND_ERROR, ex);
        }
    }
228719
protected int getCurrentProcessID() throws ProcessHandlerException {
        int pid;
        // Not ideal but using JNA failed on RHEL5.
        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
        Field jvm = null;
        try {
            jvm = runtime.getClass().getDeclaredField("jvm");
            jvm.setAccessible(true);
            VMManagement mgmt = (VMManagement) jvm.get(runtime);
            Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
            pid_method.setAccessible(true);
            pid = (Integer) pid_method.invoke(mgmt);
        } catch (NoSuchFieldException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            throw new ProcessHandlerException(e);
        }
        return pid;
    }