Class: XmlblasterCallbackServer
- Defined in:
- lib/adaptation/xmlblaster/xmlblaster_callback_server.rb
Instance Attribute Summary collapse
-
#callback_url ⇒ Object
readonly
Returns the value of attribute callback_url.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
-
#initialize(ip, port, public_ip, public_port, callbackInstance, audit = nil) ⇒ XmlblasterCallbackServer
constructor
A new instance of XmlblasterCallbackServer.
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(ip, port, public_ip, public_port, callbackInstance, audit = nil) ⇒ XmlblasterCallbackServer
Returns a new instance of XmlblasterCallbackServer.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/adaptation/xmlblaster/xmlblaster_callback_server.rb', line 10 def initialize( ip, port, public_ip, public_port, callbackInstance, audit = nil ) if audit == nil then @audit = Logger.new($stdout) else @audit = audit end @thread = nil @callback_server = nil @callback_url = "http://#{public_ip}:#{public_port}/RPC2" @port = port @ip = ip @callback_instance = callbackInstance end |
Instance Attribute Details
#callback_url ⇒ Object (readonly)
Returns the value of attribute callback_url.
8 9 10 |
# File 'lib/adaptation/xmlblaster/xmlblaster_callback_server.rb', line 8 def callback_url @callback_url end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
7 8 9 |
# File 'lib/adaptation/xmlblaster/xmlblaster_callback_server.rb', line 7 def thread @thread end |
Instance Method Details
#shutdown ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/adaptation/xmlblaster/xmlblaster_callback_server.rb', line 70 def shutdown if @callback_server then @callback_server.shutdown() @thread.kill end return true end |
#start ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/adaptation/xmlblaster/xmlblaster_callback_server.rb', line 24 def start begin @callback_server = XMLRPC::Server.new( @port, @ip, 4, @audit, false ) @audit.debug( "CallBackServer started") rescue => e msg = e. + ": " + e.backtrace.join("\n") @audit.error( "CallBackServer: Could not create XMLRPC Server: " + msg) return false end @thread = Thread.new( @port, @callback_instance ) { | port, callback_instance | Thread.current['name'] = "MOM-CallbackServer" STDOUT.sync = true if @callback_server then @audit.debug( "MOM-CallBackServer: " + @callback_url ) @callback_server.add_handler("ping") do |name, *args| @callback_instance.ping( *args ) end @callback_server.add_handler("update") do |name, *args| @callback_instance.update( *args ) end @callback_server.set_default_handler do |name, *args| raise XMLRPC::FaultException.new(-99, "MOM-CallBackServer: Method #{name} missing or wrong number of parameters!") end # listening @audit.debug( "MOM-CallBackServer: XMLRPC Server serving." ) @callback_server.serve() else return false end } return true end |