public static void init()

in extensions/torque/src/java/org/apache/turbine/services/security/torque/GroupPeerManager.java [89:163]


    public static void init(Configuration conf)
        throws InitializationException
    {
        String groupPeerClassName = conf.getString(GROUP_PEER_CLASS_KEY,
                                                   GROUP_PEER_CLASS_DEFAULT);
        String groupObjectName = null;

        try
        {
            groupPeerClass = Class.forName(groupPeerClassName);

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

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

            groupObjectName = conf.getString(GROUP_CLASS_KEY,
                    groupObject.getName());

            groupObject = Class.forName(groupObjectName); // Maybe the user set a new value...

            // If any of the following Field queries fails, the group subsystem
            // is unusable. So check this right here at init time, which saves
            // us much time and hassle if it fails...
            nameColumn = (String) groupPeerClass.getField(conf
                    .getString(GROUP_NAME_COLUMN_KEY, GROUP_NAME_COLUMN_DEFAULT)
                    ).get(null);

            idColumn = (String) groupPeerClass.getField(conf
                    .getString(GROUP_ID_COLUMN_KEY, GROUP_ID_COLUMN_DEFAULT)
                    ).get(null);

            namePropDesc = new PropertyDescriptor(conf
                    .getString(GROUP_NAME_PROPERTY_KEY,
                    GROUP_NAME_PROPERTY_DEFAULT), groupObject);

            idPropDesc = new PropertyDescriptor(conf
                    .getString(GROUP_ID_PROPERTY_KEY,
                    GROUP_ID_PROPERTY_DEFAULT), groupObject);
        }
        catch (Exception e)
        {
            if (groupPeerClassName == null || groupPeerClass == null)
            {
                throw new InitializationException(
                    "Could not find GroupPeer class ("
                    + groupPeerClassName + ")", e);
            }
            if (tableName == null)
            {
                throw new InitializationException(
                    "Failed to get the table name from the Peer object", e);
            }

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

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