| 2 |
## $Id$ |
## $Id$ |
| 3 |
## ------------------------------------------------------------------------- |
## ------------------------------------------------------------------------- |
| 4 |
## $Log$ |
## $Log$ |
| 5 |
|
## Revision 1.9 2004/06/20 16:06:57 joko |
| 6 |
|
## sub start: little modification, now using targets-cache if available |
| 7 |
|
## |
| 8 |
|
## Revision 1.8 2003/12/05 04:59:33 joko |
| 9 |
|
## + minor update: disabled some unnecessary loggers |
| 10 |
|
## |
| 11 |
|
## Revision 1.7 2003/05/13 05:52:58 joko |
| 12 |
|
## minor update: modified description printing logic |
| 13 |
|
## |
| 14 |
|
## Revision 1.6 2003/03/29 07:08:56 joko |
| 15 |
|
## rap goes global: |
| 16 |
|
## + distinguish between running in global- or project-mode |
| 17 |
|
## + some comments in pod |
| 18 |
|
## |
| 19 |
|
## Revision 1.5 2003/03/28 16:52:41 jonen |
| 20 |
|
## now using env-var 'RAPBIN' |
| 21 |
|
## |
| 22 |
|
## Revision 1.4 2003/03/27 15:31:01 joko |
| 23 |
|
## fixes to modules regarding new namespace(s) below Data::Mungle::* |
| 24 |
|
## |
| 25 |
## Revision 1.3 2003/02/20 18:44:26 joko |
## Revision 1.3 2003/02/20 18:44:26 joko |
| 26 |
## renamed modules |
## renamed modules |
| 27 |
## + sub find_rules: attempts to find 'rap.xml' |
## + sub find_rules: attempts to find 'rap.xml' |
| 48 |
A Process is a Task. |
A Process is a Task. |
| 49 |
There are just details. |
There are just details. |
| 50 |
|
|
| 51 |
|
|
| 52 |
=head2 ahh... |
=head2 ahh... |
| 53 |
|
|
| 54 |
CPAN already *has got* all the tools starting an attempt to do this. |
rap means 'Request And Process'. |
| 55 |
|
rap is contained in 'wrapped'. |
| 56 |
|
dot is the 'Database Of Targets', by default '/etc/rap.xml'. (rename to 'dot.xml'?) |
| 57 |
|
|
| 58 |
|
|
| 59 |
|
CPAN already *has got* all required tools starting an attempt to do this. |
| 60 |
|
|
| 61 |
Having enough experience with Perl now, this attempt should work out well..... |
Will this work out? |
| 62 |
But still, Hmmm...... |
But still, Hmmm...... |
| 63 |
And: lots of work, i believe.... |
And: lots of work, i believe.... |
| 64 |
|
Let's start... |
| 65 |
|
|
| 66 |
Okay: |
Okay: |
| 67 |
Look at DesignPattern:: and Data::Transform::Deep & Co. (lowlevel stuff) |
Look at DesignPattern:: and Data::Mungle::Transform::Deep & Co. (lowlevel stuff) |
| 68 |
or OEF::, Data::Storage and Data::Transfer::Sync (highlevel stuff). |
or OEF::, Data::Storage and Data::Transfer::Sync (highlevel stuff). |
| 69 |
|
|
| 70 |
And then: |
And then: |
| 91 |
|
|
| 92 |
=head2 Rap - Request And Process |
=head2 Rap - Request And Process |
| 93 |
|
|
| 94 |
|
=head3 Rap's Features |
| 95 |
|
- have targets (like make) declared in xml (like ant) |
| 96 |
|
- run these targets... |
| 97 |
|
- ... from a multitude of possible human interaction devices (HIDs), e.g. |
| 98 |
|
- cli (console mode) |
| 99 |
|
- gui |
| 100 |
|
- web |
| 101 |
|
- speech |
| 102 |
|
- scribe |
| 103 |
|
- ... from a different location (non-local - for remote administration purposes) |
| 104 |
|
- the remote wrapper is 'rapd' - the rap-daemon.... |
| 105 |
|
- rapd can run in command-mode (like apache, sendmail and related) |
| 106 |
|
and/or web-service mode (commands are wrapped into request-/response- |
| 107 |
|
xml-payload-communication) |
| 108 |
|
- rap is self contained on various levels |
| 109 |
|
- runtime-layer |
| 110 |
|
- pass arguments between targets |
| 111 |
|
- core targets are declared in xml (rap-lingo) as well |
| 112 |
|
these exist by now: (look at Data/Rap/targets/default.xml) |
| 113 |
|
- core.os.win32 |
| 114 |
|
- core.os.linux |
| 115 |
|
- core.rap.mode |
| 116 |
|
- core.rap.daemon |
| 117 |
|
- declaration-layer |
| 118 |
|
- the xml-file in rap-lingo can contain descriptions associated with each target |
| 119 |
|
- rap can make report on its guis about these |
| 120 |
|
- rap can use this declaration as an api for the rap-daemon 'rapd' |
| 121 |
|
- rap itself can run in "global"- or "project"-mode |
| 122 |
|
- FIXME: write something about this (by now: read the source, luke.....) |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
=head3 Rap's Future |
| 126 |
|
- rapd |
| 127 |
|
- rapd can also run in apache mode for non-root purposes |
| 128 |
|
- many rapd's can talk to each other - first example application would be: |
| 129 |
|
- one rapd is running as apache-mod-perl-handler (non-root) |
| 130 |
|
- one rapd is running locally as root |
| 131 |
|
- remark: the way to go (by now) is via org.netfrag.glib's DataSource-libraries, |
| 132 |
|
which wrap the innards of rpc-communication via xml (XMLRPC) (lingo: php) |
| 133 |
|
an example application is caesar.rapweb and (maybe) caesar.ums |
| 134 |
|
|
| 135 |
=head3 Rap's aims are directed to get some of this together |
=head3 Rap's aims are directed to get some of this together |
| 136 |
|
|
| 227 |
use File::Spec::Functions qw( splitpath splitdir catpath catdir ); |
use File::Spec::Functions qw( splitpath splitdir catpath catdir ); |
| 228 |
|
|
| 229 |
|
|
| 230 |
|
# a package global topic registry |
| 231 |
|
our $registry; |
| 232 |
|
|
| 233 |
|
|
| 234 |
sub constructor { |
sub constructor { |
| 235 |
my $self = shift; |
my $self = shift; |
| 236 |
|
|
| 247 |
#$self->load("Command"); |
#$self->load("Command"); |
| 248 |
#$self->load("Metadata"); |
#$self->load("Metadata"); |
| 249 |
#$self->load("Engine"); |
#$self->load("Engine"); |
| 250 |
|
|
| 251 |
} |
} |
| 252 |
|
|
| 253 |
sub start { |
sub start { |
| 254 |
my $self = shift; |
my $self = shift; |
| 255 |
$self->log("starting", 'info'); |
#$self->log("starting", 'info'); |
| 256 |
|
|
| 257 |
$self->loadGlobalProperties(); |
$self->loadGlobalProperties(); |
| 258 |
|
$self->indexTargets({ load => 1 }); |
| 259 |
|
|
| 260 |
#print Dumper($self); |
#print Dumper($self); |
| 261 |
if (my $target = $self->{target}) { |
if (my $target = $self->{target}) { |
| 262 |
#$self->{targets}->{$target} = Data::Rap::Target->new( name => $target ); |
#$self->{targets}->{$target} = Data::Rap::Target->new( name => $target ); |
| 263 |
$self->log("target: $target", 'info'); |
#$self->log("target: $target", 'info'); |
| 264 |
$self->performTarget($target); |
$self->performTarget($target); |
| 265 |
} else { |
} else { |
| 266 |
my $meta_raw = $self->getTargetList(); |
my $meta_raw = $self->getTargetList(); |
| 267 |
|
|
| 268 |
|
my $maxlength = 0; |
| 269 |
|
map { |
| 270 |
|
my $len = length($_->{name}); |
| 271 |
|
$maxlength = $len if $len > $maxlength; |
| 272 |
|
} @$meta_raw; |
| 273 |
|
|
| 274 |
|
my $program = splitpath($0); |
| 275 |
foreach my $entry (@$meta_raw) { |
foreach my $entry (@$meta_raw) { |
| 276 |
print " - rap.pl $entry->{name}", "\n"; |
my $len = length($entry->{name}); |
| 277 |
print $entry->{description}, "\n" if $entry->{description}; |
#$len = ((1 / ($len / 8)) * 1.9); |
| 278 |
|
#$len = ((1 / ($maxlength - $len / 8)) * 1.9); |
| 279 |
|
$len = $maxlength - $len + 5; |
| 280 |
|
#print "len: $len", "\n"; |
| 281 |
|
# one line per target |
| 282 |
|
print "$program $entry->{name}", " " x $len; |
| 283 |
|
print $entry->{description} if $entry->{description}; |
| 284 |
|
print "\n"; |
| 285 |
|
# more lines per target |
| 286 |
|
#print "$program $entry->{name}", "\n"; |
| 287 |
|
#print " ", $entry->{description}, "\n" if $entry->{description}; |
| 288 |
} |
} |
| 289 |
|
|
| 290 |
return; |
return; |
| 311 |
|
|
| 312 |
sub find_rules { |
sub find_rules { |
| 313 |
my $self = shift; |
my $self = shift; |
|
my $cwd = cwd(); |
|
| 314 |
|
|
| 315 |
(my $volume, my $directory, my $file) = splitpath( $cwd ); |
my $rapfile = 'etc/rap.xml'; |
| 316 |
my @dir = splitdir($directory); |
my $rapfile_found = ''; |
| 317 |
pop @dir; |
|
| 318 |
#pop @dir; |
my $basedir = ''; |
| 319 |
my $base = catpath($volume, catdir(@dir)); |
|
| 320 |
|
# directly from env-var? |
| 321 |
|
if (my $rapdir = $ENV{RAPDIR}) { |
| 322 |
|
$basedir = $rapdir; |
| 323 |
|
|
| 324 |
|
# relative? |
| 325 |
|
} else { |
| 326 |
|
my $cwd = cwd(); |
| 327 |
|
|
| 328 |
|
(my $volume, my $directory, my $file) = splitpath( $cwd ); |
| 329 |
|
|
| 330 |
|
my @dir = splitdir($directory); |
| 331 |
|
pop @dir; |
| 332 |
|
#pop @dir; |
| 333 |
|
$basedir = catpath($volume, catdir(@dir)); |
| 334 |
|
|
| 335 |
|
} |
| 336 |
|
|
| 337 |
|
#print "basedir: '$basedir'", "\n"; |
| 338 |
|
|
| 339 |
|
# check for $basedir/PROJECT |
| 340 |
|
if (! -d "$basedir/PROJECT") { |
| 341 |
|
$basedir = ''; |
| 342 |
|
} |
| 343 |
|
|
| 344 |
|
if ($basedir) { |
| 345 |
|
# TODO: review this! handle relative ./etc/rap.xml here!!! |
| 346 |
|
$rapfile_found = "$basedir/$rapfile"; |
| 347 |
|
|
| 348 |
|
} else { |
| 349 |
|
#if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; } |
| 350 |
|
$rapfile_found = "/$rapfile"; |
| 351 |
|
} |
| 352 |
|
|
| 353 |
|
#print "rapfile_found: $rapfile_found", "\n"; |
| 354 |
|
|
| 355 |
|
|
| 356 |
|
# if rapfile doesn't exists, try to fall back to absolute (global) mode (/etc/rap.xml) |
| 357 |
|
#if (! -e $rapfile_found) { $rapfile_found = catpath($volume, "/", $rapfile); } |
| 358 |
|
#if (! -e $rapfile_found) { $rapfile_found = "/$rapfile"; } |
| 359 |
|
|
| 360 |
|
$self->log( "Using rapfile $rapfile_found.", 'info' ); |
| 361 |
|
|
| 362 |
my $rap_xml = "$base/etc/rap.xml"; |
return $rapfile_found; |
|
return $rap_xml; |
|
| 363 |
} |
} |
| 364 |
|
|
| 365 |
|
|