line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenPlugin::Plugin; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Plugin.pm,v 1.22 2003/04/28 17:43:48 andreychek Exp $ |
4
|
|
|
|
|
|
|
|
5
|
7
|
|
|
7
|
|
48
|
use strict; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
385
|
|
6
|
7
|
|
|
7
|
|
9770
|
use Class::Factory 0.04 qw(); |
|
7
|
|
|
|
|
41819
|
|
|
7
|
|
|
|
|
213
|
|
7
|
7
|
|
|
7
|
|
79
|
use base qw( Class::Factory ); |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
1090
|
|
8
|
7
|
|
|
7
|
|
13782
|
use Log::Log4perl qw( get_logger ); |
|
7
|
|
|
|
|
719916
|
|
|
7
|
|
|
|
|
63
|
|
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
483
|
use constant STATE => '_state'; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
4377
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$OpenPlugin::Plugin::VERSION = sprintf("%d.%02d", q$Revision: 1.22 $ =~ /(\d+)\.(\d+)/); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $logger = get_logger(); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub load { |
17
|
24
|
|
|
24
|
0
|
64
|
my $self = shift; |
18
|
24
|
|
|
|
|
57
|
my $class = ref $self; |
19
|
24
|
|
|
|
|
387
|
$logger->info( "Calling default method load() for ($class)" ); |
20
|
24
|
|
|
|
|
438
|
return $class; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub OP { |
24
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
25
|
0
|
|
|
|
|
0
|
my $class = ref $self; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
$self->{_m}{OP}->exception->throw("In ($class): OP() must be implemented in plugin"); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Constructor for all plugins |
31
|
|
|
|
|
|
|
sub new { |
32
|
36
|
|
|
36
|
0
|
184
|
my ( $pkg, $type, $OP, @params ) = @_; |
33
|
36
|
|
|
|
|
1193
|
my $class = $pkg->get_factory_class( $type ); |
34
|
36
|
|
|
|
|
684
|
my $self = bless( { _m => { OP => $OP } }, $class ); |
35
|
36
|
|
|
|
|
241
|
$self->OP->state( $class, {} ); |
36
|
36
|
|
|
|
|
213
|
return $self->init( @params ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Retrieve state information for whatever plugin is calling us |
40
|
|
|
|
|
|
|
sub state { |
41
|
92
|
|
|
92
|
0
|
30916
|
my ( $self, $key, $value ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
92
|
|
|
|
|
174
|
my $plugin = ref $self; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#$plugin =~ m/OpenPlugin::(\w+)/; |
46
|
|
|
|
|
|
|
#$plugin = $1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Just a key passed in, return a single value |
49
|
92
|
100
|
100
|
|
|
1313
|
if( defined $key and not defined $value ) { |
|
|
100
|
66
|
|
|
|
|
50
|
5
|
|
|
|
|
40
|
$logger->info("Calling state() for [$plugin] with key [$key]."); |
51
|
|
|
|
|
|
|
|
52
|
5
|
|
|
|
|
65
|
return $self->OP->state->{ $plugin }{ $key }; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# We have a key and value, so assign the value to the key |
56
|
|
|
|
|
|
|
elsif( defined $key and defined $value ) { |
57
|
14
|
|
|
|
|
151
|
$logger->info("Calling state() for [$plugin] with key [$key] and ", |
58
|
|
|
|
|
|
|
"value [$value]."); |
59
|
|
|
|
|
|
|
|
60
|
14
|
|
|
|
|
802
|
return $self->OP->state->{ $plugin }{ $key } = $value; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# No key or value, return the entire state hash |
64
|
|
|
|
|
|
|
else { |
65
|
73
|
|
|
|
|
537
|
$logger->info("Calling state() for [$plugin] with no parameters."); |
66
|
|
|
|
|
|
|
|
67
|
73
|
|
|
|
|
828
|
return $self->OP->state->{ $plugin }; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub cleanup { |
73
|
0
|
|
|
0
|
0
|
|
my ( $self ) = @_; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
0
|
|
|
|
my $plugin = ref $self || $self; |
76
|
|
|
|
|
|
|
#$plugin =~ m/OpenPlugin::(\w+)/; |
77
|
|
|
|
|
|
|
#$plugin = $1; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return $self->OP->state->{ $plugin } = {}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
0
|
0
|
|
sub shutdown { return 1 } |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |