diff options
author | Oliver Tappe | 2007-05-07 18:05:06 +0200 |
---|---|---|
committer | Oliver Tappe | 2007-05-07 18:05:06 +0200 |
commit | 63320537aaebc55a1f2125e88f07e461c0149622 (patch) | |
tree | 34e23f9fde09167bc799fea72bfe1e4bb4a005de /lib/OpenSLX/Basics.pm | |
parent | * minor cleanup with respect to how slxldd is invoked (diff) | |
download | core-63320537aaebc55a1f2125e88f07e461c0149622.tar.gz core-63320537aaebc55a1f2125e88f07e461c0149622.tar.xz core-63320537aaebc55a1f2125e88f07e461c0149622.zip |
* moved instantiateClass() from OpenSLX::Utils to OpenSLX::Basics
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1023 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'lib/OpenSLX/Basics.pm')
-rw-r--r-- | lib/OpenSLX/Basics.pm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/OpenSLX/Basics.pm b/lib/OpenSLX/Basics.pm index 9cca7b8c..998e7982 100644 --- a/lib/OpenSLX/Basics.pm +++ b/lib/OpenSLX/Basics.pm @@ -25,6 +25,7 @@ $VERSION = 1.01; &_tr &trInit &warn &die &executeInSubprocess &slxsystem &vlog + &instantiateClass ); use vars qw(%openslxConfig %cmdlineConfig); @@ -360,4 +361,27 @@ sub die } } +# ------------------------------------------------------------------------------ +sub instantiateClass +{ + my $class = shift; + my $requestedVersion = shift; + + unless (eval "require $class") { + if ($! == 2) { + die _tr("Class <%s> not found!\n", $class); + } else { + die _tr("Unable to load class <%s> (%s)\n", $class, $@); + } + } + if (defined $requestedVersion) { + my $classVersion = $class->VERSION; + if ($classVersion < $requestedVersion) { + die _tr('Could not load class <%s> (Version <%s> required, but <%s> found)', + $class, $requestedVersion, $classVersion); + } + } + return $class->new; +} + 1; |