/[cvs]/nfo/perl/libs/Data/Storage/Handler/Abstract.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage/Handler/Abstract.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by joko, Thu Jan 30 21:46:32 2003 UTC revision 1.17 by joko, Tue May 13 07:58:49 2003 UTC
# Line 2  Line 2 
2  ##    $Id$  ##    $Id$
3  ##    ------------------------------------------------------------------------  ##    ------------------------------------------------------------------------
4  ##    $Log$  ##    $Log$
5    ##    Revision 1.17  2003/05/13 07:58:49  joko
6    ##    fix: die if methodname is empty
7    ##    fixes to log-string
8    ##
9    ##    Revision 1.16  2003/04/18 16:07:53  joko
10    ##    just use logger if instantiation successed
11    ##
12    ##    Revision 1.15  2003/02/20 20:19:13  joko
13    ##    tried to get auto-disconnect working again - failed with that
14    ##
15    ##    Revision 1.14  2003/02/09 05:12:28  joko
16    ##    + quoting of strings used in sql-queries!
17    ##
18    ##    Revision 1.13  2003/01/30 22:27:05  joko
19    ##    + added new abstract methods
20    ##
21  ##    Revision 1.12  2003/01/30 21:46:32  joko  ##    Revision 1.12  2003/01/30 21:46:32  joko
22  ##    + fixed behaviour of AUTOLOAD-method  ##    + fixed behaviour of AUTOLOAD-method
23  ##  ##
# Line 55  use base qw( DesignPattern::Object ); Line 71  use base qw( DesignPattern::Object );
71  use Data::Dumper;  use Data::Dumper;
72  use Tie::SecureHash;  use Tie::SecureHash;
73  #use Data::Storage::Handler;  #use Data::Storage::Handler;
74  use Data::Transform::Deep qw( merge );  use Hash::Merge qw( merge );
75    
76    #use Log::Dispatch::Config;
77    #Log::Dispatch::Config->configure();
78    
79  # get logger instance  # get logger instance
80  my $logger = Log::Dispatch::Config->instance;  my $logger;
81    eval('$logger = Log::Dispatch::Config->instance;');
82    
83  #our $lock_info;  #our $lock_info;
84    
# Line 68  sub new { Line 87  sub new {
87    my $class = ref($invocant) || $invocant;    my $class = ref($invocant) || $invocant;
88        
89    # logging info about the actual handler called    # logging info about the actual handler called
90      $logger->debug( "$invocant->new( @_ )" );      $logger->debug( "$invocant->new( @_ )" ) if $logger;
91      #$logger->debug( __PACKAGE__ . "->" . "new()" );      #$logger->debug( __PACKAGE__ . "->" . "new()" );
92    
93    # V1 - arguments become properties automagically / normal perl mode blessing    # V1 - arguments become properties automagically / normal perl mode blessing
# Line 225  sub AUTOLOAD { Line 244  sub AUTOLOAD {
244    }    }
245  #=cut  #=cut
246    
247      if (!$methodname) {
248        die("Methodname is not defined!");
249        return;
250      }
251    
252  #print "$methodname - 3", "\n";  #print "$methodname - 3", "\n";
253    
254    # try to dispatch method-call to Storage::Handler::*    # try to dispatch method-call to Storage::Handler::*
# Line 253  sub AUTOLOAD { Line 277  sub AUTOLOAD {
277      #$lock_AUTOLOAD = 1 if ($methodname eq 'insert');      #$lock_AUTOLOAD = 1 if ($methodname eq 'insert');
278      if (!$self->{lock_info}->{log_lock}) {      if (!$self->{lock_info}->{log_lock}) {
279        #print "method: $methodname", "\n";        #print "method: $methodname", "\n";
280        $logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->" . $methodname . "(@_)" );        my $type = $self->{metainfo}->{type};
281          $type ||= '';
282          # FIXME!
283          #$logger->debug( __PACKAGE__ . "[$type]" . "->" . $methodname . "(@_)" );
284          $logger->debug( __PACKAGE__ . "[$type]" . "->" . $methodname );
285      } else {      } else {
286        # AUTOLOAD - sub is locked to prevent deep recursions if (e.g.) db-inserts cause log-actions to same db itself        # AUTOLOAD - sub is locked to prevent deep recursions if (e.g.) db-inserts cause log-actions to same db itself
287      }      }
# Line 274  sub AUTOLOAD { Line 302  sub AUTOLOAD {
302    
303  sub DESTROY {  sub DESTROY {
304    my $self = shift;    my $self = shift;
305    #if ($self->{COREHANDLE}) {  
306    if ($self->exists('_COREHANDLE')) {  return;
307    
308      $logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->DESTROY" );
309    
310      my $disconnectMethod = $self->{metainfo}->{disconnectMethod};
311      print "meth: ", $disconnectMethod, "\n";
312      
313      #$disconnectMethod && $self->{_COREHANDLE} && ( $self->{_COREHANDLE}->$disconnectMethod() );
314      $self->{_COREHANDLE}->$disconnectMethod();
315      #$self->$disconnectMethod();
316    
317      #my $core1 = $self->getCOREHANDLE() if $self->can('getCOREHANDLE');
318      #$core1->$disconnectMethod();
319    
320    return;
321    
322      print "DESTROY-1", "\n";
323      #if ($self->{__COREHANDLE}) {
324      #if ($self->exists('_COREHANDLE')) {
325    
326      # get corehandle instance from underlying handler
327      my $core;
328      $core = $self->getCOREHANDLE() if $self->can('getCOREHANDLE');
329    
330      #if ($self->{STORAGEHANDLE}) {
331      if ($core) {
332        print "DESTROY-2", "\n";
333      $logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->DESTROY" );      $logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->DESTROY" );
334    
335      my $disconnectMethod = $self->{metainfo}->{disconnectMethod};      my $disconnectMethod = $self->{metainfo}->{disconnectMethod};
# Line 302  sub _typeCheck2 { Line 356  sub _typeCheck2 {
356    sub existsChildNode {    sub existsChildNode {
357      my $self = shift;      my $self = shift;
358      my $nodename = shift;      my $nodename = shift;
359      #$nodename = 'TransactionRoutingTable';  
360      $logger->debug( __PACKAGE__ . "->existsChildNode( nodename $nodename )" );      # TODO: don't use $self->{meta}->{childnodes} directly in here
361        # get it returned from $self->getChildNodes()!!!
362    
363        $logger->debug( __PACKAGE__ . "->existsChildNode( nodename=$nodename )" );
364      $self->getChildNodes() unless $self->{meta}->{childnodes};      $self->getChildNodes() unless $self->{meta}->{childnodes};
365      my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}});     # TODO: use "/i" only on win32-systems!  
366        # quote this, it might contain meta characters which don't work in a regex
367          $nodename = quotemeta($nodename);
368    
369        # trace
370          #print Dumper($self->{meta});
371          #print "nodename: $nodename", "\n";
372        
373        # FIXME: use "/i" only on win32-systems!
374        my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}});
375        
376      return $result;      return $result;
377    }    }
378    
# Line 426  sub _typeCheck2 { Line 493  sub _typeCheck2 {
493      return;      return;
494    }    }
495    
496      sub getDbName {
497        my $self = shift;
498        $self->_abstract_function('getDbName');
499        return;
500      }
501    
502      sub testAvailability {
503        my $self = shift;
504        $self->_abstract_function('testAvailability');
505        return;
506      }
507    
508      sub isConnected {
509        my $self = shift;
510        $self->_abstract_function('isConnected');
511        return;
512      }
513    
514      sub testDsn {
515        my $self = shift;
516        $self->_abstract_function('testDsn');
517        return;
518      }
519    
520  1;  1;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.17

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