GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  IOC::REGISTRY (3)

.ds Aq ’

NAME

IOC::Registry - Registry singleton for the IOC Framework

CONTENTS

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 laundry service";
 
  my $database = $reg->getRegisteredContainer(database);
 
  # get a list of container names
  my @container_names = $reg->getRegisteredContainerList();
 
  # and you can unregister containers too
  my $unregistered_container = $reg->unregisterContainer($container);



DESCRIPTION

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

METHODS

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

    Container Registration Methods

<B>registerContainer ($container)B> This method will add a $container to the registry, where it can be accessed by it’s name.
<B>unregisterContainer ($container|$name)B> This method accepts either the $container instance itself, or the $name of the container and removes said container from the registry.
<B>hasRegisteredContainer ($name)B> This will return true (1) if a container by that $name exists within the registry, and false (0) otherwise.
<B>getRegisteredContainer ($name)B> This will retrieve a registered container by $name from the registry. If $name is not defined, then an <B>IOC::InsufficientArgumentsB> exception will be thrown. If no container is found with $name, then an <B>IOC::ContainerNotFoundB> exception will be thrown.
<B>getRegisteredContainerListB> This will return the list of string names of all the registered containers.

    Aliasing Methods

<B>aliasService ($real_path, B>$alias_path<B>)B> This allows you to alias a path to a real service ($real_path) to be accessible from a different path ($alias_path). Basically, it is sometimes useful for the same service to be found at two different paths, especially when re-useing and combining IOC configurations for different frameworks.

The aliases set by this method will only affect the services retrieved through the locateService method. The aliases do not have any meaning outside of the IOC::Registry.

<B>NOTE:B> There is no easy way to validate that the $real_path is actually a valid path, so we make the assumption that you know what you are doing.

    Search Methods

<B>locateService ($path)B> Given a $path to a service, this will locate the service and return it. If $path is not specificed an <B>IOC::InsufficientArgumentsB> exception will be thrown.
<B>searchForService ($name)B> Given a $name for a service, this will attempt to locate the service within the entire heirarchy and return it. If the service is not found, then this method will return undef. If $name is not specificed an <B>IOC::InsufficientArgumentsB> exception will be thrown.
<B>locateContainer ($path)B> Given a $path to a container, this will locate the container and return it. If $path is not specificed an <B>IOC::InsufficientArgumentsB> exception will be thrown.
<B>searchForContainer ($name)B> Given a $name for a container, this will attempt to locate the container within the entire heirarchy and return it. If the container is not found, then this method will return undef. If $name is not specificed an <B>IOC::InsufficientArgumentsB> exception will be thrown.

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 <B>Devel::CoverB> 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-2007 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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 IOC::REGISTRY (3) 2007-04-22

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.