/[cvs]/nfo/perl/libs/DesignPattern/Bridge.pm
ViewVC logotype

Contents of /nfo/perl/libs/DesignPattern/Bridge.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Fri Dec 13 21:46:29 2002 UTC (21 years, 5 months ago) by joko
Branch: MAIN
+ initial check-in

1 ## --------------------------------------------------------------------------------
2 ## $Id$
3 ## --------------------------------------------------------------------------------
4 ## $Log$
5 ## --------------------------------------------------------------------------------
6
7
8 package DesignPattern::Bridge;
9
10 use strict;
11 use warnings;
12
13 use base qw( DesignPattern::Object );
14
15 ## ======== object inheritance ========
16
17 # TODO:
18 # - this is no inheritance and it doesn't have to be
19 # - implement this module as a bridge to its sub-modules
20 # - use the BridgePattern (http://c2.com/cgi/wiki?BridgePattern)
21 # Using patterns was already successfully done with Data::Storage::Handler
22 # by implementing the AdapterPattern (http://c2.com/cgi/wiki?AdapterPattern)
23 # with Perl's AUTOLOAD-mechanism
24 # - try to use Perl's "tie" command to implement this functionality here instead of using AUTOLOAD!
25 # - sub getChildNodes
26 # - sub run
27
28 # get logger instance
29 my $logger = Log::Dispatch::Config->instance;
30
31
32 ## ======== object constructor ========
33 sub new {
34 my $invocant = shift;
35 my $class = ref($invocant) || $invocant;
36 my @args = ();
37 @_ && (@args = @_);
38 $logger->debug( __PACKAGE__ . "->new(@args)" );
39 my $self = { @_ };
40 #print "class: $class", "\n";
41 bless $self, $class;
42 ##if (my $bizWorks = shift) {
43 ##$self->boot($bizWorks);
44 ##}
45
46 return $self;
47 }
48
49
50 ## ======== method overrider ========
51 sub AUTOLOAD2 {
52
53 my $self = shift;
54 our $AUTOLOAD;
55
56 ##print "AUTOLOAD\n";
57
58 my $method = $AUTOLOAD;
59 $method =~ s/^.*:://;
60
61 $logger->debug( __PACKAGE__ . "->" . $method . "(@_)" . " (AUTOLOAD called, not dispatched)" );
62
63 ## ->DESTROY would - if not declared - trigger an AUTOLOAD also
64 return if $method =~ m/::DESTROY$/;
65
66 ## if ($self->_filter_AUTOLOAD($method)) {
67 ## $self->_accessStorage();
68 ## $self->{STORAGEHANDLE}->$method(@_);
69 ## }
70
71 }
72
73 sub load {
74
75 my $self = shift;
76 my $self_classname = ref $self;
77
78 my $modulename_load = shift;
79
80 my $package = $self_classname . '::' . $modulename_load;
81 $logger->info( __PACKAGE__ . "->load: $package" );
82
83 # this is the module testing phase - use mixin doesn't seem to propagate errors by default
84 eval("use $package;");
85 if ($@) {
86 $logger->error( __PACKAGE__ . "->load: $@" );
87 }
88
89 #print "ref-1: ", ref $self, "\n";
90 #print "ref-2: ", ref $self::SUPER, "\n";
91
92 # V1:
93 #bless $self, $package;
94
95 # V2:
96 # switch into foreign package and mixin plugin-module
97 eval("package $self_classname; use mixin '$package';");
98 #eval("use mixin_all '$package';");
99 if ($@) {
100 $logger->error( __PACKAGE__ . "->load: $@" );
101 }
102
103 }
104
105 sub boot {
106 my $self = shift;
107 $self->_abstract_function('boot');
108 }
109
110 1;

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