org.obe.client.api.rmi
Class JNDIHelper

java.lang.Object
  extended byorg.obe.client.api.rmi.JNDIHelper

public final class JNDIHelper
extends java.lang.Object

This class can be used for remote access to the JNDI tree.

Author:
Adrian Price

Field Summary
static java.lang.String DEFAULT_DATA_SOURCE
           
static java.lang.String EJB_DATA_SOURCE
           
 
Method Summary
static javax.sql.DataSource getDataSource(java.lang.String name)
          This method returns a DataSource object from JNDI.
static javax.sql.DataSource getDataSource(java.lang.String name, javax.naming.Context ctx)
          This method returns a DataSource object from JNDI.
static javax.naming.InitialContext getInitialContext()
          This method can be used from a J2EE server.
static javax.naming.InitialContext getInitialContext(java.lang.String url)
          This method allows access to different URLs, but with the default username.
static javax.naming.InitialContext getInitialContext(java.lang.String username, java.lang.Object credentials)
          This method is used on the server when a new username is needed for the JNDI context.
static javax.naming.InitialContext getInitialContext(java.lang.String url, java.lang.String username, java.lang.Object credentials)
          This method allows client code to specify URL and credentials with which to connect.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EJB_DATA_SOURCE

public static final java.lang.String EJB_DATA_SOURCE
See Also:
Constant Field Values

DEFAULT_DATA_SOURCE

public static final java.lang.String DEFAULT_DATA_SOURCE
See Also:
Constant Field Values
Method Detail

getInitialContext

public static javax.naming.InitialContext getInitialContext()
                                                     throws javax.naming.NamingException
This method can be used from a J2EE server.

Returns:
Context
Throws:
javax.naming.NamingException

getInitialContext

public static javax.naming.InitialContext getInitialContext(java.lang.String url)
                                                     throws javax.naming.NamingException
This method allows access to different URLs, but with the default username.

Parameters:
url - Server URL.
Returns:
A JNDI InitialContext object.
Throws:
javax.naming.NamingException

getInitialContext

public static javax.naming.InitialContext getInitialContext(java.lang.String username,
                                                            java.lang.Object credentials)
                                                     throws javax.naming.NamingException
This method is used on the server when a new username is needed for the JNDI context.

Parameters:
username -
credentials -
Returns:
Context
Throws:
javax.naming.NamingException

getInitialContext

public static javax.naming.InitialContext getInitialContext(java.lang.String url,
                                                            java.lang.String username,
                                                            java.lang.Object credentials)
                                                     throws javax.naming.NamingException
This method allows client code to specify URL and credentials with which to connect. N.B. The caller must close the returned context.

Parameters:
url -
username -
credentials -
Returns:
A InitialContext object.
Throws:
javax.naming.NamingException

getDataSource

public static javax.sql.DataSource getDataSource(java.lang.String name,
                                                 javax.naming.Context ctx)
                                          throws javax.naming.NamingException
This method returns a DataSource object from JNDI.

Parameters:
name - Name of the DataSource object
ctx - JNDI Context.
Returns:
DataSource object from JNDI
Throws:
javax.naming.NamingException

getDataSource

public static javax.sql.DataSource getDataSource(java.lang.String name)
                                          throws javax.naming.NamingException
This method returns a DataSource object from JNDI. This method will open and close a temporary JNDI context.

Parameters:
name - Name of the DataSource object
Returns:
DataSource object from JNDI
Throws:
javax.naming.NamingException


SourceForge.net Logo OBE-1.0 Copyright (c) 2002-2006 Adrian Price. All Rights Reserved.