/[cvs]/nfo/perl/libs/OEF/Component/WebService/RpcXml.pm
ViewVC logotype

Contents of /nfo/perl/libs/OEF/Component/WebService/RpcXml.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Fri Jun 6 03:24:14 2003 UTC (21 years, 1 month ago) by joko
Branch: MAIN
Changes since 1.3: +18 -3 lines
+ SymbolAliasing

1 ## ------------------------------------------------------------------------
2 ## $Id: WebService.pm,v 1.3 2003/04/04 17:28:59 joko Exp $
3 ## ------------------------------------------------------------------------
4 ## $Log: WebService.pm,v $
5 ## Revision 1.3 2003/04/04 17:28:59 joko
6 ## minor update: commented hardcoded stuff
7 ##
8 ## Revision 1.2 2003/04/04 17:28:15 joko
9 ## starting the *session* server/service from here
10 ##
11 ## Revision 1.1 2003/03/27 15:41:27 joko
12 ## initial commit, code from daemon-api-admin.pl
13 ##
14 ## ------------------------------------------------------------------------
15
16
17 package OEF::Component::WebService;
18
19 use strict;
20 use warnings;
21
22 # this actually supplies the method 'new' for this package
23 use base qw( DesignPattern::Object );
24
25 use Data::Dumper;
26 use RPC::XML;
27 use RPC::XML::SessionServer;
28 use RPC::XML::Procedure;
29 use Data::Mungle::Code::Symbol qw( alias_simple );
30
31 # this is a global counter for giving unnamed webservices a unique id
32 our $instance_counter;
33
34
35 sub start {
36
37 my $self = shift;
38
39 # notice
40 print "Starting WebService listening on port $self->{ws_port}, using main API from Package $self->{api_module}.", "\n";
41
42 # trace
43 #print Dumper($self);
44 #exit;
45
46 $instance_counter++;
47
48 # here goes the server instance
49 $self->{_daemon} = RPC::XML::SessionServer->new(
50 port => $self->{ws_port},
51 path => $self->{ws_path} || 'WebService' . $instance_counter,
52 auto_updates => 1,
53
54 # FIXME: this is hardcoded!
55 authentication => {
56 type => 'plain',
57 user => 'hello',
58 pass => '123',
59 }
60 );
61
62 # API
63
64 # 1. load api module
65 my $api = DesignPattern::Object->fromPackage($self->{api_module}) or die("Could not load Api-Module '$self->{api_module}'.");
66 # build complete bunch of api declaration metadata handling recursive plugin declaration and stuff ...
67 #$api->build([qw( OEF::YAA::API::Jobs )]);
68 $api->build($self->{api_submodules});
69
70 # 2. query it for to-be-published methods ...
71 my $procs = $api->getApiMetadata() or die("Could not load Api-Declarations from '$self->{api_module}'.");
72 # ... and propagate metadata for each method to daemon instance which is not yet running
73 foreach my $proc (@{$procs}) {
74 $self->{_daemon}->add_method($proc);
75 }
76
77 # 3. SymbolAliasing: query it for to-be-established symbols ...
78 my $symbols;
79 $symbols = $api->getSymbolMetadata() if $api->can("getSymbolMetadata");
80 # ... and vivify them each pointing to a reference.
81 foreach my $symbol (@{$symbols}) {
82 $symbol->{slot} = $self->{_daemon};
83 alias_simple($symbol);
84 }
85
86 # run service / activate instance
87 # Never returns...
88 $self->{_daemon}->server_loop;
89
90 }
91
92 1;
93 __END__

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed