private RequestDispatcher createDispatcher ( String pDispatcherClass , Converters pConverters , ServerHandle pServerHandle , Restrictor pRestrictor , Configuration pConfig ) { try { Class clazz = ClassUtil . classForName ( pDispatcherClass , getClass ( ) . getClassLoader ( ) ) ; if ( clazz == null ) { throw new IllegalArgumentException ( "Couldn't lookup dispatcher " + pDispatcherClass ) ; } try { Constructor constructor = clazz . getConstructor ( Converters . class , ServerHandle . class , Restrictor . class , Configuration . class ) ; return ( RequestDispatcher ) constructor . newInstance ( pConverters , pServerHandle , pRestrictor , pConfig ) ; } catch ( NoSuchMethodException exp ) { // Try without configuration as fourth parameter Constructor constructor = clazz . getConstructor ( Converters . class , ServerHandle . class , Restrictor . class ) ; return ( RequestDispatcher ) constructor . newInstance ( pConverters , pServerHandle , pRestrictor ) ; } } catch ( NoSuchMethodException e ) { throw new IllegalArgumentException ( "Class " + pDispatcherClass + " has invalid constructor: " + e , e ) ; } catch ( IllegalAccessException e ) { throw new IllegalArgumentException ( "Constructor of " + pDispatcherClass + " couldn't be accessed: " + e , e ) ; } catch ( InvocationTargetException e ) { throw new IllegalArgumentException ( e ) ; } catch ( InstantiationException e ) { throw new IllegalArgumentException ( pDispatcherClass + " couldn't be instantiated: " + e , e ) ; } }
Create a single dispatcher