2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #ifndef __NGObjWeb_WOApplication_H__
23 #define __NGObjWeb_WOApplication_H__
25 #import <Foundation/NSObject.h>
26 #import <Foundation/NSLock.h>
27 #import <Foundation/NSMapTable.h>
28 #include <NGObjWeb/NGObjWebDecls.h>
29 #include <NGObjWeb/WOCoreApplication.h>
31 @class NSString, NSRunLoop, NSArray, NSTimer, NSException, NSNumber, NSURL;
32 @class NSMutableDictionary, NSDictionary;
33 @class WOResourceManager, WOComponent, WOContext, WOSession;
34 @class WORequest, WOResponse, WOAdaptor, WORequestHandler;
35 @class WOSessionStore, WODynamicElement, WOElement, WOStatisticsStore;
37 @interface WOApplication : WOCoreApplication
40 int minimumActiveSessionsCount;
43 WORequestHandler *defaultRequestHandler;
44 NSMapTable *requestHandlerRegistry;
45 WOSessionStore *iSessionStore;
46 WOStatisticsStore *iStatisticsStore;
47 WOResourceManager *resourceManager;
49 NSTimer *expirationTimer;
50 NSString *instanceNumber;
52 short permanentPageCacheSize;
55 BOOL doesRefuseNewSessions:1;
56 BOOL isPageRefreshOnBacktrackEnabled:1;
57 BOOL isCachingEnabled:1;
64 - (BOOL)monitoringEnabled;
68 /* request handlers */
70 - (void)registerRequestHandler:(WORequestHandler *)_hdl forKey:(NSString *)_key;
71 - (void)removeRequestHandlerForKey:(NSString *)_key;
72 - (void)setDefaultRequestHandler:(WORequestHandler *)_hdl;
73 - (WORequestHandler *)defaultRequestHandler;
74 - (NSArray *)registeredRequestHandlerKeys;
78 - (id)createSessionForRequest:(WORequest *)_request;
79 - (id)restoreSessionWithID:(NSString *)_id inContext:(WOContext *)_ctx;
80 - (void)saveSessionForContext:(WOContext *)_ctx;
82 - (void)setSessionStore:(WOSessionStore *)_store;
83 - (WOSessionStore *)sessionStore;
84 - (NSString *)sessionStoreClassName;
85 - (void)refuseNewSessions:(BOOL)_flag;
86 - (BOOL)isRefusingNewSessions;
87 - (int)activeSessionsCount;
89 - (void)setMinimumActiveSessionsCount:(int)_minimum;
90 - (int)minimumActiveSessionsCount;
92 - (WOResponse *)handleSessionCreationErrorInContext:(WOContext *)_context;
93 - (WOResponse *)handleSessionRestorationErrorInContext:(WOContext *)_context;
94 - (WOResponse *)handlePageRestorationErrorInContext:(WOContext *)_context;
98 - (void)setStatisticsStore:(WOStatisticsStore *)_statStore;
99 - (WOStatisticsStore *)statisticsStore;
100 - (bycopy NSDictionary *)statistics;
104 - (void)setResourceManager:(WOResourceManager *)_manager;
105 - (WOResourceManager *)resourceManager;
107 - (NSString *)pathForResourceNamed:(NSString *)_name ofType:(NSString *)_type;
116 - (void)takeValuesFromRequest:(WORequest *)_req inContext:(WOContext *)_ctx;
117 - (id)invokeActionForRequest:(WORequest *)_req inContext:(WOContext *)_ctx;
118 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx;
120 /* dynamic elements */
122 - (WOElement *)dynamicElementWithName:(NSString *)_name // element class name
123 associations:(NSDictionary *)_associations // bindings
124 template:(WOElement *)_template // child elements
125 languages:(NSArray *)_languages;
129 - (void)setPageRefreshOnBacktrackEnabled:(BOOL)_flag;
130 - (BOOL)isPageRefreshOnBacktrackEnabled;
131 - (void)setCachingEnabled:(BOOL)_flag;
132 - (BOOL)isCachingEnabled;
133 - (void)setPageCacheSize:(int)_size;
134 - (int)pageCacheSize;
135 - (void)setPermanentPageCacheSize:(int)_size;
136 - (int)permanentPageCacheSize;
138 - (id)pageWithName:(NSString *)_name inContext:(WOContext *)_ctx;
139 - (id)pageWithName:(NSString *)_name forRequest:(WORequest *)_req;
143 - (WOResponse *)handleException:(NSException *)_exc
144 inContext:(WOContext *)_ctx;
148 @interface WOApplication(DeprecatedMethodsInWO4)
151 - (WOContext *)context;
154 - (id)restoreSession;
155 - (void)saveSession:(WOSession *)_session;
157 - (WOResponse *)handleSessionCreationError;
158 - (WOResponse *)handleSessionRestorationError;
159 - (WOResponse *)handlePageRestorationError;
161 - (void)savePage:(WOComponent *)_page;
162 - (id)restorePageForContextID:(NSString *)_ctxId;
164 - (id)pageWithName:(NSString *)_name;
166 - (WOResponse *)handleException:(NSException *)_exception;
167 - (WOResponse *)handleRequest:(WORequest *)_request;
169 - (WOElement *)dynamicElementWithName:(NSString *)_name // element class name
170 associations:(NSDictionary *)_associations // bindings
171 template:(WOElement *)_template; // child elements
173 - (NSString *)stringForKey:(NSString *)_key
174 inTableNamed:(NSString *)_tableName
175 withDefaultValue:(NSString *)_default;
179 @interface WOApplication(NonWOMethods)
181 - (WORequestHandler *)requestHandlerForKey:(NSString *)_key;
183 - (NSString *)sessionIDFromRequest:(WORequest *)_request;
184 - (NSString *)createSessionIDForSession:(WOSession *)_session;
186 + (Class)eoEditingContextClass;
187 + (BOOL)implementsEditingContexts;
191 @interface WOApplication(Defaults)
193 /* WOComponentRequestHandlerKey */
194 + (void)setComponentRequestHandlerKey:(NSString *)_key;
195 + (NSString *)componentRequestHandlerKey;
197 /* WODirectActionRequestHandlerKey */
198 + (void)setDirectActionRequestHandlerKey:(NSString *)_key;
199 + (NSString *)directActionRequestHandlerKey;
201 /* WOResourceRequestHandlerKey */
202 + (void)setResourceRequestHandlerKey:(NSString *)_key;
203 + (NSString *)resourceRequestHandlerKey;
205 /* WODefaultSessionTimeOut */
206 + (void)setSessionTimeOut:(NSNumber *)_timeOut;
207 + (NSNumber *)sessionTimeOut;
209 /* WOCachingEnabled */
210 + (BOOL)isCachingEnabled;
212 /* WODebuggingEnabled */
213 + (BOOL)isDebuggingEnabled;
217 @interface WOApplication(WODebugging)
218 /* implemented in NGExtensions */
220 - (void)debugWithFormat:(NSString *)_format, ...;
221 - (void)logWithFormat:(NSString *)_format, ...;
225 #endif /* __NGObjWeb_WOApplication_H__ */