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 | |
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')
-rw-r--r-- | lib/OpenSLX/Basics.pm | 24 | ||||
-rw-r--r-- | lib/OpenSLX/Utils.pm | 24 |
2 files changed, 25 insertions, 23 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; diff --git a/lib/OpenSLX/Utils.pm b/lib/OpenSLX/Utils.pm index ef4c1cac..d86167a2 100644 --- a/lib/OpenSLX/Utils.pm +++ b/lib/OpenSLX/Utils.pm @@ -21,7 +21,7 @@ $VERSION = 1.01; @ISA = qw(Exporter); @EXPORT = qw( - ©File &fakeFile &linkFile &slurpFile &instantiateClass + ©File &fakeFile &linkFile &slurpFile ); ################################################################################ @@ -86,26 +86,4 @@ sub slurpFile return $text; } -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;
\ No newline at end of file |