| 3 |
# $Id$ |
# $Id$ |
| 4 |
# |
# |
| 5 |
# $Log$ |
# $Log$ |
| 6 |
|
# Revision 1.8 2003/02/18 19:19:47 joko |
| 7 |
|
# + modified locator handling |
| 8 |
|
# |
| 9 |
# Revision 1.7 2003/01/30 22:21:52 joko |
# Revision 1.7 2003/01/30 22:21:52 joko |
| 10 |
# + changed 'connect'-behaviour back to old state |
# + changed 'connect'-behaviour back to old state |
| 11 |
# + renamed log-output (now using 'initializing' instead of 'booting' - corresponding to 'initStorage') |
# + renamed log-output (now using 'initializing' instead of 'booting' - corresponding to 'initStorage') |
| 50 |
use Tie::IxHash; |
use Tie::IxHash; |
| 51 |
use Data::Dumper; |
use Data::Dumper; |
| 52 |
|
|
|
use Data::Transform::Deep qw( deep_copy ); |
|
| 53 |
use Data::Storage; |
use Data::Storage; |
| 54 |
#use Data::Storage::Locator; |
use Data::Storage::Locator; |
| 55 |
|
use Data::Transform::Deep qw( deep_copy ); |
| 56 |
|
use Data::Compare::Struct qw( isEmpty ); |
| 57 |
|
|
| 58 |
sub new { |
sub new { |
| 59 |
my $invocant = shift; |
my $invocant = shift; |
| 105 |
my $self = shift; |
my $self = shift; |
| 106 |
my $name = shift; |
my $name = shift; |
| 107 |
my $db_config = $self->{config}->{$name}; |
my $db_config = $self->{config}->{$name}; |
| 108 |
|
$db_config ||= {}; |
| 109 |
|
|
| 110 |
$logger->debug( __PACKAGE__ . "->initLocator( db_config $db_config )" ); |
$logger->debug( __PACKAGE__ . "->initLocator( name='$name' )" ); |
| 111 |
|
|
| 112 |
my $cfg_locator = {}; |
my $cfg_locator = {}; |
| 113 |
|
|
| 117 |
$cfg_locator->{$_} = $default->{$_}; |
$cfg_locator->{$_} = $default->{$_}; |
| 118 |
} |
} |
| 119 |
|
|
|
# name it |
|
|
$cfg_locator->{name} = $name; |
|
|
|
|
| 120 |
# merge in specific settings |
# merge in specific settings |
| 121 |
my $specific = deep_copy($db_config); |
my $specific = deep_copy($db_config); |
| 122 |
foreach (keys %$specific) { |
foreach (keys %$specific) { |
| 132 |
# HACK: set errorhandler if dbi settings are present |
# HACK: set errorhandler if dbi settings are present |
| 133 |
$cfg_locator->{dbi}->{HandleError} = \&_dbErrorHandler if $cfg_locator->{dbi}; |
$cfg_locator->{dbi}->{HandleError} = \&_dbErrorHandler if $cfg_locator->{dbi}; |
| 134 |
|
|
| 135 |
|
# trace |
| 136 |
|
#print "locator:", "\n"; |
| 137 |
|
#print Dumper($cfg_locator); |
| 138 |
|
|
| 139 |
|
# check locator metadata |
| 140 |
|
if (isEmpty($cfg_locator)) { |
| 141 |
|
$logger->warning( __PACKAGE__ . "->initLocator( name='$name' ): Metadata was empty. Please check configuration." ); |
| 142 |
|
return; |
| 143 |
|
} |
| 144 |
|
|
| 145 |
|
# name it |
| 146 |
|
$cfg_locator->{name} = $name; |
| 147 |
|
|
| 148 |
# create new locator object |
# create new locator object |
| 149 |
$self->{locator}->{$name} = Data::Storage::Locator->new( $cfg_locator ); |
$self->{locator}->{$name} = Data::Storage::Locator->new( $cfg_locator ); |
| 150 |
|
|