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

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

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