line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBD::Sys::Plugin; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
132
|
|
4
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
211
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
DBD::Sys::Plugin - embed own tables to DBD::Sys |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
This package is not intended to be used directly. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
DBD::Sys is developed to use a unique, well known interface (SQL) to access |
17
|
|
|
|
|
|
|
data from underlying system which is available in tabular context (or |
18
|
|
|
|
|
|
|
easily could transformed into). |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
The major goal of DBD::Sys is the ability to have an interface to collect |
21
|
|
|
|
|
|
|
relevant data to operate a system - regardless the individual type. Therefore |
22
|
|
|
|
|
|
|
it uses plugins to provide the accessible tables and can be extended by adding |
23
|
|
|
|
|
|
|
plugins. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 Plugin structure |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Each plugin must be named CI. This package |
28
|
|
|
|
|
|
|
can provide an external callable method named C which |
29
|
|
|
|
|
|
|
must return a hash containing the provided tables as key and the classes which |
30
|
|
|
|
|
|
|
implement the tables as associated value, e.g.: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
package DBD::Sys::Plugin::Foo; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use base qw(DBD::Sys::Plugin); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub get_supported_tables() |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
( |
39
|
|
|
|
|
|
|
mytable => 'DBD::Sys::Plugin::Foo::MyTable'; |
40
|
|
|
|
|
|
|
) |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
If the table is located in additional module, it must be required either by |
44
|
|
|
|
|
|
|
the plugin package on loading or at least when it's returned by |
45
|
|
|
|
|
|
|
C. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
If this method is not provided, the namespace below the plugin name will |
48
|
|
|
|
|
|
|
be scanned for tables using L: |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub DBD::Sys::Plugin::get_supported_tables |
51
|
|
|
|
|
|
|
{ |
52
|
|
|
|
|
|
|
my $proto = blessed($_[0]) || $_[0]; |
53
|
|
|
|
|
|
|
my $finder = Module::Pluggable::Object->new( |
54
|
|
|
|
|
|
|
require => 1, |
55
|
|
|
|
|
|
|
search_path => [$proto], |
56
|
|
|
|
|
|
|
inner => 0, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
my @tableClasses = $finder->plugins(); |
59
|
|
|
|
|
|
|
... |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
It's strongly recommended to derive the table classes from |
63
|
|
|
|
|
|
|
L, but it's required that it is a |
64
|
|
|
|
|
|
|
L and provides the C and |
65
|
|
|
|
|
|
|
C methods: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
package DBD::Sys::Plugin::Foo::MyTable; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
use base qw(DBD::Sys::Table); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub get_col_names() { qw(col1 col2 col3) } |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub collect_data() |
74
|
|
|
|
|
|
|
{ |
75
|
|
|
|
|
|
|
# ... |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
return \@data; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
4
|
|
|
4
|
|
30
|
use vars qw($VERSION); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
174
|
|
83
|
|
|
|
|
|
|
|
84
|
4
|
|
|
4
|
|
21
|
use Carp qw(croak); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
194
|
|
85
|
4
|
|
|
4
|
|
18
|
use Module::Pluggable::Object; |
|
4
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
84
|
|
86
|
4
|
|
|
4
|
|
18
|
use Scalar::Util qw(blessed); |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
185
|
|
87
|
4
|
|
|
4
|
|
17
|
use Params::Util qw(_ARRAY); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
662
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$VERSION = "0.102"; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=pod |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 METHODS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 get_supported_tables |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This method is using L to find all tables in |
98
|
|
|
|
|
|
|
the namespace of the class derived from C. It's called |
99
|
|
|
|
|
|
|
(once at initialization) in package context and returns a hash with the |
100
|
|
|
|
|
|
|
supported tables as key and the according classes as value. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
A plugin what knows it's tables might override this method and return a |
103
|
|
|
|
|
|
|
static hash. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub get_supported_tables |
108
|
|
|
|
|
|
|
{ |
109
|
12
|
|
|
12
|
1
|
24
|
my $self = $_[0]; |
110
|
12
|
|
33
|
|
|
89
|
my $proto = blessed($self) || $self; |
111
|
12
|
|
|
|
|
114
|
my $finder = Module::Pluggable::Object->new( |
112
|
|
|
|
|
|
|
require => 1, |
113
|
|
|
|
|
|
|
search_path => [$proto], |
114
|
|
|
|
|
|
|
inner => 0, |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
|
117
|
12
|
|
|
|
|
109
|
my %supportedTables; |
118
|
12
|
|
|
|
|
44
|
my @tblClasses = $finder->plugins(); |
119
|
12
|
|
|
|
|
26637
|
foreach my $tblClass (@tblClasses) |
120
|
|
|
|
|
|
|
{ |
121
|
48
|
|
|
|
|
60
|
my $tblName; |
122
|
48
|
50
|
|
|
|
885
|
$tblClass->can('get_table_name') and $tblName = $tblClass->get_table_name(); |
123
|
48
|
50
|
|
|
|
119
|
$tblName or ( ( $tblName = $tblClass ) =~ s/.*::(\p{Word}+)$/$1/ ); |
124
|
48
|
100
|
66
|
|
|
169
|
exists $supportedTables{$tblName} |
125
|
|
|
|
|
|
|
and !defined( _ARRAY( $supportedTables{$tblName} ) ) |
126
|
|
|
|
|
|
|
and $supportedTables{$tblName} = [ $supportedTables{$tblName} ]; |
127
|
48
|
100
|
|
|
|
104
|
exists $supportedTables{$tblName} and push( @{ $supportedTables{$tblName} }, $tblClass ); |
|
4
|
|
|
|
|
13
|
|
128
|
48
|
100
|
|
|
|
180
|
exists $supportedTables{$tblName} or $supportedTables{$tblName} = $tblClass; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
12
|
|
|
|
|
242
|
return %supportedTables; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 get_priority |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This method returns the default priority of a plugin (and table): 1000. |
137
|
|
|
|
|
|
|
See L for more information about priorities |
138
|
|
|
|
|
|
|
of plugin and table classes. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
0
|
1
|
|
sub get_priority { return 1000; } |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Jens Rehsack |
147
|
|
|
|
|
|
|
CPAN ID: REHSACK |
148
|
|
|
|
|
|
|
rehsack@cpan.org |
149
|
|
|
|
|
|
|
http://search.cpan.org/~rehsack/ |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 COPYRIGHT |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This program is free software; you can redistribute |
154
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
The full text of the license can be found in the |
157
|
|
|
|
|
|
|
LICENSE file included with this module. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 SUPPORT |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Free support can be requested via regular CPAN bug-tracking system at |
162
|
|
|
|
|
|
|
L. There is |
163
|
|
|
|
|
|
|
no guaranteed reaction time or solution time, but it's always tried to give |
164
|
|
|
|
|
|
|
accept or reject a reported ticket within a week. It depends on business load. |
165
|
|
|
|
|
|
|
That doesn't mean that ticket via rt aren't handles as soon as possible, |
166
|
|
|
|
|
|
|
that means that soon depends on how much I have to do. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Business and commercial support should be acquired from the authors via |
169
|
|
|
|
|
|
|
preferred freelancer agencies. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
1; |
174
|
|
|
|
|
|
|
|