PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Java|javax|naming|InitialContext.java =

page 4 of 6



     * <code>name</code> is not a URL string, then return
     * <code>getDefaultInitCtx()</code>.
     *<p>
     * See getURLOrDefaultInitCtx(Name) for description
     * of how a subclass should use this method.
     * @param name The non-null name for which to get the context.
     * @return A URL context for <code>name</code> or the cached 
     * 	       initial context. The result cannot be null.
     * @exception NoInitialContextException If cannot find an initial context.
     * @exception NamingException In a naming exception is encountered.
     * @see javax.naming.spi.NamingManager#getURLContext
     */
    protected Context getURLOrDefaultInitCtx(String name) 
	throws NamingException {
	if (NamingManager.hasInitialContextFactoryBuilder()) {
	    return getDefaultInitCtx();
	}
	String scheme = getURLScheme(name);
	if (scheme != null) {
	    Context ctx = NamingManager.getURLContext(scheme, myProps);
	    if (ctx != null) {
		return ctx;
	    }
	}
	return getDefaultInitCtx();
    }

    /**
     * Retrieves a context for resolving <code>name</code>.
     * If the first component of <code>name</code> name is a URL string,
     * then attempt to find a URL context for it. If none is found, or if
     * the first component of <code>name</code> is not a URL string, 
     * then return <code>getDefaultInitCtx()</code>.
     *<p>
     * When creating a subclass of InitialContext, use this method as 
     * follows.
     * Define a new method that uses this method to get an initial
     * context of the desired subclass.
     * <p><blockquote><pre>
     * protected XXXContext getURLOrDefaultInitXXXCtx(Name name) 
     * throws NamingException {
     *  Context answer = getURLOrDefaultInitCtx(name);
     *  if (!(answer instanceof XXXContext)) {
     *    if (answer == null) {
     *	    throw new NoInitialContextException();
     *    } else {
     *	    throw new NotContextException("Not an XXXContext");
     *    }
     * 	}
     *	return (XXXContext)answer;
     * }
     * </pre></blockquote>
     * When providing implementations for the new methods in the subclass,
     * use this newly defined method to get the initial context.
     * <p><blockquote><pre>
     * public Object XXXMethod1(Name name, ...) {
     *	throws NamingException {
     *    return getURLOrDefaultInitXXXCtx(name).XXXMethod1(name, ...);
     * }
     * </pre></blockquote>
     *
     * @param name The non-null name for which to get the context.
     * @return A URL context for <code>name</code> or the cached 
     * 	       initial context. The result cannot be null.
     * @exception NoInitialContextException If cannot find an initial context.
     * @exception NamingException In a naming exception is encountered.
     *
     * @see javax.naming.spi.NamingManager#getURLContext
     */
    protected Context getURLOrDefaultInitCtx(Name name) 
	throws NamingException {
	if (NamingManager.hasInitialContextFactoryBuilder()) {
	    return getDefaultInitCtx();
	}
	if (name.size() > 0) {
	    String first = name.get(0);
	    String scheme = getURLScheme(first);
	    if (scheme != null) {
		Context ctx = NamingManager.getURLContext(scheme, myProps);
		if (ctx != null) {
		    return ctx;
		}
	    } 
	}
	return getDefaultInitCtx();
    }

// Context methods
// Most Javadoc is deferred to the Context interface.

    public Object lookup(String name) throws NamingException {
	return getURLOrDefaultInitCtx(name).lookup(name);
    }

    public Object lookup(Name name) throws NamingException {
	return getURLOrDefaultInitCtx(name).lookup(name);
    }

    public void bind(String name, Object obj) throws NamingException {
	getURLOrDefaultInitCtx(name).bind(name, obj);
=4=

1|2|3| < PREV = PAGE 4 = NEXT > |5|6

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.010916 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)