protected Initable getInitableInstance()

in src/java/org/apache/turbine/services/BaseInitableBroker.java [225:274]


    protected Initable getInitableInstance(String className)
            throws InstantiationException
    {
        Initable initable = initables.get(className);

        if (initable == null)
        {
            try
            {
                initable = (Initable) Class.forName(className).getDeclaredConstructor().newInstance();
            }
            // those two errors must be passed to the VM
            catch (ThreadDeath | OutOfMemoryError t)
            {
                throw t;
            }
            catch (Throwable t)
            {
                // Used to indicate error condition.
                String msg = null;

                if (t instanceof NoClassDefFoundError)
                {
                    msg = "A class referenced by " + className +
                            " is unavailable. Check your jars and classes.";
                }
                else if (t instanceof ClassNotFoundException)
                {
                    msg = "Class " + className +
                            " is unavailable. Check your jars and classes.";
                }
                else if (t instanceof ClassCastException)
                {
                    msg = "Class " + className +
                            " doesn't implement Initable.";
                }
                else
                {
                    msg = "Failed to instantiate " + className;
                }

                throw new InstantiationException(msg, t);
            }

            initable.setInitableBroker(this);
            initables.put(className, initable);
        }

        return initable;
    }