1 23 24 package com.sun.enterprise.deployment.util; 25 26 import java.util.logging.Level ; 27 import java.util.logging.Logger ; 28 import java.lang.reflect.Method ; 29 30 import com.sun.enterprise.deployment.WebBundleDescriptor; 31 import com.sun.logging.LogDomains; 32 33 public class DOLLoadingContextFactory { 34 private static WebBundleDescriptor defaultWebXMLWbd = null; 35 private static boolean isParsingDefaultWebXML = false; 36 private static boolean isDefaultWebXMLInitialized = false; 37 38 private static Class dolLoadingContext = null; 39 private static final String DLC_CLASS_NAME = 40 "com.sun.enterprise.deployment.backend.DOLLoadingContext"; 41 private static final String DLC_METHOD_NAME = 42 "initDefaultWebBundleDescriptor"; 43 44 private static Logger _logger = 45 LogDomains.getLogger(LogDomains.DPL_LOGGER); 46 47 private static Class getDOLLoadingContext () { 48 try { 49 if (dolLoadingContext == null) { 50 dolLoadingContext = Class.forName(DLC_CLASS_NAME, 51 true, Thread.currentThread().getContextClassLoader()); 52 } 53 } catch (ClassNotFoundException cnfe) { 54 _logger.log(Level.WARNING, "enterprise.deployment.class.not.found", 55 new Object [] {DLC_CLASS_NAME}); 56 } 57 58 return dolLoadingContext; 59 } 60 61 65 public static WebBundleDescriptor getDefaultWebBundleDescriptor() { 66 if (defaultWebXMLWbd == null && !isDefaultWebXMLInitialized) { 70 initDefaultWebBundleDescriptor(); 71 } 72 73 WebBundleDescriptor defaultWebBundleDesc = 76 new WebBundleDescriptor(); 77 if (defaultWebXMLWbd != null) { 78 defaultWebBundleDesc.addWebBundleDescriptor(defaultWebXMLWbd); 79 } 80 return defaultWebBundleDesc; 81 } 82 83 87 private static void initDefaultWebBundleDescriptor() { 88 try { 90 Class dlcClass = getDOLLoadingContext(); 91 Method initWbdMethod = 92 dlcClass.getMethod(DLC_METHOD_NAME, new Class [0]); 93 if (initWbdMethod != null) { 94 defaultWebXMLWbd = 95 (WebBundleDescriptor)initWbdMethod.invoke(dlcClass, 96 new Object [0]); 97 } else { 98 _logger.log(Level.WARNING, 99 "enterprise.deployment.method.not.found", 100 new Object [] {DLC_METHOD_NAME}); 101 } 102 } catch (Exception e) { 103 _logger.log(Level.WARNING, e.getMessage()); 104 defaultWebXMLWbd = null; 105 } finally { 106 isDefaultWebXMLInitialized = true; 107 } 108 } 109 110 114 public static boolean isParsingDefaultWebXML() { 115 return isParsingDefaultWebXML; 116 } 117 118 123 public static void setParsingDefaultWebXML(boolean isDefault) { 124 isParsingDefaultWebXML = isDefault; 125 } 126 } 127 | Popular Tags |