2 |
## $Id$ |
## $Id$ |
3 |
## ------------------------------------------------------------------------ |
## ------------------------------------------------------------------------ |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.16 2003/04/18 16:07:53 joko |
6 |
|
## just use logger if instantiation successed |
7 |
|
## |
8 |
|
## Revision 1.15 2003/02/20 20:19:13 joko |
9 |
|
## tried to get auto-disconnect working again - failed with that |
10 |
|
## |
11 |
|
## Revision 1.14 2003/02/09 05:12:28 joko |
12 |
|
## + quoting of strings used in sql-queries! |
13 |
|
## |
14 |
|
## Revision 1.13 2003/01/30 22:27:05 joko |
15 |
|
## + added new abstract methods |
16 |
|
## |
17 |
## Revision 1.12 2003/01/30 21:46:32 joko |
## Revision 1.12 2003/01/30 21:46:32 joko |
18 |
## + fixed behaviour of AUTOLOAD-method |
## + fixed behaviour of AUTOLOAD-method |
19 |
## |
## |
67 |
use Data::Dumper; |
use Data::Dumper; |
68 |
use Tie::SecureHash; |
use Tie::SecureHash; |
69 |
#use Data::Storage::Handler; |
#use Data::Storage::Handler; |
70 |
use Data::Transform::Deep qw( merge ); |
use Hash::Merge qw( merge ); |
71 |
|
|
72 |
|
#use Log::Dispatch::Config; |
73 |
|
#Log::Dispatch::Config->configure(); |
74 |
|
|
75 |
# get logger instance |
# get logger instance |
76 |
my $logger = Log::Dispatch::Config->instance; |
my $logger; |
77 |
|
eval('$logger = Log::Dispatch::Config->instance;'); |
78 |
|
|
79 |
#our $lock_info; |
#our $lock_info; |
80 |
|
|
83 |
my $class = ref($invocant) || $invocant; |
my $class = ref($invocant) || $invocant; |
84 |
|
|
85 |
# logging info about the actual handler called |
# logging info about the actual handler called |
86 |
$logger->debug( "$invocant->new( @_ )" ); |
$logger->debug( "$invocant->new( @_ )" ) if $logger; |
87 |
#$logger->debug( __PACKAGE__ . "->" . "new()" ); |
#$logger->debug( __PACKAGE__ . "->" . "new()" ); |
88 |
|
|
89 |
# V1 - arguments become properties automagically / normal perl mode blessing |
# V1 - arguments become properties automagically / normal perl mode blessing |
289 |
|
|
290 |
sub DESTROY { |
sub DESTROY { |
291 |
my $self = shift; |
my $self = shift; |
292 |
#if ($self->{COREHANDLE}) { |
|
293 |
if ($self->exists('_COREHANDLE')) { |
return; |
294 |
|
|
295 |
|
$logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->DESTROY" ); |
296 |
|
|
297 |
|
my $disconnectMethod = $self->{metainfo}->{disconnectMethod}; |
298 |
|
print "meth: ", $disconnectMethod, "\n"; |
299 |
|
|
300 |
|
#$disconnectMethod && $self->{_COREHANDLE} && ( $self->{_COREHANDLE}->$disconnectMethod() ); |
301 |
|
$self->{_COREHANDLE}->$disconnectMethod(); |
302 |
|
#$self->$disconnectMethod(); |
303 |
|
|
304 |
|
#my $core1 = $self->getCOREHANDLE() if $self->can('getCOREHANDLE'); |
305 |
|
#$core1->$disconnectMethod(); |
306 |
|
|
307 |
|
return; |
308 |
|
|
309 |
|
print "DESTROY-1", "\n"; |
310 |
|
#if ($self->{__COREHANDLE}) { |
311 |
|
#if ($self->exists('_COREHANDLE')) { |
312 |
|
|
313 |
|
# get corehandle instance from underlying handler |
314 |
|
my $core; |
315 |
|
$core = $self->getCOREHANDLE() if $self->can('getCOREHANDLE'); |
316 |
|
|
317 |
|
#if ($self->{STORAGEHANDLE}) { |
318 |
|
if ($core) { |
319 |
|
print "DESTROY-2", "\n"; |
320 |
$logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->DESTROY" ); |
$logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->DESTROY" ); |
321 |
|
|
322 |
my $disconnectMethod = $self->{metainfo}->{disconnectMethod}; |
my $disconnectMethod = $self->{metainfo}->{disconnectMethod}; |
343 |
sub existsChildNode { |
sub existsChildNode { |
344 |
my $self = shift; |
my $self = shift; |
345 |
my $nodename = shift; |
my $nodename = shift; |
346 |
#$nodename = 'TransactionRoutingTable'; |
|
347 |
$logger->debug( __PACKAGE__ . "->existsChildNode( nodename $nodename )" ); |
# TODO: don't use $self->{meta}->{childnodes} directly in here |
348 |
|
# get it returned from $self->getChildNodes()!!! |
349 |
|
|
350 |
|
$logger->debug( __PACKAGE__ . "->existsChildNode( nodename=$nodename )" ); |
351 |
$self->getChildNodes() unless $self->{meta}->{childnodes}; |
$self->getChildNodes() unless $self->{meta}->{childnodes}; |
352 |
my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}}); # TODO: use "/i" only on win32-systems! |
|
353 |
|
# quote this, it might contain meta characters which don't work in a regex |
354 |
|
$nodename = quotemeta($nodename); |
355 |
|
|
356 |
|
# trace |
357 |
|
#print Dumper($self->{meta}); |
358 |
|
#print "nodename: $nodename", "\n"; |
359 |
|
|
360 |
|
# FIXME: use "/i" only on win32-systems! |
361 |
|
my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}}); |
362 |
|
|
363 |
return $result; |
return $result; |
364 |
} |
} |
365 |
|
|
480 |
return; |
return; |
481 |
} |
} |
482 |
|
|
483 |
|
sub getDbName { |
484 |
|
my $self = shift; |
485 |
|
$self->_abstract_function('getDbName'); |
486 |
|
return; |
487 |
|
} |
488 |
|
|
489 |
|
sub testAvailability { |
490 |
|
my $self = shift; |
491 |
|
$self->_abstract_function('testAvailability'); |
492 |
|
return; |
493 |
|
} |
494 |
|
|
495 |
|
sub isConnected { |
496 |
|
my $self = shift; |
497 |
|
$self->_abstract_function('isConnected'); |
498 |
|
return; |
499 |
|
} |
500 |
|
|
501 |
|
sub testDsn { |
502 |
|
my $self = shift; |
503 |
|
$self->_abstract_function('testDsn'); |
504 |
|
return; |
505 |
|
} |
506 |
|
|
507 |
1; |
1; |