NAME Class::Runtime - API for dynamic class loading/unloading/status DEPENDENCIES o Symbol o File::Spec INSTALLATION To install this module type the following: o perl Makefile.PL o make o make test o make install OVERVIEW Class for dynamically loading/unloading/stat on modules. Currently it is designed for loading a class local to the system at runtime. Future versions may include loading in a distributed environment. A specific search path can be associated with the object which will be 'unshifted' onto @INC before attempting to load the class and 'shifted' off after attempting to load. Also, a class can be checked whether it is loaded or not in the process. SYNOPSIS my $class = 'MyClass::MySubClass'; my $obj = Class::Runtime->new( class=> $class ); ## LOADING CLASS AT RUNTIME unless ( $cl->load ) { warn "Error in loading class\n"; warn "\n\n", $@, "\n\n" if DEBUG; } ## CHECKING FOR CLASS AVAILABILITY AT RUNTIME unless ( $cl->isLoaded ) { warn 'Class - ', $class, ' - is loaded', "\n"; } my $newPath; ## ADDING SEACH PATH TO OBJECT ## Multiple $newPath = $cl->addPath( path=> [ qw( /tmp/lib /tmp/lib2 ) ] ); ##OR Single $newPath = $cl->addPath( path=> '/tmp/lib' ); ## REMOVING SEARCH PATH FROM OBJECT ## Multiple $newPath = $cl->dropPath( path=> [ qw( /tmp/lib /tmp/lib2 ) ] ); ##OR Single $newPath = $cl->dropPath( path=> '/tmp/lib' ); ## GETTING PATH ASSOCIATED WITH OBJECT my @path = $cl->getPath; ## UNLOADING CLASS if ( $cl->isLoaded ) { $cl->unload or warn 'Unable to unload class - ', $class, "\n"; } METHODS new CONSTRUCTOR Creates new object and initializes member variables if passed in as arguments. Takes parameterized argument list. *Input* o class => name of class to dynamically load *Output* o Class::Runtime object getPath Method used to retrieve path associated with this object *Input* o None *Output* o array of paths o integer 0 if no paths exist addPath Method used to add path to object path list to search from *Input* o path => As a single string or as a reference to an array *Output* o array of paths o undef if error dropPath Method used to remove path from object search path *Input* o path=> As a single string or as a reference to an array *Output* o array of paths o undef if error isLoaded Method used to check whether given class is loaded. *Input* o None *Output* o 1 if loaded o 0 if not loaded load Method used to load library/class. If a path has been associated with this object it will be 'unshifted' onto the global @INC array. Immediately after the attempted load the paths 'unshifted' onto the @INC array will be 'spliced' out. This is done so as to prevent any wrongful modification of @INC since the loading library may modify @INC or perhaps some other code. *Input* o None *Output* o 1 on successful load o undef if error (setting $@) unload Method used to unload class/library *Input* o None *Output* o 1 on successful unload o undef if error invoke Method used to load class/library and call specific method with that library. *Input* o method => method name o argument => reference to array of arguments to pass to method call *Output* o value of returned method call o undef if error HISTORY o 2002/02/14 Created SUPPORT AND SUGGESTIONS Currently you can contact the author at the email address listed below. AUTHOR 1 Stathy G. Touloumis COPYRIGHT AND LICENCE Copyright (C) 2002 Stathy G. Touloumis This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.