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 - (id)checkOutSessionWithSessionID:(NSString *)_sid request:(WORequest *)_rq {
56 SYNCHRONIZED(self) { // this must become a condition lock !!!
57 if (![self->checkedOutSessions containsObject:_sid]) {
58 if ((session = [self restoreSessionWithID:_sid]))
59 [self->checkedOutSessions addObject:_sid];
69 - (void)checkInSessionForContext:(WOContext *)_context {
71 *(&sid) = [[_context session] sessionID];
73 SYNCHRONIZED(self) { // this must become a condition lock !!!
74 [self saveSessionForContext:_context];
76 if ([self->checkedOutSessions containsObject:sid])
77 [self->checkedOutSessions removeObject:sid];
82 /* deprecated store */
84 - (void)saveSession:(WOSession *)_session {
86 [self saveSessionForContext:[_session context]];
88 - (id)restoreSessionWithID:(NSString *)_sid {
90 return [self restoreSessionWithID:_sid request:nil];
95 - (void)saveSessionForContext:(WOContext *)_context {
96 [self subclassResponsibility:_cmd];
98 - (id)restoreSessionWithID:(NSString *)_sid request:(WORequest *)_request {
99 [self subclassResponsibility:_cmd];
103 @end /* WOSessionStore */