/[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.10 by joko, Sun Jan 19 02:31:51 2003 UTC revision 1.14 by joko, Sun Feb 9 05:12:28 2003 UTC
# Line 1  Line 1 
1  ##    --------------------------------------------------------------------------------  ##    ------------------------------------------------------------------------
2  ##    $Id$  ##    $Id$
3  ##    --------------------------------------------------------------------------------  ##    ------------------------------------------------------------------------
4  ##    $Log$  ##    $Log$
5    ##    Revision 1.14  2003/02/09 05:12:28  joko
6    ##    + quoting of strings used in sql-queries!
7    ##
8    ##    Revision 1.13  2003/01/30 22:27:05  joko
9    ##    + added new abstract methods
10    ##
11    ##    Revision 1.12  2003/01/30 21:46:32  joko
12    ##    + fixed behaviour of AUTOLOAD-method
13    ##
14    ##    Revision 1.11  2003/01/20 16:43:18  joko
15    ##    + better argument-property merging
16    ##    + debugging-output !!!
17    ##    + abstract-dummy 'sub createChildNode'
18    ##
19  ##    Revision 1.10  2003/01/19 02:31:51  joko  ##    Revision 1.10  2003/01/19 02:31:51  joko
20  ##    + fix to 'sub AUTOLOAD'  ##    + fix to 'sub AUTOLOAD'
21  ##  ##
# Line 33  Line 47 
47  ##  ##
48  ##    Revision 1.1  2002/10/10 03:44:07  cvsjoko  ##    Revision 1.1  2002/10/10 03:44:07  cvsjoko
49  ##    + new  ##    + new
50  ##    --------------------------------------------------------------------------------  ##    ------------------------------------------------------------------------
51    
52    
53  package Data::Storage::Handler::Abstract;  package Data::Storage::Handler::Abstract;
# Line 43  use warnings; Line 57  use warnings;
57    
58  use base qw( DesignPattern::Object );  use base qw( DesignPattern::Object );
59    
60    
61  use Data::Dumper;  use Data::Dumper;
62  use Tie::SecureHash;  use Tie::SecureHash;
63  #use Data::Storage::Handler;  #use Data::Storage::Handler;
64    use Data::Transform::Deep qw( merge );
65    
66    
67  # get logger instance  # get logger instance
68  my $logger = Log::Dispatch::Config->instance;  my $logger = Log::Dispatch::Config->instance;
# Line 95  sub new { Line 112  sub new {
112  #=cut  #=cut
113    
114    # merge passed-in arguments to constructor as properties into already blessed secure object    # merge passed-in arguments to constructor as properties into already blessed secure object
115        
116      # mungle arguments from array into hash - perl does the job  ;)      # mungle arguments from array into hash - perl does the job  ;)
117      my %args = @_;      #my %args = @_;
118          #my %args = ();
119    
120    #print Dumper(@_);
121    
122      # merge attributes one-by-one      # merge attributes one-by-one
123      # TODO: deep_copy? / merge_deep?      # TODO: deep_copy? / merge_deep?
124      foreach (keys %args) {      while (my $elemName = shift @_) {
125        #print "key: $_", "\n";        #print "elemName: $elemName", "\n";
126        $self->{$_} = $args{$_};        if (my $elemValue = shift @_) {
127            #print Dumper($elemValue);
128            #print "elemName=$elemName, elemValue=$elemValue", "\n";
129            $self->{$elemName} = $elemValue;
130          }
131          #$self->{$_} = $args{$_};
132          #$self->{$_} = $args{$_};
133      }      }
134        
135    # V3 - rolling our own security (just for {COREHANDLE} - nothing else)  -  nope, Tie::SecureHash works wonderful    # V3 - rolling our own security (just for {COREHANDLE} - nothing else)  -  nope, Tie::SecureHash works wonderful
# Line 193  sub AUTOLOAD { Line 219  sub AUTOLOAD {
219      $handlertype ||= '';      $handlertype ||= '';
220    
221      my $err_msg_core = __PACKAGE__ . "[$handlertype]" . ": " . "COREHANDLE is undefined while trying to execute method \"$methodname\"";      my $err_msg_core = __PACKAGE__ . "[$handlertype]" . ": " . "COREHANDLE is undefined while trying to execute method \"$methodname\"";
222  print $err_msg_core, "\n";  
223      if ($self->exists('lock_info') && !$self->{lock_info}->{log_lock}) {  #print $err_msg_core, "\n";
224    
225        #if ($self->exists('lock_info') && !$self->{lock_info}->{log_lock}) {
226        $logger->error( $err_msg_core );        $logger->error( $err_msg_core );
227      }      #}
228    
229      return;      return;
230        
231    }    }
232  #=cut  #=cut
233    
# Line 278  sub _typeCheck2 { Line 308  sub _typeCheck2 {
308    sub existsChildNode {    sub existsChildNode {
309      my $self = shift;      my $self = shift;
310      my $nodename = shift;      my $nodename = shift;
311      #$nodename = 'TransactionRoutingTable';  
312      $logger->debug( __PACKAGE__ . "->existsChildNode( nodename $nodename )" );      # TODO: don't use $self->{meta}->{childnodes} directly in here
313        # get it returned from $self->getChildNodes()!!!
314    
315        $logger->debug( __PACKAGE__ . "->existsChildNode( nodename=$nodename )" );
316      $self->getChildNodes() unless $self->{meta}->{childnodes};      $self->getChildNodes() unless $self->{meta}->{childnodes};
317      my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}});     # TODO: use "/i" only on win32-systems!  
318        # quote this, it might contain meta characters which don't work in a regex
319          $nodename = quotemeta($nodename);
320    
321        # trace
322          #print Dumper($self->{meta});
323          #print "nodename: $nodename", "\n";
324        
325        # FIXME: use "/i" only on win32-systems!
326        my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}});
327        
328      return $result;      return $result;
329    }    }
330    
# Line 316  sub _typeCheck2 { Line 359  sub _typeCheck2 {
359      $self->_abstract_function('sendCommand');      $self->_abstract_function('sendCommand');
360    }    }
361    
362      sub createChildNode {
363        my $self = shift;
364        $self->_abstract_function('createChildNode');
365      }
366    
367    sub existsChildNode_tmp {    sub existsChildNode_tmp {
368      my $self = shift;      my $self = shift;
369      $self->_abstract_function('existsChildNode');      $self->_abstract_function('existsChildNode');
# Line 397  sub _typeCheck2 { Line 445  sub _typeCheck2 {
445      return;      return;
446    }    }
447    
448      sub getDbName {
449        my $self = shift;
450        $self->_abstract_function('getDbName');
451        return;
452      }
453    
454      sub testAvailability {
455        my $self = shift;
456        $self->_abstract_function('testAvailability');
457        return;
458      }
459    
460      sub isConnected {
461        my $self = shift;
462        $self->_abstract_function('isConnected');
463        return;
464      }
465    
466      sub testDsn {
467        my $self = shift;
468        $self->_abstract_function('testDsn');
469        return;
470      }
471    
472  1;  1;

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.14

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