/[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.6 - (hide annotations)
Wed Jul 2 11:00:40 2003 UTC (21 years, 4 months ago) by jonen
Branch: MAIN
Changes since 1.5: +7 -1 lines
fixed: die now if http-port is used by other app

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

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