Package org.rhq.enterprise.communications.command

Examples of org.rhq.enterprise.communications.command.CommandType


     *
     * @see    CommandExecutor#execute(Command, InputStream, OutputStream)
     */
    public CommandResponse execute(Command command, InputStream in, OutputStream out) {
        // find what executor should be responsible for executing the command
        CommandType commandTypeToExecute = command.getCommandType();
        CommandTypeExecutor typeExecutor = getExecutors().get(commandTypeToExecute);

        if (typeExecutor == null) {
            // this should never really happen; I can't think of a case where it would under normal circumstances
            throw new IllegalArgumentException(getLog()
View Full Code Here


            // cross your fingers and hope that the command type defined by the user is processable on the server-side
            LOG.debug(CommI18NResourceKeys.CMDLINE_CLIENT_USING_GENERIC_CLIENT, cnfe.getMessage());

            try {
                GenericCommandClient customClient = new GenericCommandClient();
                customClient.setCommandType(new CommandType(m_commandName, m_commandVersion));
                commandClient = customClient;
            } catch (Exception e) {
                // any exception that occurred while trying to build a generic client should throw a ClassNotFound
                // to alert the caller that the original client class was not found and our workaround didn't work
                throw new ClassNotFoundException(cnfe.toString(), e);
View Full Code Here

     * Tests the ability to dynamically define metadata for a command.
     *
     * @throws Exception
     */
    public void testDynamicDefinition() throws Exception {
        GenericCommand gc = new GenericCommand(new CommandType("foo", 123), new ParameterDefinition[] {
            new ParameterDefinition("string", "java.lang.String", true, false, false, ""),
            new ParameterDefinition("int", "java.lang.Integer", true, true, false, "") });

        assertEquals(new CommandType("foo", 123), gc.getCommandType());
        assertEquals(2, gc.getParameterDefinitions().length);
        try {
            gc.checkParameterValidity(true);
            fail("should have failed - the parameters are required");
        } catch (InvalidParameterValueException e) {
View Full Code Here

    /**
     * testSetCommandType
     */
    public void testSetCommandType() {
        CommandType oldType = m_cmd.getCommandType();
        CommandType newType = new CommandType("newtesttype", 123);

        m_cmd.setCommandType(newType);

        assertFalse(oldType.equals(m_cmd.getCommandType()));
        assertEquals("newtesttype", m_cmd.getCommandType().getName());
View Full Code Here

     *
     * @return test command
     */
    private GenericCommand createGenericCommand() {
        GenericCommand cmd = new GenericCommand();
        cmd.setCommandType(new CommandType("test", 1));
        return cmd;
    }
View Full Code Here

    public void testSerializeCommands() throws Exception {
        GenericCommand gc = new GenericCommand();
        ParameterDefinition def = new ParameterDefinition("hello", String.class.getName(),
            new ParameterRenderingInformation("a", "b"));

        gc.setCommandType(new CommandType("foo", 3));
        gc.setParameterDefinitions(new ParameterDefinition[] { def });
        gc.setParameterValue("hello", "world");
        gc.getConfiguration().put("config1", "config1value");
        gc.getConfiguration().put("config2", "config2value");
        gc = (GenericCommand) serializeDeserialize(gc);

        assert gc.getCommandType().equals(new CommandType("foo", 3));
        assert gc.getParameterDefinition("hello").getType().equals(String.class.getName());
        assert gc.getParameterDefinition("hello").getRenderingInfo().getLabelKey().equals("a");
        assert gc.getParameterDefinition("hello").getRenderingInfo().getDescriptionKey().equals("b");
        assert gc.getParameterValue("hello").equals("world");
        assert gc.getConfiguration().getProperty("config1").equals("config1value");
View Full Code Here

    public void testSerializeCommandsWithNoConfig() throws Exception {
        GenericCommand gc = new GenericCommand();
        ParameterDefinition def = new ParameterDefinition("hello", String.class.getName(),
            new ParameterRenderingInformation("a", "b"));

        gc.setCommandType(new CommandType("foo", 3));
        gc.setParameterDefinitions(new ParameterDefinition[] { def });
        gc.setParameterValue("hello", "world");
        gc = (GenericCommand) serializeDeserialize(gc);

        assert gc.getCommandType().equals(new CommandType("foo", 3));
        assert gc.getParameterDefinition("hello").getType().equals(String.class.getName());
        assert gc.getParameterDefinition("hello").getRenderingInfo().getLabelKey().equals("a");
        assert gc.getParameterDefinition("hello").getRenderingInfo().getDescriptionKey().equals("b");
        assert gc.getParameterValue("hello").equals("world");
View Full Code Here

    /**
     * @see AbstractCommand#buildCommandType()
     */
    protected CommandType buildCommandType() {
        if (m_newCommandType == null) {
            m_newCommandType = new CommandType("unknown", 1);
        }

        return m_newCommandType;
    }
View Full Code Here

                        return ret_response;
                    }
                }

                // get the command's type
                CommandType cmdType = cmd.getCommandType();

                // ask the directory what command service supports the command we want to execute
                CommandServiceDirectoryEntry entry = null;
                ObjectName cmdServiceName = null;
View Full Code Here

                }
            }

            // cmd might be null under odd, error edge cases, have to just be protective here.
            if (cmd != null) {
                CommandType cmdType = cmd.getCommandType();
                m_metrics.addCallTimeData(cmdType.getName(), elapsed, unsuccessfulReason);
                if (cmd instanceof RemotePojoInvocationCommand) {
                    // add additional metrics for the individual pojo method that was invoked
                    RemotePojoInvocationCommand pojoCmd = (RemotePojoInvocationCommand) cmd;
                    String ifaceName = pojoCmd.getTargetInterfaceName();
                    ifaceName = ifaceName.substring(ifaceName.lastIndexOf('.') + 1);
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.communications.command.CommandType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.