| 2 |
## $Id$ |
## $Id$ |
| 3 |
## ------------------------------------------------------------------------ |
## ------------------------------------------------------------------------ |
| 4 |
## $Log$ |
## $Log$ |
| 5 |
|
## Revision 1.18 2003/06/06 03:40:57 joko |
| 6 |
|
## disabled autovivifying of arguments as attributes |
| 7 |
|
## |
| 8 |
|
## Revision 1.17 2003/05/13 07:58:49 joko |
| 9 |
|
## fix: die if methodname is empty |
| 10 |
|
## fixes to log-string |
| 11 |
|
## |
| 12 |
|
## Revision 1.16 2003/04/18 16:07:53 joko |
| 13 |
|
## just use logger if instantiation successed |
| 14 |
|
## |
| 15 |
|
## Revision 1.15 2003/02/20 20:19:13 joko |
| 16 |
|
## tried to get auto-disconnect working again - failed with that |
| 17 |
|
## |
| 18 |
|
## Revision 1.14 2003/02/09 05:12:28 joko |
| 19 |
|
## + quoting of strings used in sql-queries! |
| 20 |
|
## |
| 21 |
## Revision 1.13 2003/01/30 22:27:05 joko |
## Revision 1.13 2003/01/30 22:27:05 joko |
| 22 |
## + added new abstract methods |
## + added new abstract methods |
| 23 |
## |
## |
| 74 |
use Data::Dumper; |
use Data::Dumper; |
| 75 |
use Tie::SecureHash; |
use Tie::SecureHash; |
| 76 |
#use Data::Storage::Handler; |
#use Data::Storage::Handler; |
| 77 |
use Data::Transform::Deep qw( merge ); |
use Hash::Merge qw( merge ); |
| 78 |
|
|
| 79 |
|
#use Log::Dispatch::Config; |
| 80 |
|
#Log::Dispatch::Config->configure(); |
| 81 |
|
|
| 82 |
# get logger instance |
# get logger instance |
| 83 |
my $logger = Log::Dispatch::Config->instance; |
my $logger; |
| 84 |
|
eval('$logger = Log::Dispatch::Config->instance;'); |
| 85 |
|
|
| 86 |
#our $lock_info; |
#our $lock_info; |
| 87 |
|
|
| 90 |
my $class = ref($invocant) || $invocant; |
my $class = ref($invocant) || $invocant; |
| 91 |
|
|
| 92 |
# logging info about the actual handler called |
# logging info about the actual handler called |
| 93 |
$logger->debug( "$invocant->new( @_ )" ); |
$logger->debug( "$invocant->new( @_ )" ) if $logger; |
| 94 |
#$logger->debug( __PACKAGE__ . "->" . "new()" ); |
#$logger->debug( __PACKAGE__ . "->" . "new()" ); |
| 95 |
|
|
| 96 |
# V1 - arguments become properties automagically / normal perl mode blessing |
# V1 - arguments become properties automagically / normal perl mode blessing |
| 247 |
} |
} |
| 248 |
#=cut |
#=cut |
| 249 |
|
|
| 250 |
|
=pod |
| 251 |
|
if (!$methodname) { |
| 252 |
|
die("Methodname is not defined!"); |
| 253 |
|
return; |
| 254 |
|
} |
| 255 |
|
=cut |
| 256 |
|
|
| 257 |
#print "$methodname - 3", "\n"; |
#print "$methodname - 3", "\n"; |
| 258 |
|
|
| 259 |
# try to dispatch method-call to Storage::Handler::* |
# try to dispatch method-call to Storage::Handler::* |
| 282 |
#$lock_AUTOLOAD = 1 if ($methodname eq 'insert'); |
#$lock_AUTOLOAD = 1 if ($methodname eq 'insert'); |
| 283 |
if (!$self->{lock_info}->{log_lock}) { |
if (!$self->{lock_info}->{log_lock}) { |
| 284 |
#print "method: $methodname", "\n"; |
#print "method: $methodname", "\n"; |
| 285 |
$logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->" . $methodname . "(@_)" ); |
my $type = $self->{metainfo}->{type}; |
| 286 |
|
$type ||= ''; |
| 287 |
|
# FIXME! |
| 288 |
|
#$logger->debug( __PACKAGE__ . "[$type]" . "->" . $methodname . "(@_)" ); |
| 289 |
|
$logger->debug( __PACKAGE__ . "[$type]" . "->" . $methodname ); |
| 290 |
} else { |
} else { |
| 291 |
# 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 |
| 292 |
} |
} |
| 307 |
|
|
| 308 |
sub DESTROY { |
sub DESTROY { |
| 309 |
my $self = shift; |
my $self = shift; |
| 310 |
#if ($self->{COREHANDLE}) { |
|
| 311 |
if ($self->exists('_COREHANDLE')) { |
return; |
| 312 |
|
|
| 313 |
|
$logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->DESTROY" ); |
| 314 |
|
|
| 315 |
|
my $disconnectMethod = $self->{metainfo}->{disconnectMethod}; |
| 316 |
|
print "meth: ", $disconnectMethod, "\n"; |
| 317 |
|
|
| 318 |
|
#$disconnectMethod && $self->{_COREHANDLE} && ( $self->{_COREHANDLE}->$disconnectMethod() ); |
| 319 |
|
$self->{_COREHANDLE}->$disconnectMethod(); |
| 320 |
|
#$self->$disconnectMethod(); |
| 321 |
|
|
| 322 |
|
#my $core1 = $self->getCOREHANDLE() if $self->can('getCOREHANDLE'); |
| 323 |
|
#$core1->$disconnectMethod(); |
| 324 |
|
|
| 325 |
|
return; |
| 326 |
|
|
| 327 |
|
print "DESTROY-1", "\n"; |
| 328 |
|
#if ($self->{__COREHANDLE}) { |
| 329 |
|
#if ($self->exists('_COREHANDLE')) { |
| 330 |
|
|
| 331 |
|
# get corehandle instance from underlying handler |
| 332 |
|
my $core; |
| 333 |
|
$core = $self->getCOREHANDLE() if $self->can('getCOREHANDLE'); |
| 334 |
|
|
| 335 |
|
#if ($self->{STORAGEHANDLE}) { |
| 336 |
|
if ($core) { |
| 337 |
|
print "DESTROY-2", "\n"; |
| 338 |
$logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->DESTROY" ); |
$logger->debug( __PACKAGE__ . "[$self->{metainfo}->{type}]" . "->DESTROY" ); |
| 339 |
|
|
| 340 |
my $disconnectMethod = $self->{metainfo}->{disconnectMethod}; |
my $disconnectMethod = $self->{metainfo}->{disconnectMethod}; |
| 361 |
sub existsChildNode { |
sub existsChildNode { |
| 362 |
my $self = shift; |
my $self = shift; |
| 363 |
my $nodename = shift; |
my $nodename = shift; |
| 364 |
#$nodename = 'TransactionRoutingTable'; |
|
| 365 |
$logger->debug( __PACKAGE__ . "->existsChildNode( nodename $nodename )" ); |
# TODO: don't use $self->{meta}->{childnodes} directly in here |
| 366 |
|
# get it returned from $self->getChildNodes()!!! |
| 367 |
|
|
| 368 |
|
$logger->debug( __PACKAGE__ . "->existsChildNode( nodename=$nodename )" ); |
| 369 |
$self->getChildNodes() unless $self->{meta}->{childnodes}; |
$self->getChildNodes() unless $self->{meta}->{childnodes}; |
| 370 |
my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}}); # TODO: use "/i" only on win32-systems! |
|
| 371 |
|
# quote this, it might contain meta characters which don't work in a regex |
| 372 |
|
$nodename = quotemeta($nodename); |
| 373 |
|
|
| 374 |
|
# trace |
| 375 |
|
#print Dumper($self->{meta}); |
| 376 |
|
#print "nodename: $nodename", "\n"; |
| 377 |
|
|
| 378 |
|
# FIXME: use "/i" only on win32-systems! |
| 379 |
|
my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}}); |
| 380 |
|
|
| 381 |
return $result; |
return $result; |
| 382 |
} |
} |
| 383 |
|
|