Skip navigation links
com.bea.p13n.util
Class JndiHelper
java.lang.Object
com.bea.p13n.util.JndiHelper
-
public class JndiHelper
- extends Object
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JndiHelper
public JndiHelper()
getContext
public static Context getContext()
throws NamingException
- Returns a reference to an InitialContext object. This method is functionally equivalent to: "new InitialContext()", but the use of this method allows for centralized configuration and caching strategies.
-
- Returns
- ctx The Context reference
- Throws
NamingException
- if InitialContext cannot be obtained
getApplicationContext
public static Context getApplicationContext()
throws NamingException
-
- Throws
NamingException
lookupNarrow
public static <T> T lookupNarrow(String lookupName,
Class<T> lookupClass)
throws NamingException,
ClassCastException
- Convenience method for getting a remote JNDI reference to an object. This will mostly be used to locate a remote EJB's home interface, but is generic to allow location of any JNDI-bound object.
The code this executes looks like:
PortableRemoteObject.narrow(
JndiHelper.getContext().lookup(lookupName),
lookupClass);
-
- Parameters
lookupName
- The JNDI name of the object to locate
lookupClass
- The desired class type
- Returns
- An object which can be cast to the desired type
- Throws
NamingException
- If the lookup() call fails
ClassCastException
- If lookupName cannot be cast to lookupClass
- See Also
PortableRemoteObject.narrow(java.lang.Object, java.lang.Class)
lookup
public static <T> T lookup(String lookupname,
Class<T> lookupClass)
throws NamingException
-
- Throws
NamingException
lookupApplicationScope
public static <T> T lookupApplicationScope(String lookupname,
Class<T> lookupClass)
throws NamingException
-
- Throws
NamingException
translateDatasourceName
public static String translateDatasourceName(String originalDatasourceName)
lookupDataSource
public static DataSource lookupDataSource(String originalLookup)
throws NamingException
-
- Throws
NamingException
Skip navigation links
Copyright © 2010, Oracle. All rights reserved.