The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

IOC::Registry - Registry singleton for the IOC Framework

SYNOPSIS

  use IOC::Registry;

  my $container = IOC::Container->new('database');
  my $other_container = IOC::Container->new('logging');
  # ... bunch of IOC::Container creation code omitted
  
  # create a registry singleton
  my $reg = IOC::Registry->new();
  $reg->registerContainer($container);
  $reg->registerContainer($other_container);
  
  # ... somewhere later in your program
  
  my $reg = IOC::Registry->instance(); # get the singleton
  
  # and try and find a service
  my $service = $reg->searchForService('laundry') || die "Could not find the logger service";
  
  my $database = $reg->getRootContainer('database');

DESCRIPTION

This is a singleton object which is meant to be used as a global registry for all your IoC needs.

METHODS

new

Creates a new singleton instance of the Registry, the same singleton will be returned each time new is called after the first one.

registerContainer ($container)
getRootContainer ($name)
searchForContainer ($name)
searchForService ($name)

TO DO

Work on the documentation

BUGS

None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it.

CODE COVERAGE

I use Devel::Cover to test the code coverage of my tests, see the CODE COVERAGE section of IOC for more information.

SEE ALSO

Class::StrongSingleton

This is a subclass of Class::StrongSingleton, if you want to know about how the singleton-ness is handled, check there.

AUTHOR

stevan little, <stevan@iinteractive.com>

COPYRIGHT AND LICENSE

Copyright 2004 by Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.