1 |
#!/usr/bin/perl |
2 |
|
3 |
## -------------------------------------------------------------------------------- |
4 |
## $Id: daemon-api-admin.pl,v 1.3 2003/02/21 07:05:16 joko Exp $ |
5 |
## -------------------------------------------------------------------------------- |
6 |
## $Log: daemon-api-admin.pl,v $ |
7 |
## -------------------------------------------------------------------------------- |
8 |
|
9 |
|
10 |
package OEF::Component::WebService; |
11 |
|
12 |
use strict; |
13 |
use warnings; |
14 |
|
15 |
# this actually supplies the method 'new' for this package |
16 |
use base qw( DesignPattern::Object ); |
17 |
|
18 |
use Data::Dumper; |
19 |
use RPC::XML; |
20 |
use RPC::XML::Server; |
21 |
use RPC::XML::Procedure; |
22 |
|
23 |
sub start { |
24 |
|
25 |
my $self = shift; |
26 |
|
27 |
# notice |
28 |
print "Starting WebService listening on port $self->{port}, using main API from Package $self->{api_module}.", "\n"; |
29 |
|
30 |
# trace |
31 |
#print Dumper($self); |
32 |
#exit; |
33 |
|
34 |
# here goes the server instance |
35 |
$self->{_daemon} = RPC::XML::Server->new( |
36 |
port => $self->{port}, |
37 |
#path => 'RPCSERV', |
38 |
auto_updates => 1, |
39 |
); |
40 |
|
41 |
# API |
42 |
# load api module |
43 |
my $api = DesignPattern::Object->fromPackage($self->{api_module}) or die("Could not load Api-Module '$self->{api_module}'."); |
44 |
# build complete bunch of api declaration metadata handling recursive plugin declaration and stuff ... |
45 |
#$api->build([qw( OEF::YAA::API::Jobs )]); |
46 |
$api->build($self->{api_submodules}); |
47 |
# get it! |
48 |
my $procs = $api->getApiMetadata() or die("Could not load Api-Declarations from '$self->{api_module}'."); |
49 |
# ... and propagate metadata for each method to daemon instance which is not yet running |
50 |
foreach my $proc (@{$procs}) { |
51 |
$self->{_daemon}->add_method($proc); |
52 |
} |
53 |
|
54 |
# run service / activate instance |
55 |
# Never returns... |
56 |
$self->{_daemon}->server_loop; |
57 |
|
58 |
} |
59 |
|
60 |
1; |
61 |
__END__ |