3 See the NOTICE file distributed with
this work
for additional information
4 regarding copyright ownership.
6 Licensed under the Apache License, Version 2.0 (the
"License");
7 you may not use
this file except in compliance with the License.
8 You may obtain a copy of the License at
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an
"AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License
for the specific language governing permissions and
16 limitations under the License.
23 Please email comments or questions to the
public Ensembl
24 developers list at <http:
26 Questions may also be sent to the Ensembl help desk at
37 #Simple arounds logging proxy
41 my ($invoker, $package, $method) = @_;
44 warn
"Entering into ${package}::${method}";
45 my @capture = $self->$method(@args);
46 warn
"Exiting from ${package}::${method}";
55 This
class offers
Proxy objects similar to those found in Java's
56 C<java.lang.reflect.
Proxy> object. This class should be overriden and
57 then implement C<__resolver()>. The C<__resolver()> method returns a
58 subroutine to the intended action which the proxy object installs into
59 the calling class' scope.
61 All methods internal to the proxy are prefixed with a double underscore
62 to avoid corruption/intrusion into the normal public and private scope of
69 package Bio::EnsEMBL::Utils::Proxy;
80 Arg [1] : The
object to proxy
82 Description : Provides a
new instance of a proxy
91 my ($class, $proxy) = @_;
92 my $self = bless({}, ref($class)||$class);
93 $self->{__proxy} = $proxy;
100 Description : The proxy accessor
101 Returntype : Any the proxied
object
110 return $_[0]->{__proxy};
115 Args : Object type to test
116 Example : $obj->
isa(
'Bio::EnsEMBL::Utils::Proxy');
117 Description : Overriden to provide C<isa()> support
for proxies. Will
return
118 true if this object is assignable to the given type or the
120 Returntype : Boolean; performs same as a normal can
129 my ($self, $class) = @_;
130 return 1
if $self->SUPER::isa($class);
131 return 1
if $self->__proxy()->isa($class);
137 Args : Method name to test
138 Example : $obj->can(
'__proxy');
139 Description : Overriden to provide C<can()> support
for proxies. Will
return
140 true if this object implements the given method or the
142 Returntype : Code; performs same as a normal can
150 my ($self, $method) = @_;
151 my $super_can = $self->SUPER::can($method);
152 return $super_can
if $super_can;
153 my $proxy_can = $self->__proxy()->can($method);
154 return $proxy_can
if $proxy_can;
161 Description : Provided because of AutoLoad
178 Description : Performs calls to C<__resolver()> and installs the subroutine
179 into the current
package scope.
181 Exceptions : Thrown if C<__resolver()> could not return a subroutine
188 my ($self, @args) = @_;
189 my ($package_name, $method_name) = $AUTOLOAD =~ m/ (.*) :: (.*) /xms;
190 my $sub = $self->__resolver($package_name, $method_name, @args);
192 my $type = ref $self ?
'object' :
'class';
193 throw qq{Can
't locate $type method "$method_name" via package "$package_name". No subroutine was generated};
196 no strict 'refs
'; ## no critic ProhibitNoStrict
203 my ($self, $package_name, $method, @args) = @_;
204 #override to provide the subroutine to install
205 throw "Unimplemented __resolver() in $package_name. Please implement";