From b7083885c70346921772e6edf8f9227342dd8837 Mon Sep 17 00:00:00 2001 From: helge Date: Mon, 23 Aug 2004 00:58:37 +0000 Subject: [PATCH] changes to component activation and context tracking git-svn-id: http://svn.opengroupware.org/SOPE/trunk@39 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/NGObjWeb/ChangeLog | 14 +++++ .../NGObjWeb/SoObjects/SoProductClassInfo.m | 8 ++- sope-appserver/NGObjWeb/Version | 2 +- sope-appserver/NGObjWeb/WOApplication.m | 14 ++++- sope-appserver/NGObjWeb/WOComponent.m | 3 +- .../NGObjWeb/WOComponentDefinition.m | 1 - .../NGObjWeb/WOComponentRequestHandler.m | 10 ++-- sope-appserver/NGObjWeb/WOContext+private.h | 7 ++- sope-appserver/NGObjWeb/WOContext.m | 58 ++++++++++++++----- sope-appserver/NGObjWeb/WOCoreApplication.m | 1 - sope-appserver/NGObjWeb/WORequestHandler.m | 14 ++--- sope-appserver/NGObjWeb/WOResourceManager.m | 7 ++- 12 files changed, 99 insertions(+), 40 deletions(-) diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 8c09dd3c..9f09b4d8 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,17 @@ +2004-08-23 Helge Hess + + * v4.3.5 + + * WOContext.m, WOComponent.m: modified component awake handling, should + fix some awake-in-context logs + + * WOComponentRequestHandler.m: use _setCurrentContext: method + + * WOApplication.m: added -_setCurrentContext: method to set the global + context (should be avoided, but not always possible ..) + + * SoObjects/SoProductClassInfo.m: improved error handling (v4.3.4) + 2004-08-22 Helge Hess * v4.3.3 diff --git a/sope-appserver/NGObjWeb/SoObjects/SoProductClassInfo.m b/sope-appserver/NGObjWeb/SoObjects/SoProductClassInfo.m index 229c66b5..80669f7f 100644 --- a/sope-appserver/NGObjWeb/SoObjects/SoProductClassInfo.m +++ b/sope-appserver/NGObjWeb/SoObjects/SoProductClassInfo.m @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ +// $Id: SoProductClassInfo.m 1 2004-08-20 10:08:27Z znek $ #include "SoProductClassInfo.h" #include "SoPageInvocation.h" @@ -220,6 +220,12 @@ static int loadDebugOn = 0; - (void)applyOnRegistry:(SoClassRegistry *)_registry { SoClass *soClass; id security; + + if (_registry == nil) { + [self logWithFormat:@"WARNING(%s): did not pass a registry?!", + __PRETTY_FUNCTION__]; + return; + } if ((soClass = [_registry soClassWithName:[self className]]) == nil) { [self logWithFormat: diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index fbecef63..8c98006a 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=3 +SUBMINOR_VERSION:=4 # v4.2.413 requires libSaxObjC v4.2.33 # v4.2.341 requires libNGExtensions v4.2.77 diff --git a/sope-appserver/NGObjWeb/WOApplication.m b/sope-appserver/NGObjWeb/WOApplication.m index 77324128..64dc6924 100644 --- a/sope-appserver/NGObjWeb/WOApplication.m +++ b/sope-appserver/NGObjWeb/WOApplication.m @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ +// $Id: WOApplication.m 1 2004-08-20 10:08:27Z znek $ #include #include "WOContext+private.h" @@ -236,7 +236,8 @@ static NSString *rapidTurnAroundPath = nil; /* setup request handlers */ self->defaultRequestHandler = - [[NSClassFromString([[self class] defaultRequestHandlerClassName]) alloc] init]; + [[NSClassFromString([[self class] defaultRequestHandlerClassName]) + alloc] init]; self->requestHandlerRegistry = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 8); @@ -372,6 +373,15 @@ static NSString *rapidTurnAroundPath = nil; return self->instanceNumber; } +- (void)_setCurrentContext:(WOContext *)_ctx { + NSMutableDictionary *info; + + info = [[NSThread currentThread] threadDictionary]; + if (_ctx != nil) + [info setObject:_ctx forKey:@"WOContext"]; + else + [info removeObjectForKey:@"WOContext"]; +} - (WOContext *)context { // deprecated in WO4 NSThread *t; diff --git a/sope-appserver/NGObjWeb/WOComponent.m b/sope-appserver/NGObjWeb/WOComponent.m index 94e3cb7c..54550173 100644 --- a/sope-appserver/NGObjWeb/WOComponent.m +++ b/sope-appserver/NGObjWeb/WOComponent.m @@ -18,7 +18,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ +// $Id: WOComponent.m 1 2004-08-20 10:08:27Z znek $ #include #include "WOComponent+private.h" @@ -268,6 +268,7 @@ static inline id _getExtraVar(WOComponent *self, NSString *_key) { self->session = [_ctx session]; self->componentFlags.isAwake = 1; + [_ctx _addAwakeComponent:self]; /* ensure that sleep is called */ /* awake subcomponents */ { diff --git a/sope-appserver/NGObjWeb/WOComponentDefinition.m b/sope-appserver/NGObjWeb/WOComponentDefinition.m index 4791d9cd..9b9200e8 100644 --- a/sope-appserver/NGObjWeb/WOComponentDefinition.m +++ b/sope-appserver/NGObjWeb/WOComponentDefinition.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "WOComponentDefinition.h" #include "WOComponent+private.h" diff --git a/sope-appserver/NGObjWeb/WOComponentRequestHandler.m b/sope-appserver/NGObjWeb/WOComponentRequestHandler.m index 870fece1..0209ec39 100644 --- a/sope-appserver/NGObjWeb/WOComponentRequestHandler.m +++ b/sope-appserver/NGObjWeb/WOComponentRequestHandler.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "WOComponentRequestHandler.h" #include "WORequestHandler+private.h" @@ -32,6 +31,7 @@ @interface WOApplication(Privates) - (WOSession *)_initializeSessionInContext:(WOContext *)_ctx; +- (void)_setCurrentContext:(WOContext *)_ctx; @end @implementation WOComponentRequestHandler @@ -104,8 +104,7 @@ } context = [WOContext contextWithRequest:_request]; - [[[NSThread currentThread] threadDictionary] - setObject:context forKey:@"WOContext"]; + [application _setCurrentContext:context]; /* parse handler path (URL) @@ -241,9 +240,8 @@ [application unlockRequestHandling]; isLocked = NO; } - - [[[NSThread currentThread] threadDictionary] - removeObjectForKey:@"WOContext"]; + + [application _setCurrentContext:nil]; return response; } diff --git a/sope-appserver/NGObjWeb/WOContext+private.h b/sope-appserver/NGObjWeb/WOContext+private.h index 31552e78..6ab75c0c 100644 --- a/sope-appserver/NGObjWeb/WOContext+private.h +++ b/sope-appserver/NGObjWeb/WOContext+private.h @@ -1,7 +1,7 @@ /* - Copyright (C) 2000-2003 SKYRIX Software AG + Copyright (C) 2000-2004 SKYRIX Software AG - This file is part of OGo + This file is part of OpenGroupware.org. OGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __NGObjWeb_WOContext_private_H__ #define __NGObjWeb_WOContext_private_H__ @@ -33,6 +32,8 @@ extern void WOContext_leaveComponent(WOContext *_ctx, WOComponent *_component); @interface WOContext(NGObjWebInternal) +- (void)_addAwakeComponent:(WOComponent *)_component; + - (void)enterComponent:(WOComponent *)_component content:(WOElement *)_content; - (void)leaveComponent:(WOComponent *)_component; - (void)sleepComponents; diff --git a/sope-appserver/NGObjWeb/WOContext.m b/sope-appserver/NGObjWeb/WOContext.m index a565c141..d5403214 100644 --- a/sope-appserver/NGObjWeb/WOContext.m +++ b/sope-appserver/NGObjWeb/WOContext.m @@ -112,25 +112,67 @@ static NSString *WOApplicationSuffix = nil; /* components */ +- (void)_addAwakeComponent:(WOComponent *)_component { + if (_component == nil) + return; + + if ([self->awakeComponents containsObject:_component]) + return; + + /* wake up component */ + if (debugComponentAwake) + [self logWithFormat:@"mark component awake: %@", _component]; + + [self->awakeComponents addObject:_component]; +} + +- (void)_awakeComponent:(WOComponent *)_component { + if (_component == nil) + return; + + if ([self->awakeComponents containsObject:_component]) + return; + + /* wake up component */ + if (debugComponentAwake) + [self logWithFormat:@"awake component: %@", _component]; + + [_component _awakeWithContext:self]; + + [self _addAwakeComponent:_component]; + + if (debugComponentAwake) + [self logWithFormat:@"woke up component: %@", _component]; +} + - (void)sleepComponents { NSEnumerator *e; WOComponent *component; BOOL sendSleepToPage; + + if (debugComponentAwake) { + [self logWithFormat:@"sleep %d components ...", + [self->awakeComponents count]]; + } sendSleepToPage = YES; e = [self->awakeComponents objectEnumerator]; while ((component = [e nextObject])) { if (debugComponentAwake) - [self logWithFormat:@"sleep component: %@", component]; + [self logWithFormat:@" sleep component: %@", component]; [component _sleepWithContext:self]; if (component == self->page) sendSleepToPage = NO; } if (sendSleepToPage && (self->page != nil)) { if (debugComponentAwake) - [self logWithFormat:@"sleep page: %@", self->page]; + [self logWithFormat:@" sleep page: %@", self->page]; [self->page _sleepWithContext:self]; } + if (debugComponentAwake) { + [self logWithFormat:@"done sleep %d components.", + [self->awakeComponents count]]; + } [self->awakeComponents removeAllObjects]; } @@ -347,17 +389,7 @@ void WOContext_enterComponent self->contentStack[(int)self->componentStackCount] = [_content retain]; self->componentStackCount++; - if (![self->awakeComponents containsObject:_component]) { - /* wake up component */ - if (debugComponentAwake) - [self logWithFormat:@"awake component: %@", _component]; - - [_component _awakeWithContext:self]; - [self->awakeComponents addObject:_component]; - - if (debugComponentAwake) - [self logWithFormat:@"woke up component: %@", _component]; - } + [self _awakeComponent:_component]; if (parent) { if ([_component synchronizesVariablesWithBindings]) diff --git a/sope-appserver/NGObjWeb/WOCoreApplication.m b/sope-appserver/NGObjWeb/WOCoreApplication.m index 49070208..218ec0be 100644 --- a/sope-appserver/NGObjWeb/WOCoreApplication.m +++ b/sope-appserver/NGObjWeb/WOCoreApplication.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include #include diff --git a/sope-appserver/NGObjWeb/WORequestHandler.m b/sope-appserver/NGObjWeb/WORequestHandler.m index 5c7546c9..faccd753 100644 --- a/sope-appserver/NGObjWeb/WORequestHandler.m +++ b/sope-appserver/NGObjWeb/WORequestHandler.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "WORequestHandler+private.h" #include "WOApplication+private.h" @@ -41,6 +40,10 @@ @end #endif +@interface WOApplication(Privates) +- (void)_setCurrentContext:(WOContext *)_ctx; +@end + @implementation WORequestHandler static BOOL perflog = NO; @@ -122,7 +125,6 @@ static Class NSDateClass = Nil; WOResponse *response = nil; WOContext *context = nil; NSThread *thread; - NSMutableDictionary *threadDict; NSString *sessionId = nil; WOSession *session = nil; NSString *uri; @@ -143,8 +145,6 @@ static Class NSDateClass = Nil; thread = [NSThread currentThread]; NSAssert(thread, @"missing current thread ..."); - threadDict = [thread threadDictionary]; - NSAssert(threadDict, @"missing current thread's dictionary ..."); if (_request == nil) return nil; @@ -158,8 +158,7 @@ static Class NSDateClass = Nil; /* setup context */ context = [WOContext contextWithRequest:_request]; NSAssert(context, @"no context assigned .."); - NSAssert(threadDict, @"missing current thread's dictionary ..."); - [threadDict setObject:context forKey:@"WOContext"]; + [app _setCurrentContext:context]; /* check session id */ *(&session) = nil; @@ -269,8 +268,7 @@ static Class NSDateClass = Nil; } NS_ENDHANDLER; - NSAssert(threadDict, @"missing current thread's dictionary ..."); - [threadDict removeObjectForKey:@"WOContext"]; + [app _setCurrentContext:nil]; } #if USE_POOLS [pool release]; pool = nil; diff --git a/sope-appserver/NGObjWeb/WOResourceManager.m b/sope-appserver/NGObjWeb/WOResourceManager.m index b347b9a7..79c763a5 100644 --- a/sope-appserver/NGObjWeb/WOResourceManager.m +++ b/sope-appserver/NGObjWeb/WOResourceManager.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include #include "WOComponentDefinition.h" @@ -646,7 +645,8 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path) if (DefClass == Nil) DefClass = [WOComponentDefinition class]; - + + // TODO: is retained response intended? cdef = [[DefClass alloc] initWithName:_name path:[_url path] baseURL:_baseURL frameworkName:_fwname]; @@ -843,7 +843,8 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path) /* take a look into the file system */ languagePath = [language stringByAppendingPathExtension:@"lproj"]; - languagePath = [componentPath stringByAppendingPathComponent:languagePath]; + languagePath = + [componentPath stringByAppendingPathComponent:languagePath]; if ([fm fileExistsAtPath:languagePath isDirectory:&isDirectory]) { NSString *baseUrl = nil; -- 2.39.5