1 package NCIP::Configuration;
3 #===============================================================================
5 # FILE: Configuration.pm
12 # AUTHOR: Chris Cormack (rangi), chrisc@catalyst.net.nz
13 # ORGANIZATION: Koha Development Team
15 # CREATED: 28/08/13 10:16:55
17 #===============================================================================
25 use NCIP::Configuration;
26 my $config = NCIP::Configuration->new($config_dir);
32 use NCIP::Configuration::Service;
33 use base qw(Config::Merge);
37 my $self = $class->SUPER::new(@_);
40 # we might have a few services set them up safely
41 if ( ref( $self->('NCIP.listeners.service') ) eq 'ARRAY' ) {
42 @services = $self->('NCIP.listeners.service');
45 @services = ( $self->('NCIP.listeners')->{'service'} );
48 foreach my $service (@services) {
49 my $serv_object = NCIP::Configuration::Service->new($service);
50 $listeners{ lc $service->{'port'} } = $serv_object;
52 $self->{'listeners'} = \%listeners;
57 my ( $self, $sockaddr, $port, $proto ) = @_;
59 foreach my $addr ( '', '*:', "$sockaddr:" ) {
60 $portstr = sprintf( "%s%s/%s", $addr, $port, lc $proto );
62 # Sys::Syslog::syslog( "LOG_DEBUG",
63 # "Configuration::find_service: Trying $portstr" );
64 # print "Configuration::find_service: Trying $portstr";
65 last if ( exists( ( $self->{listeners} )->{$portstr} ) );
67 return $self->{listeners}->{$portstr};