Apache2-ASP
view release on metacpan or search on metacpan
lib/Apache2/ASP/Config.pm view on Meta::CPAN
package Apache2::ASP::Config;
use strict;
use warnings 'all';
use Carp 'confess';
use base 'Apache2::ASP::ConfigNode';
#==============================================================================
sub new
{
my ($class, $ref, $root) = @_;
my $s = $class->SUPER::new( $ref );
$s->init_server_root( $root );
$s->_init_inc();
foreach my $var ( $s->system->env_vars )
{
while( my ($key,$val) = each(%$var) )
{
$ENV{$key} = $val;
}# end while()
}# end foreach()
map { $s->load_class( $_ ) } $s->system->load_modules;
return $s;
}# end new()
#==============================================================================
sub _init_inc
{
my $s = shift;
my %saw = map { $_ => 1 } @INC;
push @INC, grep { ! $saw{$_}++ } ( $s->system->libs, $s->web->handler_root );
}# end _init_inc()
#==============================================================================
sub init_server_root
{
my ($s, $root) = @_;
no warnings 'uninitialized';
foreach( @{ $s->{system}->{libs}->{lib} } )
{
$_ =~ s/\@ServerRoot\@/$root/;
}# end foreach()
foreach( @{ $s->{system}->{settings}->{setting} } )
{
$_->{value} =~ s/\@ServerRoot\@/$root/;
}# end foreach()
foreach my $key (qw/ application handler media_manager_upload www page_cache /)
{
$s->{web}->{"$key\_root"} =~ s/\@ServerRoot\@/$root/;
}# end foreach()
}# end init_server_root()
#==============================================================================
sub load_class
{
my ($s, $class) = @_;
(my $file = "$class.pm") =~ s/::/\//g;
eval { require $file unless $INC{$file}; 1 }
or confess "Cannot load $class: $@";
( run in 0.699 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )