Java Code Examples for java.util.Collections.asLifoQueue()

The following are Jave code examples for showing how to use asLifoQueue() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: myfaces-trinidad   File: UIXDocumentTemplate.java   View Source Code Vote up 6 votes
/**
 * Suspends any context changes before allowing invokeOnComponent or visitTree calls to continue,
 * allowing components to undo any context changes during a re-entrant call.
 * @param facesContext the faces context
 * @see ComponentContextManager#suspend(FacesContext)
 */
@Override
protected void setupVisitingContext(FacesContext facesContext)
{
  ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
    .getComponentContextManager();

  // Suspend any current component context during a visit tree for re-entrant
  // component tree processing
  SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);

  Map<String, Object> reqMap = facesContext.getExternalContext().getRequestMap();
  @SuppressWarnings("unchecked")
  Queue<SuspendedContextChanges> suspendedChangesQueue = (Queue<SuspendedContextChanges>)
    reqMap.get(_SUSPENDED_CHANGES_KEY);
  if (suspendedChangesQueue == null)
  {
    suspendedChangesQueue = Collections.asLifoQueue(new ArrayDeque<SuspendedContextChanges>());
    reqMap.put(_SUSPENDED_CHANGES_KEY, suspendedChangesQueue);
  }

  suspendedChangesQueue.offer(suspendedChanges);
  _LOG.fine("UIXDocument suspended context changes in setupVisitingContext");

  super.setupVisitingContext(facesContext);
}
 
Example 2
Project: myfaces-trinidad   File: HtmlBodyTemplate.java   View Source Code Vote up 6 votes
/**
 * Suspends any context changes before allowing invokeOnComponent or visitTree calls to continue,
 * allowing components to undo any context changes during a re-entrant call.
 * @param facesContext the faces context
 * @see ComponentContextManager#suspend(FacesContext)
 */
@Override
protected void setupVisitingContext(FacesContext facesContext)
{
  ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
    .getComponentContextManager();

  // Suspend any current component context during a visit tree for re-entrant
  // component tree processing
  SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);

  Map<String, Object> reqMap = facesContext.getExternalContext().getRequestMap();
  @SuppressWarnings("unchecked")
  Queue<SuspendedContextChanges> suspendedChangesQueue = (Queue<SuspendedContextChanges>)
    reqMap.get(_SUSPENDED_CHANGES_KEY);
  if (suspendedChangesQueue == null)
  {
    suspendedChangesQueue = Collections.asLifoQueue(new ArrayDeque<SuspendedContextChanges>());
    reqMap.put(_SUSPENDED_CHANGES_KEY, suspendedChangesQueue);
  }

  suspendedChangesQueue.offer(suspendedChanges);

  super.setupVisitingContext(facesContext);
}
 
Example 3
Project: myfaces-trinidad   File: HtmlHeadTemplate.java   View Source Code Vote up 6 votes
/**
 * Suspends any context changes before allowing invokeOnComponent or visitTree calls to continue,
 * allowing components to undo any context changes during a re-entrant call.
 * @param facesContext the faces context
 * @see ComponentContextManager#suspend(FacesContext)
 */
@Override
protected void setupVisitingContext(FacesContext facesContext)
{
  ComponentContextManager ctxMgr = RequestContext.getCurrentInstance()
    .getComponentContextManager();

  // Suspend any current component context during a visit tree for re-entrant
  // component tree processing
  SuspendedContextChanges suspendedChanges = ctxMgr.suspend(facesContext);

  Map<String, Object> reqMap = facesContext.getExternalContext().getRequestMap();
  @SuppressWarnings("unchecked")
  Queue<SuspendedContextChanges> suspendedChangesQueue = (Queue<SuspendedContextChanges>)
    reqMap.get(_SUSPENDED_CHANGES_KEY);
  if (suspendedChangesQueue == null)
  {
    suspendedChangesQueue = Collections.asLifoQueue(new ArrayDeque<SuspendedContextChanges>());
    reqMap.put(_SUSPENDED_CHANGES_KEY, suspendedChangesQueue);
  }

  suspendedChangesQueue.offer(suspendedChanges);

  super.setupVisitingContext(facesContext);
}
 
Example 4
Project: myfaces-trinidad   File: ComponentContextManagerImpl.java   View Source Code Vote up 5 votes
public void pushChange(ComponentContextChange change)
{
  if (_stack == null)
  {
    _stack = Collections.asLifoQueue(new ArrayDeque<ComponentContextChange>());
  }

  _stack.offer(change);

  if (_LOG.isFine())
  {
    _LOG.fine("Component context change pushed onto the stack. Change: {0}. New stack size: {1}",
      new Object[] { change, _stack.size() });
  }
}
 
Example 5
Project: util   File: QueueUtil.java   View Source Code Vote up 2 votes
/**
 * 支持后进先出的栈,用ArrayDeque实现, 经过Collections#asLifoQueue()转换顺序
 * 
 * 需设置初始长度,默认为16,数组满时成倍扩容
 * 
 * @see Collections#asLifoQueue()
 */
public static <E> Queue<E> createStack(int initSize) {
	return Collections.asLifoQueue(new ArrayDeque<E>(initSize));
}
 
Example 6
Project: util   File: QueueUtil.java   View Source Code Vote up 2 votes
/**
 * 支持后进先出的并发栈,用ConcurrentLinkedDeque实现,经过Collections#asLifoQueue()转换顺序
 * 
 * 另对于BlockingQueue接口, JDK暂无Lifo倒转实现,因此只能直接使用未调转顺序的LinkedBlockingDeque
 * 
 * @see Collections#asLifoQueue()
 */
@SuppressWarnings("unchecked")
public static <E> Queue<E> createConcurrentStack() {
	return (Queue<E>) Collections.asLifoQueue(newConcurrentNonBlockingDeque());
}