public static MessageQ getInstance(final String className, final CommonProperties properties)
            throws FactoryException {

        Validate.notBlank(className, "The validated character sequence 'className' is null or empty");
        Validate.notNull(properties, "The validated object 'properties' is null");

        final Class<? extends MessageQ> messageClazz;
        try {
            messageClazz = Class.forName(className).asSubclass(MessageQ.class);
        } catch (ClassNotFoundException e) {
            final String error = "Class not found: " + className;
            LOG.warn(error);
            throw new FactoryException(error, e);
        } catch (ClassCastException e) {
            final String error = "The provided registry factory class name ('" + className
                    + "') is not a subclass of '" + MessageQ.class.getCanonicalName() + "'";
            LOG.warn(error);
            throw new FactoryException(error, e);
        }

        final MessageQ messageQ;
        try {
            final Constructor<? extends MessageQ> constructor = messageClazz.getDeclaredConstructor();
            if (!constructor.isAccessible()) {
                final String error = "Constructor of class '" + messageClazz.getCanonicalName()
                        + "' is not accessible, changing the accessible flag to instantiate the class";
                LOG.info(error);
                constructor.setAccessible(true);
            }
            messageQ = constructor.newInstance();
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException
                | NoSuchMethodException | IllegalArgumentException e) {
            final String error = "Cannot instantiate class '" + messageClazz.getCanonicalName() + "'";
            LOG.warn(error, e);
            throw new FactoryException(error, e);
        }

        messageQ.init(properties);

        return messageQ;
    }
public static MessageQ getInstance(final String className, final CommonProperties properties)
            throws FactoryException {

        Validate.notBlank(className, "The validated character sequence 'className' is null or empty");
        Validate.notNull(properties, "The validated object 'properties' is null");

        final Class<? extends MessageQ> messageClazz;
        try {
            messageClazz = Class.forName(className).asSubclass(MessageQ.class);
        } catch (ClassNotFoundException e) {
            final String error = "Class not found: " + className;
            LOG.warn(error);
            throw new FactoryException(error, e);
        } catch (ClassCastException e) {
            final String error = "The provided registry factory class name ('" + className
                    + "') is not a subclass of '" + MessageQ.class.getCanonicalName() + "'";
            LOG.warn(error);
            throw new FactoryException(error, e);
        }

        final MessageQ messageQ;
        try {
            final Constructor<? extends MessageQ> constructor = messageClazz.getDeclaredConstructor();
            if (!constructor.isAccessible()) {
                final String error = "Constructor of class '" + messageClazz.getCanonicalName()
                        + "' is not accessible, changing the accessible flag to instantiate the class";
                LOG.info(error);
                constructor.setAccessible(true);
            }
            messageQ = constructor.newInstance();
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException
                | NoSuchMethodException | IllegalArgumentException e) {
            final String error = "Cannot instantiate class '" + messageClazz.getCanonicalName() + "'";
            LOG.warn(error, e);
            throw new FactoryException(error, e);
        }

        messageQ.init(properties);

        return messageQ;
    }
public static MessageQ getInstance ( final String className , final CommonProperties properties ) throws FactoryException { Validate . notBlank ( className , "The validated character sequence 'className' is null or empty" ) ; Validate . notNull ( properties , "The validated object 'properties' is null" ) ; final Class < ? extends MessageQ > messageClazz ; try { messageClazz = Class . forName ( className ) . asSubclass ( MessageQ . class ) ; } catch ( ClassNotFoundException e ) { final String error = "Class not found: " + className ; LOG . warn ( error ) ; throw new FactoryException ( error , e ) ; } catch ( ClassCastException e ) { final String error = "The provided registry factory class name ('" + className + "') is not a subclass of '" + MessageQ . class . getCanonicalName ( ) + "'" ; LOG . warn ( error ) ; throw new FactoryException ( error , e ) ; } final MessageQ messageQ ; try { final Constructor < ? extends MessageQ > constructor = messageClazz . getDeclaredConstructor ( ) ; if ( ! constructor . isAccessible ( ) ) { final String error = "Constructor of class '" + messageClazz . getCanonicalName ( ) + "' is not accessible, changing the accessible flag to instantiate the class" ; LOG . info ( error ) ; constructor . setAccessible ( true ) ; } messageQ = constructor . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | IllegalArgumentException e ) { final String error = "Cannot instantiate class '" + messageClazz . getCanonicalName ( ) + "'" ; LOG . warn ( error , e ) ; throw new FactoryException ( error , e ) ; } messageQ . init ( properties ) ; return messageQ ; }
Return a new, fully initialized instance of a {@link MessageQ} class to use for JAAS event messageing.
<p>
Classes implementing the {@link MessageQ} interface <b>must</b> be thread safe.

@param className  The name of a class that implements the Message interface
@param properties The properties to initialize the instance with
@return An instance of a class implementing the {@link MessageQ} interface
@throws FactoryException         When the class cannot be instantiated
@throws NullPointerException     When the {@code className} or {@code properties} are {@code null}
@throws IllegalArgumentException When {@code className} is empty
Return a new fully initialized instance of a { @link MessageQ } class to use for JAAS event messageing . <p > Classes implementing the { @link MessageQ } interface <b > must< / b > be thread safe .