2 |
## $Id$ |
## $Id$ |
3 |
## ------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.8 2003/12/05 04:59:33 joko |
6 |
|
## + minor update: disabled some unnecessary loggers |
7 |
|
## |
8 |
|
## Revision 1.7 2003/05/13 05:52:58 joko |
9 |
|
## minor update: modified description printing logic |
10 |
|
## |
11 |
|
## Revision 1.6 2003/03/29 07:08:56 joko |
12 |
|
## rap goes global: |
13 |
|
## + distinguish between running in global- or project-mode |
14 |
|
## + some comments in pod |
15 |
|
## |
16 |
|
## Revision 1.5 2003/03/28 16:52:41 jonen |
17 |
|
## now using env-var 'RAPBIN' |
18 |
|
## |
19 |
|
## Revision 1.4 2003/03/27 15:31:01 joko |
20 |
|
## fixes to modules regarding new namespace(s) below Data::Mungle::* |
21 |
|
## |
22 |
|
## Revision 1.3 2003/02/20 18:44:26 joko |
23 |
|
## renamed modules |
24 |
|
## + sub find_rules: attempts to find 'rap.xml' |
25 |
|
## + updated documentation: added SYNOPSIS |
26 |
|
## |
27 |
|
## Revision 1.2 2003/02/18 16:02:04 joko |
28 |
|
## +- renamed module |
29 |
|
## |
30 |
## Revision 1.1 2003/02/18 15:34:26 joko |
## Revision 1.1 2003/02/18 15:34:26 joko |
31 |
## + initial commit |
## + initial commit |
32 |
## |
## |
45 |
A Process is a Task. |
A Process is a Task. |
46 |
There are just details. |
There are just details. |
47 |
|
|
48 |
|
|
49 |
=head2 ahh... |
=head2 ahh... |
50 |
|
|
51 |
CPAN already *has got* all the tools starting an attempt to do this. |
rap means 'Request And Process'. |
52 |
|
rap is contained in 'wrapped'. |
53 |
|
dot is the 'Database Of Targets', by default '/etc/rap.xml'. (rename to 'dot.xml'?) |
54 |
|
|
55 |
|
|
56 |
|
CPAN already *has got* all required tools starting an attempt to do this. |
57 |
|
|
58 |
Having enough experience with Perl now, this attempt should work out well..... |
Will this work out? |
59 |
But still, Hmmm...... |
But still, Hmmm...... |
60 |
And: lots of work, i believe.... |
And: lots of work, i believe.... |
61 |
|
Let's start... |
62 |
|
|
63 |
Okay: |
Okay: |
64 |
Look at DesignPattern:: and Data::Transform::Deep & Co. (lowlevel stuff) |
Look at DesignPattern:: and Data::Mungle::Transform::Deep & Co. (lowlevel stuff) |
65 |
or OEF::, Data::Storage and Data::Transfer::Sync (highlevel stuff). |
or OEF::, Data::Storage and Data::Transfer::Sync (highlevel stuff). |
66 |
|
|
67 |
And then: |
And then: |
68 |
|
|
69 |
|
|
70 |
|
=head1 SYNOPSIS |
71 |
|
|
72 |
|
my $rap = Data::Rap->new( target => 'sync-core' ); |
73 |
|
$rap->start(); |
74 |
|
|
75 |
|
print Dumper($rap); |
76 |
|
|
77 |
|
print Dumper($rap->get_property('/')); |
78 |
|
|
79 |
|
print Dumper($rap->get_property('.')); |
80 |
|
print Dumper($rap->get_property('global')); |
81 |
|
print Dumper($rap->get_property('app')); |
82 |
|
print Dumper($rap->get_property('app.config')); |
83 |
|
print Dumper($rap->get_property('app.config.preboot')); |
84 |
|
print Dumper($rap->get_property('app.config.databases.oefcore')); |
85 |
|
|
86 |
|
|
87 |
=head1 Overview |
=head1 Overview |
88 |
|
|
89 |
=head2 Rap - Request And Process |
=head2 Rap - Request And Process |
90 |
|
|
91 |
|
=head3 Rap's Features |
92 |
|
- have targets (like make) declared in xml (like ant) |
93 |
|
- run these targets... |
94 |
|
- ... from a multitude of possible human interaction devices (HIDs), e.g. |
95 |
|
- cli (console mode) |
96 |
|
- gui |
97 |
|
- web |
98 |
|
- speech |
99 |
|
- scribe |
100 |
|
- ... from a different location (non-local - for remote administration purposes) |
101 |
|
- the remote wrapper is 'rapd' - the rap-daemon.... |
102 |
|
- rapd can run in command-mode (like apache, sendmail and related) |
103 |
|
and/or web-service mode (commands are wrapped into request-/response- |
104 |
|
xml-payload-communication) |
105 |
|
- rap is self contained on various levels |
106 |
|
- runtime-layer |
107 |
|
- pass arguments between targets |
108 |
|
- core targets are declared in xml (rap-lingo) as well |
109 |
|
these exist by now: (look at Data/Rap/targets/default.xml) |
110 |
|
- core.os.win32 |
111 |
|
- core.os.linux |
112 |
|
- core.rap.mode |
113 |
|
- core.rap.daemon |
114 |
|
- declaration-layer |
115 |
|
- the xml-file in rap-lingo can contain descriptions associated with each target |
116 |
|
- rap can make report on its guis about these |
117 |
|
- rap can use this declaration as an api for the rap-daemon 'rapd' |
118 |
|
- rap itself can run in "global"- or "project"-mode |
119 |
|
- FIXME: write something about this (by now: read the source, luke.....) |
120 |
|
|
121 |
|
|
122 |
|
=head3 Rap's Future |
123 |
|
- rapd |
124 |
|
- rapd can also run in apache mode for non-root purposes |
125 |
|
- many rapd's can talk to each other - first example application would be: |
126 |
|
- one rapd is running as apache-mod-perl-handler (non-root) |
127 |
|
- one rapd is running locally as root |
128 |
|
- remark: the way to go (by now) is via org.netfrag.glib's DataSource-libraries, |
129 |
|
which wrap the innards of rpc-communication via xml (XMLRPC) (lingo: php) |
130 |
|
an example application is caesar.rapweb and (maybe) caesar.ums |
131 |
|
|
132 |
=head3 Rap's aims are directed to get some of this together |
=head3 Rap's aims are directed to get some of this together |
133 |
|
|
141 |
- OEF::Component::Task |
- OEF::Component::Task |
142 |
- make "old" shortcut programs like "feed.pl", "tell.pl" and such obsolete |
- make "old" shortcut programs like "feed.pl", "tell.pl" and such obsolete |
143 |
- add more targets in order to make "setup.pl" & Co. obsolete as well |
- add more targets in order to make "setup.pl" & Co. obsolete as well |
144 |
|
- some new concepts (perly): |
145 |
|
- namespaces |
146 |
|
- plugins |
147 |
|
- contexts |
148 |
|
|
149 |
|
|
150 |
=head3 It's using these fine modules from CPAN |
=head3 It's using these fine modules from CPAN |
163 |
|
|
164 |
=head3 Rap does networking |
=head3 Rap does networking |
165 |
|
|
166 |
- It's a client. (cli program, standalone) |
x It's a client. (cli program, standalone) |
167 |
- It's a server/daemon as well. (cli interacts with daemon via tcp-socket) |
(->Command-Frontends: rap.pl) |
168 |
|
o It's a server/daemon as well. (cli interacts with daemonized engine via tcp-socket) |
169 |
|
(->Command-Frontends: rap.pl --remote|--host=<hostname>) |
170 |
|
|
171 |
|
|
172 |
=head3 Rap is open for enhancements and/or integration into/with other stuff |
=head3 Rap is open for enhancements and/or integration into/with other stuff |
173 |
|
|
174 |
=head4 Command-Frontends (local and/or remote) |
=head4 Command-Frontends (local and/or remote) |
175 |
|
|
176 |
|
x rap.pl |
177 |
o Commands can be sent via psh (The Perl Shell) or similar frontends (via rap.pl or Rap.pm) |
o Commands can be sent via psh (The Perl Shell) or similar frontends (via rap.pl or Rap.pm) |
178 |
o Commands can be issued from a php-frontend (via RPC using Rap::) |
o Commands can be issued from a php-frontend (via RPC using Rap::) |
179 |
|
|
213 |
|
|
214 |
use base qw( |
use base qw( |
215 |
DesignPattern::Object |
DesignPattern::Object |
|
DesignPattern::Object::Logger |
|
216 |
DesignPattern::Bridge |
DesignPattern::Bridge |
217 |
|
DesignPattern::Logger |
218 |
|
DesignPattern::Exception |
219 |
); |
); |
220 |
|
|
221 |
|
|
222 |
use Data::Dumper; |
use Data::Dumper; |
223 |
|
use Cwd; |
224 |
|
use File::Spec::Functions qw( splitpath splitdir catpath catdir ); |
225 |
|
|
226 |
|
|
227 |
|
# a package global topic registry |
228 |
|
our $registry; |
229 |
|
|
230 |
|
|
231 |
sub constructor { |
sub constructor { |
232 |
my $self = shift; |
my $self = shift; |
233 |
$self->load([qw( Metadata Engine Property Command )]); |
|
234 |
|
# patch |
235 |
|
$self->{__rap}->{filename} = $self->{filename}; |
236 |
|
delete $self->{filename}; |
237 |
|
|
238 |
|
# check |
239 |
|
if (!$self->{__rap}->{filename}) { |
240 |
|
$self->{__rap}->{filename} = $self->find_rules(); |
241 |
|
} |
242 |
|
|
243 |
|
$self->load([qw( Metadata Engine Command Context Property )]); |
244 |
#$self->load("Command"); |
#$self->load("Command"); |
245 |
#$self->load("Metadata"); |
#$self->load("Metadata"); |
246 |
#$self->load("Engine"); |
#$self->load("Engine"); |
247 |
|
|
248 |
} |
} |
249 |
|
|
250 |
sub start { |
sub start { |
251 |
my $self = shift; |
my $self = shift; |
252 |
$self->log("starting", 'info'); |
#$self->log("starting", 'info'); |
253 |
|
|
254 |
$self->loadGlobalProperties(); |
$self->loadGlobalProperties(); |
255 |
|
|
256 |
#print Dumper($self); |
#print Dumper($self); |
257 |
if (my $target = $self->{target}) { |
if (my $target = $self->{target}) { |
258 |
#$self->{targets}->{$target} = Data::Rap::Target->new( name => $target ); |
#$self->{targets}->{$target} = Data::Rap::Target->new( name => $target ); |
259 |
$self->log("target: $target", 'info'); |
#$self->log("target: $target", 'info'); |
260 |
$self->performTarget($target); |
$self->performTarget($target); |
261 |
} else { |
} else { |
262 |
my $meta_raw = $self->readXmlOverview(); |
my $meta_raw = $self->getTargetList(); |
263 |
#print Dumper($meta_raw); |
|
264 |
|
my $maxlength = 0; |
265 |
|
map { |
266 |
|
my $len = length($_->{name}); |
267 |
|
$maxlength = $len if $len > $maxlength; |
268 |
|
} @$meta_raw; |
269 |
|
|
270 |
|
my $program = splitpath($0); |
271 |
|
foreach my $entry (@$meta_raw) { |
272 |
|
my $len = length($entry->{name}); |
273 |
|
#$len = ((1 / ($len / 8)) * 1.9); |
274 |
|
#$len = ((1 / ($maxlength - $len / 8)) * 1.9); |
275 |
|
$len = $maxlength - $len + 5; |
276 |
|
#print "len: $len", "\n"; |
277 |
|
# one line per target |
278 |
|
print "$program $entry->{name}", " " x $len; |
279 |
|
print $entry->{description} if $entry->{description}; |
280 |
|
print "\n"; |
281 |
|
# more lines per target |
282 |
|
#print "$program $entry->{name}", "\n"; |
283 |
|
#print " ", $entry->{description}, "\n" if $entry->{description}; |
284 |
|
} |
285 |
|
|
286 |
|
return; |
287 |
|
|
288 |
|
print Dumper($meta_raw); |
289 |
|
exit; |
290 |
|
|
291 |
foreach my $key (keys %{$meta_raw->{target}}) { |
foreach my $key (keys %{$meta_raw->{target}}) { |
292 |
my $target = $meta_raw->{target}->{$key}; |
my $target = $meta_raw->{target}->{$key}; |
293 |
print " - rap.pl $key", "\n"; |
print " - rap.pl $key", "\n"; |
305 |
|
|
306 |
} |
} |
307 |
|
|
308 |
|
sub find_rules { |
309 |
|
my $self = shift; |
310 |
|
|
311 |
|
my $rapfile = 'etc/rap.xml'; |
312 |
|
my $rapfile_found = ''; |
313 |
|
|
314 |
|
my $basedir = ''; |
315 |
|
|
316 |
|
# directly from env-var? |
317 |
|
if (my $rapdir = $ENV{RAPDIR}) { |
318 |
|
$basedir = $rapdir; |
319 |
|
|
320 |
|
# relative? |
321 |
|
} else { |
322 |
|
my $cwd = cwd(); |
323 |
|
|
324 |
|
(my $volume, my $directory, my $file) = splitpath( $cwd ); |
325 |
|
|
326 |
|
my @dir = splitdir($directory); |
327 |
|
pop @dir; |
328 |
|
#pop @dir; |
329 |
|
$basedir = catpath($volume, catdir(@dir)); |
330 |
|
|
331 |
|
} |
332 |
|
|
333 |
|
#print "basedir: '$basedir'", "\n"; |
334 |
|
|
335 |
|
# check for $basedir/PROJECT |
336 |
|
if (! -d "$basedir/PROJECT") { |
337 |
|
$basedir = ''; |
338 |
|
} |
339 |
|
|
340 |
|
if ($basedir) { |
341 |
|
# TODO: review this! handle relative ./etc/rap.xml here!!! |
342 |
|
$rapfile_found = "$basedir/$rapfile"; |
343 |
|
|
344 |
|
} else { |
345 |
|
#if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; } |
346 |
|
$rapfile_found = "/$rapfile"; |
347 |
|
} |
348 |
|
|
349 |
|
#print "rapfile_found: $rapfile_found", "\n"; |
350 |
|
|
351 |
|
|
352 |
|
# if rapfile doesn't exists, try to fall back to absolute (global) mode (/etc/rap.xml) |
353 |
|
#if (! -e $rapfile_found) { $rapfile_found = catpath($volume, "/", $rapfile); } |
354 |
|
#if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; } |
355 |
|
|
356 |
|
$self->log( "Using rapfile $rapfile_found.", 'info' ); |
357 |
|
|
358 |
|
return $rapfile_found; |
359 |
|
} |
360 |
|
|
361 |
|
|
362 |
1; |
1; |
363 |
__END__ |
__END__ |