public static RaidNode createRaidNode ( Configuration conf ) throws ClassNotFoundException { try { // default to distributed raid node Class < ? > raidNodeClass = conf . getClass ( RAIDNODE_CLASSNAME_KEY , DistRaidNode . class ) ; if ( ! RaidNode . class . isAssignableFrom ( raidNodeClass ) ) { throw new ClassNotFoundException ( "not an implementation of RaidNode" ) ; } Constructor < ? > constructor = raidNodeClass . getConstructor ( new Class [ ] { Configuration . class } ) ; return ( RaidNode ) constructor . newInstance ( conf ) ; } catch ( NoSuchMethodException e ) { throw new ClassNotFoundException ( "cannot construct raidnode" , e ) ; } catch ( InstantiationException e ) { throw new ClassNotFoundException ( "cannot construct raidnode" , e ) ; } catch ( IllegalAccessException e ) { throw new ClassNotFoundException ( "cannot construct raidnode" , e ) ; } catch ( InvocationTargetException e ) { throw new ClassNotFoundException ( "cannot construct raidnode" , e ) ; } }
Create an instance of the appropriate subclass of RaidNode