2 |
## $Id$ |
## $Id$ |
3 |
## ------------------------------------------------------------------------ |
## ------------------------------------------------------------------------ |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.6 2003/07/02 11:00:40 jonen |
6 |
|
## fixed: die now if http-port is used by other app |
7 |
|
## |
8 |
|
## Revision 1.5 2003/07/01 18:11:15 joko |
9 |
|
## fixed: renamed package name according to new filenames |
10 |
|
## |
11 |
|
## Revision 1.4 2003/06/06 03:24:14 joko |
12 |
|
## + SymbolAliasing |
13 |
|
## |
14 |
|
## Revision 1.3 2003/04/04 17:28:59 joko |
15 |
|
## minor update: commented hardcoded stuff |
16 |
|
## |
17 |
## Revision 1.2 2003/04/04 17:28:15 joko |
## Revision 1.2 2003/04/04 17:28:15 joko |
18 |
## starting the *session* server/service from here |
## starting the *session* server/service from here |
19 |
## |
## |
23 |
## ------------------------------------------------------------------------ |
## ------------------------------------------------------------------------ |
24 |
|
|
25 |
|
|
26 |
package OEF::Component::WebService; |
package OEF::Component::WebService::RpcXml; |
27 |
|
|
28 |
use strict; |
use strict; |
29 |
use warnings; |
use warnings; |
35 |
use RPC::XML; |
use RPC::XML; |
36 |
use RPC::XML::SessionServer; |
use RPC::XML::SessionServer; |
37 |
use RPC::XML::Procedure; |
use RPC::XML::Procedure; |
38 |
|
use Data::Mungle::Code::Symbol qw( alias_simple ); |
39 |
|
|
40 |
# this is a global counter for giving unnamed webservices a unique id |
# this is a global counter for giving unnamed webservices a unique id |
41 |
our $instance_counter; |
our $instance_counter; |
59 |
port => $self->{ws_port}, |
port => $self->{ws_port}, |
60 |
path => $self->{ws_path} || 'WebService' . $instance_counter, |
path => $self->{ws_path} || 'WebService' . $instance_counter, |
61 |
auto_updates => 1, |
auto_updates => 1, |
62 |
|
|
63 |
|
# FIXME: this is hardcoded! |
64 |
authentication => { |
authentication => { |
65 |
type => 'plain', |
type => 'plain', |
66 |
user => 'hello', |
user => 'hello', |
68 |
} |
} |
69 |
); |
); |
70 |
|
|
71 |
|
#print Dumper($self->{_daemon}) . "\n"; |
72 |
|
if(!ref($self->{_daemon})) { die($self->{_daemon} . ", maybe same daemon or other daemon on same port is already running??" . "\n"); } |
73 |
|
|
74 |
# API |
# API |
75 |
# load api module |
|
76 |
|
# 1. load api module |
77 |
my $api = DesignPattern::Object->fromPackage($self->{api_module}) or die("Could not load Api-Module '$self->{api_module}'."); |
my $api = DesignPattern::Object->fromPackage($self->{api_module}) or die("Could not load Api-Module '$self->{api_module}'."); |
78 |
# build complete bunch of api declaration metadata handling recursive plugin declaration and stuff ... |
# build complete bunch of api declaration metadata handling recursive plugin declaration and stuff ... |
79 |
#$api->build([qw( OEF::YAA::API::Jobs )]); |
#$api->build([qw( OEF::YAA::API::Jobs )]); |
80 |
$api->build($self->{api_submodules}); |
$api->build($self->{api_submodules}); |
81 |
# get it! |
|
82 |
|
# 2. query it for to-be-published methods ... |
83 |
my $procs = $api->getApiMetadata() or die("Could not load Api-Declarations from '$self->{api_module}'."); |
my $procs = $api->getApiMetadata() or die("Could not load Api-Declarations from '$self->{api_module}'."); |
84 |
# ... and propagate metadata for each method to daemon instance which is not yet running |
# ... and propagate metadata for each method to daemon instance which is not yet running |
85 |
foreach my $proc (@{$procs}) { |
foreach my $proc (@{$procs}) { |
86 |
$self->{_daemon}->add_method($proc); |
$self->{_daemon}->add_method($proc); |
87 |
} |
} |
88 |
|
|
89 |
|
# 3. SymbolAliasing: query it for to-be-established symbols ... |
90 |
|
my $symbols; |
91 |
|
$symbols = $api->getSymbolMetadata() if $api->can("getSymbolMetadata"); |
92 |
|
# ... and vivify them each pointing to a reference. |
93 |
|
foreach my $symbol (@{$symbols}) { |
94 |
|
$symbol->{slot} = $self->{_daemon}; |
95 |
|
alias_simple($symbol); |
96 |
|
} |
97 |
|
|
98 |
# run service / activate instance |
# run service / activate instance |
99 |
# Never returns... |
# Never returns... |