MyCassandra-0.2.1/src/java/org/apache/cassandra/utils/FBUtilities.java
/**
     * Constructs an instance of the given class, which must have a no-arg constructor.
     * @param classname Fully qualified classname.
     * @param readable Descriptive noun for the role the class plays.
     * @throws ConfigurationException If the class cannot be found.
     */
Constructs an instance of the given class, which must have a no-arg constructor.
@param classname Fully qualified classname.
@param readable Descriptive noun for the role the class plays.
@throws ConfigurationException If the class cannot be found.
Constructs an instance of the given class which must have a no - arg constructor . @param classname Fully qualified classname . @param readable Descriptive noun for the role the class plays . @throws ConfigurationException If the class cannot be found .
public static <T> T construct(String classname, String readable) throws ConfigurationException
    {
        Class<T> cls = FBUtilities.classForName(classname, readable);
        try
        {
            return cls.getConstructor().newInstance();
        }
        catch (NoSuchMethodException e)
        {
            throw new ConfigurationException(String.format("No default constructor for %s class '%s'.", readable, classname));
        }
        catch (IllegalAccessException e)
        {
            throw new ConfigurationException(String.format("Default constructor for %s class '%s' is inaccessible.", readable, classname));
        }
        catch (InstantiationException e)
        {
            throw new ConfigurationException(String.format("Cannot use abstract class '%s' as %s.", classname, readable));
        }
        catch (InvocationTargetException e)
        {
            if (e.getCause() instanceof ConfigurationException)
                throw (ConfigurationException)e.getCause();
            throw new ConfigurationException(String.format("Error instantiating %s class '%s'.", readable, classname), e);
        }
    }
public static < T > T construct ( String classname , String readable ) throws ConfigurationException { Class < T > cls = FBUtilities . classForName ( classname , readable ) ; try { return cls . getConstructor ( ) . newInstance ( ) ; } catch ( NoSuchMethodException e ) { throw new ConfigurationException ( String . format ( "No default constructor for %s class '%s'." , readable , classname ) ) ; } catch ( IllegalAccessException e ) { throw new ConfigurationException ( String . format ( "Default constructor for %s class '%s' is inaccessible." , readable , classname ) ) ; } catch ( InstantiationException e ) { throw new ConfigurationException ( String . format ( "Cannot use abstract class '%s' as %s." , classname , readable ) ) ; } catch ( InvocationTargetException e ) { if ( e . getCause ( ) instanceof ConfigurationException ) throw ( ConfigurationException ) e . getCause ( ) ; throw new ConfigurationException ( String . format ( "Error instantiating %s class '%s'." , readable , classname ) , e ) ; } }
Constructs an instance of the given class, which must have a no-arg constructor.
Constructs an instance of the given class which must have a no - arg constructor .