1 5 package com.tc.object.loaders; 6 7 public class Namespace { 8 9 private static final String SEP = "."; 11 12 private static final String CLASS_NAME_LOADER_SEPARATOR = ":://::"; 14 15 private static final String LOGICAL_CLASS_EXTENDS_SEPARATOR = "::"; 16 17 public static final String STANDARD_NAMESPACE = "Standard" + SEP; 19 public static final String TOMCAT_NAMESPACE = "Tomcat" + SEP; 20 public static final String GERONIMO_NAMESPACE = "Geronimo" + SEP; 21 public static final String WEBLOGIC_NAMESPACE = "Weblogic" + SEP; 22 public static final String JBOSS_NAMESPACE = "JBoss" + SEP; 23 public static final String MODULES_NAMESPACE = "Modules" + SEP; 24 25 private static final String SYSTEM_LOADER_NAME = STANDARD_NAMESPACE + "system"; 26 private static final String EXT_LOADER_NAME = STANDARD_NAMESPACE + "ext"; 27 private static final String BOOT_LOADER_NAME = STANDARD_NAMESPACE + "bootstrap"; 28 29 public static String getStandardSystemLoaderName() { 30 return SYSTEM_LOADER_NAME; 31 } 32 33 public static String getStandardExtensionsLoaderName() { 34 return EXT_LOADER_NAME; 35 } 36 37 public static String getStandardBootstrapLoaderName() { 38 return BOOT_LOADER_NAME; 39 } 40 41 public static String getClassNameAndLoaderSeparator() { 42 return CLASS_NAME_LOADER_SEPARATOR; 43 } 44 45 public static String getLogicalClassExtendsSeparator() { 46 return LOGICAL_CLASS_EXTENDS_SEPARATOR; 47 } 48 49 public static String createLogicalExtendingClassName(String className, String superClassName) { 50 return className + LOGICAL_CLASS_EXTENDS_SEPARATOR + superClassName; 51 } 52 53 public static String parseClassNameIfNecessary(String className) { 54 int separatorIndex = className.indexOf(LOGICAL_CLASS_EXTENDS_SEPARATOR); 55 if (separatorIndex == -1) { return className; } 56 return className.substring(0, separatorIndex); 57 } 58 59 public static String parseLogicalNameIfNeceesary(String className) { 60 int separatorIndex = className.indexOf(LOGICAL_CLASS_EXTENDS_SEPARATOR); 61 if (separatorIndex == -1) { return null; } 62 return className.substring(separatorIndex + LOGICAL_CLASS_EXTENDS_SEPARATOR.length()); 63 } 64 65 public static String createLoaderName(String topLevel, String subName) { 66 if (topLevel == null) { throw new IllegalArgumentException ("topLevel space is null"); } 67 if (subName == null) { throw new IllegalArgumentException ("subName is null"); } 68 69 if (topLevel.equals(TOMCAT_NAMESPACE) || topLevel.equals(WEBLOGIC_NAMESPACE) || topLevel.equals(GERONIMO_NAMESPACE) 70 || topLevel.equals(JBOSS_NAMESPACE) || topLevel.equals(MODULES_NAMESPACE)) { 71 return new StringBuffer (topLevel).append(subName).toString(); 73 } 74 75 throw new IllegalArgumentException ("Invalid top level namespace: " + topLevel); 76 } 77 78 private Namespace() { 79 } 81 } 82 | Popular Tags |