alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Jetty example source code file (javaURLContextFactory.java)

This example Jetty source code file (javaURLContextFactory.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Jetty tags/keywords

context, context, exception, hashtable, name, naming, namingexception, namingexception, no, object, object, objectfactory, string, string, util

The Jetty javaURLContextFactory.java source code

// ========================================================================
// $Id: javaURLContextFactory.java 231 2006-02-19 15:09:58Z janb $
// Copyright 1999-2006 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at 
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ========================================================================

package org.mortbay.naming.java;

import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NamingException;
import javax.naming.spi.ObjectFactory;

import org.mortbay.log.Log;


/** javaURLContextFactory
 * <p>This is the URL context factory for the java: URL.
 *
 * <p>

Notes

* <p> * * <p>

Usage

* <pre> */ /* * </pre> * * @see * * @author <a href="mailto:janb@mortbay.com">Jan Bartel * @version 1.0 */ public class javaURLContextFactory implements ObjectFactory { /** * Either return a new context or the resolution of a url. * * @param url an <code>Object value * @param name a <code>Name value * @param ctx a <code>Context value * @param env a <code>Hashtable value * @return a new context or the resolved object for the url * @exception Exception if an error occurs */ public Object getObjectInstance(Object url, Name name, Context ctx, Hashtable env) throws Exception { // null object means return a root context for doing resolutions if (url == null) { if(Log.isDebugEnabled())Log.debug(">>> new root context requested "); return new javaRootURLContext(env); } // return the resolution of the url if (url instanceof String) { if(Log.isDebugEnabled())Log.debug(">>> resolution of url "+url+" requested"); Context rootctx = new javaRootURLContext (env); return rootctx.lookup ((String)url); } // return the resolution of at least one of the urls if (url instanceof String[]) { if(Log.isDebugEnabled())Log.debug(">>> resolution of array of urls requested"); String[] urls = (String[])url; Context rootctx = new javaRootURLContext (env); Object object = null; NamingException e = null; for (int i=0;(i< urls.length) && (object == null); i++) { try { object = rootctx.lookup (urls[i]); } catch (NamingException x) { e = x; } } if (object == null) throw e; else return object; } if(Log.isDebugEnabled())Log.debug(">>> No idea what to do, so return a new root context anyway"); return new javaRootURLContext (env); } };

Other Jetty examples (source code examples)

Here is a short list of links related to this Jetty javaURLContextFactory.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.