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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations)
Fri Mar 28 16:52:41 2003 UTC (21 years, 3 months ago) by jonen
Branch: MAIN
Changes since 1.4: +21 -8 lines
now using env-var 'RAPBIN'

1 joko 1.1 ## -------------------------------------------------------------------------
2 jonen 1.5 ## $Id: Rap.pm,v 1.4 2003/03/27 15:31:01 joko Exp $
3 joko 1.1 ## -------------------------------------------------------------------------
4 joko 1.2 ## $Log: Rap.pm,v $
5 jonen 1.5 ## Revision 1.4 2003/03/27 15:31:01 joko
6     ## fixes to modules regarding new namespace(s) below Data::Mungle::*
7     ##
8 joko 1.4 ## Revision 1.3 2003/02/20 18:44:26 joko
9     ## renamed modules
10     ## + sub find_rules: attempts to find 'rap.xml'
11     ## + updated documentation: added SYNOPSIS
12     ##
13 joko 1.3 ## Revision 1.2 2003/02/18 16:02:04 joko
14     ## +- renamed module
15     ##
16 joko 1.2 ## Revision 1.1 2003/02/18 15:34:26 joko
17     ## + initial commit
18     ##
19 joko 1.1 ## -------------------------------------------------------------------------
20    
21    
22     =pod
23    
24     =head1 Preface
25    
26     =head2 hmm.....
27    
28     A Command is a Request.
29     A Task is a Process.
30     A Request is a Command.
31     A Process is a Task.
32     There are just details.
33    
34     =head2 ahh...
35    
36     CPAN already *has got* all the tools starting an attempt to do this.
37    
38     Having enough experience with Perl now, this attempt should work out well.....
39     But still, Hmmm......
40     And: lots of work, i believe....
41    
42     Okay:
43 joko 1.4 Look at DesignPattern:: and Data::Mungle::Transform::Deep & Co. (lowlevel stuff)
44 joko 1.1 or OEF::, Data::Storage and Data::Transfer::Sync (highlevel stuff).
45    
46     And then:
47    
48    
49 joko 1.3 =head1 SYNOPSIS
50    
51     my $rap = Data::Rap->new( target => 'sync-core' );
52     $rap->start();
53    
54     print Dumper($rap);
55    
56     print Dumper($rap->get_property('/'));
57    
58     print Dumper($rap->get_property('.'));
59     print Dumper($rap->get_property('global'));
60     print Dumper($rap->get_property('app'));
61     print Dumper($rap->get_property('app.config'));
62     print Dumper($rap->get_property('app.config.preboot'));
63     print Dumper($rap->get_property('app.config.databases.oefcore'));
64    
65    
66 joko 1.1 =head1 Overview
67    
68     =head2 Rap - Request And Process
69    
70    
71     =head3 Rap's aims are directed to get some of this together
72    
73     - some concepts of make (->targets)
74     - some concepts of ant (->tasks)
75     - some code written while developing a custom application with Perl:
76     - libraries/modules (CPAN proposals)
77     - Data::Storage::Container
78     - Data::Storage
79     - Data::Transfer::Sync
80     - OEF::Component::Task
81     - make "old" shortcut programs like "feed.pl", "tell.pl" and such obsolete
82     - add more targets in order to make "setup.pl" & Co. obsolete as well
83 joko 1.3 - some new concepts (perly):
84     - namespaces
85     - plugins
86     - contexts
87 joko 1.1
88    
89     =head3 It's using these fine modules from CPAN
90    
91     - xml, xpath and such (XML::Parser, XML::XPath)
92     - local os native (background) process execution (IPC::Run)
93     - remote procedure calls with xml payloads: XMLRPC, SOAP and such (RPC::XML, SOAP::Lite)
94     - configuration- and property-data inheritance: Hash::Merge
95    
96     - under the hood:
97     - logging: Log::Dispatch
98     - data-access: DBI & Co., Tangram
99     - data-manipulation: Data::Dumper, Iterate
100     - in other words: all modules already included in some declaration inside 'setup.pl'
101    
102    
103     =head3 Rap does networking
104    
105 joko 1.3 x It's a client. (cli program, standalone)
106     (->Command-Frontends: rap.pl)
107     o It's a server/daemon as well. (cli interacts with daemonized engine via tcp-socket)
108     (->Command-Frontends: rap.pl --remote|--host=<hostname>)
109 joko 1.1
110    
111     =head3 Rap is open for enhancements and/or integration into/with other stuff
112    
113     =head4 Command-Frontends (local and/or remote)
114    
115 joko 1.3 x rap.pl
116 joko 1.1 o Commands can be sent via psh (The Perl Shell) or similar frontends (via rap.pl or Rap.pm)
117     o Commands can be issued from a php-frontend (via RPC using Rap::)
118    
119     =head4 Target-Registry (local and/or remote)
120    
121     x Targets can be defined inside a rap.xml or similar
122     o Targets can be stored in arbitrary data structures (e.g. read from an rdbms or ldap-storage)
123    
124     =head4 Task-Backends (local and/or remote)
125    
126     x Tasks can run as local native processes (attached and/or background)
127     o Tasks can be triggered by issuing RPC-calls to arbitrary multiple hosts
128    
129     =head4 TODO
130     o look at Maven's POM (Project Object Model):
131     - http://jakarta.apache.org/turbine/maven/reference/project-descriptor.html
132     - http://jakarta.apache.org/turbine/maven/images/project-descriptor.gif
133     - http://jakarta.apache.org/turbine/maven/start/integrate.html
134     - http://jakarta.apache.org/turbine/maven/reference/dirlayout.html
135     o integrate with:
136     o POE
137     o PP5E
138     o integrate with pod (for reporting purposes)
139     o look at:
140     btw: "expand": look at scripts@CPAN (System Administration):
141     there is a perl make with perl
142     o refactore child-modules using code from Data::Code only!
143    
144    
145     =cut
146    
147    
148     package Data::Rap;
149    
150     use strict;
151     use warnings;
152    
153     use base qw(
154     DesignPattern::Object
155     DesignPattern::Bridge
156 joko 1.3 DesignPattern::Logger
157     DesignPattern::Exception
158 joko 1.1 );
159    
160    
161     use Data::Dumper;
162 joko 1.3 use Cwd;
163     use File::Spec::Functions qw( splitpath splitdir catpath catdir );
164 joko 1.1
165    
166     sub constructor {
167     my $self = shift;
168 joko 1.3
169     # patch
170     $self->{__rap}->{filename} = $self->{filename};
171     delete $self->{filename};
172    
173     # check
174     if (!$self->{__rap}->{filename}) {
175     $self->{__rap}->{filename} = $self->find_rules();
176     }
177    
178     $self->load([qw( Metadata Engine Command Context Property )]);
179 joko 1.1 #$self->load("Command");
180     #$self->load("Metadata");
181     #$self->load("Engine");
182 jonen 1.5
183     # check for another environment-variable: 'RAPBIN'
184     chdir $ENV{RAPBIN} if $ENV{RAPBIN};
185 joko 1.1
186     }
187    
188     sub start {
189     my $self = shift;
190     $self->log("starting", 'info');
191    
192     $self->loadGlobalProperties();
193    
194     #print Dumper($self);
195     if (my $target = $self->{target}) {
196     #$self->{targets}->{$target} = Data::Rap::Target->new( name => $target );
197     $self->log("target: $target", 'info');
198     $self->performTarget($target);
199     } else {
200 joko 1.3 my $meta_raw = $self->getTargetList();
201    
202     foreach my $entry (@$meta_raw) {
203     print " - rap.pl $entry->{name}", "\n";
204     print $entry->{description}, "\n" if $entry->{description};
205     }
206    
207     return;
208    
209     print Dumper($meta_raw);
210     exit;
211    
212 joko 1.1 foreach my $key (keys %{$meta_raw->{target}}) {
213     my $target = $meta_raw->{target}->{$key};
214     print " - rap.pl $key", "\n";
215     my $description = $target->{description};
216     if ($description) {
217     #chomp($description);
218     $description =~ s/^\n+//;
219     $description =~ s/\n+$//;
220     #print "\n" if $description !~ /^\n/;
221     print $description, "\n" if !ref $description;
222     }
223     #print "\n";
224     }
225     }
226    
227     }
228 joko 1.3
229     sub find_rules {
230     my $self = shift;
231    
232 jonen 1.5 my $basedir;
233     if (my $rapdir = $ENV{RAPDIR}) {
234     $basedir = $rapdir;
235     } else {
236     my $cwd = cwd();
237    
238     (my $volume, my $directory, my $file) = splitpath( $cwd );
239     my @dir = splitdir($directory);
240     pop @dir;
241     #pop @dir;
242     $basedir = catpath($volume, catdir(@dir));
243    
244     }
245 joko 1.3
246 jonen 1.5 my $rap_xml = "$basedir/etc/rap.xml";
247 joko 1.3 return $rap_xml;
248     }
249    
250 joko 1.1
251     1;
252     __END__

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