--- nfo/perl/libs/Data/Storage/Handler/Abstract.pm 2002/10/17 00:08:07 1.2 +++ nfo/perl/libs/Data/Storage/Handler/Abstract.pm 2002/11/29 04:58:20 1.3 @@ -1,8 +1,11 @@ ################################# # -# $Id: Abstract.pm,v 1.2 2002/10/17 00:08:07 joko Exp $ +# $Id: Abstract.pm,v 1.3 2002/11/29 04:58:20 joko Exp $ # # $Log: Abstract.pm,v $ +# Revision 1.3 2002/11/29 04:58:20 joko +# + Storage::Result now uses the same dispatching mechanism like Storage::Handler +# # Revision 1.2 2002/10/17 00:08:07 joko # + bugfixes regarding "deep recursion" stuff # @@ -32,17 +35,21 @@ $logger->debug( "$invocant->new( @_ )" ); #$logger->debug( __PACKAGE__ . "->" . "new()" ); + # arguments become properties + my $self = { @_ }; + # create object from blessed hash-reference + bless $self, $class; + # handle meta data - my $metainfo = _getMetaInfo($class); + #my $metainfo = $self->getMetaInfo($class); + my $metainfo = $self->getMetaInfo(); if (!$metainfo->{disconnectMethod}) { $metainfo->{disconnectMethod} = 'disconnect'; } # type? $invocant =~ s/Data::Storage::Handler:://; $metainfo->{type} = $invocant; - # create object from blessed hash-reference # direct accessible (non-protected) properties ( was: my $self = { }; ) - my $self = { metainfo => $metainfo, @_ }; - bless $self, $class; + $self->{metainfo} = $metainfo; return $self; } @@ -106,6 +113,8 @@ } #$lock_AUTOLOAD = 0; #$logger->log( level => 'debug', message => __PACKAGE__ . "->" . $methodname . " (AUTOLOAD)" ); + + # method calls doing it until here will get dispatched to the proper handler return $self->{COREHANDLE}->$methodname(@_); } @@ -141,31 +150,22 @@ eval("use Data::Storage::$type;"); } -sub _getMetaInfo { - my $packagename = shift; - #return $self->$metainfo; - - my $ns = '$' . $packagename . "::metainfo"; - $logger->debug( __PACKAGE__ . "->" . "_getMetaInfo()" . " " . "[$ns]" ); - return eval($ns); -} - # ==================================================== # PUBLIC METHODS # ==================================================== - # TODO: abstract "abstract methods" to list/hash to be used in AUTOLOAD - # e.g.: my @ABSTRACT_METHODS = (qw( connect sendCommand getChildNodes )); - - sub connect { - + sub existsChildNode { my $self = shift; - $self->_abstract_function('connect'); - return; - - $logger->debug( "\"connect\" has to be implemented by handler!" ); - return; + my $nodename = shift; + #$nodename = 'TransactionRoutingTable'; + $logger->debug( __PACKAGE__ . "->getChildNode( nodename $nodename )" ); + $self->getChildNodes() unless $self->{meta}->{childnodes}; + my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}}); # TODO: use "/i" only on win32-systems! + return $result; + } + + sub connect_tmp { # my $self = shift; # my $connectionString = shift; @@ -174,6 +174,17 @@ } + +# ==================================================== +# CONCRETE METHOD DUMMIES (croaking via "$logger" by calling "_abstract_function") +# ==================================================== + + # TODO: + # - abstract "abstract methods" to list/hash to be used in AUTOLOAD + # e.g.: my @ABSTRACT_METHODS = (qw( connect sendCommand getChildNodes )); + # - build them via anonymous subs + # - introduce them via symbols + sub sendCommand { my $self = shift; $self->_abstract_function('sendCommand'); @@ -189,4 +200,46 @@ $self->_abstract_function('configureCOREHANDLE'); } -1; \ No newline at end of file + sub getMetaInfo { + my $self = shift; + $self->_abstract_function('getMetaInfo'); + return; + } + + sub getListUnfiltered { + my $self = shift; + $self->_abstract_function('getListUnfiltered'); + return; + } + + sub getListFiltered { + my $self = shift; + $self->_abstract_function('getListFiltered'); + return; + } + + sub sendQuery { + my $self = shift; + $self->_abstract_function('sendQuery'); + return; + } + + sub connect { + my $self = shift; + $self->_abstract_function('connect'); + return; + } + + sub testIntegrity { + my $self = shift; + $self->_abstract_function('testIntegrity'); + return; + } + + sub quoteSql { + my $self = shift; + $self->_abstract_function('quoteSql'); + return; + } + +1;