WebObjects 5.4.1

com.webobjects.appserver
Class WOApplication

java.lang.Object
  extended by com.webobjects.appserver.WOApplication
All Implemented Interfaces:
WOApplicationMBean, NSKeyValueCoding, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions

public class WOApplication
extends Object
implements NSKeyValueCoding, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, WOApplicationMBean

The primary role of the WOApplication class is to coordinate the handling of HTTP requests. Each application must have exactly one WOApplication object. The application object receives client requests from an HTTP server adaptor, manages the processing that generates a response, and returns that response to the adaptor. Typically, the response is an object representing a web page. The adaptor then packages the response in a form specific to the HTTP server that orginated the request and then forwards the response to that HTTP server.

In handling requests, an application object creates and manages one or more sessions. A session (represented by a WOSession object) dedicates resources to a period of access by a single user and stores persistent state during that period. Conceptually, each cycle of the request-response loop (or transaction) takes place within a session.

Besides mediating between the adaptor and the rest of the application during request handling, WOApplication performs many secondary functions. It returns pages based on component name, caches page instances and component definitions, provides some facilities for error handling and script debugging, coordinates the different levels of multi-threaded execution, and furnishes a variety of data.

Typical deployment schemes balance the processing load by having multiple application instances per web server adaptor. A single application can interact with multiple adaptors. For example, an application can simultaneously communicate with secure-socket adaptors and HTTP adaptors.

You can instantiate ready-made application objects from the WOApplication class or you can obtain the application object from a custom subclass of WOApplication. Custom WOApplication subclasses are common in WebObjects applications since there is often a need to override the awake, sleep, and request-handling methods. Compiled WOApplication subclasses can take any name, but if the name is anything other than "Application" you must implement your own main method to instantiate the application object from this class. However, if the class name is "Application", you don't need to modify main.

See Also:
awake(), sleep()

Nested Class Summary
static class WOApplication.Event
          This is a subclass of WOEvent used by the WebObjects runtime to collect pageWithName events.
protected  class WOApplication.TimeoutTask
          Replacement for WOTimer
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null<T>, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor
 
Field Summary
static String ApplicationDidDispatchRequestNotification
          Contains a String that names the notification posted at the end of WOApplication's dispatchRequest method.
static String ApplicationDidFinishLaunchingNotification
          Contains a String that names the notification posted by WOApplication's run method after the application is launched.
static String ApplicationWillDispatchRequestNotification
          Contains a String that names the notification posted at the very beginning of WOApplication's dispatchRequest method.
static String ApplicationWillFinishLaunchingNotification
          Contains a String that names the notification posted at the very beginning of WOApplication's run method.
static String CGIAdaptorURLProperty
           
static String DirectoryAliasProperty
           
static String DocumentRootProperty
           
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Constructor Summary
WOApplication()
          Creates and initializes the instance of WOApplication.
 
Method Summary
 int activeSessionsCount()
          The number returned is only accurate if the application stores state in the server's memory, which is the default.
 String adaptor()
          Returns the class name of the primary adaptor.
 String[] adaptorExtensions()
           
 String adaptorName()
           
 String adaptorPath()
           
 NSArray<WOAdaptor> adaptors()
          Returns a list of the loaded application adaptors.
 boolean adaptorsDispatchRequestsConcurrently()
          Return whether or not there is at least one multi-threaded adaptor which may attempt to dispatch requests concurrently.
 WOAdaptor adaptorWithName(String aClassName, NSDictionary<String,Object> anArgsDictionary)
          Invoked in the constructor to create an adaptor.
 NSArray<NSDictionary<String,Object>> additionalAdaptors()
          Returns an array of adaptor description dictionaries.
 String ajaxRequestHandlerKey()
          Returns the key which identifies URLs directed at the Ajax Handler for XMLHTTPRequests.
 boolean allowsConcurrentRequestHandling()
          Return whether or not concurrent request handling is allowed.
 void appendToResponse(WOResponse aResponse, WOContext aContext)
          The WOApplication object invokes this method on itself to initiate the final phase of request handling.
static WOApplication application()
          Return the application instance.
 String applicationBaseURL()
          This is the cover method for the property WOApplicationBaseURL.
 String applicationExtension()
           
 WOAssociationFactory associationFactory()
          Return the WOAssociationFactory for the application.
 WOAssociationFactoryRegistry associationFactoryRegistry()
          Return the WOAssociationFactoryRegistry for the application.
 boolean autoOpenClientApplication()
          Returns whether automatic client application launching is enabled for Java Client applications.
 boolean autoOpenInBrowser()
          Return whether starting the application instance will launch a browser pointing at the main page of the application.
 void awake()
          Invoked at the beginning of each cycle of the request-response loop, affording the opportunity to perform initializations with application-wide scope.
 String baseURL()
          Returns the application URL relative to the server's document root.
static boolean canAccessFieldsDirectly()
          WOApplication's implementation of this static method returns true, indicating that key-value coding is allowed to access fields in this object if an appropriate method isn't present.
 String cgiAdaptorURL()
          Returns the URL for the web server including the path to the WebObjects CGI adaptor: for example, http://localhost/cgi-bin/WebObjects.
protected  URL combinedComponentPathURL(WOResourceManager aResourceManager, String templateName, String aFrameworkName, String aLanguage, boolean refreshProjectOnCacheMiss)
           
 String componentRequestHandlerKey()
          Returns the key which identifies URLs directed at component-action based requests.
 String contextClassName()
          Defaults to WOContext.
 WOContext createContextForRequest(WORequest aRequest)
          Creates a new context object for a given request.
protected  WOAssociationFactoryRegistry createDefaultAssociationFactoryRegistry()
          Creates the default application association factory registry.
protected  WOMLDefaultNamespaceProvider createDefaultNamespaceProvider()
          Creates the default namespace provider, which provides the "wo" and "woq" namespaces to WOML templates.
 WORequest createRequest(String aMethod, String aURL, String anHTTPVersion, Map<String,? extends List<String>> someHeaders, NSData aContent, Map<String,Object> someInfo)
          Convenience method that instantiates and returns a new WORequest object.
 WOResourceManager createResourceManager()
          Creates a new instance of WOResourceManager.
 WOResponse createResponseInContext(WOContext aContext)
          Convenience method that instantiates and returns a new, empty WOResponse object.
 WOSession createSessionForRequest(WORequest aRequest)
          Creates and returns a WOSession object to manage a session for the client.
 void debugString(String aString)
          Deprecated. use NSLog instead.
 WOAdaptor defaultAdaptor()
          Returns the default application adaptor.
 WORequestHandler defaultRequestHandler()
          Returns the request handler to be used when no request handler key is found in the URL or WORequest.
 String defaultRequestHandlerClassName()
          Returns the class name of the default request handler.
 Number defaultUndoStackLimit()
          Return the number of levels of undo for a session's default editing context.
 String directActionRequestHandlerKey()
          Returns the key which identifies URLs directed at Direct Action based requests.
 String directConnectURL()
          Returns the URL to connect to the application directly without going through the web server and WOAdaptors.
 WOResponse dispatchRequest(WORequest aRequest)
          The starting point of the request-response cycle in WOApplication.
 String documentRoot()
          Returns the document root for static resources.
 WOElement dynamicElementWithName(String aName, NSDictionary<String,WOAssociation> someAssociations, WOElement anElement, NSArray<String> aLanguageArray)
          Creates and returns a WOElement object based on the element's name, a dictionary of associations, and a template of WOElements.
 String frameworksBaseURL()
          This value is used to determine URLs that should be generated to reference Web Server Resources in those frameworks.
 boolean getAdaptorsDispatchRequestsConcurrently()
          JMX Support
 ArrayList<HashMap<String,Object>> getAdditionalAdaptors()
          JMX Support
 String getAgentID()
          Return the agentid for app instance where agentid=[your_unique_id_for_your_instance] Used for sticky session support.
 boolean getAllowsConcurrentRequestHandling()
          JMX Support
 String getApplicationBaseURL()
          JMX support
 String getApplicationExtension()
          JMX support
 boolean getAutoOpenClientApplication()
          JMX Support
 String getBaseURL()
          JMX Support
 String getCGIAdaptorURL()
          JMX Support
 ArrayList<String> getClassPaths()
          Return a list of URI formatted classpaths used at bootstrap time by the classloader.
 String getComponentRequestHandlerKey()
          JMX Support
 String getDefaultAdaptor()
          JMX Support
 int getDefaultUndoStackLimit()
          JMX Support
 String getDirectConnectURL()
          JMX Support
 HashMap<String,String> getFrameworkVersions()
          Return versions of NSBundle-aware frameworks or jars found at runtime.
 String getHost()
          JMX support
 String getHostAddress()
          JMX Support
 boolean getIncludeCommentsInResponses()
          JMX Support
 boolean getIsCachingEnabled()
          JMX Support
 boolean getIsMonitorEnabled()
           
 boolean getIsPageRefreshOnBacktrackEnabled()
          JMX Support
 boolean getIsRefusingNewSessions()
          JMX Support
 boolean getIsTerminating()
          JMX Support
 String getJMXDomain()
          The default JMX domain is composed of the host + app name + port number.
 int getLifebeatDestinationPort()
          JMX Support
 int getLifebeatInterval()
          JMX Support
 int getListenQueueSize()
          JMX Support
 int getMaxSocketIdleTime()
          JMX Support
 MBeanServer getMBeanServer()
          Return an instance of the MBeanserver.
 int getMinimumActiveSessionsCount()
          JXM Support
 String getName()
          JMX Support
 String getOutputPath()
          JMX Support
 int getPageCacheSize()
          JMX Support
 int getPageFragmentCacheSize()
          JMX Support
 int getPort()
          JMX Support
 String getServletConnectURL()
          JMX Support
 int getSessionTimeOut()
          JMX Support
 double getTimeOut()
          JMX Support
 String getWebObjectsVersion()
          Current version number.
 String getWebserverConnectURL()
          JMX Support
 int getWorkerThreadCountMax()
          JMX Support
 int getWorkerThreadCountMin()
          JMX Support
 WOResponse handleActionRequestError(WORequest aRequest, Exception exception, String reason, WORequestHandler aHandler, String actionClassName, String actionName, Class actionClass, WOAction actionInstance)
          Invoked when an action handler throws an exception in handleRequest.
 WOResponse handleException(Exception anException, WOContext aContext)
          Invoked when an unexpected exception is thrown in the request-response loop.
 NSMutableDictionary<String,NSMutableArray<String>> handleMalformedCookieString(RuntimeException anException, String cookieString, NSMutableDictionary<String,NSMutableArray<String>> aReturnDict)
          Invoked when a malformed cookie is parsed.
 WOResponse handlePageRestorationErrorInContext(WOContext aContext)
          Invoked when a page (WOComponent) instance cannot be restored, which typically happens when a user backtracks too far.
 Object handleQueryWithUnboundKey(String key)
          Conformance to NSKeyValueCoding.ErrorHandling.
 WORequestHandler handlerForRequest(WORequest aRequest)
          Returns the request handler to be used to handle a given request.
 WOResponse handleSessionCreationErrorInContext(WOContext aContext)
          Invoked by the component request handler when a session (WOSession) instance cannot be created.
 WOResponse handleSessionRestorationErrorInContext(WOContext aContext)
          Invoked when a session (WOSession) instance cannot be restored, which typically happens when the session times out.
 void handleTakeValueForUnboundKey(Object value, String key)
          Conformance to NSKeyValueCoding.ErrorHandling.
 String host()
          Return the name of the host the instance is running on.
 InetAddress hostAddress()
          Return the InetAddress for the host returned by host.
 boolean includeCommentsInResponses()
          Returns whether or not HTML comments are appended to the response.
 String instanceIdKey()
          String key used to obtain the application instance number from a request using methods like formValueForKey(String) and cookieValueForKey(String).
 WOActionResults invokeAction(WORequest aRequest, WOContext aContext)
          The WOApplication object invokes this method on itself to initiate the middle phase of request handling.
 boolean isCachingEnabled()
          Returns whether or not component caching is enabled.
 boolean isConcurrentRequestHandlingEnabled()
          Returns true if at least one adaptor may dispatch requests concurrently and allowsConcurrentRequestHandling returns true.
 boolean isDebuggingEnabled()
          Do not use.
 boolean isDirectConnectEnabled()
          Returns whether or not direct connect is enabled.
 boolean isMonitorEnabled()
          This is a cover method for the property WOMonitorEnabled.
 boolean isPageRefreshOnBacktrackEnabled()
          Returns whether caching of pages is disabled in the client.
 boolean isRefusingNewSessions()
          Returns true if the application instance is refusing new sessions, and false otherwise.
 boolean isTerminating()
          Returns whether the application will terminate at the end of the current request-response loop.
 String[] launchArguments()
          Returns a String array of launch arguments.
static int licensedRequestLimit()
          Deprecated. There is no license key
static long licensedRequestWindow()
          Deprecated. There is no license key
static boolean licensingAllowsMultipleInstances()
          Deprecated. There is no license key
static boolean licensingAllowsMultipleThreads()
          Deprecated. There is no license key
 int lifebeatDestinationPort()
          Returns the port to which lifebeat signals will be sent.
 boolean lifebeatEnabled()
          Return whether or not the application is sending lifebeats.
 int lifebeatInterval()
          Return the interval at which the application instance will send lifebeat signals to wotaskd.
 Number listenQueueSize()
          Returns the size of the listen queue which will created by the primary adaptor, usually WODefaultAdaptor.
 NSArray loadFrameworks()
          Return the NSArray of frameworks to be loaded during application initialization.
 void lock()
          Deprecated. synchronized(WOApplication.application()) should be used instead.
 void logSetValueForDeclarationNamed(String aDeclarationName, String aDeclarationType, String aBindingName, String anAssociationDescription, Object aValue)
          Formats and logs a message anytime a value is set through a WOAssociation, when WODebug is set to true for the declaration in which the association appears.
 void logString(String aString)
          Deprecated. Use NSLog instead
 void logTakeValueForDeclarationNamed(String aDeclarationName, String aDeclarationType, String aBindingName, String anAssociationDescription, Object aValue)
          Formats and logs a message anytime a value is taken through a WOAssociation, when WODebug is set to true for the declaration in which the association appears.
static void main(String[] argv)
          The WebObjects application's main method.
static void main(String[] argv, Class applicationClass)
          An alternate main method for the WebObjects applications that allows you to specify a subclass of WOApplication to be instantiated and run instead of WOApplication.
 Number maxSocketIdleTime()
          Returns the maximum interval in milliseconds for which a socket should be allowed to wait on incoming data.
 int minimumActiveSessionsCount()
          If the number of active sessions is less than or equal to this number and isRefusingNewSessions returns true, the application instance terminates.
 boolean monitorEnabled()
          Deprecated. monitorEnabled no longer supported
 String monitorHost()
          Deprecated. monitorHost no longer supported
 boolean monitoringEnabled()
          Deprecated. monitoringEnabled is no longer supported
 String name()
          Returns the name of the application, which is the value of the WOApplicationName property.
 WOMLNamespaceProvider namespaceProvider()
           
 WODynamicURL newDynamicURL()
          Create a new dynamic URL for the WORequest.
 WODynamicURL newDynamicURL(String url)
          Create a new dynamic URL for the WORequest.
 String number()
          Provided for backwards compatibility only.
 String outputPath()
          Return the path to which logs will be written.
 int pageCacheSize()
          Provides the size of the default page cache.
 int pageFragmentCacheSize()
          Provides the size of the default page fragments cache.
 WOComponent pageWithName(String aName, WOContext aContext)
          Returns a new page instance (a WOComponent object) identified by aName.
 String path()
          Returns the file system path of the application, which is an absolute path and includes the .woa extension; for example "C:/NETSCAPE/ns-home/docs/WebObjects/Examples/HelloWorld.woa" is a typical application path.
 int permanentPageCacheSize()
          Provides the size of the permanent page cache.
 Number port()
          Returns the port number on which the primary adaptor will listen This is the cover method for the property WOPort.
static void primeApplication(String mainBundlePath, String nameOfApplicationSubclass)
          Deprecated. use primeApplication(String, URL, String) instead.
static void primeApplication(String mainBundleName, URL mainBundlePathURL, String nameOfApplicationSubclass)
          This is used when calling into WebObjects programmatically (typically to use responseForComponentWithName) rather than running a WebObjects application standalone.
 boolean printsHTMLParserDiagnostics()
          Deprecated. See com.webobjects.foundation.NSLog
 NSArray projectSearchPath()
          Returns an array of file system paths which are searched for projects for rapid turnaround mode.
 String recordingPath()
          Returns a file system path which is where the recording information should be saved.
 void refuseNewSessions(boolean aVal)
          Controls whether this application instance will create a session when it receives an HTTP request from a new user.
 NSArray registeredRequestHandlerKeys()
          Returns an array of Strings containing the keys of all of the registered request handlers.
 void registerMBean(Object aMBean, ObjectName aName)
          Convenience to register an MBean with the MBean server.
 void registerMBean(Object aMBean, String aDomainName, String aMBeanName)
          Convenience to register an MBean with the MBean server.
 void registerRequestHandler(WORequestHandler aHandler, String aRequestHandlerKey)
          Registers a new request handler.
 WORequestHandler removeRequestHandlerForKey(String aRequestHandlerKey)
          Removes the specified request handler from the application.
 WORequestHandler requestHandlerForKey(String aKey)
          Returns the request handler used to handle requests containing the specified key.
 Object requestHandlingLock()
          Returns an Object suitable for a synchronization lock or null if the application isn't multithreaded.
 WOResourceManager resourceManager()
          Returns the WOResourceManager object that the application uses to manage resources.
 String resourceRequestHandlerKey()
          Resource requests are only used during development of an application or when the application is being run without an HTTP server.
 WOResponse responseForComponentWithName(String name, Map<String,Object> bindings, Map<String,? extends List<String>> headers, Map<String,Object> userInfo, String uriPrefix, String appName)
          Returns a WOResponse for the WOComponent named name, using bindings.
 WOResponse responseForDirectActionWithNameAndClass(String actionName, String className, Map<String,Object> formValueDict, InputStream contentStream, Map<String,? extends List<String>> headers, Map<String,Object> userInfo, String uriPrefix, String appName)
          Returns a WOResponse for the Direct Action actionName in the class named className (optional).
 WOSession restoreSessionWithID(String aSessionID, WOContext aContext)
          Restores the WOSession object representing a session.
 void run()
          Runs the application in a near-indefinite run loop in the default run-loop mode.
 void saveSessionForContext(WOContext aContext)
          Called at the end of the request handling loop when the current session object needs to be saved.
 String servletConnectURL()
          Returns the URL to connect to the application through a servlet container.
 String sessionIdKey()
          Return the string key used to obtain the session ID from a request using methods like formValueForKey(String) and cookieValueForKey(String).
 WOSessionStore sessionStore()
          Returns the application's current WOSessionStore object.
 String sessionStoreClassName()
          Return the name of the class that will be used to store sessions.
 Number sessionTimeOut()
          Return the number of seconds for which a session may be idle before it times out.
 void setAdaptor(String aString)
          Deprecated. Use the system property WOAdaptor instead
 void setAdditionalAdaptors(NSArray<NSDictionary<String,Object>> anAdaptorArray)
          Deprecated. Use the system property WOAdditionalAdaptors instead
 void setAllowsConcurrentRequestHandling(boolean aValue)
          Explicitly specifiy whether concurrent request handling is allowed.
 void setApplicationBaseURL(String aString)
          Sets to aString the path to which the current application may be found under the document root, with or without the .woa.
 void setAutoOpenClientApplication(boolean aBool)
          Controls whether starting up an application instance also launches a Java Client client application.
 void setAutoOpenInBrowser(boolean aBool)
          Controls whether starting up this application also launches a web browser.
 void setCachingEnabled(boolean aBool)
          Sets whether or not component caching is enabled.
 void setCGIAdaptorURL(String aString)
          Sets the URL through the web server to aString.
 void setComponentRequestHandlerKey(String aString)
          Deprecated. Use the system property _ComponentRequestHandlerKey instead
 void setContextClassName(String name)
          Sets the name of the WOContext subclass class.
 void setDefaultRequestHandler(WORequestHandler aRequestHandler)
          Sets the default request handler.
 void setDefaultUndoStackLimit(int stackLimit)
          Set the limit size for the undo stack for a session's default editing context.
 void setDirectActionRequestHandlerKey(String aString)
          Deprecated. Use the system property _DirectActionRe