当前位置: 首页>>代码示例>>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;未经允许,请勿转载。