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