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 |
## |
## |
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; |
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; |
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 |
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 |
|
|
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 |
|
|
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'); |
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; |