/[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.5 - (show annotations)
Tue Jul 1 18:11:15 2003 UTC (21 years, 1 month ago) by joko
Branch: MAIN
Changes since 1.4: +6 -3 lines
fixed: renamed package name according to new filenames

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

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