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
IOC::Service(3) User Contributed Perl Documentation IOC::Service(3)

IOC::Service - An IOC Service object

  use IOC::Service;
  
  my $container = IOC::Container->new();
  $container->register(IOC::Service::Literal->new('log_file' => "logfile.log"));
  $container->register(IOC::Service->new('logger' => sub { 
      my $c = shift; 
      return FileLogger->new($c->get('log_file'));
  }));
  $container->register(IOC::Service->new('application' => sub {
      my $c = shift; 
      my $app = Application->new();
      $app->logger($c->get('logger'));
      return $app;
  }));

  $container->get('application')->run();

In this IOC framework, the IOC::Service object holds instances of components to be managed.

   +--------------+                 +-------------------------+
   | IOC::Service |---(instance)--->| <Your Component/Object> |
   +--------------+                 +-------------------------+ 
          |
  (parent_container)
          |
          V
 +------------------+                  
 |  IOC::Container  |
 +------------------+

new ($name, $block)
Creates a service with a $name, and uses the $block argument to initialize the service on demand.
name
Returns the name of the service instance.
setContainer ($container)
Given a $container, which is an instance of IOC::Container or a subclass of it, this method will associate the service instance with that container object.
removeContainer
This will break the connection between a service and a container. This method is usually only called by the "unregister" method in IOC::Container.
instance
This method returns the component held by the service object, the is basically the value returned by the $block constructor argument.
deferred
This method returns an IOC::Service::Deferred wrapper which will lazy load the service. This is used for handling circular dependencies, and rarely used directly.

Work on the documentation

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

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

stevan little, <stevan@iinteractive.com>

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.

2007-04-22 perl v5.32.1

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

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