gpt4 book ai didi

org.apache.cocoon.components.flow.WebContinuation类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 03:15:05 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.cocoon.components.flow.WebContinuation类的一些代码示例,展示了WebContinuation类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebContinuation类的具体详情如下:
包路径:org.apache.cocoon.components.flow.WebContinuation
类名称:WebContinuation

WebContinuation介绍

[英]Representation of continuations in a Web environment.

Because a user may click on the back button of the browser and restart a saved computation in a continuation, each WebContinuation becomes the parent of a subtree of continuations.

If there is no parent WebContinuation, the created continuation becomes the root of a tree of WebContinuations.
[中]在Web环境中表示连续性。
由于用户可以单击浏览器的“上一步”按钮并在延续中重新启动已保存的计算,因此每个WebContinuation都将成为延续子树的父级。
如果没有父级WebContinuation,则创建的延续将成为WebContinuations树的根。

代码示例

代码示例来源:origin: org.apache.cocoon/cocoon-core

/**
 * Helper method to process a <jpath:continuation select=""/> element.
 *
 * @param a an <code>Attributes</code> value
 * @exception SAXException if an error occurs
 */
private void doContinuation(final Attributes a)
  throws SAXException {
  final String level = a.getValue(JPATH_CONTINUATION_SELECT);
  final String id = (level != null)
    ? m_kont.getContinuation(Integer.decode(level).intValue()).getId()
    : m_kont.getContinuation(0).getId();
  sendTextEvent(id);
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-api

/**
 * Debugging method.
 *
 * <p>Assumes the receiving instance as the root of a tree and
 * displays the tree of continuations.
 */
public void display() {
  getLogger().debug("\nWK: Tree" + display(0));
}

代码示例来源:origin: org.apache.cocoon/cocoon-flowscript-impl

/**
 * Return this continuation if it is valid, or first valid parent
 */
private FOM_WebContinuation findValidParent(FOM_WebContinuation wk) {
  if (wk != null) {
    WebContinuation wc = wk.getWebContinuation();
    while (wc != null && wc.disposed()) {
      wc = wc.getParentContinuation();
    }
    if (wc != null) {
      return new FOM_WebContinuation(wc);
    }
  }
  return null;
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-api

public void detachFromParent() {
    if (getParentContinuation() != null) {
      getParentContinuation().getChildren().remove(this);
    }
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

public String hasExpired() {
  if ((wc.getLastAccessTime() + wc.getTimeToLive()) < System
      .currentTimeMillis()) {
    return HAS_EXPIRED_YES;
  }
  return HAS_EXPIRED_NO;
}

代码示例来源:origin: org.apache.cocoon/cocoon-flowscript-impl

/**
   * Return text representation of the WebContinuation.
   */
  public String toString() {
    return "WC" + wk.getId();
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * Removes an expired leaf <code>WebContinuation</code> node
 * from its continuation tree, and recursively removes its
 * parent(s) if it they have expired and have no (other) children.
 * @param continuationsHolder
 *
 * @param wk <code>WebContinuation</code> node
 */
protected void removeContinuation(WebContinuationsHolder continuationsHolder,
    WebContinuation wk) {
  if (wk.getChildren().size() != 0) {
    return;
  }
  // remove access to this contination
  disposeContinuation(continuationsHolder, wk);
  _detach(wk);
  if (getLogger().isDebugEnabled()) {
    getLogger().debug("WK: Deleted continuation: " + wk.getId());
  }
  // now check if parent needs to be removed.
  WebContinuation parent = wk.getParentContinuation();
  if (null != parent && parent.hasExpired()) {
    //parent must have the same continuations holder, lookup not needed
    removeContinuation(continuationsHolder, parent);
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-ajax-impl

public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception {
  String continuationId;
  if (source == null) {
    continuationId = ObjectModelHelper.getRequest(objectModel).getParameter("continuation-id");
  } else {
    continuationId = source;
  }
  
  // The interpreter id is the sitemap's URI
  String interpreterId = SitemapParameters.getLocation(parameters).getURI();
  WebContinuation wk = this.contManager.lookupWebContinuation(continuationId, interpreterId);
  if (wk == null || wk.disposed()) {
    return null;
  } else {
    // Getting the continuation updates the last access time
    wk.getContinuation();
    FlowHelper.setWebContinuation(objectModel, newObjectModel, wk);
    return Collections.EMPTY_MAP;
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-flowscript-impl

public Continuation jsGet_continuation() {
  return (Continuation)wk.getContinuation();
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * Dump to Log file the current contents of
 * the expirations <code>SortedSet</code>
 */
protected void displayExpireSet() {
  StringBuffer wkSet = new StringBuffer("\nWK; Expire set size: " + expirations.size());
  Iterator i = expirations.iterator();
  while (i.hasNext()) {
    final WebContinuation wk = (WebContinuation) i.next();
    final long lat = wk.getLastAccessTime() + wk.getTimeToLive();
    wkSet.append("\nWK: ")
        .append(wk.getId())
        .append(" ExpireTime [");
    if (lat < System.currentTimeMillis()) {
      wkSet.append("Expired");
    } else {
      wkSet.append(lat);
    }
    wkSet.append("]");
  }
  getLogger().debug(wkSet.toString());
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

private void _invalidate(WebContinuationsHolder continuationsHolder, WebContinuation wk) {
  if (getLogger().isDebugEnabled()) {
    getLogger().debug("WK: Manual expire of continuation " + wk.getId());
  }
  disposeContinuation(continuationsHolder, wk);
  expirations.remove(wk);
  // Invalidate all the children continuations as well
  List children = wk.getChildren();
  int size = children.size();
  for (int i = 0; i < size; i++) {
    _invalidate(continuationsHolder, (WebContinuation) children.get(i));
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-api

/**
 * Return the ancestor continuation situated <code>level</code>s
 * above the current continuation. The current instance is
 * considered to be at level 0. The parent continuation of the
 * receiving instance at level 1, its parent is at level 2 relative
 * to the receiving instance. If <code>level</code> is bigger than
 * the depth of the tree, the root of the tree is returned.
 *
 * @param level an <code>int</code> value
 * @return a <code>WebContinuation</code> value
 */
public WebContinuation getContinuation(int level) {
  if (level <= 0) {
    updateLastAccessTime();
    return this;
  } else if (parentContinuation == null) {
    return this;
  } else {
    return parentContinuation.getContinuation(level - 1);
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

public WebContinuation lookupWebContinuation(String id, String interpreterId) {
  // REVISIT: Is the following check needed to avoid threading issues:
  // return wk only if !(wk.hasExpired) ?
  WebContinuationsHolder continuationsHolder = lookupWebContinuationsHolder(false);
  if (continuationsHolder == null)
    return null;
  
  WebContinuation kont = continuationsHolder.get(id);
  if (kont == null)
    return null;
    
  if (!kont.interpreterMatches(interpreterId)) {
    getLogger().error(
        "WK: Continuation (" + kont.getId()
            + ") lookup for wrong interpreter. Bound to: "
            + kont.getInterpreterId() + ", looked up for: "
            + interpreterId);
    return null;
  }
  return kont;
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * Detach this continuation from parent. This method removes
 * continuation from {@link #forest} set, or, if it has parent,
 * from parent's children collection.
 *
 * @param wk Continuation to detach from parent.
 */
protected void _detach(WebContinuation wk) {
  WebContinuation parent = wk.getParentContinuation();
  if (parent == null) {
    forest.remove(wk);
  } else 
    wk.detachFromParent();
}

代码示例来源:origin: org.apache.cocoon/cocoon-forms-impl

public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException {
  super.setup(resolver, objectModel, src, par);
  
  Request req = ObjectModelHelper.getRequest(objectModel);
  
  String continuationId = par.getParameter("continuation-id", req.getParameter("continuation-id"));
  String widgetPath = par.getParameter("widget", req.getParameter("widget")).replace('.', '/');
  this.filter = par.getParameter("filter", req.getParameter("filter"));
  
  // The interpreter id is the sitemap's URI
  String interpreterId = SitemapParameters.getLocation(parameters).getURI();
  wk = this.contManager.lookupWebContinuation(continuationId, interpreterId);
  if (wk == null || wk.disposed()) {
    throw new InvalidContinuationException("Cannot get continuation for suggestion list");
  }
  
  Form form = (Form)wk.getAttribute("form");
  if (form == null) {
    throw new ProcessingException("No form is attached to the continuation");
  }
  
  this.locale = form.getLocale();
  
  Field field = (Field)form.lookupWidget(widgetPath);
  list = field.getSuggestionList();
  if (list == null) {
    throw new ProcessingException(field + " has no suggestion list");
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-sitemap-impl

/**
 * When a new continuation is created in @link #createWebContinuation(Object, WebContinuation, int, String, ContinuationsDisposer),
 * its parent continuation is removed from the expiration set. This way only leaf continuations are part of
 * the expiration set.
 */
protected void handleParentContinuationExpiration(WebContinuation parent) {
  if (parent.getChildren().size() < 2) {
    expirations.remove(parent);
  }
}

代码示例来源:origin: org.apache.cocoon/cocoon-flowscript-impl

public void jsFunction_display() {
  wk.display();
}

代码示例来源:origin: org.apache.cocoon/cocoon-flowscript-impl

public FOM_WebContinuation jsGet_previousBookmark() {
  WebContinuation c = wk.getParentContinuation();
  if (c == null) {
    return null;
  }
  // If this is a continuation of sendPageAndWait()
  // and the immediate parent is a bookmark, then
  // it is the bookmark for this page, so skip it.
  if (!isBookmark(wk) && isBookmark(c)) {
    c = c.getParentContinuation();
  }
  while (c != null && !isBookmark(c)) {
    c = c.getParentContinuation();
  }
  if (c == null) {
    return null;
  }
  FOM_WebContinuation pwk = new FOM_WebContinuation(c);
  pwk.setParentScope(getParentScope());
  pwk.setPrototype(getClassPrototype(getParentScope(), pwk.getClassName()));
  return pwk;
}

代码示例来源:origin: org.apache.cocoon/cocoon-flowscript-impl

public void jsFunction_setBookmark(boolean value) {
  UserObject userObj = (UserObject)wk.getUserObject();
  if (userObj == null) {
    userObj = new UserObject();
    wk.setUserObject(userObj);
  }
  userObj.isBookmark = value;
}

代码示例来源:origin: org.apache.cocoon/cocoon-flowscript-impl

PageLocalScopeImpl getPageLocal() {
  UserObject userObj = (UserObject)wk.getUserObject();
  if (userObj == null) return null;
  return userObj.pageLocal;
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com