为什么 JSF Mojarra 2.2 中存在 initContextServletContext FacesContext.java
why exist initContextServletContext in JSF Mojarra 2.2 FacesContext.java
private static ConcurrentHashMap initContextServletContext = new ConcurrentHashMap(2);
字段是私有的,但从未在 FacesContext 中使用过 class。有存在的理由吗?
它在 Mojarra 特定的 com.sun.faces.config.InitFacesContext
实现中通过反射访问,仅在容器初始化期间使用(行号匹配 Mojarra 2.2.11):
675 static Map getThreadInitContextMap() {
676 ConcurrentHashMap threadInitContext = null;
677 try {
678 Field threadMap = FacesContext.class.getDeclaredField("threadInitContext");
679 threadMap.setAccessible(true);
680 threadInitContext = (ConcurrentHashMap)threadMap.get(null);
681 } catch (Exception e) {
682 if (LOGGER.isLoggable(Level.FINEST)) {
683 LOGGER.log(Level.FINEST, "Unable to get (thread, init context) map", e);
684 }
685 }
686 return threadInitContext;
687 }
另请参阅:
private static ConcurrentHashMap initContextServletContext = new ConcurrentHashMap(2);
字段是私有的,但从未在 FacesContext 中使用过 class。有存在的理由吗?
它在 Mojarra 特定的 com.sun.faces.config.InitFacesContext
实现中通过反射访问,仅在容器初始化期间使用(行号匹配 Mojarra 2.2.11):
675 static Map getThreadInitContextMap() {
676 ConcurrentHashMap threadInitContext = null;
677 try {
678 Field threadMap = FacesContext.class.getDeclaredField("threadInitContext");
679 threadMap.setAccessible(true);
680 threadInitContext = (ConcurrentHashMap)threadMap.get(null);
681 } catch (Exception e) {
682 if (LOGGER.isLoggable(Level.FINEST)) {
683 LOGGER.log(Level.FINEST, "Unable to get (thread, init context) map", e);
684 }
685 }
686 return threadInitContext;
687 }