public void invoke ( ) { try { m_console . setBusy ( true ) ; m_console . print ( "Invoking " + m_command . toString ( ) + "\n" ) ; Object [ ] parameters = new Object [ m_command . getParameterTypes ( ) . length ] ; if ( m_command . getParameterTypes ( ) . length > 0 ) { for ( int i = 0 ; i < m_command . getParameterTypes ( ) . length ; i ++ ) { m_console . print ( m_command . getParameterNames ( ) [ i ] ) ; m_console . print ( "=" ) ; Object paramValue = m_inputPanels [ i ] . getValue ( ) ; parameters [ i ] = paramValue ; if ( paramValue == null ) { m_console . print ( "<null>" ) ; } else { m_console . print ( stringify ( paramValue ) ) ; } m_console . print ( "\n" ) ; } } long startms = new Date ( ) . getTime ( ) ; Object returned = m_command . invoke ( m_console . getInvocationTarget ( m_command ) , parameters ) ; long endms = new Date ( ) . getTime ( ) ; long totalms = endms - startms ; if ( returned != null ) { m_console . print ( "Returned: " + stringify ( returned ) + "\n" ) ; } else { if ( m_command . getReturnType ( ) == null ) { m_console . print ( "Returned.\n" ) ; } else { m_console . print ( "Returned: <null>\n" ) ; } } String duration ; if ( totalms == 0 ) { duration = "< 0.001 seconds." ; } else { double secs = totalms / 1000.0 ; duration = secs + " seconds." ; } m_console . print ( "Roundtrip time: " ) ; m_console . print ( duration ) ; m_console . print ( "\n" ) ; } catch ( InvocationTargetException ite ) { m_console . print ( "ERROR (" + ite . getTargetException ( ) . getClass ( ) . getName ( ) + ") : " + ite . getTargetException ( ) . getMessage ( ) + "\n" ) ; } catch ( Throwable th ) { m_console . print ( "ERROR (" + th . getClass ( ) . getName ( ) + ") : " + th . getMessage ( ) + "\n" ) ; StringWriter sw = new StringWriter ( ) ; th . printStackTrace ( new PrintWriter ( sw ) ) ; m_console . print ( sw . toString ( ) ) ; } finally { m_console . setBusy ( false ) ; } }
Invokes the console command with whatever parameters have been set thus far sending any errors to the console .