1 |
## ---------------------------------------------------------------------- |
2 |
## $Id: PrebootParser.pm,v 1.1 2003/02/18 15:36:46 joko Exp $ |
3 |
## ---------------------------------------------------------------------- |
4 |
## $Log: PrebootParser.pm,v $ |
5 |
## Revision 1.1 2003/02/18 15:36:46 joko |
6 |
## + initial commit |
7 |
## |
8 |
## ---------------------------------------------------------------------- |
9 |
|
10 |
|
11 |
package Data::Rap::Extension::PrebootParser; |
12 |
|
13 |
use strict; |
14 |
use warnings; |
15 |
|
16 |
|
17 |
use Data::Dumper; |
18 |
|
19 |
|
20 |
sub _prebootparser_start { |
21 |
my $self = shift; |
22 |
$self->_add_inc(@_); |
23 |
$self->_load_config(@_); |
24 |
} |
25 |
|
26 |
sub _add_inc { |
27 |
my $self = shift; |
28 |
|
29 |
# get some variables from preboot-config |
30 |
my $basepath = $self->get_property('app.config.preboot.path.base'); |
31 |
my $pathlist = $self->get_property('app.config.preboot.path.libs'); |
32 |
|
33 |
# trace |
34 |
#$basepath = "abc"; |
35 |
#print Dumper($pathlist); |
36 |
|
37 |
# build list of paths to be added to @INC |
38 |
map { |
39 |
# make relative paths absolute (if no leading "/" or e.g. "c:\" or e.g. "c:/" is present) |
40 |
!m/^\// && !m/^\w:[\/|\\]/ && ($_ = "$basepath/$_"); |
41 |
# substitute backslashes through slashes |
42 |
$_ =~ s/\\/\//g; |
43 |
$_ =~ s/\/$//; |
44 |
} @$pathlist; |
45 |
|
46 |
# trace |
47 |
#print Dumper($pathlist); |
48 |
#exit; |
49 |
|
50 |
# use local modules first |
51 |
unshift @INC, @$pathlist; |
52 |
|
53 |
# use modules from repository first |
54 |
#push @INC, @pathlist; |
55 |
|
56 |
} |
57 |
|
58 |
sub _load_config { |
59 |
my $self = shift; |
60 |
my $args = shift; |
61 |
my $preboot = $self->get_property('app.config.preboot'); |
62 |
|
63 |
#print Dumper($preboot); |
64 |
#print Dumper($self); |
65 |
#exit; |
66 |
|
67 |
my $module = $preboot->{module}->{config}; |
68 |
#$self->("Loading |
69 |
#print "module: $module", "\n"; |
70 |
$self->log("load-module: $module"); |
71 |
|
72 |
#print Dumper($preboot); |
73 |
#exit; |
74 |
$self->loadFromPerlModule($module, $args->{name}, $args->{'varnames'}); |
75 |
} |
76 |
|
77 |
|
78 |
=pod |
79 |
|
80 |
sub parseIncludePaths_old { |
81 |
|
82 |
my @libpaths = @{$PREBOOT->{path}{libs}}; |
83 |
|
84 |
# build list of paths to be added to @INC |
85 |
map { |
86 |
# make relative paths absolute (if no leading "/" or e.g. "c:\" or e.g. "c:/" is present) |
87 |
!m/^\// && !m/^\w:[\/|\\]/ && ($_ = "$PREBOOT->{path}{base}/$_"); |
88 |
# substitute backslashes through slashes |
89 |
$_ =~ s/\\/\//g; |
90 |
$_ =~ s/\/$//; |
91 |
} @libpaths; |
92 |
|
93 |
my @INC_ADDITIONAL = ( |
94 |
#"$path_base/etc", "$path_base/lib", "$path_base/bin", |
95 |
#$PREBOOT->{path}{libs}, |
96 |
@libpaths, |
97 |
); |
98 |
|
99 |
addIncludePaths(@INC_ADDITIONAL); |
100 |
|
101 |
} |
102 |
|
103 |
sub addIncludePaths_old { |
104 |
|
105 |
my @pathlist = @_; |
106 |
|
107 |
# if context says we are under apache, modify @INC |
108 |
if ($PREBOOT->{context}->{type} eq CONTEXT_APACHE || |
109 |
$PREBOOT->{context}->{type} eq CONTEXT_CONSOLE || |
110 |
$PREBOOT->{context}->{type} eq CONTEXT_HARNESS) { |
111 |
|
112 |
# use our libraries first! |
113 |
# why? in case we deliver some older, but required versions - |
114 |
# unfortunately "Class::Tangram" is such a candidate for now |
115 |
# TODO: make a switch here to optionally use System-/CPAN-libraries first |
116 |
# if ($use_system_libs) { |
117 |
# push @INC, @INC_ADDITIONAL; |
118 |
# } |
119 |
unshift @INC, @pathlist; |
120 |
|
121 |
|
122 |
# # try with "use lib" - would still be preferred method - |
123 |
# # modifying "@INC" may cause problems! |
124 |
# foreach my $incpath (@INC_ADDITIONAL) { |
125 |
# print "inc: $incpath\n"; |
126 |
# if (grep(/$incpath/m, @INC)) { |
127 |
# #print $incpath, "\n"; |
128 |
# #eval("use lib '$incpath';"); |
129 |
# } |
130 |
# } |
131 |
|
132 |
} |
133 |
|
134 |
} |
135 |
|
136 |
=cut |
137 |
|
138 |
|
139 |
1; |
140 |
__END__ |