Package com.webobjects.appserver

Examples of com.webobjects.appserver.WOContext


   * </span>
   */
    @Override
  public void _saveCurrentPage() {
    if(overridePrivateCache) {
      WOContext _currentContext = context();
      if (_currentContext != null) {
        String contextID = context().contextID();
        if (logger.isDebugEnabled()) logger.debug("Saving page for contextID: " + contextID);
        WOComponent currentPage = _currentContext._pageComponent();
        if (currentPage != null && currentPage._isPage()) {
          WOComponent permanentSenderPage = _permanentPageWithContextID(_currentContext._requestContextID());
          WOComponent permanentCurrentPage = _permanentPageWithContextID(contextID);
          if (permanentCurrentPage == null && _permanentPageCache().containsValue(currentPage)) {
            // AK: note that we put it directly in the cache, not bothering with
            // savePageInPermanentCache() as this one would clear out the old IDs
            _permanentPageCache.setObjectForKey(currentPage, contextID);
View Full Code Here


  // FIXME: ak: as we save the perm pages under a lot of context IDs, we should have a way to actually limit the size...
  // not sure how, though
    @Override
  public void savePageInPermanentCache(WOComponent wocomponent) {
    if(overridePrivateCache) {
      WOContext wocontext = context();
      String contextID = wocontext.contextID();
      if (logger.isDebugEnabled()) logger.debug("Saving page for contextID: " + contextID);
      NSMutableDictionary permanentPageCache = _permanentPageCache();
      for (int i = WOApplication.application().permanentPageCacheSize(); _permanentContextIDArray.count() >= i; _permanentContextIDArray.removeObjectAtIndex(0)) {
        String s1 = (String) _permanentContextIDArray.objectAtIndex(0);
        WOComponent page = (WOComponent) permanentPageCache.removeObjectForKey(s1);
View Full Code Here

    if (page == null) {
      page = super.restorePageForContextID(contextID);
    }

    if (page != null) {
      WOContext context = page.context();
      if(context == null) {
          page._awakeInContext(context());
          context = page.context();
      }
      WORequest request = context.request();
      // MS: I suspect we don't have to do this all the time, but I don't know if we have
      // enough information at this point to know whether to do it or not, unfortunately.
      if (request != null) {
        request.setHeader(contextID, ERXAjaxSession.ORIGINAL_CONTEXT_ID_KEY);
      }
View Full Code Here

    return aResponse;
  }

  WOResponse _handleRequest(WORequest aRequest)
  {
    WOContext aContext = null;
    WOResponse aResponse;

    NSDictionary requestHandlerValues = requestHandlerValuesForRequest(aRequest);

    WOApplication anApplication = WOApplication.application();
    String aSessionID = (String)requestHandlerValues.objectForKey(WOApplication.application().sessionIdKey());

    if ((!anApplication.isRefusingNewSessions()) || (aSessionID != null)) {
      String aSenderID = (String)requestHandlerValues.objectForKey("woeid");

      String oldContextID = (String)requestHandlerValues.objectForKey("wocid");

      WOStatisticsStore aStatisticsStore = anApplication.statisticsStore();
      if (aStatisticsStore != null)
        aStatisticsStore.applicationWillHandleComponentActionRequest();

      try {
        aContext = anApplication.createContextForRequest(aRequest);

        aContext._setRequestContextID(oldContextID);
        aContext._setSenderID(aSenderID);
        anApplication.awake();
        aResponse = _dispatchWithPreparedApplication(anApplication, aContext, requestHandlerValues);
        NSNotificationCenter.defaultCenter().postNotification(WORequestHandler.DidHandleRequestNotification, aContext);

        anApplication.sleep();
      }
      catch (Exception exception)
      {
        try
        {
          NSLog.err.appendln("<" + getClass().getName() + ">: Exception occurred while handling request:\n" + exception.toString());
          if (NSLog.debugLoggingAllowedForLevelAndGroups(1, 4L)) {
            NSLog.debug.appendln(exception);
          }

          if (aContext == null)
            aContext = anApplication.createContextForRequest(aRequest);
          else {
            aContext._putAwakeComponentsToSleep();
          }
          WOSession aSession = aContext._session();
          aResponse = anApplication.handleException(exception, aContext);
          if (aSession != null)
          {
            try
            {
              anApplication.saveSessionForContext(aContext);
              anApplication.sleep();
            } catch (Exception eAgain) {
              NSLog.err.appendln("<WOApplication '" + anApplication.name() + "'>: Another Exception  occurred while trying to clean the application:\n" + eAgain.toString());
              if (NSLog.debugLoggingAllowedForLevelAndGroups(1, 4L))
                NSLog.debug.appendln(eAgain);
            }
          }
        }
        finally
        {
          if ((aContext != null) && (aContext._session() != null))
            anApplication.saveSessionForContext(aContext);
        }
      }
      if (aResponse != null) {
        aResponse._finalizeInContext(aContext);
      }

      if (aStatisticsStore != null) {
        WOComponent aPage = aContext.page();
        String aName = null;
        if (aPage != null) {
          aName = aPage.name();
        }
        aStatisticsStore.applicationDidHandleComponentActionRequestWithPageNamed(aName);
View Full Code Here

            // worker thread that's been calling the current handleRequest method.
            WOSession session;
            if(false) {
                // ak only enable when fixed
                // as we will create deadlocks checking out the session this early.
                WOContext context = ERXWOContext.currentContext();
                session = context != null ? context.session() : null;
            } else {
                session = ERXSession.anySession();   // get it from the thread specific storage
            }

            if (session != null  &&  session instanceof ERXSession) {
View Full Code Here

    private static final Logger log = Logger.getLogger(ERXAbstractPerformWOAction.class);

    public ERXAbstractPerformWOAction() {
        if (log.isDebugEnabled()) {
            WOContext context = ERXWOContext.currentContext();
            pageNameThatCreated = (context == null ? "Unknown" : context.page().name());
            log.info("Controller named '" + getClass().getName() + "' just instantiated in page named '" + pageNameThatCreated + "'");
        }
    }
View Full Code Here

   * </span>
   */
  protected String _componentContentString(WOComponent component) {
    String contentString = null;
    if (component != null) {
      WOContext context = component.context();

      // CHECKME: It's probably not a good idea to do this here
      // since the context could also have been generating relative URLs
      // unless the context is created from scratch
      context.generateCompleteURLs();
      WOMessage response = component.generateResponse();
      contentString = response.contentString();
    }
    return contentString;
  }
View Full Code Here

   *            the key to push the partial as
   * @return the new ERXResponse to write to
   */
  public static ERXResponse pushPartial(String key) {
    Context context = currentContext();
    WOContext wocontext = ERXWOContext.currentContext();
    context.stack.push((ERXResponse) wocontext.response());
    ERXResponse response = context.partials.get(key);
    if (response == null) {
      response = new ERXResponse(wocontext);
      context.partials.put(key, response);
    }
    wocontext._setResponse(response);
    return response;
  }
View Full Code Here

   * @return the previous partial
   */
  public static ERXResponse popPartial() {
    Context context = currentContext();
    ERXResponse response = context.stack.pop();
    WOContext wocontext = ERXWOContext.currentContext();
    wocontext._setResponse(response);
    return response;
  }
View Full Code Here

   * Returns an array of the current component names.
   *
   * @return array of current component names
   */
  public static NSArray<String> componentTree() {
    WOContext context = ERXWOContext.currentContext();
    NSMutableArray<String> result = new NSMutableArray<String>();
    if (context != null) {
      WOComponent c = context.component();
      while (c != null) {
        result.addObject(c.name());
        c = c.parent();
      }
    }
View Full Code Here

TOP

Related Classes of com.webobjects.appserver.WOContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.