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 #include <NGObjWeb/WOSessionStore.h>
23 #include <NGObjWeb/WOApplication.h>
24 #include <NGObjWeb/WOContext.h>
25 #include <NGObjWeb/WOSession.h>
28 #if APPLE_FOUNDATION_LIBRARY || NeXT_Foundation_LIBRARY
29 @interface NSObject(Miss)
30 - (void)subclassResponsibility:(SEL)cmd;
34 @implementation WOSessionStore
40 + (WOSessionStore *)serverSessionStore {
42 [[[NSClassFromString(@"WOServerSessionStore") alloc] init] autorelease];
45 - (int)activeSessionsCount {
46 [self subclassResponsibility:_cmd];
52 - (WOSession *)checkOutSessionWithSessionID:(NSString *)_sid
53 request:(WORequest *)_request
58 SYNCHRONIZED(self) { // this must become a condition lock !!!
59 if (![self->checkedOutSessions containsObject:_sid]) {
60 if ((session = [self restoreSessionWithID:_sid]))
61 [self->checkedOutSessions addObject:_sid];
71 - (void)checkInSessionForContext:(WOContext *)_context {
73 *(&sid) = [[_context session] sessionID];
75 SYNCHRONIZED(self) { // this must become a condition lock !!!
76 [self saveSessionForContext:_context];
78 if ([self->checkedOutSessions containsObject:sid])
79 [self->checkedOutSessions removeObject:sid];
84 /* deprecated store */
86 - (void)saveSession:(WOSession *)_session {
88 [self saveSessionForContext:[_session context]];
90 - (WOSession *)restoreSessionWithID:(NSString *)_sid {
92 return [self restoreSessionWithID:_sid request:nil];
97 - (void)saveSessionForContext:(WOContext *)_context {
98 [self subclassResponsibility:_cmd];
100 - (WOSession *)restoreSessionWithID:(NSString *)_sid
101 request:(WORequest *)_request
103 [self subclassResponsibility:_cmd];
107 @end /* WOSessionStore */