Class::Runtime - API for dynamic class loading/unloading/status


NAME

Class::Runtime - API for dynamic class loading/unloading/status


DEPENDENCIES


INSTALLATION

To install this module type the following:


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;
 ## INVOKING METHOD 
 my $method = 'new';
 if ( $cl->isLoaded and $class->can( 'new' ) ) {
        my $obj = $cl->invoke( 'new', arg1=> 1, arg2=> 2 );
        $obj->method2;
 }
 ## NOT NECESSARY AS ONCE CLASS HAS BEEN LOADED CAN INVOKE DIRECTLY
 if ( $cl->isLoaded and $class->can( 'new' ) ) {
        my $obj = $class->new( arg1=> 1, arg2=> 2 );
        $obj->method2;
 }
 ## 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
Output

getPath

Method used to retrieve path associated with this object

Input
Output

addPath

Method used to add path to object path list to search from

Input
Output

dropPath

Method used to remove path from object search path

Input
Output

isLoaded

Method used to check whether given class is loaded.

Input
Output

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
Output

unload

Method used to unload class/library

Input
Output

invoke

Method used to load class/library and call specific method with that library.

Input
Output


HISTORY


SUPPORT AND SUGGESTIONS

Currently you can contact the author at the email address listed below.


AUTHOR


CREDITS


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.

 Class::Runtime - API for dynamic class loading/unloading/status