當前位置: 首頁>>代碼示例>>Java>>正文


Java ExternalContext.getContext方法代碼示例

本文整理匯總了Java中javax.faces.context.ExternalContext.getContext方法的典型用法代碼示例。如果您正苦於以下問題:Java ExternalContext.getContext方法的具體用法?Java ExternalContext.getContext怎麽用?Java ExternalContext.getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.context.ExternalContext的用法示例。


在下文中一共展示了ExternalContext.getContext方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: _getServletContextFromFacesContext

import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
/**
 *Returns the servlet context object from the FacesContext
 * 
 * @param context
 * @return
 */
private Object _getServletContextFromFacesContext(FacesContext context)
{
  ExternalContext ec = null;
  Object sc = null;
  
  if (context != null)
  {
    ec = context.getExternalContext();
    
    if (ec != null)
    {
      sc = ec.getContext();
    }
  }
  
  return sc;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:24,代碼來源:ResourceServlet.java

示例2: getContentHandlerMap

import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
/**
* Returns the map of content handlers
* which hold the state of one XML tree.
* @param scopeMap
* @return
*/
 protected Map<Object, List<MenuContentHandler> > getContentHandlerMap()
 {
   FacesContext facesContext = FacesContext.getCurrentInstance();
   ExternalContext externalContext = facesContext.getExternalContext();
   Map<String, Object> scopeMap =
       externalContext.getApplicationMap();
  Object lock  = externalContext.getContext();
  
  // cannot use double checked lock here as
  // we cannot mark the reference as volatile
  // therefore any reads should happen inside
  // a synchronized block.
  synchronized (lock)
  {
    TransientHolder<Map<Object, List<MenuContentHandler> >> holder =  
      (TransientHolder<Map<Object, List<MenuContentHandler> >>) scopeMap.get(_CACHED_MODELS_KEY);
     Map<Object, List<MenuContentHandler>> contentHandlerMap = (holder != null) ? holder.getValue() : null;
     if (contentHandlerMap == null)
     {
       contentHandlerMap =
           new ConcurrentHashMap<Object, List<MenuContentHandler>>();
       scopeMap.put(_CACHED_MODELS_KEY, TransientHolder.newTransientHolder( contentHandlerMap) );
       scopeMap.put(_CACHED_MODELS_ID_CNTR_KEY,new AtomicInteger(-1));
     }
     return contentHandlerMap;
   }
   
 }
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:35,代碼來源:XMLMenuModel.java

示例3: SerializationChecker

import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
/**
 * Creates a SerializationChecker for this request
 * @param extContext               ExternalContext to use to initialize the SerializationChecker
 * @param checkSession If true check serializability of session attributes 
 * @param checkApplication if true, check serializability of application attributes
 * @param checkManagedBeanMutation if true, check for mutations to attributes in the session
 *                                 if checkSession is true and the application if
 *                                 checkApplication is true.
 */
private SerializationChecker(
  ExternalContext extContext,
  boolean checkSession,
  boolean checkApplication,
  boolean checkManagedBeanMutation,
  boolean checkSessionAtEnd)
{
  Map<String, Object> sessionMap = extContext.getSessionMap();
  Map<String, Object> applicationMap = extContext.getApplicationMap();
  
  if (checkManagedBeanMutation)
  {
    // note that the mutated bean checekd implicitly checks for attribute serialization as well.
    _sessionBeanChecker = new MutatedBeanChecker(sessionMap,
                                                 "Session",
                                                 extContext.getSession(true),
                                                 true);
    sessionMap = CollectionUtils.newMutationHookedMap(sessionMap, _sessionBeanChecker);
    
    // only check the application for mutations if the application checking is enabled
    if (checkApplication)
    {
      _applicationBeanChecker = new MutatedBeanChecker(applicationMap,
                                                       "Application",
                                                       extContext.getContext(),
                                                       false);
      applicationMap = CollectionUtils.newMutationHookedMap(applicationMap,
                                                            _applicationBeanChecker);
    }
    else
    {
      _applicationBeanChecker = null;
    }
  }
  else
  {
    _sessionBeanChecker     = null;
    _applicationBeanChecker = null;
    
    if (checkSession)
    {
      sessionMap = CollectionUtils.getCheckedSerializationMap(sessionMap, true);
    }

    if (checkApplication)
    {
      applicationMap =  CollectionUtils.getCheckedSerializationMap(applicationMap, false);
    }        
  }
        
  _sessionMap     = sessionMap;
  _applicationMap = applicationMap;
  _checkSessionAttrs = checkSessionAtEnd;
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:64,代碼來源:CheckSerializationConfigurator.java


注:本文中的javax.faces.context.ExternalContext.getContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。