0N/A/*
2362N/A * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.naming.internal;
0N/A
0N/Aimport java.io.InputStream;
0N/Aimport java.io.IOException;
0N/Aimport java.net.MalformedURLException;
0N/Aimport java.net.URL;
0N/Aimport java.util.Enumeration;
0N/Aimport java.util.StringTokenizer;
0N/Aimport java.util.Vector;
0N/A
0N/Aimport javax.naming.NamingEnumeration;
0N/A
0N/A/**
0N/A * VersionHelper was used by JNDI to accommodate differences between
0N/A * JDK 1.1.x and the Java 2 platform. As this is no longer necessary
0N/A * since JNDI's inclusion in the platform, this class currently
0N/A * serves as a set of utilities for performing system-level things,
0N/A * such as class-loading and reading system properties.
0N/A *
0N/A * @author Rosanna Lee
0N/A * @author Scott Seligman
0N/A */
0N/A
0N/Apublic abstract class VersionHelper {
0N/A private static VersionHelper helper = null;
0N/A
0N/A final static String[] PROPS = new String[] {
0N/A javax.naming.Context.INITIAL_CONTEXT_FACTORY,
0N/A javax.naming.Context.OBJECT_FACTORIES,
0N/A javax.naming.Context.URL_PKG_PREFIXES,
0N/A javax.naming.Context.STATE_FACTORIES,
0N/A javax.naming.Context.PROVIDER_URL,
0N/A javax.naming.Context.DNS_URL,
0N/A // The following shouldn't create a runtime dependence on ldap package.
0N/A javax.naming.ldap.LdapContext.CONTROL_FACTORIES
0N/A };
0N/A
0N/A public final static int INITIAL_CONTEXT_FACTORY = 0;
0N/A public final static int OBJECT_FACTORIES = 1;
0N/A public final static int URL_PKG_PREFIXES = 2;
0N/A public final static int STATE_FACTORIES = 3;
0N/A public final static int PROVIDER_URL = 4;
0N/A public final static int DNS_URL = 5;
0N/A public final static int CONTROL_FACTORIES = 6;
0N/A
0N/A VersionHelper() {} // Disallow anyone from creating one of these.
0N/A
0N/A static {
0N/A helper = new VersionHelper12();
0N/A }
0N/A
0N/A public static VersionHelper getVersionHelper() {
0N/A return helper;
0N/A }
0N/A
0N/A public abstract Class loadClass(String className)
0N/A throws ClassNotFoundException;
0N/A
0N/A abstract Class loadClass(String className, ClassLoader cl)
0N/A throws ClassNotFoundException;
0N/A
0N/A public abstract Class loadClass(String className, String codebase)
0N/A throws ClassNotFoundException, MalformedURLException;
0N/A
0N/A /*
0N/A * Returns a JNDI property from the system properties. Returns
0N/A * null if the property is not set, or if there is no permission
0N/A * to read it.
0N/A */
0N/A abstract String getJndiProperty(int i);
0N/A
0N/A /*
0N/A * Reads each property in PROPS from the system properties, and
0N/A * returns their values -- in order -- in an array. For each
0N/A * unset property, the corresponding array element is set to null.
0N/A * Returns null if there is no permission to call System.getProperties().
0N/A */
0N/A abstract String[] getJndiProperties();
0N/A
0N/A /*
0N/A * Returns the resource of a given name associated with a particular
0N/A * class (never null), or null if none can be found.
0N/A */
0N/A abstract InputStream getResourceAsStream(Class c, String name);
0N/A
0N/A /*
0N/A * Returns an input stream for a file in <java.home>/lib,
0N/A * or null if it cannot be located or opened.
0N/A *
0N/A * @param filename The file name, sans directory.
0N/A */
0N/A abstract InputStream getJavaHomeLibStream(String filename);
0N/A
0N/A /*
0N/A * Returns an enumeration (never null) of InputStreams of the
0N/A * resources of a given name associated with a particular class
0N/A * loader. Null represents the bootstrap class loader in some
0N/A * Java implementations.
0N/A */
0N/A abstract NamingEnumeration getResources(ClassLoader cl, String name)
0N/A throws IOException;
0N/A
0N/A /*
0N/A * Returns the context class loader associated with the current thread.
0N/A * Null indicates the bootstrap class loader in some Java implementations.
0N/A *
0N/A * @throws SecurityException if the class loader is not accessible.
0N/A */
0N/A abstract ClassLoader getContextClassLoader();
0N/A
0N/A static protected URL[] getUrlArray(String codebase)
0N/A throws MalformedURLException {
0N/A // Parse codebase into separate URLs
0N/A StringTokenizer parser = new StringTokenizer(codebase);
0N/A Vector vec = new Vector(10);
0N/A while (parser.hasMoreTokens()) {
0N/A vec.addElement(parser.nextToken());
0N/A }
0N/A String[] url = new String[vec.size()];
0N/A for (int i = 0; i < url.length; i++) {
0N/A url[i] = (String)vec.elementAt(i);
0N/A }
0N/A
0N/A URL[] urlArray = new URL[url.length];
0N/A for (int i = 0; i < urlArray.length; i++) {
0N/A urlArray[i] = new URL(url[i]);
0N/A }
0N/A return urlArray;
0N/A }
0N/A}