You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/07/11 15:40:13 UTC
svn commit: r555268 -
/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/javax/naming/InitialContext.java
Author: tellison
Date: Wed Jul 11 06:40:12 2007
New Revision: 555268
URL: http://svn.apache.org/viewvc?view=rev&rev=555268
Log:
Implement missing doLookup methods.
Modified:
harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/javax/naming/InitialContext.java
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/javax/naming/InitialContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/javax/naming/InitialContext.java?view=diff&rev=555268&r1=555267&r2=555268
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/javax/naming/InitialContext.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/javax/naming/InitialContext.java Wed Jul 11 06:40:12 2007
@@ -125,6 +125,51 @@
protected Hashtable<Object, Object> myProps;
/**
+ * A shortcut method for retrieving the named object by <code>Name</code>.
+ * It is equivalent to
+ *
+ * <pre>
+ * InitialContext icxt = new InitialContext();
+ * T obj = icxt.lookup();
+ * </pre>
+ *
+ * <p>
+ * Returns a new instance of this context when <code>name</code> is empty.
+ * The new instance represents the same naming context as this context, but
+ * may be accessed/modified independently and concurrently.
+ * </p>
+ *
+ * @param name
+ * the name to be looked up
+ * @return the object bound to <code>name</code>
+ * @throws NamingException
+ * if a naming exception is encountered
+ *
+ * @see #doLookup(String)
+ * @see #lookup(Name)
+ * @since 1.6
+ */
+ public static <T> T doLookup(Name name) throws NamingException {
+ return (T) new InitialContext().lookup(name);
+ }
+
+ /**
+ * A static method that retrieves the named object by <code>String</code>.
+ *
+ * @param name
+ * the name of the object being looked up
+ * @return the object bound to <code>name</code>
+ * @throws NamingException
+ * if a naming exception is encountered
+ *
+ * @see #doLookup(Name)
+ * @since 1.6
+ */
+ public static <T> T doLookup(String name) throws NamingException {
+ return (T) new InitialContext().lookup(name);
+ }
+
+ /**
* Constructs an <code>InitialContext</code> instance without using any
* environment properties. This constructor is effectively the same as using
* constructor <code>InitialContext((Hashtable)null)</code>.