/[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.3 - (show annotations)
Thu Feb 20 18:44:26 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.2: +72 -7 lines
renamed modules
+ sub find_rules: attempts to find 'rap.xml'
+ updated documentation: added SYNOPSIS

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

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