1 7 8 package com.sun.naming.internal; 9 10 import java.io.InputStream ; 11 import java.io.IOException ; 12 import java.net.MalformedURLException ; 13 import java.net.URL ; 14 import java.util.Enumeration ; 15 import java.util.StringTokenizer ; 16 import java.util.Vector ; 17 18 import javax.naming.NamingEnumeration ; 19 20 31 32 public abstract class VersionHelper { 33 private static VersionHelper helper = null; 34 35 final static String [] PROPS = new String [] { 36 javax.naming.Context.INITIAL_CONTEXT_FACTORY, 37 javax.naming.Context.OBJECT_FACTORIES, 38 javax.naming.Context.URL_PKG_PREFIXES, 39 javax.naming.Context.STATE_FACTORIES, 40 javax.naming.Context.PROVIDER_URL, 41 javax.naming.Context.DNS_URL, 42 javax.naming.ldap.LdapContext.CONTROL_FACTORIES 44 }; 45 46 public final static int INITIAL_CONTEXT_FACTORY = 0; 47 public final static int OBJECT_FACTORIES = 1; 48 public final static int URL_PKG_PREFIXES = 2; 49 public final static int STATE_FACTORIES = 3; 50 public final static int PROVIDER_URL = 4; 51 public final static int DNS_URL = 5; 52 public final static int CONTROL_FACTORIES = 6; 53 54 VersionHelper() {} 56 static { 57 helper = new VersionHelper12(); 58 } 59 60 public static VersionHelper getVersionHelper() { 61 return helper; 62 } 63 64 public abstract Class loadClass(String className) 65 throws ClassNotFoundException ; 66 67 abstract Class loadClass(String className, ClassLoader cl) 68 throws ClassNotFoundException ; 69 70 public abstract Class loadClass(String className, String codebase) 71 throws ClassNotFoundException , MalformedURLException ; 72 73 78 abstract String getJndiProperty(int i); 79 80 86 abstract String [] getJndiProperties(); 87 88 92 abstract InputStream getResourceAsStream(Class c, String name); 93 94 100 abstract InputStream getJavaHomeLibStream(String filename); 101 102 108 abstract NamingEnumeration getResources(ClassLoader cl, String name) 109 throws IOException ; 110 111 117 abstract ClassLoader getContextClassLoader(); 118 119 static protected URL [] getUrlArray(String codebase) 120 throws MalformedURLException { 121 StringTokenizer parser = new StringTokenizer (codebase); 123 Vector vec = new Vector (10); 124 while (parser.hasMoreTokens()) { 125 vec.addElement(parser.nextToken()); 126 } 127 String [] url = new String [vec.size()]; 128 for (int i = 0; i < url.length; i++) { 129 url[i] = (String )vec.elementAt(i); 130 } 131 132 URL [] urlArray = new URL [url.length]; 133 for (int i = 0; i < urlArray.length; i++) { 134 urlArray[i] = new URL (url[i]); 135 } 136 return urlArray; 137 } 138 } 139 | Popular Tags |