protected void handleOperation(Map<String, String> map, String operation) throws Exception {
        int index=operation.indexOf('.');
        if(index == -1)
            throw new IllegalArgumentException("operation " + operation + " is missing the protocol name");
        String prot_name=operation.substring(0, index);
        Protocol prot=ch.getProtocolStack().findProtocol(prot_name);
        if(prot == null) {
            log.error("protocol %s not found", prot_name);
            return; // less drastic than throwing an exception...
        }

        int args_index=operation.indexOf('[');
        String method_name;
        if(args_index != -1)
            method_name=operation.substring(index +1, args_index).trim();
        else
            method_name=operation.substring(index+1).trim();

        String[] args=null;
        if(args_index != -1) {
            int end_index=operation.indexOf(']');
            if(end_index == -1)
                throw new IllegalArgumentException("] not found");
            List<String> str_args=Util.parseCommaDelimitedStrings(operation.substring(args_index + 1, end_index));
            Object[] strings=str_args.toArray();
            args=new String[strings.length];
            for(int i=0; i < strings.length; i++)
                args[i]=(String)strings[i];
        }

        Method method=findMethod(prot, method_name, args);
        MethodCall call=new MethodCall(method);
        Object[] converted_args=null;
        if(args != null) {
            converted_args=new Object[args.length];
            Class<?>[] types=method.getParameterTypes();
            for(int i=0; i < args.length; i++)
                converted_args[i]=Util.convert(args[i], types[i]);
        }
        Object retval=call.invoke(prot, converted_args);
        if(retval != null)
            map.put(prot_name + "." + method_name, retval.toString());
    }
protected void handleOperation ( Map < String , String > map , String operation ) throws Exception { int index = operation . indexOf ( '.' ) ; if ( index == - 1 ) throw new IllegalArgumentException ( "operation " + operation + " is missing the protocol name" ) ; String prot_name = operation . substring ( 0 , index ) ; Protocol prot = ch . getProtocolStack ( ) . findProtocol ( prot_name ) ; if ( prot == null ) { log . error ( "protocol %s not found" , prot_name ) ; return ; } int args_index = operation . indexOf ( '[' ) ; String method_name ; if ( args_index != - 1 ) method_name = operation . substring ( index + 1 , args_index ) . trim ( ) ; else method_name = operation . substring ( index + 1 ) . trim ( ) ; String [ ] args = null ; if ( args_index != - 1 ) { int end_index = operation . indexOf ( ']' ) ; if ( end_index == - 1 ) throw new IllegalArgumentException ( "] not found" ) ; List < String > str_args = Util . parseCommaDelimitedStrings ( operation . substring ( args_index + 1 , end_index ) ) ; Object [ ] strings = str_args . toArray ( ) ; args = new String [ strings . length ] ; for ( int i = 0 ; i < strings . length ; i ++ ) args [ i ] = ( String ) strings [ i ] ; } Method method = findMethod ( prot , method_name , args ) ; MethodCall call = new MethodCall ( method ) ; Object [ ] converted_args = null ; if ( args != null ) { converted_args = new Object [ args . length ] ; Class < ? > [ ] types = method . getParameterTypes ( ) ; for ( int i = 0 ; i < args . length ; i ++ ) converted_args [ i ] = Util . convert ( args [ i ] , types [ i ] ) ; } Object retval = call . invoke ( prot , converted_args ) ; if ( retval != null ) map . put ( prot_name + "." + method_name , retval . toString ( ) ) ; }
Invokes an operation and puts the return value into map
@param map
@param operation Protocol.OperationName[args], e.g. STABLE.foo[arg1 arg2 arg3]