/[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.7 - (show annotations)
Tue Jul 6 00:45:18 2004 UTC (20 years ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +7 -2 lines
disabled RPC::XML::SessionServer (TODO: reactivate!)

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

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