2 |
## $Id$ |
## $Id$ |
3 |
## ------------------------------------------------------------------------ |
## ------------------------------------------------------------------------ |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.5 2003/07/01 18:11:15 joko |
6 |
|
## fixed: renamed package name according to new filenames |
7 |
|
## |
8 |
|
## Revision 1.4 2003/06/06 03:24:14 joko |
9 |
|
## + SymbolAliasing |
10 |
|
## |
11 |
|
## Revision 1.3 2003/04/04 17:28:59 joko |
12 |
|
## minor update: commented hardcoded stuff |
13 |
|
## |
14 |
## Revision 1.2 2003/04/04 17:28:15 joko |
## Revision 1.2 2003/04/04 17:28:15 joko |
15 |
## starting the *session* server/service from here |
## starting the *session* server/service from here |
16 |
## |
## |
20 |
## ------------------------------------------------------------------------ |
## ------------------------------------------------------------------------ |
21 |
|
|
22 |
|
|
23 |
package OEF::Component::WebService; |
package OEF::Component::WebService::RpcXml; |
24 |
|
|
25 |
use strict; |
use strict; |
26 |
use warnings; |
use warnings; |
32 |
use RPC::XML; |
use RPC::XML; |
33 |
use RPC::XML::SessionServer; |
use RPC::XML::SessionServer; |
34 |
use RPC::XML::Procedure; |
use RPC::XML::Procedure; |
35 |
|
use Data::Mungle::Code::Symbol qw( alias_simple ); |
36 |
|
|
37 |
# this is a global counter for giving unnamed webservices a unique id |
# this is a global counter for giving unnamed webservices a unique id |
38 |
our $instance_counter; |
our $instance_counter; |
56 |
port => $self->{ws_port}, |
port => $self->{ws_port}, |
57 |
path => $self->{ws_path} || 'WebService' . $instance_counter, |
path => $self->{ws_path} || 'WebService' . $instance_counter, |
58 |
auto_updates => 1, |
auto_updates => 1, |
59 |
|
|
60 |
|
# FIXME: this is hardcoded! |
61 |
authentication => { |
authentication => { |
62 |
type => 'plain', |
type => 'plain', |
63 |
user => 'hello', |
user => 'hello', |
66 |
); |
); |
67 |
|
|
68 |
# API |
# API |
69 |
# load api module |
|
70 |
|
# 1. load api module |
71 |
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}'."); |
72 |
# 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 ... |
73 |
#$api->build([qw( OEF::YAA::API::Jobs )]); |
#$api->build([qw( OEF::YAA::API::Jobs )]); |
74 |
$api->build($self->{api_submodules}); |
$api->build($self->{api_submodules}); |
75 |
# get it! |
|
76 |
|
# 2. query it for to-be-published methods ... |
77 |
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}'."); |
78 |
# ... 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 |
79 |
foreach my $proc (@{$procs}) { |
foreach my $proc (@{$procs}) { |
80 |
$self->{_daemon}->add_method($proc); |
$self->{_daemon}->add_method($proc); |
81 |
} |
} |
82 |
|
|
83 |
|
# 3. SymbolAliasing: query it for to-be-established symbols ... |
84 |
|
my $symbols; |
85 |
|
$symbols = $api->getSymbolMetadata() if $api->can("getSymbolMetadata"); |
86 |
|
# ... and vivify them each pointing to a reference. |
87 |
|
foreach my $symbol (@{$symbols}) { |
88 |
|
$symbol->{slot} = $self->{_daemon}; |
89 |
|
alias_simple($symbol); |
90 |
|
} |
91 |
|
|
92 |
# run service / activate instance |
# run service / activate instance |
93 |
# Never returns... |
# Never returns... |