Documentation Archive Developer
Search
[an error occurred while processing this directive] PATH  Documentation > WebObjects 4.5 > WebObjects Reference

Table of Contents

WOApplication


Inherits from: NSObject
Conforms to: NSObject
(NSObject)
Declared in: WebObjects/WOApplication.h




Class Description


The primary role of the WOApplication class is to coordinate the handling of HTTP requests. Each application must have exactly one WOApplication object (or, simply, application object). The application object receives client requests from an HTTP server adaptor, manages the processing that generates a response, and returns that response-typically an object representing a web page-to the adaptor. The adaptor, in turn, forwards the response in a suitable form to the HTTP server that originated the request.

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 acting as a facilitator 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 server adaptor. A single application, in turn, can interact with multiple adaptors; for example, an application can simultaneously communicate with secure-socket and Distributed Object adaptors as well as 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, init, 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 function to instantiate the application object from this class. However, if the class name is "Application," you don't need to modify main. In scripted applications, the code in the Application.wos file becomes the implementation logic of a WOApplication subclass automatically created at run time; the application object is instantiated from this subclass.




Adopted Protocols


NSLocking
- lock
- unlock


Method Types


Creating
- init
+ application
Obtaining attributes
- adaptorsDispatchRequestsConcurrently
- allowsConcurrentRequestHandling
- isConcurrentRequestHandlingEnabled
- baseURL
- name
- number
- path
Locking
- lock
- unlock
- lockRequestHandling
- unlockRequestHandling
Managing adaptors
- adaptorWithName:arguments:
- adaptors
Managing cache
- setCachingEnabled:
- isCachingEnabled
Managing sessions
- setSessionStore:
- sessionStore
- saveSessionForContext:
- restoreSessionWithID:inContext:
- createSessionForRequest:
Managing pages
- setPageCacheSize:
- pageCacheSize
- permanentPageCacheSize
- setPermanentPageCacheSize:
- setPageRefreshOnBacktrackEnabled:
- isPageRefreshOnBacktrackEnabled
- pageWithName:forRequest:
- pageWithName:inContext:
Creating elements
- dynamicElementWithName:associations:template:languages:
Running
- runLoop
- run
- setTimeOut:
- timeOut
- defaultRequestHandler
- terminate
- terminateAfterTimeInterval:
Handling requests
- appendToResponse:inContext:
- awake
- createContextForRequest:
- createSessionForRequest:
- defaultRequestHandler
- defaultRequestHandlerClassName
- dispatchRequest:
- handlerForRequest:
- invokeActionForRequest:inContext:
- registeredRequestHandlerKeys
- registerRequestHandler:forKey:
- removeRequestHandlerForKey:
- requestHandlerForKey:
- setDefaultRequestHandler:
- sleep
- takeValuesFromRequest:inContext:
Handling errors
- handleSessionCreationErrorInContext:
- handlePageRestorationErrorInContext:
- handleSessionRestorationErrorInContext:
- handleException:inContext:
Backward compatibility
- requiresWOF35RequestHandling
- requiresWOF35TemplateParser
Scripted class support
- scriptedClassWithPath:
- scriptedClassWithPath:encoding
Script debugging
- logWithFormat:
- debugWithFormat:
- printsHTMLParserDiagnostics
- setPrintsHTMLParserDiagnostics:
- traceAll:
Statistics report
- setStatisticsStore:
- statisticsStore
- statistics
Monitor support
- monitoringEnabled
- activeSessionsCount
- refuseNewSessions:
- isRefusingNewSessions
- setMinimumActiveSessionsCount:
- minimumActiveSessionsCount
- terminateAfterTimeInterval:
Resource manager support
- setResourceManager:
- resourceManager
User defaults
+ loadFrameworks
+ setLoadFrameworks:
+ isDebuggingEnabled
+ setDebuggingEnabled:
+ autoOpenInBrowser
+ setAutoOpenInBrowser:
+ isDirectConnectEnabled
+ setDirectConnectEnabled:
+ cgiAdaptorURL
+ setCGIAdaptorURL:
+ isCachingEnabled
+ setCachingEnabled:
+ applicationBaseURL
+ setApplicationBaseURL:
+ frameworksBaseURL
+ setFrameworksBaseURL:
+ recordingPath
+ setRecordingPath:
+ projectSearchPath
+ setProjectSearchPath:
+ isMonitorEnabled
+ setMonitorEnabled:
+ monitorHost
+ setMonitorHost:
+ SMTPHost
+ setSMTPHost:
+ adaptor
+ setAdaptor:
+ port
+ setPort:
+ listenQueueSize
+ setListenQueueSize:
+ workerThreadCount
+ setWorkerThreadCount:
+ additionalAdaptors
+ setAdditionalAdaptors:
+ includeCommentsInResponses
+ setIncludeCommentsInResponses:
+ componentRequestHandlerKey
+ setComponentRequestHandlerKey:
+ directActionRequestHandlerKey
+ setDirectActionRequestHandlerKey:
+ resourceRequestHandlerKey
+ setResourceRequestHandlerKey:
+ sessionTimeout
+ setSessionTimeOut:
Convenience Methods
- sharedEditingContext


Class Methods



adaptor

+ (NSString *)adaptor

Returns the class name of the primary adaptor. This is the cover method for the user default WOAdaptor.

See Also: + setAdaptor:



additionalAdaptors

+ (NSArray *)additionalAdaptors

Returns an array of adaptor description dictionaries. This is the cover method for the user default WOAdditionalAdaptors.

See Also: + setAdditionalAdaptors:



application

+ (WOApplication *)application

Initializes and returns a WOApplication object. This initializes application attributes and initializes the adaptor or adaptors specified on the command line. If no adaptor is specified, WODefaultAdaptor is made the default adaptor. Some of the more interesting attribute initializations are:

A exception is raised if initialization does not succeed.

You may call this method, but do not override it.



applicationBaseURL

+ (NSString *)applicationBaseURL

Returns a path to where the current application may be found under the document root (either the project or the .woa wrapper). This is the cover method for the user default WOApplicationBaseURL.

See Also: + setApplicationBaseURL:



autoOpenInBrowser

+ (BOOL)autoOpenInBrowser

Returns whether automatic browser launching is enabled. By default, automatic browser launching is enabled.

cgiAdaptorURL

+ (NSString *)cgiAdaptorURL

Returns the URL for the web server including the path to the WebObjects CGI adaptor (for example, http://localhost/cgi-bin/WebObjects). This URL is used by the direct connect feature only. This is the cover for the user default WOCGIAdaptorURL.

See Also: + setCGIAdaptorURL:



componentRequestHandlerKey

+ (NSString *)componentRequestHandlerKey

Returns the key which identifies URLs directed at component-action-based requests. By default, this method returns the string "wo".

directActionRequestHandlerKey

+ (NSString *)directActionRequestHandlerKey

Returns the key which identifies URLs directed at component-based requests. By default, this method returns the string "wa".

frameworksBaseURL

+ (NSString *)frameworksBaseURL

Returns a path to where all frameworks may be found under the document root. This value is used to determine URLs that should be generated to reference Web Server Resources in those frameworks. This is the cover method for the user default WOFrameworksBaseURL.

See Also: + setFrameworksBaseURL:



includeCommentsInResponses

+ (BOOL)includeCommentsInResponses

Returns whether or not HTML comments are appended to the response. This is the cover method for the user default WOIncludeCommentsInResponses.

See Also: + setIncludeCommentsInResponses:



isCachingEnabled

+ (BOOL)isCachingEnabled

Returns whether or not component caching is enabled. If this is enabled, changes to a component will be reparsed after being saved (assuming the project is under the NSProjectSearchPath). Note that this has no effect on page caching. This is the cover method for the user default WOCachingEnabled.

See Also: + setCachingEnabled:, - pageCacheSize, - isCachingEnabled



isDebuggingEnabled

+ (BOOL)isDebuggingEnabled

Returns whether or not debugging is enabled. If YES, - debugWithFormat: prints out. Most startup-time status message are supressed if this method returns NO. By default, debugging is enabled. This is the cover method for the user default WODebuggingEnabled.

See Also: - setDebuggingEnabled:, - debugWithFormat:



isDirectConnectEnabled

+ (BOOL)isDirectConnectEnabled

Returns whether or not direct connect is enabled. By default it is enabled. For more information, see setDirectConnectEnabled:.

See Also: + cgiAdaptorURL



isMonitorEnabled

+ (BOOL)isMonitorEnabled

Returns whether or not the application can communicate with a Monitor application. It returns YES if the application can contact Monitor upon startup and subsequently let Monitor gather statistics. It returns NO if no comunication with Monitor can take place. By default, it can communicate with a Monitor application. 'This is a cover method for the user default WOMonitorEnabled.

See Also: + setMonitorEnabled:, + monitorHost, + setMonitorHost:



listenQueueSize

+ (NSNumber *)listenQueueSize

Returns the size of the listen queue which will created by the primary adaptor (usually WODefaultAdaptor). This is the cover method for the user default WOListenQueueSize.

See Also: + setListenQueueSize:



loadFrameworks

+ (NSArray *)loadFrameworks

Returns the array of frameworks to be loaded during application initialization.

See Also: + setLoadFrameworks:



monitorHost

+ (NSString *)monitorHost

Returns the host on which Monitor is assumed to be running. This value is used during initialization if isMonitorEnabled returns YES. This is a cover for the user default WOMonitorHost.

See Also: + setMonitorHost:, + isMonitorEnabled



port

+ (NSNumber *)port

Returns the port number on which the primary adaptor will listen (usually WODefaultAdaptor). This is the cover method for the user default WOPort.

See Also: + setPort:



projectSearchPath

+ (NSArray *)projectSearchPath

Returns an array of file system paths which are searched for projects for rapid turnaround mode. This is the cover method for the user default NSProjectSearchPath.

See Also: + setProjectSearchPath:



recordingPath

+ (NSString *)recordingPath

Returns a file system path which is where the recording information should be saved. By default, this method returns nil.

If this method returns a path, all requests and responses are recorded in the HTTP format in numbered files (0000-request, 0000-response, 0001-request, 0001-response, and so on), and saved under the recording path specified. This directory is then used by the Playback tool to test the application. You will most likely set this as a command line argument (-WORecordingPath pathname), exercise your application to record a scenario you would like to test, and then stop the application. Afterward you can restart the application without the WORecordingPath argument, and point Playback to the recording directory just created to replay your sequence of requests and compare the responses received with the ones recorded.

See Also: + setRecordingPath:



resourceRequestHandlerKey

+ (NSString *)resourceRequestHandlerKey

Returns the key which identifies URLs directed through the resource request handler. Resource requests are only used during development of an application when the application is being run without an HTTP server.

See Also: + setResourceRequestHandlerKey:



sessionTimeout

+ (NSNumber*)sessionTimeOut

Returns the number (of seconds) which will be used as the default timeout for each newly created session. You may either override this method, change the user default WOSessionTimeOut, or set the session timeout in your session's init method.

See Also: + setSessionTimeOut:



setAdaptor:

+ (void)setAdaptor:(NSString *)anAdaptorName

Sets the the class name of the primary adaptor to anAdaptorName.

See Also: + adaptor



setAdditionalAdaptors:

+ (void)setAdditionalAdaptors:(NSArray *)anAdaptorPlist

Sets the array of adaptor description dictionaries to anAdaptorPlist. Each adaptor description dictionary must have "WOAdaptor" defined, which is the name of the adaptor class. Other attributes such as WOPort may also be specified, but are adaptor specific. For example WOWorkerThreadCount is specific to the WODefaultAdaptor class and may not apply for all adaptors.

See Also: + additionalAdaptors



setApplicationBaseURL:

+ (void)setApplicationBaseURL:(NSString *)aBaseURL

Sets to aBaseURL the path to which the current application may be found under the document root (either the project or the .woa wrapper).

See Also: + applicationBaseURL



setAutoOpenInBrowser:

+ (void)setAutoOpenInBrowser:(BOOL)isEnabled

Controls whether starting up this application also launches a web browser. If isEnabled is YES, the application launches the web browser. If NO, the application does not launch the browser. Browser launching is enabled by default as long as there is a WOAdaptorURL key in the file NeXT_ROOT/NextLibrary/WOAdaptors/Configuration/WebServerConfig.plist.

To disable web browser launching, you must send this message in the init method of your application subclass (or application script).

See Also: + autoOpenInBrowser



setCGIAdaptorURL:

+ (void)setCGIAdaptorURL:(NSString *)aURL

Sets the URL for the web server to aURL. The URL must include the path to the WebObjects CGI adaptor (for example, http://localhost/cgi-bin/WebObjects). This URL is used by the direct connect feature only..

See Also: + cgiAdaptorURL



setCachingEnabled:

+ (void)setCachingEnabled:(BOOL)flag

Sets whether or not component caching is enabled. If this is enabled, changes to a component will be reparsed after being saved (assuming the project is under the NSProjectSearchPath). Note that this has no effect on page caching.

See Also: + isCachingEnabled, - pageCacheSize, - setCachingEnabled:



setComponentRequestHandlerKey:

+ (void)setComponentRequestHandlerKey:(NSString *)key

Sets the component request handler key. This affects all URLs generated during appendToResponse:inContext:: of component-based actions.

See Also: + componentRequestHandlerKey



setDebuggingEnabled:

+ (void)setDebuggingEnabled:(BOOL)flag

Sets whether or not debugging is enabled. If YES, - debugWithFormat: prints out. Most startup-time status message are supressed if this method returns NO. By default, debugging is enabled.

See Also: + isDebuggingEnabled, - debugWithFormat:



setDirectActionRequestHandlerKey:

+ (void)setDirectActionRequestHandlerKey:(NSString *)key

Sets the Direct Action request handler key. This affects all URLs generated during appendToResponse:inContext:: of direct actions.

See Also: + directActionRequestHandlerKey



setDirectConnectEnabled:

+ (void)setDirectConnectEnabled:(BOOL)flag

Sets whether or not direct connect is enabled. By default it is enabled.

Direct connect actually transforms your application in a simple web server of its own. In particular, it is then able to find and return its images and resources as if it were a web server. It is very useful in development mode: You don't need a web server. Just point your URL to the port where your application is listening, and the application will handle all urls.

If this flag is YES, the following happens:

See Also: + isDirectConnectEnabled, + cgiAdaptorURL



setFrameworksBaseURL:

+ (void)setFrameworksBaseURL:(NSString *)aString

Sets to aString the path to where all frameworks may be found under the document root. This value is used to determine URLs that should be generated to reference Web Server Resources in those frameworks.

See Also: + frameworksBaseURL



setIncludeCommentsInResponses:

+ (void)setIncludeCommentsInResponses:(BOOL)flag

Sets whether or not HTML comments are appended to the response.

See Also: + includeCommentsInResponses



setListenQueueSize:

+ (void)setListenQueueSize:(NSNumber *)aListenQueueSize

Sets the size of the listen queue which will created by the primary adaptor (usually WODefaultAdaptor).

See Also: + listenQueueSize



setLoadFrameworks:

+ (void)setLoadFrameworks:(NSArray *)frameworkList

Sets the array of frameworks to be loaded during application initialization.

See Also: + loadFrameworks



setMonitorEnabled:

+ (void)setMonitorEnabled:(BOOL)flag

Sets whether or not the application will communicate with a Monitor application. If flag is YES, the application can contact Monitor upon startup and subsequently let Monitor gather statistics. If flag is NO, no comunication with Monitor can take place. By default, it can communicate with a Monitor application.

See Also: + isMonitorEnabled



setMonitorHost:

+ (void)setMonitorHost:(NSString *)hostName

Sets the host on which Monitor is assumed to be running. This value is used during initialization if isMonitorEnabled returns YES.

See Also: + monitorHost, + isMonitorEnabled



setPort:

+ (void)setPort:(NSNumber *)port

Sets the port number on which the primary adaptor will listen (usually WODefaultAdaptor).

See Also: + port



setProjectSearchPath:

+ (void)setProjectSearchPath:(NSArray)searchPath

Sets the array of file system paths which are searched for projects for rapid turnaround mode.

See Also: + projectSearchPath



setRecordingPath:

+ (void)setRecordingPath:(NSString *)path

Sets the file system path where the recording information should be saved. Use nil as the path if you don't want to save recording information. By default, recording information is not saved.

If you save recording information, all requests and responses are recorded in the HTTP format in numbered files (0000-request, 0000-response, 0001-request, 0001-response, and so on), and saved under the recording path specified. This directory is then used by the Playback tool to test the application. You will most likely set this as a command line argument (-WORecordingPath pathname), exercise your application to record a scenario you would like to test, and then stop the application. Afterward you can restart the application without the WORecordingPath argument, and point Playback to the recording directory just created to replay your sequence of requests and compare the responses received with the ones recorded.

See Also: + recordingPath



setResourceRequestHandlerKey:

+ (void)setResourceRequestHandlerKey:(NSString *)key

Sets the resource request handler key. This affects all URLs generated during appendToResponse:inContext: of resources.

See Also: + resourceRequestHandlerKey



setSessionTimeOut:

+ (void)setSessionTimeOut:(NSNumber*)aTimeOut

Accessor to set the default session timeOut.

See Also: + sessionTimeout



setSMTPHost:

+ (void)setSMTPHost:(NSString *)hostName

Sets the name of the host that will be used to send e-mail messages created by WOMailDelivery.

See Also: + SMTPHost



setWorkerThreadCount:

+ (void)setWorkerThreadCount:(NSNumber *)aWorkerThreadCount

SEts the count of worker threads which will created by the primary adaptor (usually WODefaultAdaptor). A worker thread count of 0 implies single-threaded mode.

See Also: + workerThreadCount



SMTPHost

+ (NSString *)SMTPHost

Returns the name of the host that will be used to send e-mail messages created by WOMailDelivery. This is the cover method for the user default WOSMTPHost.

See Also: + setSMTPHost:



workerThreadCount

+ (NSNumber *)workerThreadCount

Returns the count of worker threads which will created by the primary adaptor (usually WODefaultAdaptor). A worker thread count of 0 implies single-threaded mode. This is the cover method for the user default WOWorkerThreadCount.

See Also: + setWorkerThreadCount:




Instance Methods



activeSessionsCount

- (int)activeSessionsCount

Returns the number of sessions that are currently active. (A session is active if it has not yet timed out.)

The number returned here is only accurate if the application stores state in memory in the server, which is the default. If you use a custom state-storage strategy, there may be no way to tell how many sessions are active for a given application instance.

See Also: - minimumActiveSessionsCount, - setMinimumActiveSessionsCount:



adaptorWithName:arguments:

- (WOAdaptor *)adaptorWithName:(NSString *)aName arguments:(NSDictionary *)someArguments

Invoked during the init method to create an adaptor. If you subclass WOAdaptor, you specify the WOAdaptor subclass you want the application to use with the -a option on the application's command line. When WOApplication encounters the -a option, it invokes this method. This method looks for a subclass of WOAdaptor with the name aName (which was supplied as the -a option's argument), and if such a class exists, a new instance is initialized using the WOAdaptor method initWithName:arguments:. The someArguments array is populated with any adaptor-specific options (such as -p or -q) that follow the adaptor name on the command line. See the WOAdaptor class for more information.

See Also: - adaptors



adaptors

- (NSArray *)adaptors

Returns the current list of application adaptors. A WOApplication can have multiple adaptors. (To associate the WOApplication with multiple adaptors, you specify each adaptor on the application's command line using the -a option.) This allows you to design an application that can not only listen to a socket for incoming HTTP requests (using the WODefaultAdaptor), but can also receive remote request messages using more advanced RPC mechanisms such as DO, CORBA, and DCOM.

adaptorsDispatchRequestsConcurrently

- (BOOL)adaptorsDispatchRequestsConcurrently

Returns YES if at least one adaptor contains multiple threads and will attempt to concurrently invoke the request handlers.

allowsConcurrentRequestHandling

- (BOOL)allowsConcurrentRequestHandling

Override to return YES if concurrent request handling is allowed.

See Also: - isConcurrentRequestHandlingEnabled



appendToResponse:inContext:

- (void)appendToResponse:(WOResponse *)aResponse inContext:(WOContext *)aContext

The WOApplication object sends this message to itself to initiate the last phase of request handling. This occurs right after the invokeActionForRequest:inContext: method has completed, typically with the return a response page. In the append-to-response phase, the application objects (particularly the response component itself) generate the HTML content of the page. WOApplication's default implementation of this method forwards the message to the session object.

See Also: - invokeActionForRequest:inContext:



awake

- (void)awake

Invoked at the beginning of each cycle of the request-response loop, affording the opportunity to perform initializations with application-wide scope. Since the default implementation does nothing, overridden implementations do not have to call super.

See Also: - sleep



baseURL

- (NSString *)baseURL

Returns the application URL relative to the server's document root, for example:
WebObjects/Examples/HelloWorld.woa. 

See Also: - name, - path



createContextForRequest:

- (WOContext *)createContextForRequest:(WORequest *)aRequest

Creates a new context object for a given request. Override this method if you need to provide your own subclass of WOContext. If you override it, your implementation need not call super.

createSessionForRequest:

- (WOSession *)createSessionForRequest:(WORequest *)aRequest

Creates and returns a WOSession object to manage a session for the application. The method goes through several steps to locate the class to use for instantiating this object:
  1. First it looks for a compiled class of name "Session" that is a subclass of WOSession.
  2. If such a class does not exist, it looks for a ".wos" script with the name of "Session" in the application wrapper (".woa" directory).
  3. If the Session.wos script exists, the method parses the script and dynamically adds a scripted-class subclass of WOSession to the runtime.

The method then returns an allocated and initialized (using the default WOSession initializer) session instance of the selected class. It raises an exception if it is unable to create a new session.



See Also: - restoreSessionWithID:inContext:, - saveSessionForContext:



debugWithFormat:

- (void)debugWithFormat:(NSString *)aFormatString,...

Prints a message to the standard error device (stderr), if WODebuggingEnabled is YES. The message can include formatted variable data using printf-style conversion specifiers. Note that in WebScript, all variables are objects, so the only conversion specifier allowed is %@. In compiled Objective-C code, all printf conversion specifiers are allowed.

You control whether this method displays output with the WODebuggingEnabled user default option. If WODebuggingEnabled is YES, then the debugWithFormat: messages display their output. If WODebuggingEnabled is NO, the debugWithFormat: messages don't display their output.



defaultRequestHandler

- (WORequestHandler *)defaultRequestHandler

Returns the request handler to be used when no request handler key was found in the URL or WORequest. This method returns the WOComponent request handler by default. When an application is contacted for the first time it is usually via a URL like the following:
http://somehost/cgi-bin/WebObjects/AppName.woa

The way that URLs of that type are handled is determined by the default request handler.



defaultRequestHandlerClassName

- (NSString *)defaultRequestHandlerClassName

The default implementation of this method returns @"WOComponentRequestHandler", which is the default request handler. Override this method to return @"WODirectActionRequestHandler" to make the direct action request handler the default.

dispatchRequest:

- (WOResponse *)dispatchRequest:(WORequest *)aRequest

The main entry point for any given interaction. Invoked by the adaptor.

dynamicElementWithName:associations:template:languages:

- (WODynamicElement *)dynamicElementWithName:(NSString *)aName associations:(NSDictionary *)someAssociations template:(WOElement *)anElement languages:(NSArray *)languages

Creates and returns a WODynamicElement object based on the element's name, a dictionary of associations, and a template of elements. This method is invoked automatically to provide a WODynamicElement object that represents a WEBOBJECT element in the HTML template. You don't ordinarily invoke dynamicElementWithName:associations:template:languages:, but you might override it to substitute your own WODynamicElement or reusable component for one of the built-in WODynamicElements.

The arguments aName and someAssociations are derived from a corresponding line in the declarations file. aName is an NSString that identifies the kind of element to create. Generally aName specifies a built-in WODynamicElement such as WOString, but it may also identify a reusable component. (For more information, see the chapter "Using Reusable Components" in the WebObjects Developer's Guide.) For example, in the dynamicElementWithName:associations:template:languages: message for the following declaration:

APP_STRING: WOString {value = applicationString;};

aName contains the string "WOString".

The someAssociations dictionary contains an entry for each attribute specified in the corresponding declaration. For the declaration above, someAssociations contains a single entry for WOString's value attribute. The keys of someAssociations are the attribute names and the values are WOAssociation objects.

WOApplication's implementation of dynamicElementWithName:associations:template:languages: first searches for a WODynamicElement named aName. If a WODynamicElement is found, the method creates an instance using the method initWithName:associations:template: and returns it. Otherwise, it searches for a component-either scripted or compiled-to return instead. If neither are found, this method returns nil.



handleException:inContext:

- (WOResponse *)handleException:(NSException *)anException inContext:(WOContext *)aContext

Invoked when an exception occurs within the request-response loop. The default behavior displays a page with debugging information. You can override this method to catch exceptions and display a "friendlier" error page. For example, the following code replaces the standard error page with a component named ErrorPage.wo.
- (WOResponse *)handleException:(NSException *)anException {
    WOResponse *response = [[WOResponse alloc] init];
    WORequest *request = [[self context] request];
    WOString newURL = [NSString stringWithFormat:@"http://%@%@/%@.woa/-/ErrorPage.wo", 
        [request applicationHost], 
        [request adaptorPrefix], 
        [request applicationName]];

    [response setHeader:newURL forKey:@"location"];
    [response setHeader:@"text/html" forKey:@"content-type"];
    [response setHeader:@"0" forKey:@"content-length"];
    [response setStatus:302];
    return response;
}

See Also: - handleSessionCreationErrorInContext:, - handleSessionRestorationErrorInContext:



handlePageRestorationErrorInContext:

- (WOResponse *)handlePageRestorationErrorInContext:(WOContext *)aContext

Invoked when a page (WOComponent) instance cannot be restored, which typically happens when a user backtracks too far. Specifically, this method is invoked when the following occurs: the request is not the first of a session, page restoration by context ID fails, and page re-creation is disabled. The default behavior displays a page with debugging information. You can override this method to display a "friendlier" error page.

See Also: - handleException:inContext:, - handleSessionCreationErrorInContext:, - handleSessionRestorationErrorInContext:



handleSessionCreationErrorInContext:

- (WOResponse *)handleSessionCreationErrorInContext:(WOContext *)aContext

Invoked when a session (WOSession) instance cannot be created. The default behavior displays a page with debugging information. You can override this method to display a "friendlier" error page.

See Also: - handleException:inContext:, - handlePageRestorationErrorInContext:, - handleSessionRestorationErrorInContext:



handleSessionRestorationErrorInContext:

- (WOResponse *)handleSessionRestorationErrorInContext:(WOContext *)aContext

Invoked when a session (WOSession) instance cannot be restored, which typically happens when the session times out. The default behavior displays a page with debugging information. You can override this method to display a "friendlier" error page.

See Also: - handleException:inContext:, - handlePageRestorationErrorInContext:, - handleSessionCreationErrorInContext:



handlerForRequest:

- (WORequestHandler *)handlerForRequest:(WORequest *)aRequest

Returns the request handler used to handle a given request.

See Also: - registerRequestHandler:forKey:, - registeredRequestHandlerKeys, - requestHandlerForKey:



init

- (id)init

Initializes application attributes and initializes the adaptor or adaptors specified on the command line. If no adaptor is specified, WODefaultAdaptor is made the default adaptor. Some of the more interesting attribute initializations are:

A exception is raised if initialization does not succeed.


An implication of the foregoing description is that the names of compiled WOSession subclasses should be "Session"; if not, you will have to override this method to use the proper class to create the session object.



invokeActionForRequest:inContext:

- (WOElement *)invokeActionForRequest:(WORequest *)aRequest inContext:(WOContext *)aContext

The WOApplication object sends this message to itself to initiate the middle phase of request handling. In this phase, the message is propagated through the objects of the application until the dynamic element that has received the user action (for instance, a click on a button) responds to the message by triggering the method in the request component that is bound to the action. The default WOApplication implementation of this method forwards the message to the session object.

See Also: - appendToResponse:inContext:



isCachingEnabled

- (BOOL)isCachingEnabled

Returns whether component-definition caching is enabled. The default is NO.

See Also: - setCachingEnabled:



isConcurrentRequestHandlingEnabled

- (BOOL)isConcurrentRequestHandlingEnabled

Returns YES if adaptors dispatch requests concurrently and allowsConcurrentRequestHandling has been overridden to allow concurrent request handling.

See Also: - allowsConcurrentRequestHandling



isPageRefreshOnBacktrackEnabled

- (BOOL)isPageRefreshOnBacktrackEnabled

Returns whether caching of pages is disabled in the client. If so, the client does not restore request pages from its cache but re-creates them "from scratch" by resending the URL to the server. This flag is set to NO by default.

See Also: - setPageRefreshOnBacktrackEnabled:



isRefusingNewSessions

- (BOOL)isRefusingNewSessions

Returns YES if the application instance is refusing new sessions, and NO otherwise. When the application instance refuses new sessions, the WebObjects adaptor tries to start the session in another instance of the same application. If no other instance is running and accepting new sessions, the user receives an error message.

isTerminating

- (BOOL)isTerminating

Returns whether the application will terminate at the end of the current request-response loop.

See Also: - setTimeOut:, - defaultRequestHandler, - terminateAfterTimeInterval:, - timeOut



lock

- (void)lock

Locks the application object.

lockRequestHandling

- (void)lockRequestHandling

Serializes request handler access if concurrent request handling isn't enabled.

logSetValueForDeclarationNamed:type:bindingNamed:associationDescription:value:

- (void)logSetValueForDeclarationNamed:(NSString*)aDeclarationName type:(NSString*)aDeclarationType bindingNamed:(NSString*)aBindingName associationDescription:(NSString*)anAssociationDescription value:(id)aValue

Formats and logs a message anytime a value is set through a WOAssociation, when WODebug is set to YES for the declaration in which the association appears. (Setting a value means the child component/element is setting a value in the parent). See logTakeValueForDeclarationNamed:type:bindingNamed:associationDescription:value: for a description of each of the arguments to this method.

logTakeValueForDeclarationNamed:type:bindingNamed:associationDescription:value:

- (void)logTakeValueForDeclarationNamed:(NSString*)aDeclarationName type:(NSString*)aDeclarationType bindingNamed:(NSString*)aBindingName associationDescription:(NSString*)anAssociationDescription value:(id)aValue

Formats and logs a message anytime a value is "taken" through a WOAssociation , when WODebug is set to YES for the declaration in which the association appears. (Taking a value means the child component/element is taking a value from the parent). Override this method to alter the format of the log message. The arguments of this method are defined in the following example of a WebObjects declaration.
aDeclarationName : aDeclarationType {
    aBindingName = anAssociationDescription;
}

Also, aValue is the value which is being pushed to or pulled from the child to the parent.



logWithFormat:

- (void)logWithFormat:(NSString *)aFormat,...

Prints a message to the standard error device (stderr). The message can include formatted variable data using printf-style conversion specifiers, for example:
id i = 500;
id f = 2.045;
[self logWithFormat:@"Amount = %@, Rate = %@, Total = %@", i, f, i*f];

Note that in WebScript, all variables are objects, so the only conversion specifier allowed is %@ as shown above. In compiled Objective-C code, all printf conversion specifiers are allowed. The equivalent method in Java is logString.



minimumActiveSessionsCount

- (int)minimumActiveSessionsCount

Returns the minimum number of active sessions allowed. If the number of active sessions is less than or equal to this number and isRefusingNewSessions is YES, the application instance terminates. The default is 0.

See Also: - activeSessionsCount, - refuseNewSessions:, - setMinimumActiveSessionsCount:



monitoringEnabled

- (BOOL)monitoringEnabled

Returns YES if the application is "monitorable" by the Monitor application, and NO otherwise. An application is "monitorable" if it was able to find a running Monitor upon startup and it is able to successfully communicate with that Monitor.

By default, all applications are monitorable if the Monitor application is running on the same machine as the application. You can specifically disable monitoring using the -WOMonitorEnabled NO option on the application command line. If you want the application to be monitorable and the Monitor is running on another host, you can start up the application through Monitor, or you can specify Monitor's host on the application command line this way:

MyApp.exe -WOMonitorEnabled YES -WOMonitorHost monitorHost ...



name

- (NSString *)name

Returns the name of the application, which is the name of the executable (without the .exe extension).

See Also: - baseURL, - path



number

- (NSString *)number

Returns @"-1". This is provided for backwards compatibility only.

pageCacheSize

- (unsigned int)pageCacheSize

Returns the size of the internal cache for page instances. The default size is 30 instances.

See Also: - setPageCacheSize:



pageWithName:forRequest:

- (WOComponent *)pageWithName:(NSString *)aName forRequest:(WORequest *)aRequest

Returns a new page instance (a WOComponent object) identified by aName. If aName is nil, the "Main" component is assumed. If the method cannot create a valid page instance, it raises an exception.

As part of its implementation, this method creates a context with aRequest and calls pageWithName:inContext:.

See Also: - restorePageForContextID: (WOSession), - savePage: (WOSession)



pageWithName:inContext:

- (WOComponent *)pageWithName:(NSString *)aName inContext:(WOContext *)aContext

Returns a new page instance (a WOComponent object) identified by aName. If aName is nil, the "Main" component is assumed. If the method cannot create a valid page instance, it raises an exception.

See Also: pageWithName:forRequest:, - restorePageForContextID: (WOSession), - savePage: (WOSession)



path

- (NSString *)path

Returns the filesystem 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.

See Also: - baseURL, - name



permanentPageCacheSize

- (unsigned int)permanentPageCacheSize

Returns the permanent page cache size. The default is 30. The permanent page cache holds pages which should not fall out of the regular page cache. For example, a control page in a frameset should exist for the duration of a session.

See Also: savePageInPermanentCache: ( WOApplication)



printsHTMLParserDiagnostics

- (BOOL)printsHTMLParserDiagnostics

Returns whether the HTML parser prints diagnostic information to stdout when it encounters unbalanced HTML containers or other syntactically incorrect HTML. This method returns NO by default.

See Also: + isDebuggingEnabled, - debugWithFormat:



refuseNewSessions:

- (void)refuseNewSessions:(BOOL)flag

Controls whether this application instance will create a session when it receives an HTTP request from a new user. If flag is YES, the application does not create new sessions; when it receives a request from a new user, it refuses that request, and the adaptor must try to find another application instance that can process the request. If flag is NO, the application creates new sessions. NO is the default.

You use this method with setMinimumActiveSessionsCount: to gracefully shut down application instances. Use setMinimumActiveSessionsCount: to set the active session minimum to a certain number. When number of active sessions reaches the number you set and isRefusingNewSessions returns YES, the application terminates.

See Also: - activeSessionsCount, - isRefusingNewSessions, - minimumActiveSessionsCount, - setMinimumActiveSessionsCount:



registerRequestHandler:forKey:

- (void)registerRequestHandler:(WORequestHandler *)aHandler forKey:(NSString *)aKey

Registers a new request handler. aKey must specify a key which can be found in the URLs following the instance number or application name.

See Also: - removeRequestHandlerForKey:, - registeredRequestHandlerKeys, - requestHandlerForKey:



registeredRequestHandlerKeys

- (NSArray *)registeredRequestHandlerKeys

Returns an array of strings containing the keys of all of the registered request handlers.

See Also: - handlerForRequest:, - requestHandlerForKey:



removeRequestHandlerForKey:

- (WORequestHandler *)removeRequestHandlerForKey:(NSString *)aRequestHandlerKey

Removes the specified request handler from the application.

See Also: - registerRequestHandler:forKey:, - requestHandlerForKey:



requestHandlerForKey:

- (WORequestHandler *)requestHandlerForKey:(NSString *)key

Returns the request handler used to handle requests containing the specified key.

See Also: - handlerForRequest:, - registerRequestHandler:forKey:, - registeredRequestHandlerKeys



requiresWOF35RequestHandling

- (BOOL)requiresWOF35RequestHandling

For backward compatibility, if your project depends upon features or side effects of the old request handling, you will want to override this method and return YES. By default, it returns NO.

requiresWOF35TemplateParser

- (BOOL)requiresWOF35TemplateParser

For backward compatibility, if your project depends upon features or side effects removed from the new, 4.0 template parser, you will want to override this method and return YES. By default, it returns NO.

resourceManager

- (WOResourceManager *)resourceManager

Returns the WOResourceManager object that the application uses to manage resources.

See Also: - setResourceManager:



restoreSessionWithID:inContext:

- (WOSession *)restoreSessionWithID:(NSString *)aSessionID inContext:(WOContext *)aContext

Restores the WOSession object representing a session. In normal request handling, this method is invoked at the start of a cycle of the request-response loop. The default implementation simply invokes WOSessionStore's checkOutSessionWithID:request: method, but raises an exception if the WOSessionStore object is missing.

See Also: - createSessionForRequest:, - saveSessionForContext:



run

- (void)run

Runs the application in a near-indefinite run loop in the default run-loop mode. Before starting the run loop, the method sends registerForEvents to the application's adaptors so that they can begin receiving run-loop events. Normally, run is invoked in the main function.

See Also: - setTimeOut:, - defaultRequestHandler, - terminateAfterTimeInterval:



runLoop

- (NSRunLoop *)runLoop

Returns the application's run loop. Use this method when you need a run loop for such things as registering timers.

saveSessionForContext:

- (void)saveSessionForContext:(WOContext *)aContext

Called at the end of the request handling loop, when the current session object needs to be saved. The default implementation simply invokes WOSessionStore's checkInSessionForContext: method, but raises an exception if the WOSessionStore object is missing.

See Also: - restoreSessionWithID:inContext:



scriptedClassWithPath:

- (Class)scriptedClassWithPath:(NSString *)aPath

Loads a Webscript-based class with the pathname aPath into the application. The specified script is parsed assuming the default string encoding, and the class and categories found in the script file are dynamically added to the runtime.

scriptedClassWithPath:encoding

- (Class)scriptedClassWithPath:(NSString *)aPath encoding:(NSStringEncoding)anEncoding

Loads a scripted class with the pathname aPath using the encoding anEncoding. The class and categories found in the script file are dynamically added to the runtime. The script must use the @interface/@implementation syntax.

sessionStore

- (WOSessionStore *)sessionStore

Returns the application's current WOSessionStore object (which, by default, stores state in the server).

See Also: - setSessionStore:



setCachingEnabled:

- (void)setCachingEnabled:(BOOL)flag

Enables or disables the caching of component definitions. Component definitions contain templates and other information about pages and subcomponents, and are used to generate instances of those components. When this flag is enabled, the application parses the script (or implementation) file, the HTML, and the declaration (".wod") file of a component once and then stores the resulting component definition. By default, this kind of caching is disabled so that you can edit a scripted component without having to relaunch the application every time to check the results. You should always enable component-definition caching when you deploy an application since performance improves significantly.

Do not confuse this type of caching with page-instance caching (see setPageCacheSize:). Caching Strategies in the class description provides further details.

See Also: - isCachingEnabled



setDefaultRequestHandler:

- (void)setDefaultRequestHandler:(WORequestHandler *)aHandler

Sets the default request handler. If, for instance, you want the default request handler to use direct actions, write something like the following:

aHandler = [self requestHandlerForKey:@"wa"]; [self setDefaultRequestHandler:aHandler];

See Also: - defaultRequestHandler



setMinimumActiveSessionsCount:

- (void)setMinimumActiveSessionsCount:(int)anInt

Sets the minimum number of active sessions to anInt. The default is 0.

You use this method to gracefully shut down application instances. If the active sessions count reaches this number and isRefusingNewSessions returns YES, the application terminates. You might want to terminate application instances periodically for performance reasons; some applications leak a certain amount of memory per transaction, and shutting down and restarting instances of those applications can free up that memory.

See Also: - activeSessionsCount, - isRefusingNewSessions, - minimumActiveSessionsCount, - refuseNewSessions:



setPageCacheSize:

- (void)setPageCacheSize:(unsigned int)anInt

Sets whether caching of page instances will occur and the number of pages the cache will hold. When page-instance caching is enabled, the application stores the WOComponent instance corresponding to the response page in the session. When the page is backtracked to, it restores it from the session and makes it the request page. The state of the page is retained. By default, page-instance caching is enabled, with a cache limit of 30 pages.

You turn page-instance caching off by invoking this method with an argument of zero. In this case, when the user backtracks to a page, the page is not stored in the session and so must be re-created "from scratch." Do not confuse this type of caching with component-definition caching (see setCachingEnabled:).

See Also: - pageCacheSize



setPageRefreshOnBacktrackEnabled:

- (void)setPageRefreshOnBacktrackEnabled:(BOOL)flag

When flag is YES, disables caching of pages by the client by setting the page's expiration-time header to the current date and time. (By default, this attribute is set to NO.) Disabling of client caching affects what happens during backtracking. With client caching turned off, the browser resends the URL to the server for the page requested by backtracking. The application must return a new page to the browser (corresponding to a new WOComponent instance). This behavior is desirable when you do not want the user to backtrack to a page that might be obsolete because of changes that have occurred in the session.

When this flag is turned on and a request corresponding to a client backtrack occurs, the retrieved page will only be asked to regenerate its response. The first two phases of a normal request-response loop (value extraction from the request and action invocation) do not occur.

See Caching Strategies in the class description for further details.

See Also: - isPageRefreshOnBacktrackEnabled



setPermanentPageCacheSize:

- (void)setPermanentPageCacheSize:(unsigned int)aSize

Sets the permanentPageCacheSize to aSize

See Also: - permanentPageCacheSize



setPrintsHTMLParserDiagnostics:

- (void)printsHTMLParserDiagnostics:(BOOL)flag

Sets whether the HTML parser prints diagnostic information to stdout when it encounters unbalanced HTML containers or other syntactically incorrect HTML. This diagnostic information is not printed by default.

See Also: + setDebuggingEnabled:, - debugWithFormat:



setResourceManager:

- (void)setResourceManager:(WOResourceManager *)aResourceManager

Sets the WOResourceManager object to aResourceManager. WOResourceManager objects search for and retrieve resources from the application directory and from shared framework directories.

See Also: - resourceManager



setSessionStore:

- (void)setSessionStore:(WOSessionStore *)aSessionStore

Set the session-store object for the application. By default, an object that stores session state in process memory (that is, in the server) is used. The session-store object specifies the state storage strategy for the whole application. This object is responsible for making session objects persistent. You should set the session store object when the application starts up, before the first request is handled.

See Also: - sessionStore



setStatisticsStore:

- (void)setStatisticsStore:(WOStatisticsStore *)aStatisticsStore

Sets the WOStatisticsStore object to aStatisticsStore. WOStatisticsStore objects record application statistics while the application runs.

See Also: - statisticsStore



setTimeOut:

- (void)setTimeOut:(NSTimeInterval)aTimeInterval

Sets the number of seconds the application can experience inactivity (no HTTP requests) before it terminates execution.

This method differs from terminateAfterTimeInterval: in that with this method, the application must be idle for aTimeInterval seconds for the application to terminate. terminateAfterTimeInterval: terminates the application whether it is active or not.

See Also: - timeOut



sharedEditingContext

- (EOSharedEditingContext *)sharedEditingContext

This is a convenience method that returns the default shared editing context.

See Also: EOSharedEditingContext class description in the EOControl Framework



sleep

- (void)sleep

Invoked at the conclusion of a request-handling cycle to give an application the opportunity for deallocating objects created and initialized in its awake method. The default implementation does nothing.

statistics

- (bycopyNSDictionary *)statistics

Returns a copy of the dictionary containing the application statistics maintained by WOStatisticsStore. This method is used by the Monitor application to retrieve application statistics. If you need to access the statistics internally, use this message instead:
[[[WOApplication application] statisticsStore] statistics]



statisticsStore

- (WOStatisticsStore *)statisticsStore

Returns the WOStatisticsStore object, which records statistics while the application runs.

See Also: - setStatisticsStore:



takeValuesFromRequest:inContext:

- (void)takeValuesFromRequest:(WORequest *)aRequest inContext:(WOContext *)aContext

The component action request handler sends this message to the WOApplication to start the first phase of request handling. In this phase, the message is propagated to the session and component objects involved in the request as well as the request page's dynamic elements. Each dynamic element acquires any entered data or changed state (such as a check in a check box) associated with an attribute and assigns the value to the variable bound to the attribute. The default WOApplication implementation of this method forwards the message to the session object.

See Also: - appendToResponse:inContext:, - invokeActionForRequest:inContext:



terminate

- (oneway void)terminate

Terminates the application process. Termination does not take place until the handling of the current request has completed.

See Also: - isTerminating, - setTimeOut:



terminateAfterTimeInterval:

- (void)terminateAfterTimeInterval:(NSTimeInterval)aTimeInterval

Sets the application to terminate itself after aTimeInterval seconds has elapsed. After the specified time interval has elapsed, the application immediately stops all current processing. If any sessions are active, users may lose information.

This method differs from setTimeOut: in that it does not set idle time; terminateAfterTimeInterval: shuts down the application regardless of whether it is idle.



timeOut

- (NSTimeInterval)timeOut

Returns the application's time-out interval: a period (in seconds) of inactivity before the application terminates execution. The default application time-out interval is a very large number.

See Also: - setTimeOut:



trace:

- (void)trace:(BOOL)flag

If flag is YES, prints all trace messages (messages for scripted messages, compiled messages, and all statements in the application) to the standard error device. If flag is NO, stops printing all trace messages.

See Also: - traceAssignments:, - traceObjectiveCMessages:, - traceScriptedMessages:, - traceStatements:



traceAll:

- (void)traceAll:(BOOL)flag

If flag is YES, prints all trace messages (messages for scripted messages, compiled messages, and all statements in the application) to the standard error device. If flag is NO, stops printing all trace messages.

See Also: - traceAssignments:, - traceObjectiveCMessages:, - traceScriptedMessages:, - traceStatements:



traceAssignments:

- (void)traceAssignments:(BOOL)flag

If flag is YES, prints a message to the standard error device every time an assignment statement is executed. If flag is NO, stops printing trace assignment messages.

See Also: - trace:, - traceObjectiveCMessages:, - traceScriptedMessages:, - traceStatements:



traceObjectiveCMessages:

- (void)traceObjectiveCMessages:(BOOL)flag

If flag is YES, prints a message to the standard error device every time a message is sent to a compiled class from Webscript. If flag is NO, stops printing these messages.

See Also: - trace:, - traceAssignments:, - traceScriptedMessages:, - traceStatements:



traceScriptedMessages:

- (void)traceScriptedMessages:(BOOL)flag

If flag is YES, prints a message to the standard error device every time a message is sent to a scripted class from Webscript. If flag is NO, stops printing trace scripted method messages.

See Also: - trace:, - traceAssignments:, - traceObjectiveCMessages:, - traceStatements:



traceStatements:

- (void)traceStatements:(BOOL)flag

If flag is YES, prints a message to the standard error device every time a statement in the application is executed from Webscript. If flag is NO, stops printing trace statement messages.

See Also: - trace:, - traceAssignments:, - traceObjectiveCMessages:, - traceScriptedMessages:



unlock

- (void)unlock

Unlocks the application object.

unlockRequestHandling

- (void)unlockRequestHandling

Disables serialized request handler access if concurrent request handling isn't enabled.


Notifications


WOApplicationDidFinishLaunchingNotification

Posted just before the application begins waiting for requests. The notification contains the application instance.

The notification contains the application instance.

WOApplicationWillFinishLaunchingNotification

Posted when an application has finished its init method. Register to receive this notification if you have an object that wishes to set various setting in the application. For example, if you have a WORequestHandler implemented in a framework and you want to register it with the WOApplication, you would register to receive this notification and then implement a method that register your WORequestHandler with the application.

The notification contains the application instance.



Table of Contents
The global variable "WOApp" is initialized in this method. Your subclasses of WOApplication (including Application.wos) should be sure to call super's init method as their first line of code.