NAME
    FML::Process::Switch - dispatch a module suitable with the program name.

SYNOPSIS
    used in "libexec/loader".

       package main;
       use FML::Process::Switch;
       &Bootstrap2($main_cf_file); # main::Bootstrap2()

DESCRIPTION
    "libexec/loader" ("libexec/fml/loader"), the wrapper, loads this program
    and calls "Bootstrap2()". "Bootstrap2()" loads main.cf, analyzes the
    command arguments and call "_load_module()" finally.

    "_load_module()" emulates "use $package" to load module suitable with
    the arguments. The fml flow bifurcates here through "_load_module()".

    The flow details of program exists in FML::Process:: class. For example,
    libexec/distribute (fml.pl) runs in this way.

           functions                class
           ----------------------------------------

           main::Bootstrap()        libexec/loader
                |
                V
           main::Bootstrap2()       Process::Switch
                |
                V
           _load_module()            Process::Switch
                |
                |  <---  $obj = FML::Process:Distribute
                |
                V
           ProcessStart($obj,$args) Process::Flow

FUNCTIONS
  main::Bootstrap2()
    kick off the second phase of bootstrap.

    It reads *.cf files, parses them and set the result to @cf array
    variable. We pass it to "_load_module()" later.

        @cf = (
               /etc/fml/defaults/$VERSION/default_config.cf
               /etc/fml/site_default_config.cf (required ?)
               /etc/fml/domains/$DOMAIN/default_config.cf
               /var/spool/ml/elena/config.cf
               );

  NewProcess($curproc, $args, $new_myname, $ml_name, $ml_domain)
    restart new another process (switch to it on running).

  _load_module($args)
    load the library and prepare environment to use it.
    "_load_module($args)" return process object $obj.

    To start the process, we pass $obj with $args to
    "FML::Process::Flow::ProcessStart($obj, $args)".

    $args is like this:

        my $args = {
            fml_version    => $main_cf->{ fml_version },

            myname         => $myname,
            ml_home_prefix => $main_cf->{ ml_home_prefix },
            ml_home_dir    => $main_cf->{ ml_home_dir },

            cf_list        => $cf,
            options        => \%options,

            argv           => \@argv, # pass the original @ARGV
            ARGV           => \@ARGV, # @ARGV after getopts()

            main_cf        => $main_cf,

            # options
            need_ml_name   => _ml_name_is_required($args, $myname),
        };

        # get the object. The suitable module is speculcated by $0.
        my $obj = _load_module($args);

        # start the process.
        FML::Process::Flow::ProcessStart($obj, $args);

UTILITIES
SEE ALSO
    FML::Process::Distribute, FML::Process::Command,
    FML::Process::ListServer, FML::Process::Configure,
    FML::Process::MailErrorAnalyzer

CODING STYLE
    See "http://www.fml.org/software/FNF/" on fml coding style guide.

AUTHOR
    Ken'ichi Fukamachi

COPYRIGHT
    Copyright (C) 2001,2002,2003,2004,2005,2006,2008,2009 Ken'ichi Fukamachi

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

HISTORY
    FML::Process::Switch first appeared in fml8 mailing list driver package.
    See "http://www.fml.org/" for more details.

