9 |
## ------------------------------------------------------------------------ |
## ------------------------------------------------------------------------ |
10 |
## |
## |
11 |
## $Log$ |
## $Log$ |
12 |
|
## Revision 1.19 2003/02/18 19:22:11 joko |
13 |
|
## + fixed logging |
14 |
|
## |
15 |
|
## Revision 1.18 2003/01/30 22:12:17 joko |
16 |
|
## - removed/refactored old code: ->Data::Storage::Handler::Tangram|DBI |
17 |
|
## |
18 |
## Revision 1.17 2003/01/30 21:42:22 joko |
## Revision 1.17 2003/01/30 21:42:22 joko |
19 |
## + minor update: renamed method |
## + minor update: renamed method |
20 |
## |
## |
114 |
|
|
115 |
my $arg_locator = shift; |
my $arg_locator = shift; |
116 |
my $arg_options = shift; |
my $arg_options = shift; |
117 |
|
#my @args = @_; |
118 |
|
#@args ||= (); |
119 |
|
|
120 |
if (!$arg_locator) { |
if (!$arg_locator) { |
121 |
$logger->critical( __PACKAGE__ . "->new: No locator passed in!" ); |
$logger->critical( __PACKAGE__ . "->new: No locator passed in!" ); |
122 |
return; |
return; |
123 |
} |
} |
124 |
|
|
125 |
|
#print Dumper($arg_locator); |
126 |
|
|
127 |
#my $self = { STORAGEHANDLE => undef, @_ }; |
#my $self = { STORAGEHANDLE => undef, @_ }; |
128 |
my $self = { STORAGEHANDLE => undef, locator => $arg_locator, options => $arg_options }; |
my $self = { STORAGEHANDLE => undef, locator => $arg_locator, options => $arg_options }; |
129 |
#$logger->debug( __PACKAGE__ . "[$self->{locator}->{type}]" . "->new(@_)" ); |
#$logger->debug( __PACKAGE__ . "[$self->{locator}->{type}]" . "->new(@_)" ); |
130 |
$logger->debug( __PACKAGE__ . "[$arg_locator->{type}]" . "->new(@_)" ); |
$logger->debug( __PACKAGE__ . "[$arg_locator->{type}]" . "->new()" ); |
131 |
return bless $self, $class; |
return bless $self, $class; |
132 |
} |
} |
133 |
|
|
191 |
} |
} |
192 |
|
|
193 |
|
|
|
sub normalizeArgs { |
|
|
my %args = @_; |
|
|
if (!$args{dsn} && $args{meta}{dsn}) { |
|
|
$args{dsn} = $args{meta}{dsn}; |
|
|
} |
|
|
my @result = %args; |
|
|
return @result; |
|
|
} |
|
|
|
|
194 |
sub _accessStorageHandle { |
sub _accessStorageHandle { |
195 |
my $self = shift; |
my $self = shift; |
196 |
# TODO: to some tracelevel! |
# TODO: to some tracelevel! |
298 |
$logger->remove($name); |
$logger->remove($name); |
299 |
} |
} |
300 |
|
|
|
=pod |
|
|
sub getDbName { |
|
|
my $self = shift; |
|
|
my $dsn = $self->{locator}->{dbi}->{dsn}; |
|
|
$dsn =~ m/database=(.+?);/; |
|
|
my $database_name = $1; |
|
|
return $database_name; |
|
|
} |
|
|
|
|
|
sub testAvailability { |
|
|
my $self = shift; |
|
|
my $status = $self->testDsn(); |
|
|
$self->{locator}->{status}->{available} = $status; |
|
|
return $status; |
|
|
} |
|
|
|
|
|
sub isConnected { |
|
|
my $self = shift; |
|
|
# TODO: REVIEW! |
|
|
return 1 if $self->{STORAGEHANDLE}; |
|
|
} |
|
|
|
|
|
sub testDsn { |
|
|
my $self = shift; |
|
|
my $dsn = $self->{locator}->{dbi}->{dsn}; |
|
|
my $result; |
|
|
if ( my $dbh = DBI->connect($dsn, '', '', { |
|
|
PrintError => 0, |
|
|
} ) ) { |
|
|
|
|
|
# TODO: REVIEW |
|
|
$dbh->disconnect(); |
|
|
|
|
|
return 1; |
|
|
} else { |
|
|
$logger->warning( __PACKAGE__ . "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr ); |
|
|
} |
|
|
} |
|
|
=cut |
|
301 |
|
|
302 |
1; |
1; |
303 |
__END__ |
__END__ |