Module: TorqueBox::Naming

Defined in:
lib/torquebox/naming.rb

Constant Summary collapse

REMOTE_NAMING_FACTORY =
'org.jboss.naming.remote.client.InitialContextFactory'
LOCAL_NAMING_FACTORY =
'org.jboss.as.naming.InitialContextFactory'

Class Method Summary collapse

Class Method Details

.remote_context(options = {}, &block) ⇒ Object

Note:

If you use this method without providing a block, make sure you close the context after usage (use close method).

Note:

JBoss AS 7.1+ provides the java:jboss/exported context, entries bound to this context are accessible over remote JNDI. No other objects will be available for remote lookups. This means that if you want to have a JNDI object available for remote lookup you need to export it first. For more information please refer to the JBoss AS 7 wiki: docs.jboss.org/author/display/AS71/JNDI+Reference

Connects to a remote server and returns (or yields) InitialContext for lookups.



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

def self.remote_context(options = {}, &block)
  ctx = javax.naming::InitialContext.new(populate_properties(options.merge(:remote => true)))

  return ctx unless block

  begin
    block.call(ctx)
  ensure
    ctx.close
  end
end