cvs commit: qpsmtpd/lib/Qpsmtpd Plugin.pm
[email protected] (Robert Spier)
| Newsgroups | perl.cvs.qpsmtpd |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 04/09/07 22:14:10
Modified: lib/Qpsmtpd Plugin.pm
Log:
plugin wrapping:
replace wrap_plugin implementation with
isa_plugin inheritance based implementation
Revision Changes Path
1.12 +18 -29 qpsmtpd/lib/Qpsmtpd/Plugin.pm
Index: Plugin.pm
===================================================================
RCS file: /cvs/public/qpsmtpd/lib/Qpsmtpd/Plugin.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- Plugin.pm 7 Sep 2004 05:07:20 -0000 1.11
+++ Plugin.pm 8 Sep 2004 05:14:10 -0000 1.12
@@ -52,37 +52,26 @@
shift->qp->connection;
}
-sub wrap_plugin {
- my ($self, $plugin_file, @args) = @_;
-
- # Wrap all of the methods in an existing plugin so that functions
- # can easily be replaced. Yes, we could use something like
- # Hook::Lexwrap isntead, but since it's only 15 lines of code, might
- # as well do it ourself.
-
- # Static methods in plugins will probably not work right in this
- # scheme.
-
- # Load the new plugin under our namespace.
- my $newPackage = __PACKAGE__."::_wrap_";
- Qpsmtpd::_compile($self->plugin_name, $newPackage, $plugin_file)
- unless defined &{"${newPackage}::register"};
+# plugin inheritance:
+# usage:
+# sub register {
+# my $self = shift;
+# $self->isa_plugin("rhsbl");
+# $self->SUPER::register(@_);
+# }
+sub isa_plugin {
+ my ($self, $parent) = @_;
+ my ($currentPackage) = caller;
+ my $newPackage = $currentPackage."::_isa_";
+
+ return if defined &{"${newPackage}::register"};
+
+ Qpsmtpd::_compile($self->plugin_name . "_isa",
+ $newPackage,
+ "plugins/$parent"); # assumes Cwd is qpsmtpd root
no strict 'refs';
- my $currentPackage = ref $self;
- local *{${newPackage}."::register_hook"} = sub {
- if (defined &{ $currentPackage . "::$_[2]"}) {
- # We're wrapping this hook. Store the old value in $self-{_wrap_FUNC}
- $self->{"_wrap_".$_[2]} = \&{${newPackage}."::$_[2]"};
- } else {
- # We're not wrapping this hook. Alias it into our namespace.
- *{$currentPackage."::$_[2]"} = \&{${newPackage}."::$_[2]"};
- }
- $self->register_hook($_[1],$_[2]);
- };
-
- $self->{_wrapped_package} = $newPackage;
- $newPackage->register($self->{_qp},@args);
+ push @{"${currentPackage}::ISA"}, $newPackage;
}
1;