< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/ContextClassloaderLocal.java

Print this page




  53     public void set(V instance) {
  54         CACHE.put(getContextClassLoader(), instance);
  55     }
  56 
  57     protected abstract V initialValue() throws Exception;
  58 
  59     private V createNewInstance() {
  60         try {
  61             return initialValue();
  62         } catch (Exception e) {
  63             throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
  64         }
  65     }
  66 
  67     private static String format(String property, Object... args) {
  68         String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
  69         return MessageFormat.format(text, args);
  70     }
  71 
  72     private static ClassLoader getContextClassLoader() {
  73         return (ClassLoader)
  74                 AccessController.doPrivileged(new PrivilegedAction() {
  75                     public Object run() {
  76                         ClassLoader cl = null;
  77                         try {
  78                             cl = Thread.currentThread().getContextClassLoader();
  79                         } catch (SecurityException ex) {
  80                         }
  81                         return cl;
  82                     }
  83                 });
  84     }
  85 }


  53     public void set(V instance) {
  54         CACHE.put(getContextClassLoader(), instance);
  55     }
  56 
  57     protected abstract V initialValue() throws Exception;
  58 
  59     private V createNewInstance() {
  60         try {
  61             return initialValue();
  62         } catch (Exception e) {
  63             throw new Error(format(FAILED_TO_CREATE_NEW_INSTANCE, getClass().getName()), e);
  64         }
  65     }
  66 
  67     private static String format(String property, Object... args) {
  68         String text = ResourceBundle.getBundle(ContextClassloaderLocal.class.getName()).getString(property);
  69         return MessageFormat.format(text, args);
  70     }
  71 
  72     private static ClassLoader getContextClassLoader() {
  73         return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
  74                     public ClassLoader run() {

  75                         ClassLoader cl = null;
  76                         try {
  77                             cl = Thread.currentThread().getContextClassLoader();
  78                         } catch (SecurityException ex) {
  79                         }
  80                         return cl;
  81                     }
  82                 });
  83     }
  84 }
< prev index next >