2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo 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 OGo 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 OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include <NGObjWeb/WOSessionStore.h>
24 #include <NGObjWeb/WOApplication.h>
25 #include <NGObjWeb/WOContext.h>
26 #include <NGObjWeb/WOSession.h>
29 #if APPLE_FOUNDATION_LIBRARY || NeXT_Foundation_LIBRARY
30 @interface NSObject(Miss)
31 - (void)subclassResponsibility:(SEL)cmd;
35 @implementation WOSessionStore
41 + (WOSessionStore *)serverSessionStore {
43 [[[NSClassFromString(@"WOServerSessionStore") alloc] init] autorelease];
46 - (int)activeSessionsCount {
47 [self subclassResponsibility:_cmd];
53 - (WOSession *)checkOutSessionWithSessionID:(NSString *)_sid
54 request:(WORequest *)_request
59 SYNCHRONIZED(self) { // this must become a condition lock !!!
60 if (![self->checkedOutSessions containsObject:_sid]) {
61 if ((session = [self restoreSessionWithID:_sid]))
62 [self->checkedOutSessions addObject:_sid];
72 - (void)checkInSessionForContext:(WOContext *)_context {
74 *(&sid) = [[_context session] sessionID];
76 SYNCHRONIZED(self) { // this must become a condition lock !!!
77 [self saveSessionForContext:_context];
79 if ([self->checkedOutSessions containsObject:sid])
80 [self->checkedOutSessions removeObject:sid];
85 /* deprecated store */
87 - (void)saveSession:(WOSession *)_session {
89 [self saveSessionForContext:[_session context]];
91 - (WOSession *)restoreSessionWithID:(NSString *)_sid {
93 return [self restoreSessionWithID:_sid request:nil];
98 - (void)saveSessionForContext:(WOContext *)_context {
99 [self subclassResponsibility:_cmd];
101 - (WOSession *)restoreSessionWithID:(NSString *)_sid
102 request:(WORequest *)_request
104 [self subclassResponsibility:_cmd];
108 @end /* WOSessionStore */