Class: TorqueBox::Naming::NamingService

Inherits:
Object
  • Object
show all
Defined in:
lib/torquebox/naming/naming_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ NamingService

Returns a new instance of NamingService.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/torquebox/naming/naming_service.rb', line 41

def initialize(&block)
  @host = 'localhost'
  @port = 1099

  @rmi_host = 'localhost'
  @rmi_port = 1098

  @export = true

  instance_eval(&block) if block
end

Instance Attribute Details

#exportObject

Returns the value of attribute export.



39
40
41
# File 'lib/torquebox/naming/naming_service.rb', line 39

def export
  @export
end

#hostObject

Returns the value of attribute host.



34
35
36
# File 'lib/torquebox/naming/naming_service.rb', line 34

def host
  @host
end

#portObject

Returns the value of attribute port.



33
34
35
# File 'lib/torquebox/naming/naming_service.rb', line 33

def port
  @port
end

#rmi_hostObject

Returns the value of attribute rmi_host.



37
38
39
# File 'lib/torquebox/naming/naming_service.rb', line 37

def rmi_host
  @rmi_host
end

#rmi_portObject

Returns the value of attribute rmi_port.



36
37
38
# File 'lib/torquebox/naming/naming_service.rb', line 36

def rmi_port
  @rmi_port
end

Instance Method Details

#available_portObject



70
71
72
73
74
75
# File 'lib/torquebox/naming/naming_service.rb', line 70

def available_port
  server = TCPServer.new('127.0.0.1', 0)
  port = server.addr[1]
  server.close
  port
end

#before_start(container) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/torquebox/naming/naming_service.rb', line 61

def before_start(container)
  Java::java.lang::System.setProperty( 'java.naming.factory.initial',  'org.jnp.interfaces.NamingContextFactory' )
  Java::java.lang::System.setProperty( 'java.naming.factory.url.pkgs', 'org.jboss.naming:org.jnp.interfaces' )
  Java::java.lang::System.setProperty( 'jnp.host', self.host.to_s )
  Java::java.lang::System.setProperty( 'jnp.port', self.port.to_s )
  Java::java.lang::System.setProperty( 'jnp.rmiHost', self.rmi_host.to_s )
  Java::java.lang::System.setProperty( 'jnp.rmiPort', self.rmi_port.to_s )
end

#fundamental_deployment_pathsObject



25
26
27
28
29
30
31
# File 'lib/torquebox/naming/naming_service.rb', line 25

def fundamental_deployment_paths
  paths = [ File.join( File.dirname(__FILE__), 'naming-local-jboss-beans.xml' ) ]
  if ( @export )
    paths << File.join( File.dirname(__FILE__), 'naming-rmi-jboss-beans.xml' )
  end
  paths
end