1 package Local::Multipath;
...
45 my %mpByType;
46
47 sub new {
48 my ($class, %opts) = @_;
49 return bless \%opts, $class;
50 }
51
52 sub factory {
53 my (%opts) = @_;
54 croak ("Missing parameters!") unless exists $opts{co};
55 my $type = _whichType;
56 my $module = "Local::Multipath::$type";
57 {
58 eval "use $module";
59 }
60 croak "Failed to load module $module: $@\n" if $@;
61 $mpByType{$type}->new (%opts);
62 }
63
64 sub REGISTER_TYPE {
65 my ($type) = @_;
66 my ($name) = $type =~ m/Multipath::(.*)/;
67 $mpByType{$name} = $type;
68 }
####
1 package Local::Multipath::DMMP;
2 use strict;
3 use warnings;
...
7
8 REGISTER_TYPE Local::Multipath::DMMP;
...
####
my $mp = Local::Multipath::factory (co => $conf);