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