public static MessageTransformer createMessageTransformer ( String className , SecorConfig config ) throws Exception { Class < ? > clazz = Class . forName ( className ) ; if ( ! MessageTransformer . class . isAssignableFrom ( clazz ) ) { throw new IllegalArgumentException ( String . format ( "The class '%s' is not assignable to '%s'." , className , MessageTransformer . class . getName ( ) ) ) ; } return ( MessageTransformer ) clazz . getConstructor ( SecorConfig . class ) . newInstance ( config ) ; }
Create a MessageTransformer from it s fully qualified class name . The class passed in by name must be assignable to MessageTransformers and have 1 - parameter constructor accepting a SecorConfig . Allows the MessageTransformers to be pluggable by providing the class name of a desired MessageTransformers in config .