| 3 | #  $Id$ | #  $Id$ | 
| 4 | # | # | 
| 5 | #  $Log$ | #  $Log$ | 
| 6 |  | #  Revision 1.5  2002/12/01 22:19:33  joko | 
| 7 |  | #  + just disconnect if COREHANDLE exists | 
| 8 |  | # | 
| 9 |  | #  Revision 1.4  2002/12/01 04:45:38  joko | 
| 10 |  | #  + sub eraseAll | 
| 11 |  | #  + sub createDb | 
| 12 |  | # | 
| 13 |  | #  Revision 1.3  2002/11/29 04:58:20  joko | 
| 14 |  | #  + Storage::Result now uses the same dispatching mechanism like Storage::Handler | 
| 15 |  | # | 
| 16 | #  Revision 1.2  2002/10/17 00:08:07  joko | #  Revision 1.2  2002/10/17 00:08:07  joko | 
| 17 | #  + bugfixes regarding "deep recursion" stuff | #  + bugfixes regarding "deep recursion" stuff | 
| 18 | # | # | 
| 42 | $logger->debug( "$invocant->new( @_ )" ); | $logger->debug( "$invocant->new( @_ )" ); | 
| 43 | #$logger->debug( __PACKAGE__ . "->" . "new()" ); | #$logger->debug( __PACKAGE__ . "->" . "new()" ); | 
| 44 |  |  | 
| 45 |  | # arguments become properties | 
| 46 |  | my $self = { @_ }; | 
| 47 |  | # create object from blessed hash-reference | 
| 48 |  | bless $self, $class; | 
| 49 |  |  | 
| 50 | # handle meta data | # handle meta data | 
| 51 | my $metainfo = _getMetaInfo($class); | #my $metainfo = $self->getMetaInfo($class); | 
| 52 |  | my $metainfo = $self->getMetaInfo(); | 
| 53 | if (!$metainfo->{disconnectMethod}) { $metainfo->{disconnectMethod} = 'disconnect'; } | if (!$metainfo->{disconnectMethod}) { $metainfo->{disconnectMethod} = 'disconnect'; } | 
| 54 | # type? | # type? | 
| 55 | $invocant =~ s/Data::Storage::Handler:://; | $invocant =~ s/Data::Storage::Handler:://; | 
| 56 | $metainfo->{type} = $invocant; | $metainfo->{type} = $invocant; | 
| 57 |  |  | 
|  | # create object from blessed hash-reference |  | 
| 58 | # direct accessible (non-protected) properties         ( was: my $self = { }; ) | # direct accessible (non-protected) properties         ( was: my $self = { }; ) | 
| 59 | my $self = { metainfo => $metainfo, @_ }; | $self->{metainfo} = $metainfo; | 
|  | bless $self, $class; |  | 
| 60 |  |  | 
| 61 | return $self; | return $self; | 
| 62 | } | } | 
| 120 | } | } | 
| 121 | #$lock_AUTOLOAD = 0; | #$lock_AUTOLOAD = 0; | 
| 122 | #$logger->log( level => 'debug', message => __PACKAGE__ . "->" . $methodname . " (AUTOLOAD)" ); | #$logger->log( level => 'debug', message => __PACKAGE__ . "->" . $methodname . " (AUTOLOAD)" ); | 
| 123 |  |  | 
| 124 |  | # method calls doing it until here will get dispatched to the proper handler | 
| 125 | return $self->{COREHANDLE}->$methodname(@_); | return $self->{COREHANDLE}->$methodname(@_); | 
| 126 | } | } | 
| 127 |  |  | 
| 136 |  |  | 
| 137 | # call "disconnect" or alike on COREHANDLE | # call "disconnect" or alike on COREHANDLE | 
| 138 | # was: $self->{COREHANDLE}->disconnect(); | # was: $self->{COREHANDLE}->disconnect(); | 
| 139 | $disconnectMethod && ( $self->{COREHANDLE}->$disconnectMethod() ); | $disconnectMethod && $self->{COREHANDLE} && ( $self->{COREHANDLE}->$disconnectMethod() ); | 
| 140 |  |  | 
| 141 | undef $self->{COREHANDLE}; | undef $self->{COREHANDLE}; | 
| 142 | } | } | 
| 157 | eval("use Data::Storage::$type;"); | eval("use Data::Storage::$type;"); | 
| 158 | } | } | 
| 159 |  |  | 
|  | sub _getMetaInfo { |  | 
|  | my $packagename = shift; |  | 
|  | #return $self->$metainfo; |  | 
|  |  |  | 
|  | my $ns = '$' . $packagename . "::metainfo"; |  | 
|  | $logger->debug( __PACKAGE__ . "->" . "_getMetaInfo()" . "   " . "[$ns]" ); |  | 
|  | return eval($ns); |  | 
|  | } |  | 
|  |  |  | 
| 160 |  |  | 
| 161 | # ==================================================== | # ==================================================== | 
| 162 | #   PUBLIC METHODS | #   PUBLIC METHODS | 
| 163 | # ==================================================== | # ==================================================== | 
| 164 |  |  | 
| 165 | # TODO: abstract "abstract methods" to list/hash to be used in AUTOLOAD | sub existsChildNode { | 
|  | # e.g.: my @ABSTRACT_METHODS = (qw( connect sendCommand getChildNodes )); |  | 
|  |  |  | 
|  | sub connect { |  | 
|  |  |  | 
| 166 | my $self = shift; | my $self = shift; | 
| 167 | $self->_abstract_function('connect'); | my $nodename = shift; | 
| 168 | return; | #$nodename = 'TransactionRoutingTable'; | 
| 169 |  | $logger->debug( __PACKAGE__ . "->getChildNode( nodename $nodename )" ); | 
| 170 | $logger->debug( "\"connect\" has to be implemented by handler!" ); | $self->getChildNodes() unless $self->{meta}->{childnodes}; | 
| 171 | return; | my $result = grep(m/$nodename/i, @{$self->{meta}->{childnodes}});     # TODO: use "/i" only on win32-systems! | 
| 172 |  | return $result; | 
| 173 |  | } | 
| 174 |  |  | 
| 175 |  | sub connect_tmp { | 
| 176 |  |  | 
| 177 | #    my $self = shift; | #    my $self = shift; | 
| 178 | #    my $connectionString = shift; | #    my $connectionString = shift; | 
| 181 |  |  | 
| 182 | } | } | 
| 183 |  |  | 
| 184 |  |  | 
| 185 |  | # ==================================================== | 
| 186 |  | #   CONCRETE METHOD DUMMIES (croaking via "$logger" by calling "_abstract_function") | 
| 187 |  | # ==================================================== | 
| 188 |  |  | 
| 189 |  | # TODO: | 
| 190 |  | #   - abstract "abstract methods" to list/hash to be used in AUTOLOAD | 
| 191 |  | #      e.g.: my @ABSTRACT_METHODS = (qw( connect sendCommand getChildNodes )); | 
| 192 |  | #      use Class::XYZ (Construct) | 
| 193 |  | #   - build them via anonymous subs | 
| 194 |  | #   - introduce them via symbols | 
| 195 |  |  | 
| 196 | sub sendCommand { | sub sendCommand { | 
| 197 | my $self = shift; | my $self = shift; | 
| 198 | $self->_abstract_function('sendCommand'); | $self->_abstract_function('sendCommand'); | 
| 208 | $self->_abstract_function('configureCOREHANDLE'); | $self->_abstract_function('configureCOREHANDLE'); | 
| 209 | } | } | 
| 210 |  |  | 
|  | 1; |  | 
| 211 |  | sub getMetaInfo { | 
| 212 |  | my $self = shift; | 
| 213 |  | $self->_abstract_function('getMetaInfo'); | 
| 214 |  | return; | 
| 215 |  | } | 
| 216 |  |  | 
| 217 |  | sub getListUnfiltered { | 
| 218 |  | my $self = shift; | 
| 219 |  | $self->_abstract_function('getListUnfiltered'); | 
| 220 |  | return; | 
| 221 |  | } | 
| 222 |  |  | 
| 223 |  | sub getListFiltered { | 
| 224 |  | my $self = shift; | 
| 225 |  | $self->_abstract_function('getListFiltered'); | 
| 226 |  | return; | 
| 227 |  | } | 
| 228 |  |  | 
| 229 |  | sub sendQuery { | 
| 230 |  | my $self = shift; | 
| 231 |  | $self->_abstract_function('sendQuery'); | 
| 232 |  | return; | 
| 233 |  | } | 
| 234 |  |  | 
| 235 |  | sub connect { | 
| 236 |  | my $self = shift; | 
| 237 |  | $self->_abstract_function('connect'); | 
| 238 |  | return; | 
| 239 |  | } | 
| 240 |  |  | 
| 241 |  | sub testIntegrity { | 
| 242 |  | my $self = shift; | 
| 243 |  | $self->_abstract_function('testIntegrity'); | 
| 244 |  | return; | 
| 245 |  | } | 
| 246 |  |  | 
| 247 |  | sub quoteSql { | 
| 248 |  | my $self = shift; | 
| 249 |  | $self->_abstract_function('quoteSql'); | 
| 250 |  | return; | 
| 251 |  | } | 
| 252 |  |  | 
| 253 |  | sub eraseAll { | 
| 254 |  | my $self = shift; | 
| 255 |  | $self->_abstract_function('eraseAll'); | 
| 256 |  | return; | 
| 257 |  | } | 
| 258 |  |  | 
| 259 |  | sub createDb { | 
| 260 |  | my $self = shift; | 
| 261 |  | $self->_abstract_function('createDb'); | 
| 262 |  | return; | 
| 263 |  | } | 
| 264 |  |  | 
| 265 |  | 1; |