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

IOC::Proxy::Interfaces - A IOC::Proxy subclasss to proxy objects with a given interface

  use IOC::Proxy::Interfaces;
  
  my $proxy_server = IOC::Proxy->new({
                        interface => 'AnInterface',
                        # ... add other config values here
                    });
  
  $proxy_server->wrap($object);
  # our $object is now proxied, but only the 
  # methods which are part of the interface 
  # will work, all others will throw exceptions
  
  $object->method_in_interface(); # works as normal
  
  $object->method_not_in_interface(); # will thrown an exception

This is a subclass of IOC::Proxy which allows for the partial proxing of an object. It will only proxy the methods of a given interface, all other methods will throw a IOC::MethodNotFound exception. This could be used to (in a very weird way) emulate the concept of upcasting in Java, it is also somewhat like the idea of using interfaces with Dynamic Proxies in Java as well (see the article link in "SEE ALSO").

This proxy can be useful if you need to have an object strictly conform to a particular interface in a particular situation. The interface class is also pushed onto the proxies @ISA so that it will respond to "UNIVERSAL::isa($object, 'Interface')" correctly. Keep in mind that there is no need for the object being proxied to have the interface in it's @ISA prior to being proxied. The proxy is dynamic and only requires that the object conform to the interface when it is being "wrap"ed but the proxy object.

The only change to the IOC::Proxy API is to require an 'interface' key in the $config hash given to the object constructor. If that key is not present an IOC::InsufficientArguments exception will be thrown.

It should be noted that this module's definition of an interface is really just a package. There are no restrictions on it past that. So in fact it is possible for an interface to be a regular class with implemented methods and all, this proxy will just make sure your proxied object implements all the same methods and proxy them.

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.

Dynamic Proxy API in Java
This package is not really an implementation of this concept, but concepts found in this article served as inspiration for this package. It's an interesting read if nothing more.

<http://www.javaworld.com/javaworld/jw-11-2000/jw-1110-proxy.html>

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.