public static void init()

in extensions/torque/src/java/org/apache/turbine/services/security/torque/UserPeerManager.java [137:363]


    public static void init(Configuration conf)
        throws InitializationException
    {
        String userPeerClassName = conf.getString(USER_PEER_CLASS_KEY,
                                                  USER_PEER_CLASS_DEFAULT);
        String userObjectName = null;

        try
        {
            userPeerClass = Class.forName(userPeerClassName);

            tableName  =
              (String) userPeerClass.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

            userObject = getPersistenceClass();

            userObjectName = conf.getString(USER_CLASS_KEY,
                    userObject.getName());

            // Maybe the user set a new value...
            userObject = Class.forName(userObjectName);

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

            nameColumn = (String) userPeerClass.getField(
                conf.getString(USER_NAME_COLUMN_KEY,
                               USER_NAME_COLUMN_DEFAULT)
                ).get(null);

            idColumn = (String) userPeerClass.getField(
                conf.getString(USER_ID_COLUMN_KEY,
                               USER_ID_COLUMN_DEFAULT)
                ).get(null);

            passwordColumn = (String) userPeerClass.getField(
                conf.getString(USER_PASSWORD_COLUMN_KEY,
                               USER_PASSWORD_COLUMN_DEFAULT)
                ).get(null);

            firstNameColumn  = (String) userPeerClass.getField(
                conf.getString(USER_FIRST_NAME_COLUMN_KEY,
                               USER_FIRST_NAME_COLUMN_DEFAULT)
                ).get(null);

            lastNameColumn = (String) userPeerClass.getField(
                conf.getString(USER_LAST_NAME_COLUMN_KEY,
                               USER_LAST_NAME_COLUMN_DEFAULT)
                ).get(null);

            emailColumn = (String) userPeerClass.getField(
                conf.getString(USER_EMAIL_COLUMN_KEY,
                               USER_EMAIL_COLUMN_DEFAULT)
                ).get(null);

            confirmColumn    = (String) userPeerClass.getField(
                conf.getString(USER_CONFIRM_COLUMN_KEY,
                               USER_CONFIRM_COLUMN_DEFAULT)
                ).get(null);

            createDateColumn = (String) userPeerClass.getField(
                conf.getString(USER_CREATE_COLUMN_KEY,
                               USER_CREATE_COLUMN_DEFAULT)
                ).get(null);

            lastLoginColumn = (String) userPeerClass.getField(
                conf.getString(USER_LAST_LOGIN_COLUMN_KEY,
                               USER_LAST_LOGIN_COLUMN_DEFAULT)
                ).get(null);

            objectdataColumn = (String) userPeerClass.getField(
                conf.getString(USER_OBJECTDATA_COLUMN_KEY,
                               USER_OBJECTDATA_COLUMN_DEFAULT)
                ).get(null);

            namePropDesc =
                new PropertyDescriptor(conf.getString(
                                           USER_NAME_PROPERTY_KEY,
                                           USER_NAME_PROPERTY_DEFAULT),
                                       userObject);

            idPropDesc =
                new PropertyDescriptor(conf.getString(
                                           USER_ID_PROPERTY_KEY,
                                           USER_ID_PROPERTY_DEFAULT),
                                       userObject);

            passwordPropDesc =
                new PropertyDescriptor(conf.getString(
                                           USER_PASSWORD_PROPERTY_KEY,
                                           USER_PASSWORD_PROPERTY_DEFAULT),
                                       userObject);

            firstNamePropDesc =
                new PropertyDescriptor(conf.getString(
                                           USER_FIRST_NAME_PROPERTY_KEY,
                                           USER_FIRST_NAME_PROPERTY_DEFAULT),
                                       userObject);

            lastNamePropDesc   =
                new PropertyDescriptor(conf.getString(
                                           USER_LAST_NAME_PROPERTY_KEY,
                                           USER_LAST_NAME_PROPERTY_DEFAULT),
                                       userObject);

            emailPropDesc =
                new PropertyDescriptor(conf.getString(
                                           USER_EMAIL_PROPERTY_KEY,
                                           USER_EMAIL_PROPERTY_DEFAULT),
                                       userObject);

            confirmPropDesc =
                new PropertyDescriptor(conf.getString(
                                           USER_CONFIRM_PROPERTY_KEY,
                                           USER_CONFIRM_PROPERTY_DEFAULT),
                                       userObject);

            createDatePropDesc =
                new PropertyDescriptor(conf.getString(
                                           USER_CREATE_PROPERTY_KEY,
                                           USER_CREATE_PROPERTY_DEFAULT),
                                       userObject);

            lastLoginPropDesc  =
                new PropertyDescriptor(conf.getString(
                                           USER_LAST_LOGIN_PROPERTY_KEY,
                                           USER_LAST_LOGIN_PROPERTY_DEFAULT),
                                       userObject);

            objectdataPropDesc =
                new PropertyDescriptor(conf.getString(
                                           USER_OBJECTDATA_PROPERTY_KEY,
                                           USER_OBJECTDATA_PROPERTY_DEFAULT),
                                       userObject);
        }
        catch (Exception e)
        {
            if (userPeerClassName == null || userPeerClass == null)
            {
                throw new InitializationException(
                    "Could not find UserPeer class ("
                    + userPeerClassName + ")", e);
            }
            if (tableName == null)
            {
                throw new InitializationException(
                    "Failed to get the table name from the Peer object", e);
            }

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


            if (nameColumn == null || namePropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no name column information!", e);
            }
            if (idColumn == null || idPropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no id column information!", e);
            }
            if (passwordColumn == null || passwordPropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no password column information!", e);
            }
            if (firstNameColumn == null || firstNamePropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no firstName column information!", e);
            }
            if (lastNameColumn == null || lastNamePropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no lastName column information!", e);
            }
            if (emailColumn == null || emailPropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no email column information!", e);
            }
            if (confirmColumn == null || confirmPropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no confirm column information!", e);
            }
            if (createDateColumn == null || createDatePropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no createDate column information!", e);
            }
            if (lastLoginColumn == null || lastLoginPropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no lastLogin column information!", e);
            }
            if (objectdataColumn == null || objectdataPropDesc == null)
            {
                throw new InitializationException(
                    "UserPeer " + userPeerClassName
                    + " has no objectdata column information!", e);
            }
        }
    }