From 63320537aaebc55a1f2125e88f07e461c0149622 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 7 May 2007 16:05:06 +0000 Subject: * moved instantiateClass() from OpenSLX::Utils to OpenSLX::Basics git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1023 95ad53e4-c205-0410-b2fa-d234c58c8868 --- lib/OpenSLX/Basics.pm | 24 ++++++++++++++++++++++++ lib/OpenSLX/Utils.pm | 24 +----------------------- 2 files changed, 25 insertions(+), 23 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3-55-g7522