/[cvs]/nfo/perl/libs/Data/Rap.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Rap.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Tue Feb 18 15:34:26 2003 UTC revision 1.9 by joko, Sun Jun 20 16:06:57 2004 UTC
# Line 2  Line 2 
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
26    ##  renamed modules
27    ##  + sub find_rules: attempts to find 'rap.xml'
28    ##  + updated documentation: added SYNOPSIS
29    ##
30    ##  Revision 1.2  2003/02/18 16:02:04  joko
31    ##  +- renamed module
32    ##
33  ##  Revision 1.1  2003/02/18 15:34:26  joko  ##  Revision 1.1  2003/02/18 15:34:26  joko
34  ##  + initial commit  ##  + initial commit
35  ##  ##
# Line 20  Line 48 
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:
71    
72    
73    =head1 SYNOPSIS
74    
75      my $rap = Data::Rap->new( target => 'sync-core' );
76      $rap->start();
77    
78      print Dumper($rap);
79      
80      print Dumper($rap->get_property('/'));
81    
82      print Dumper($rap->get_property('.'));
83      print Dumper($rap->get_property('global'));
84      print Dumper($rap->get_property('app'));
85      print Dumper($rap->get_property('app.config'));
86      print Dumper($rap->get_property('app.config.preboot'));
87      print Dumper($rap->get_property('app.config.databases.oefcore'));
88    
89    
90  =head1 Overview  =head1 Overview
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    
# Line 52  Line 144 
144         - OEF::Component::Task         - OEF::Component::Task
145      - make "old" shortcut programs like "feed.pl", "tell.pl" and such obsolete      - make "old" shortcut programs like "feed.pl", "tell.pl" and such obsolete
146      - 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
147      - some new concepts (perly):
148        - namespaces
149        - plugins
150        - contexts
151    
152    
153  =head3 It's using these fine modules from CPAN  =head3 It's using these fine modules from CPAN
# Line 70  Line 166 
166    
167  =head3 Rap does networking  =head3 Rap does networking
168    
169    - It's a client. (cli program, standalone)    x It's a client. (cli program, standalone)
170    - It's a server/daemon as well. (cli interacts with daemon via tcp-socket)        (->Command-Frontends: rap.pl)
171      o It's a server/daemon as well. (cli interacts with daemonized engine via tcp-socket)
172          (->Command-Frontends: rap.pl --remote|--host=<hostname>)
173    
174        
175  =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
176    
177  =head4 Command-Frontends (local and/or remote)  =head4 Command-Frontends (local and/or remote)
178    
179      x rap.pl
180    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)
181    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::)
182    
# Line 117  use warnings; Line 216  use warnings;
216    
217  use base qw(  use base qw(
218    DesignPattern::Object    DesignPattern::Object
   DesignPattern::Object::Logger  
219    DesignPattern::Bridge    DesignPattern::Bridge
220      DesignPattern::Logger
221      DesignPattern::Exception
222  );  );
223    
224    
225  use Data::Dumper;  use Data::Dumper;
226    use Cwd;
227    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    $self->load([qw( Metadata Engine Property Command )]);    
237      # patch
238        $self->{__rap}->{filename} = $self->{filename};
239        delete $self->{filename};
240      
241      # check
242        if (!$self->{__rap}->{filename}) {
243          $self->{__rap}->{filename} = $self->find_rules();
244        }
245      
246      $self->load([qw( Metadata Engine Command Context Property )]);
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->readXmlOverview();      my $meta_raw = $self->getTargetList();
267      #print Dumper($meta_raw);  
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) {
276          my $len = length($entry->{name});
277          #$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;
291    
292        print Dumper($meta_raw);
293        exit;
294        
295      foreach my $key (keys %{$meta_raw->{target}}) {      foreach my $key (keys %{$meta_raw->{target}}) {
296        my $target = $meta_raw->{target}->{$key};        my $target = $meta_raw->{target}->{$key};
297        print "  - rap.pl $key", "\n";        print "  - rap.pl $key", "\n";
# Line 165  sub start { Line 309  sub start {
309        
310  }  }
311    
312    sub find_rules {
313      my $self = shift;
314    
315      my $rapfile = 'etc/rap.xml';
316      my $rapfile_found = '';
317      
318      my $basedir = '';
319      
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      return $rapfile_found;
363    }
364    
365    
366  1;  1;
367  __END__  __END__

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.9

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed