public static void init()

in extensions/torque/src/java/org/apache/turbine/services/security/torque/PermissionPeerManager.java [94:183]


    public static void init(Configuration conf)
        throws InitializationException
    {
        String persistentPeerClassName =
            conf.getString(PERMISSION_PEER_CLASS_KEY,
                           PERMISSION_PEER_CLASS_DEFAULT);

        String permissionObjectName = null;

        try
        {
            persistentPeerClass = Class.forName(persistentPeerClassName);

            tableName  =
                (String) persistentPeerClass.getField("TABLE_NAME").get(null);

            //
            // We have either an user configured Object class or we use the
            // default as supplied by the Peer class
            //
            // Default from Peer, can be overridden

            permissionObject = getPersistenceClass();

            permissionObjectName = conf.getString(PERMISSION_CLASS_KEY,
                                        permissionObject.getName());

            // Maybe the user set a new value...
            permissionObject = Class.forName(permissionObjectName);

            /* If any of the following Field queries fails, the permission
             * subsystem is unusable. So check this right here at init time,
             * which saves us much time and hassle if it fails...
             */

            nameColumn = (String) persistentPeerClass.getField(
                    conf.getString(PERMISSION_NAME_COLUMN_KEY,
                                   PERMISSION_NAME_COLUMN_DEFAULT)
                    ).get(null);

            idColumn = (String) persistentPeerClass.getField(
                    conf.getString(PERMISSION_ID_COLUMN_KEY,
                                   PERMISSION_ID_COLUMN_DEFAULT)
                    ).get(null);

            namePropDesc = new PropertyDescriptor(
                    conf.getString(PERMISSION_NAME_PROPERTY_KEY,
                                   PERMISSION_NAME_PROPERTY_DEFAULT),
                    permissionObject);

            idPropDesc = new PropertyDescriptor(
                    conf.getString(PERMISSION_ID_PROPERTY_KEY,
                                   PERMISSION_ID_PROPERTY_DEFAULT),
                    permissionObject);
        }
        catch (Exception e)
        {
            if (persistentPeerClassName == null || persistentPeerClass == null)
            {
                throw new InitializationException(
                    "Could not find PermissionPeer class ("
                    + persistentPeerClassName + ")", e);
            }
            if (tableName == null)
            {
                throw new InitializationException(
                    "Failed to get the table name from the Peer object", e);
            }

            if (permissionObject == null || permissionObjectName == null)
            {
                throw new InitializationException(
                    "Failed to get the object type from the Peer object", e);
            }


            if (nameColumn == null || namePropDesc == null)
            {
                throw new InitializationException(
                    "PermissionPeer " + persistentPeerClassName +
                    " has no name column information!", e);
            }
            if (idColumn == null || idPropDesc == null)
            {
                throw new InitializationException(
                    "PermissionPeer " + persistentPeerClassName +
                    " has no id column information!", e);
            }
        }
    }