SPOPS logo

NAME

SPOPS::Initialize - Provide methods for initializing groups of SPOPS objects at once

SYNOPSIS

 # Bring in the class
 use SPOPS::Initialize;
 # Assumes that all your SPOPS configuration information is collected
 # in a series of files 'spops/*.perl'
 my $config = SPOPS::Initialize->read_config({
                              directory => '/path/to/spops',
                              pattern   => '\.perl' });
 # You could also have all your SPOPS classes in a single file:
 my $config = SPOPS::Initialize->read_config({
                              filename => '/path/to/my/spops.config' });
 # Or in a number of files:
 my $config = SPOPS::Initialize->read_config({
                              filename => [ '/path/to/my/spops.config.1',
                                            '/path/to/my/spops.config.2' ] });
 # As a shortcut, you read the config and process all at once
 SPOPS::Initialize->process({ directory => '/path/to/spops',
                              pattern   => '\.perl' });
 SPOPS::Initialize->process({ filename => '/path/to/my/spops.config' });
 SPOPS::Initialize->process({ filename => [ '/path/to/my/spops.config.1',
                                            '/path/to/my/spops.config.2' ] });
 # Use an already-formed config hashref from somewhere else
 SPOPS::Initialize->process({ config => \%spops_config });
 # You can also pass in multiple config hashrefs that get processed at
 # once, taking care of circular relationship problems (e.g., 'user'
 # links-to 'group', 'group' links-to 'user').
 SPOPS::Initialize->process({ config => [ $config1, $config2 ] });

DESCRIPTION

This class makes it simple to initialize SPOPS classes and should be suitable for utilizing at a server (or long-running process) startup.

Initialization of a SPOPS class consists of four steps:

  1. Read in the configuration. The configuration can be in a separate file, read from a database or built on the fly.

  2. Ensure that the classes used by SPOPS are 'require'd.

  3. Build the SPOPS class, using SPOPS::ClassFactory.

  4. Initialize the SPOPS class. This ensures any initial work the class needs to do on behalf of its objects is done. Once this step is complete you can instantiate objects of the class and use them at will.

METHODS

process( \%params )

The configuration parameter 'config' can refer to one or more SPOPS object configuration hashrefs. These can be already-formed configuration hashrefs which, if there are more than one,are merged.

Example:

 SPOPS::Initialize->process({ config => $spops_config });
 SPOPS::Initialize->process({ config => [ $spops_config, $spops_config ] });

You can also pass one or more filenames of SPOPS information (using 'filename', or a combination of 'directory' and 'pattern'). Filename/directory processing parameters are passed directly to read_config().

Examples:

 # Process configurations in files 'user/spops.perl' and
 # 'group/spops.perl'
 SPOPS::Initialize->process({ filename => [ 'user/spops.perl',
                                            'group/spops.perl' ] });
 # Process all configuration files ending in .perl in the directory
 # 'conf/spops/':
 SPOPS::Initialize->process({ directory => 'conf/spops/',
                              pattern   => q(\.perl$) });

Other parameters in \%params depend on SPOPS::ClassFactory -- any values you pass will be passed through. This is fairly rare -- the only one you might ever want to pass is 'alias_list', which is an arrayref of aliases in the (merged or not) SPOPS config hashref to process.

Example:

 # We're just clowning around, so only process 'bozo' -- 'user' and
 # 'group' aren't touched
 my $config = {  user  => { ... },
                 group => { ... },
                 bozo  => { ... } };
 SPOPS::Initialize->process({ config => $config, alias_list => [ 'bozo' ] });

read_config( \%params )

Read in SPOPS configuration information from one or more files in the filesystem.

Parameters:

SEE ALSO

SPOPS::ClassFactory

COPYRIGHT

Copyright (c) 2001-2004 Chris Winters. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHORS

Chris Winters <chris@cwinters.com>

Generated from the SPOPS 0.87 source.

SourceForge Logo