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::SERVICE::CONSTRUCTORINJECTION (3)

.ds Aq ’

NAME

IOC::Service::ConstructorInjection - An IOC Service object which uses Constructor Injection

CONTENTS

SYNOPSIS



  use IOC::Service::ConstructorInjection;
 
  # this will call :
  #   FileLogger->new()
  # when it creates a logger
  # component instance
  my $service = IOC::Service::ConstructorInjection->new(logger => (FileLogger, new, []));

  # this will call :
  #    FileLogger->new($container->get(log_file), "some other argument")
  # when it creates a logger
  # component instance
  my $service = IOC::Service::ConstructorInjection->new(logger => (
                    FileLogger, new, [
                        IOC::Service::ConstructorInjection->ComponentParameter(log_file),
                        "some other argument"
                    ]));

  # this will call :
  #    FileLogger->new($container->find(/files/log_file), "some other argument")
  # when it creates a logger
  # component instance
  my $service = IOC::Service::ConstructorInjection->new(logger => (
                    FileLogger, new, [
                        IOC::Service::ConstructorInjection->ComponentParameter(/files/log_file),
                        "some other argument"
                    ]));



DESCRIPTION

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



             +--------------+
             | IOC::Service |
             +--------------+
                    |
                    ^
                    |
   +------------------------------------+
   | IOC::Service::ConstructorInjection |
   +------------------------------------+



METHODS

<B>new ($name, B>$component_class<B>, B>$component_constructor<B>, B>$parameters<B>)B> Creates a service with a $name, and uses the $component_class and $component_constructor string arguments to initialize the service on demand.

If the $component_class and $component_constructor arguments are not defined, an <B>IOC::InsufficientArgumentsB> exception will be thrown.

Upon request of the component managed by this service, an attempt will be made to load the $component_class. If that loading fails, an <B>IOC::ClassLoadingErrorB> exception will be thrown with the details of the underlying error. If the $component_class loads successfully, then it will be inspected for an available $component_constructor method. If the $component_constructor method is not found, an <B>IOC::ConstructorNotFoundB> exception will be thrown. If the $component_constructor method is found, then it will be called with the values found in $paramaters. However, before $paramaters are passed, they are first looped through looking for any ComponentParameters (these are place holders created with the class method ComponentParameter (see below)), and replaces these items with the proper values extracted from the IOC framework.

CLASS METHODS

<B>ComponentParameter ($component_name)B> Given a $component_name this will create a place holder suitable for placement in the $parameters argument of the new method. The $component_name must be a valid service name available to the service either through get or find.

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

Constructor Injection in the PicoContainer is explained on this page <http://docs.codehaus.org/display/PICO/Constructor+Injection>

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::SERVICE::CONSTRUCTORINJECTION (3) 2007-04-22

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