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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 joko 1.2 ## ------------------------------------------------------------------------
2 joko 1.4 ## $Id: WebService.pm,v 1.3 2003/04/04 17:28:59 joko Exp $
3 joko 1.2 ## ------------------------------------------------------------------------
4     ## $Log: WebService.pm,v $
5 joko 1.4 ## Revision 1.3 2003/04/04 17:28:59 joko
6     ## minor update: commented hardcoded stuff
7     ##
8 joko 1.3 ## Revision 1.2 2003/04/04 17:28:15 joko
9     ## starting the *session* server/service from here
10     ##
11 joko 1.2 ## Revision 1.1 2003/03/27 15:41:27 joko
12     ## initial commit, code from daemon-api-admin.pl
13     ##
14     ## ------------------------------------------------------------------------
15 joko 1.1
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 joko 1.2 use RPC::XML::SessionServer;
28 joko 1.1 use RPC::XML::Procedure;
29 joko 1.4 use Data::Mungle::Code::Symbol qw( alias_simple );
30 joko 1.1
31 joko 1.2 # this is a global counter for giving unnamed webservices a unique id
32     our $instance_counter;
33    
34    
35 joko 1.1 sub start {
36    
37     my $self = shift;
38    
39     # notice
40 joko 1.2 print "Starting WebService listening on port $self->{ws_port}, using main API from Package $self->{api_module}.", "\n";
41 joko 1.1
42     # trace
43     #print Dumper($self);
44     #exit;
45    
46 joko 1.2 $instance_counter++;
47    
48 joko 1.1 # here goes the server instance
49 joko 1.2 $self->{_daemon} = RPC::XML::SessionServer->new(
50     port => $self->{ws_port},
51     path => $self->{ws_path} || 'WebService' . $instance_counter,
52 joko 1.1 auto_updates => 1,
53 joko 1.3
54     # FIXME: this is hardcoded!
55 joko 1.2 authentication => {
56     type => 'plain',
57     user => 'hello',
58     pass => '123',
59     }
60 joko 1.1 );
61    
62     # API
63 joko 1.4
64     # 1. load api module
65 joko 1.1 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 joko 1.4
70     # 2. query it for to-be-published methods ...
71 joko 1.1 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 joko 1.4 }
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 joko 1.1 }
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