Project Wonder 5.0.0.8794

er.extensions.appserver
Class ERXApplication

java.lang.Object
  extended by com.webobjects.appserver.WOApplication
      extended by er.extensions.appserver.ajax.ERXAjaxApplication
          extended by er.extensions.appserver.ERXApplication
All Implemented Interfaces:
WOApplicationMBean, NSKeyValueCoding, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, ERXGracefulShutdown.GracefulApplication
Direct Known Subclasses:
Application, ERXMainRunner

public abstract class ERXApplication
extends ERXAjaxApplication
implements ERXGracefulShutdown.GracefulApplication

ERXApplication is the abstract superclass of WebObjects applications built with the ER frameworks.

Useful enhancements include the ability to change the deployed name of the application, support for automatic application restarting at given intervals and more context information when handling exceptions.


Nested Class Summary
static class ERXApplication.JarChecker
          Utility class to track down duplicate items in the class path.
static class ERXApplication.Loader
          Responsible for classpath munging.
 
Nested classes/interfaces inherited from class er.extensions.appserver.ajax.ERXAjaxApplication
ERXAjaxApplication.ERXAjaxResponseDelegate
 
Nested classes/interfaces inherited from class com.webobjects.appserver.WOApplication
WOApplication._EventLoggingEnabler, WOApplication.Event, WOApplication.TimeoutTask
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
 
Field Summary
protected static ERXFormatterFactory _formatterFactory
           
protected  boolean _initializedAdaptors
          Tracks whether or not _addAdditionalAdaptors has been called yet.
protected  WOTimer _killTimer
           
protected  BigDecimal _memoryLowThreshold
          Holds the value of the property er.extensions.ERXApplication.memoryLowThreshold
protected  BigDecimal _memoryStarvedThreshold
          Holds the value of the property er.extensions.ERXApplication.memoryStarvedThreshold
protected  String _replaceApplicationPathPattern
          The path rewriting pattern to match (@see _rewriteURL)
protected  String _replaceApplicationPathReplace
          The path rewriting replacement to apply to the matched pattern (@see _rewriteURL)
protected  Boolean _responseCompressionEnabled
           
protected  String _sslHost
          The SSL host used by this application.
protected  Integer _sslPort
          The SSL port used by this application.
protected  NSMutableArray<String> _streamingRequestHandlerKeys
          improved streaming support
protected  Boolean _useSessionStoreDeadlockDetection
          use the redirect feature
static String AllBundlesLoadedNotification
          Notification to post when all bundles were loaded but before their principal was called
static String ApplicationDidCreateNotification
          Notification to post when all bundles were loaded but before their principal was called
static Logger log
          logging support
static String LowMemoryNotification
          Notification to get posted when we get an OutOfMemoryError or when memory passes the low memory threshold set in er.extensions.ERXApplication.memoryLowThreshold.
static String LowMemoryResolvedNotification
          Notification to get posted when we have recovered from a LowMemory condition.
static Logger requestHandlingLog
          request logging support
static String StarvedMemoryNotification
          Notification to get posted when we are on the brink of running out of memory.
static String StarvedMemoryResolvedNotification
          Notification to get posted when we have recovered from a StarvedMemory condition.
static Logger statsLog
          statistic logging support
protected  Boolean useComponentActionRedirection
          use the redirect feature
 
Fields inherited from class er.extensions.appserver.ajax.ERXAjaxApplication
KEY_AJAX_SUBMIT_BUTTON, KEY_PARTIAL_FORM_SENDER_ID, KEY_UPDATE_CONTAINER_ID
 
Fields inherited from class com.webobjects.appserver.WOApplication
_adminRequestHandlerKey, _cgiAdaptorURLParsed, _classPathURLs, _launchServices, _terminating, _TheLastApplicationAccessTime, _unsetHost, _wasMainInvoked, ApplicationDidDispatchRequestNotification, ApplicationDidFinishLaunchingNotification, ApplicationWillDispatchRequestNotification, ApplicationWillFinishLaunchingNotification, CGIAdaptorURLProperty, DirectoryAliasProperty, DocumentRootProperty
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
 
Constructor Summary
ERXApplication()
          The ERXApplication contructor.
 
Method Summary
protected  void _addAdditionalAdaptors(NSMutableArray<NSDictionary<String,Object>> additionalAdaptors)
          Injects additional adaptors into the WOAdditionalAdaptors setting.
 com.webobjects.appserver._private.WOComponentDefinition _componentDefinition(String s, NSArray nsarray)
          Bugfix for WO component loading.
protected  WORequest _createRequest(String aMethod, String aURL, String anHTTPVersion, NSDictionary someHeaders, NSData aContent, NSDictionary someInfo)
          Bottleneck for WORequest creation in WO 5.3 and 5.4 to use an ERXRequest object that fixes a bug with localization.
protected  void _debugValueForDeclarationNamed(WOComponent component, String verb, String aDeclarationName, String aDeclarationType, String aBindingName, String anAssociationDescription, Object aValue)
           
protected static boolean _defaultIsDevelopmentMode()
          Returns whether or not this application is running in development-mode.
static void _endRequest()
          Cleans up the current thread after a request is complete.
 String _rewriteURL(String url)
          This method is called by ERXWOContext and provides the application a hook to rewrite generated URLs.
 void _setSslHost(String sslHost)
          Sets an SSL host override.
 void _setSslPort(int sslPort)
          Sets an SSL port override (called back by the ERXSecureAdaptor)
static void _startRequest()
          Initializes the current thread for a request.
 NSArray<NSDictionary<String,Object>> additionalAdaptors()
          Returns the additionalAdaptors, but calls _addAdditionalAdaptors to give the runtime an opportunity to programmatically force adaptors into the list.
 void appendToResponse(WOResponse response, WOContext context)
          Overridden to allow for redirected responses.
protected  void checkMemory()
           Checks if the free memory is less than the threshold given in er.extensions.ERXApplication.memoryStarvedThreshold (should be set to around 0.90 meaning 90% of total memory or 100 meaning 100 MB of minimal available memory) and if it is greater start to refuse new sessions until more memory becomes available.
protected  boolean checkMemory(BigDecimal memoryThreshold, boolean attemptGC)
           
 void clearDebugEnabledForAllComponents()
          Turns off binding debugging for all components.
 void configureStatisticsLogging()
          Configures the statistics logging for a given application.
 NSKeyValueCodingAdditions constants()
          Makes ERXConstants available for binding in the UI.
 WOContext createContextForRequest(WORequest request)
          When a context is created we push it into thread local storage.
 WORequest createRequest(String method, String aurl, String anHTTPVersion, Map<String,? extends List<String>> someHeaders, NSData content, Map<String,Object> someInfo)
          Creates the request object for this loop.
 WORequest createRequest(String aMethod, String aURL, String anHTTPVersion, NSDictionary someHeaders, NSData aContent, NSDictionary someInfo)
          Creates the request object for this loop.
 WOResourceManager createResourceManager()
           
 WOResponse createResponseInContext(WOContext context)
           
 WOSession createSessionForRequest(WORequest worequest)
          Overridden to check the sessions
 boolean debugEnabledForComponent(String componentName)
          Returns whether or not binding debugging is enabled for the given component
 ERXDelayedRequestHandler delayedRequestHandler()
          Returns the delayedRequestHandler, if any is registered.
 void didFinishLaunching()
          Called when the application posts WOApplication.ApplicationDidFinishLaunchingNotification.
 void didFinishLaunching(NSNotification n)
          Notification method called when the application posts the notification WOApplication.ApplicationDidFinishLaunchingNotification.
 String directConnectURL()
          Returns the directConnecURL, optionally rewritten.
 WOResponse dispatchRequest(WORequest request)
          Overridden to allow for redirected responses and null the thread local storage.
 WOResponse dispatchRequestImmediately(WORequest request)
          Dispatches the request without checking for the delayedRequestHandler()
static ERXApplication erxApplication()
          The ERXApplication singleton.
 NSMutableDictionary extraInformationForExceptionInContext(Exception e, WOContext context)
          Puts together a dictionary with a bunch of useful information relative to the current state when the exception occurred.
 void finishInitialization()
          Called when the application posts WOApplication.ApplicationWillFinishLaunchingNotification.
 void finishInitialization(NSNotification n)
          Notification method called when the application posts the notification WOApplication.ApplicationWillFinishLaunchingNotification.
 ERXFormatterFactory formatterFactory()
          Getting formatters into KVC: bind to application.formatterFactory.(60/#,##0.00)
 WOResponse genericHandleException(Exception exception, WOContext context)
          Standard exception page.
 void gracefulTerminate()
          Override to perform any last minute cleanup before the application terminates.
 WOResponse handleActionRequestError(WORequest aRequest, Exception exception, String reason, WORequestHandler aHandler, String actionClassName, String actionName, Class actionClass, WOAction actionInstance)
          Workaround for WO 5.2 DirectAction lock-ups.
 WOResponse handleException(Exception exception, WOContext context)
          Logs extra information about the current state.
 void handlePotentiallyFatalException(Exception exception)
          Handles the potentially fatal OutOfMemoryError by quitting the application ASAP.
 void installPatches()
          Installs several bufixes and enhancements to WODynamicElements.
static WOComponent instantiatePage(String pageName)
          Used to instantiate a WOComponent when no context is available, typically outside of a session
 WOActionResults invokeAction(WORequest request, WOContext context)
          Overridden to allow for redirected responses.
 boolean isDevelopmentMode()
          Returns whether or not this application is running in development-mode.
static boolean isDevelopmentModeSafe()
          Returns whether or not this application is in development mode.
static boolean isInRequest()
          Returns true if the current thread is dispatching a request.
 boolean isRefusingNewSessions()
          Overridden to return the super value OR true if the app is memory starved.
 boolean isStreamingRequestHandlerKey(String s)
           
static boolean isWO54()
          Returns true if this app is running in WO 5.4.
 void killInstance()
          Killing the instance will log a 'Forcing exit' message and then call System.exit(1)
 void logSetValueForDeclarationNamed(String aDeclarationName, String aDeclarationType, String aBindingName, String anAssociationDescription, Object aValue)
          Little bit better binding debug output than the original.
 void logTakeValueForDeclarationNamed(String aDeclarationName, String aDeclarationType, String aBindingName, String anAssociationDescription, Object aValue)
          Little bit better binding debug output than the original.
static void main(String[] argv, Class applicationClass)
          Called when the application starts up and saves the command line arguments for ERXConfigurationManager.
 ERXMigrator migrator()
          Returns an ERXMigrator with the lock owner name "appname-instancenumber".
 String name()
          Adds the ability to completely change the applications name by setting the System property ERApplicationName.
 String nameSuffix()
          The name suffix is appended to the current name of the application.
<T extends WOComponent>
T
pageWithName(Class<T> componentClass)
          Calls pageWithName with ERXWOContext.currentContext() for the current thread.
<T extends WOComponent>
T
pageWithName(Class<T> componentClass, WOContext context)
          Returns the component for the given class without having to cast.
 String rawName()
          This method returns WOApplication's name method.
 void refuseNewSessions(boolean value)
          Overridden to install/uninstall a timer that will terminate the application in ERTimeToKill seconds from the time this method is called.
protected  boolean refuseSessionsOnStarvedMemory()
          Override and return false if you do not want sessions to be refused when memory is starved.
 void registerStreamingRequestHandlerKey(String s)
           
 WOResponse reportException(Throwable exception, WOContext context, NSDictionary extraInfo)
          Reports an exception.
 boolean responseCompressionEnabled()
          checks the value of er.extensions.ERXApplication.responseCompressionEnabled and if true turns on response compression by gzip
 WOSession restoreSessionWithID(String sessionID, WOContext wocontext)
          Overridden to check the sessions
 boolean rewriteDirectConnectURL()
          Returns whether or not to rewrite direct connect URLs.
 void run()
          Adds support for automatic application cycling.
 void saveSessionForContext(WOContext wocontext)
          Overridden to check the sessions
 Number sessionTimeOutInMinutes()
           
 void setDebugEnabledForComponent(boolean debugEnabled, String componentName)
          Turns on/off binding debugging for the given component.
 void setDefaultEncoding(String encoding)
          Set the default encoding of the app (message encodings)
static void setup(String[] argv)
          Called prior to actually initializing the app.
 boolean sslEnabled()
          Returns whether or not DirectConnect SSL should be enabled.
 String sslHost()
          Returns the host name that will be used to bind the SSL socket to (defaults to host()).
 int sslPort()
          Returns the SSL port that will be used for DirectConnect SSL (defaults to 443).
 void startRefusingSessions()
          Stops the application from handling any new requests.
 Boolean traceOpenEditingContextLocks()
          Deprecated. use er.extensions.ERXEC.traceOpenLocks property instead
 boolean useComponentActionRedirection()
          Set the er.extensions.ERXComponentActionRedirector.enabled=true property to actually the redirect feature.
 Boolean useEditingContextUnlocker()
          Deprecated. use er.extensions.ERXEC.useUnlocker property instead
 boolean useSessionStoreDeadlockDetection()
          Deadlock in session-store detection.
 
Methods inherited from class er.extensions.appserver.ajax.ERXAjaxApplication
ajaxSubmitButtonName, cleanUpHeaders, forceStorePage, isAjaxRequest, isAjaxSubmit, partialFormSenderID, setForceStorePage, setResponseDelegate, shouldNotStorePage, shouldNotStorePage
 
Methods inherited from class com.webobjects.appserver.WOApplication
_addToExpectedLanguages, _allowsCacheControlHeader, _checksForSpecialHeaders, _componentDefinitionFromClassNamed, _debugString, _discountTerminatedSession, _expectedLanguages, _finishInitializingSession, _initializeSessionInContext, _isDebuggingEnabled, _isDomesticSupportedDevelopmentPlatform, _isForeignSupportedDevelopmentPlatform, _isPageRecreationEnabled, _isSupportedDevelopmentPlatform, _lockDefaultEditingContext, _newLocationForRequest, _openInitialURL, _parseCGIAdaptorURL, _quitTimer, _rapidTurnaroundActiveForAnyProject, _removeComponentDefinitionCacheContents, _runLoop, _sessionClass, _setAllowsCacheControlHeader, _setChecksForSpecialHeaders, _setHost, _setHostAddress, _setLifebeatDestinationPort, _setLockDefaultEditingContext, _terminateFromMonitor, _terminateOrResetTimer, activeSessionsCount, adaptor, adaptorExtensions, adaptorName, adaptorPath, adaptors, adaptorsDispatchRequestsConcurrently, adaptorWithName, ajaxRequestHandlerKey, allowsConcurrentRequestHandling, application, applicationBaseURL, applicationExtension, associationFactory, autoOpenClientApplication, autoOpenInBrowser, awake, baseURL, canAccessFieldsDirectly, cgiAdaptorURL, combinedComponentPathURL, componentRequestHandlerKey, contextClassName, createDefaultNamespaceProvider, debugString, defaultAdaptor, defaultRequestHandler, defaultRequestHandlerClassName, defaultUndoStackLimit, directActionRequestHandlerKey, documentRoot, dynamicElementWithName, frameworksBaseURL, getAdaptorsDispatchRequestsConcurrently, getAdditionalAdaptors, getAgentID, getAllowsConcurrentRequestHandling, getApplicationBaseURL, getApplicationExtension, getAutoOpenClientApplication, getBaseURL, getCGIAdaptorURL, getClassPaths, getComponentRequestHandlerKey, getDefaultAdaptor, getDefaultUndoStackLimit, getDirectConnectURL, getFrameworkVersions, getHost, getHostAddress, getIncludeCommentsInResponses, getIsCachingEnabled, getIsMonitorEnabled, getIsPageRefreshOnBacktrackEnabled, getIsRefusingNewSessions, getIsTerminating, getJMXDomain, getLifebeatDestinationPort, getLifebeatInterval, getListenQueueSize, getMaxSocketIdleTime, getMBeanServer, getMinimumActiveSessionsCount, getName, getOutputPath, getPageCacheSize, getPageFragmentCacheSize, getPort, getServletConnectURL, getSessionTimeOut, getTimeOut, getWebObjectsVersion, getWebserverConnectURL, getWorkerThreadCountMax, getWorkerThreadCountMin, handleMalformedCookieString, handlePageRestorationErrorInContext, handleQueryWithUnboundKey, handlerForRequest, handleSessionCreationErrorInContext, handleSessionRestorationErrorInContext, handleTakeValueForUnboundKey, host, hostAddress, includeCommentsInResponses, instanceIdKey, isCachingEnabled, isConcurrentRequestHandlingEnabled, isDebuggingEnabled, isDirectConnectEnabled, isMonitorEnabled, isPageRefreshOnBacktrackEnabled, isTerminating, launchArguments, licensedRequestLimit, licensedRequestWindow, licensingAllowsMultipleInstances, licensingAllowsMultipleThreads, lifebeatDestinationPort, lifebeatEnabled, lifebeatInterval, listenQueueSize, loadFrameworks, lock, logString, main, maxSocketIdleTime, minimumActiveSessionsCount, monitorEnabled, monitorHost, monitoringEnabled, namespaceProvider, newDynamicURL, newDynamicURL, number, outputPath, pageCacheSize, pageFragmentCacheSize, pageWithName, path,