资源说明:An object factory
# NAME Object::Stock - An object factory # SYNOPSIS # singleton object of LWP::UserAgent use Object::Stock; my $stock = Object::Stock->new( builder => sub { LWP::UserAgent->new( @_ ) }, ); my $obj_x = $stock->get( agent => 'MyAgent/1.0' ); my $obj_y = $stock->get( agent => 'KoolAgent/0.3' ); print $obj_x->agent."\n"; # MyAgent/1.0 print $obj_y->agent."\n"; # KoolAgent/0.3 $stock->is_stored( agent => 'MyAgent/1.0' ); # TRUE $stock->is_stored( agent => 'KoolAgent/0.3' ); # FALSE # some objects(LWP::UserAgent) in Object::Stock use Object::Stock; my $stock = Object::Stock->new( builder => sub { LWP::UserAgent->new( @_ ) }, max_objects => 10, ); my $obj_x = $stock->get( agent => 'MyAgent/1.0' ); my $obj_y = $stock->get( agent => 'KoolAgent/0.3' ); print $obj_x->agent."\n"; # MyAgent/1.0 print $obj_y->agent."\n"; # KoolAgent/0.3 $stock->is_stored( agent => 'MyAgent/1.0' ); # TRUE $stock->is_stored( agent => 'KoolAgent/0.3' ); # TRUE!!! # DESCRIPTION Object::Stock is An object factory class. Object::Stock identifies objects by their instantiation attributes. # AUTHOR satoshi azuma# SEE ALSO # LICENSE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。