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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

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