Navigation

 + + + 

Sleep/jIRCii Extensions - Classloader Bridge


Classloader Bridge for Sleep 2.1 Version 2008/6/9         Classloader Bridge for Sleep 2.0

This extension for SLEEP provides some useful functions which lets a user load classes from directories and jar/zip files that are not in the current classpath. For example:

import shuteye.Classloader from: classloader.jar;
use(^Classloader);

# add a jar file with database driver class
addClassPath('hsqldb.jar'); 
# HSQL Database Engine(http://sourceforge.net/projects/hsqldb)

addClassPath('slumber.jar'); 
# jdbc sleep bridge: see http://code.google.com/p/slumber/

# use JDBC class as sleep Bridge (implements sleep.interfaces.Loadable)
# like use in sleep but loads class thru classloader bridge
use(loadClass('no.printf.slumber.JDBC'));

# now are the db   functions available
$db = dbConnect('org.hsqldb.jdbcDriver', 'jdbc:hsqldb:<dbname>', 
                  '<user>', '<password>');
# The JDBC bridge can load the driver class since the database jar 
# and the JDBC jar are managed by the same classloader

Download Version 2008/6/9


Functions Reference

$ addClassPath( $path )

returns true(1) if path is a valid directory of jar/zip file else false(0)

Adds a directory or jar/zip file to the ClassLoader, there is only one ClassLoader per script which could be responsible for an arbitrary number of jar/zip files and directories.

$ loadClass( $classname )

returns a $class_ref on success else $empty

$classname has to be a fully-qualified java classname.

useClass( $loadable_class_ref )

like use in SLEEP but takes a $class_ref as parameter which was prevously loaded thru loadClass() function. This function instantiates the Loadable like use

Example:

    $loadable_class = loadClass('ext.sleep.LoadableImpl');
    useClass( $loadable_class );


Internally the stuff from $loadable is added to the script's enviroment.


useLoadable( $loadable_instance )

like use in SLEEP but takes a $obj_ref of a sleep.interfaces.Loadable implementation

Example:

    $loadable_class = loadClass('ext.sleep.LoadableImpl');
    $loadable = [$loadable_class newInstance];
    useLoadable( $loadable );


Internally the stuff from $loadable is added to the script's enviroment.


addSysClassPath( $path )

returns true(1) if path is a valid directory of jar/zip file else false(0)

Adds a directory or jar/zip file to the SystemClassLoader.


addLibraryPath( $libpath ) [ or: addBinaryPath( $libpath ) ]

adds $libpath to java.library.path
where $libpath is a directory name or a file name, in case of file name the parent directory is taken.


loadLibrary( $libname )

loads native library $libname
returns true(1) on success else false(0)


Usage

     import shuteye.Classloader from: '[path/to/]classloader.jar';
     use(^Classloader);


Classloader Bridge for Sleep 2.0 Version 2006/2/20         Classloader Bridge for Sleep 2.1

This extension for SLEEP provides some useful functions which lets a user load classes from directories and jar/zip files that are not in the current classpath. For example:

use('classloader.jar', 'org.ululatus.sleep.bridges.ClassloaderBridge');

# add a jar file with database driver class
addClassPath('hsqldb.jar'); 
# HSQL Database Engine(http://sourceforge.net/projects/hsqldb)

addClassPath('JDBC.jar'); 
# jdbc sleep bridge: see http://jircii.hick.org/jirc/wwwboard.prl?MSGNO=592

# use JDBC class as sleep Bridge (implements sleep.interfaces.Loadable)
# like use in sleep but loads class thru classloader bridge
useClass('JDBC');

# now are the db   functions available
$db = dbConnect('org.hsqldb.jdbcDriver', 'jdbc:hsqldb:<dbname>', 
                  '<user>', '<password>');
# The JDBC bridge can load the driver class since the database jar 
# and the JDBC jar are managed by the same classloader

Download Version 2006/2/20


Functions Reference

$ addClassPath( $path )

returns true(1) if path is a valid directory of jar/zip file else false(0)

Adds a directory or jar/zip file to the ClassLoader, there is only one ClassLoader per script which could be responsible for an arbitrary number of jar/zip files and directories.

$ loadClass( $classname )

returns a $class_ref on success else $empty

$classname has to be a fully-qualified java classname.

useClass( $loadable_class_ref )

like use in SLEEP but takes a $class_ref as parameter which was prevously loaded thru loadClass() function. This function instantiates the Loadable like use

Example:

    $loadable_class = loadClass('ext.sleep.LoadableImpl');
    useClass( $loadable_class );


Internally the stuff from $loadable is added to the script's enviroment.


useLoadable( $loadable_instance )

like use in SLEEP but takes a $obj_ref of a sleep.interfaces.Loadable implementation

Example:

    $loadable_class = loadClass('ext.sleep.LoadableImpl');
    $loadable = [$loadable_class newInstance];
    useLoadable( $loadable );


Internally the stuff from $loadable is added to the script's enviroment.


New in this release (Thanks Serge)


addSysClassPath( $path )

returns true(1) if path is a valid directory of jar/zip file else false(0)

Adds a directory or jar/zip file to the SystemClassLoader.


addLibraryPath( $libpath ) [ or: addBinaryPath( $libpath ) ]

adds $libpath to java.library.path
where $libpath is a directory name or a file name, in case of file name the parent directory is taken.


loadLibrary( $libname )

loads native library $libname
returns true(1) on success else false(0)


Usage

     use( '[path/to/]classloader.jar', 'org.ululatus.sleep.bridges.ClassloaderBridge' );

                                                                                                                                                                                                                           

ululatus.org     Valid XHTML 1.0!      Valid CSS!      Last modified 14 Aug 2008 16:46