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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Thu Mar 27 15:31:01 2003 UTC (21 years, 3 months ago) by joko
Branch: MAIN
Changes since 1.3: +7 -2 lines
fixes to modules regarding new namespace(s) below Data::Mungle::*

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

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