Class: HornetQ::URI
- Inherits:
-
Object
- Object
- HornetQ::URI
- Defined in:
- lib/hornetq/uri.rb
Instance Attribute Summary collapse
-
#backup_host ⇒ Object
readonly
Returns the value of attribute backup_host.
-
#backup_port ⇒ Object
readonly
Returns the value of attribute backup_port.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #backup? ⇒ Boolean
-
#initialize(uri) ⇒ URI
constructor
hornetq://localhost hornetq://localhost,192.168.0.22 hornetq://localhost:5445,backupserver:5445/?protocol=netty hornetq://localhost/?protocol=invm hornetq://discoveryserver:5445/?protocol=discovery.
Constructor Details
#initialize(uri) ⇒ URI
hornetq://localhost hornetq://localhost,192.168.0.22 hornetq://localhost:5445,backupserver:5445/?protocol=netty hornetq://localhost/?protocol=invm hornetq://discoveryserver:5445/?protocol=discovery
11 12 13 14 15 16 17 18 19 20 21 22 23 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 |
# File 'lib/hornetq/uri.rb', line 11 def initialize(uri) raise Exception,"Invalid protocol format: #{uri}" unless uri =~ /(.*):\/\/(.*)/ @scheme, @host = $1, $2 raise Exception,"Bad URI(only scheme hornetq:// is supported): #{uri}" unless @scheme == 'hornetq' raise 'Mandatory hostname missing in uri' if @host.empty? if @host =~ /(.*?)(\/.*)/ @host, @path = $1, $2 else @path = '/' end if @host =~ /(.*),(.*)/ @host, @backup_host = $1, $2 end if @host =~ /(.*):(.*)/ @host, @port = $1, HornetQ.netty_port($2) else @port = HornetQ::DEFAULT_NETTY_PORT end if @backup_host if @backup_host =~ /(.*):(.*)/ @backup_host, @backup_port = $1, HornetQ.netty_port($2) else @backup_port = HornetQ::DEFAULT_NETTY_PORT end end query = nil if @path =~ /(.*)\?(.*)/ @path, query = $1, $2 end # Extract settings passed in query @params = {} if query query.split('&').each do |i| key, value = i.split('=') value = true if value == 'true' value = false if value == 'false' value = value.to_i if value =~ /^\d+$/ value = value.to_f if value =~ /^\d+\.\d*$/ @params[key] = value end end end |
Instance Attribute Details
#backup_host ⇒ Object (readonly)
Returns the value of attribute backup_host.
3 4 5 |
# File 'lib/hornetq/uri.rb', line 3 def backup_host @backup_host end |
#backup_port ⇒ Object (readonly)
Returns the value of attribute backup_port.
3 4 5 |
# File 'lib/hornetq/uri.rb', line 3 def backup_port @backup_port end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/hornetq/uri.rb', line 3 def host @host end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/hornetq/uri.rb', line 3 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/hornetq/uri.rb', line 3 def path @path end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/hornetq/uri.rb', line 3 def port @port end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
3 4 5 |
# File 'lib/hornetq/uri.rb', line 3 def scheme @scheme end |
Instance Method Details
#[](key) ⇒ Object
55 56 57 |
# File 'lib/hornetq/uri.rb', line 55 def [](key) @params[key] end |
#backup? ⇒ Boolean
59 60 61 |
# File 'lib/hornetq/uri.rb', line 59 def backup? !!@params['backup'] end |