protected void invokeHandler ( Event event , ApiContext apiContext ) throws ClassNotFoundException , NoSuchMethodException , SecurityException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , InstantiationException { String topic [ ] = event . getTopic ( ) . split ( "\\." ) ; String eventCategory = topic [ 0 ] . substring ( 0 , 1 ) . toUpperCase ( ) + topic [ 0 ] . substring ( 1 ) ; String eventAction = topic [ 1 ] ; // get list of registered handlers Object handler = EventManager . getInstance ( ) . getRegisteredClassHandlers ( eventCategory ) ; if ( handler != null ) { String methodName = eventAction ; String className = handler . getClass ( ) . getName ( ) ; try { Method m ; m = handler . getClass ( ) . getMethod ( methodName , ApiContext . class , Event . class ) ; m . invoke ( handler , apiContext , event ) ; } catch ( NoSuchMethodException e ) { logger . warn ( "No " + eventAction + " method on class " + className ) ; throw e ; } catch ( SecurityException e ) { logger . warn ( "Security exception: " + e . getMessage ( ) ) ; throw e ; } catch ( IllegalAccessException e ) { logger . warn ( "Illegal access for method " + eventAction + " on class " + className ) ; throw e ; } catch ( IllegalArgumentException e ) { logger . warn ( "Illegal argument exception for method " + eventAction + " on class " + className ) ; throw e ; } catch ( InvocationTargetException e ) { logger . warn ( "Invocation target exception for method " + eventAction + " on class " + className ) ; throw e ; } } }
Dispatch the event to the handler registered for the category . The method corresponding to the event type is invoked .