![]() |
![]()
| ![]() |
![]()
NAMEIOC::Config::XML - An XML Config reader for IOC SYNOPSISuse IOC::Config::XML; my $conf_reader = IOC::Config::XML->new(); $conf_reader->read('my_ioc_conf.xml'); # now the IOC::Registry singleton is all configured DESCRIPTIONThis is the second version of an XML configuration module for IOC. The first version used XML::Simple, which is a great module, but not really the best fit for this. I have now ported this over to use XML::SAX, which is much more flexible solution (not to mention a really nice way to interact with XML). I consider this module to be late-BETA quality (it is currently in production and working without issue for a month now). SAMPLE XML CONFE<lt>RegistryE<gt> E<lt>Container name='Application'E<gt> E<lt>Container name='Database'E<gt> E<lt>Service name='dsn' type='Literal'E<gt>dbi:Mock:E<lt>/ServiceE<gt> E<lt>Service name='username' type='Literal'E<gt>userE<lt>/ServiceE<gt> E<lt>Service name='password' type='Literal'E<gt>****E<lt>/ServiceE<gt> E<lt>Service name='connection' type='ConstructorInjection' prototype='true'E<gt> E<lt>Class name='DBI' constructor='connect' /E<gt> E<lt>Parameter type='component'E<gt>dsnE<lt>/ParameterE<gt> E<lt>Parameter type='component'E<gt>usernameE<lt>/ParameterE<gt> E<lt>Parameter type='component'E<gt>passwordE<lt>/ParameterE<gt> E<lt>/ServiceE<gt> E<lt>/ContainerE<gt> E<lt>Service name='logger_table' type='Literal'E<gt>tbl_logE<lt>/ServiceE<gt> E<lt>Service name='logger' type='SetterInjection'E<gt> E<lt>Class name='My::DB::Logger' constructor='new' /E<gt> E<lt>Setter name='setDBIConnection'E<gt>/Database/connectionE<lt>/SetterE<gt> E<lt>Setter name='setDBTableName'E<gt>logger_tableE<lt>/SetterE<gt> E<lt>/ServiceE<gt> E<lt>Service name='template_factory' type='ConstructorInjection'E<gt> E<lt>Class name='My::Template::Factory' constructor='new' /E<gt> E<lt>Parameter type='perl'E<gt>[ path =E<gt> 'test' ]E<lt>/ParameterE<gt> E<lt>/ServiceE<gt> E<lt>Service name='app'E<gt> E<lt>![CDATA[ my $c = shift; my $app = My::Application-E<gt>new(); $app-E<gt>setLogger($c-E<gt>get('logger')); return $app; ]]E<gt> E<lt>/ServiceE<gt> E<lt>/ContainerE<gt> E<lt>/RegistryE<gt> METHODS
TO DO
BUGSNone that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it. CODE COVERAGEI use Devel::Cover to test the code coverage of my tests, see the CODE COVERAGE section of IOC for more information. SEE ALSOAUTHORstevan little, <stevan@iinteractive.com> COPYRIGHT AND LICENSECopyright 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.
|