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 "WOComponentFault.h"
24 #include "WOComponent+private.h"
25 #include <NGObjWeb/WOResourceManager.h>
26 #include <NGObjWeb/WOContext.h>
27 #include <NGObjWeb/WOApplication.h>
30 @implementation WOComponentFault
36 - (id)initWithResourceManager:(WOResourceManager *)_rm
37 pageName:(NSString *)_name
38 languages:(NSArray *)_langs
39 bindings:(NSDictionary *)_bindings
41 NSZone *z = [self zone];
42 self->resourceManager = RETAIN(_rm);
43 self->pageName = [_name copyWithZone:z];
44 self->languages = [_langs copyWithZone:z];
45 self->bindings = [_bindings copyWithZone:z];
47 [[NSNotificationCenter defaultCenter]
49 selector:@selector(_contextWillDealloc:)
50 name:@"WOContextWillDeallocate" object:nil];
56 [[NSNotificationCenter defaultCenter] removeObserver:self];
57 RELEASE(self->bindings);
58 RELEASE(self->resourceManager);
59 RELEASE(self->pageName);
60 RELEASE(self->languages);
66 - (void)_contextWillDealloc:(NSNotification *)_notification {
68 NSAssert(_notification, @"missing valid notification arg ...");
72 /* component isn't interested in context anyway ... */
74 if (![[self->ctx contextID] isEqualToString:[_notification object]])
75 /* not the component's context ... */
81 /* cached awake & sleep */
83 - (void)ensureAwakeInContext:(WOContext *)_ctx {
86 - (void)_awakeWithContext:(WOContext *)_ctx {
87 [self ensureAwakeInContext:_ctx];
89 - (void)_sleepWithContext:(WOContext *)_ctx {
95 - (WOComponent *)resolveWithParent:(WOComponent *)_parent {
97 WOResourceManager *rm;
100 [self logWithFormat:@"resolving fault for component %@", self->pageName];
103 if ((rm = self->resourceManager))
105 else if ((rm = [_parent resourceManager]))
108 rm = [[WOApplication application] resourceManager];
110 c = [rm pageWithName:self->pageName languages:self->languages];
111 //[self logWithFormat:@" rm: %@", rm];
112 //[self logWithFormat:@" c: %@", c];
114 [c setBindings:self->bindings];
115 [c setParent:_parent];
116 if (self->ctx) [c _awakeWithContext:self->ctx];
119 [self logWithFormat:@"could not resolve fault for component: %@",
121 [self logWithFormat:@" resource-manager: %@", rm];
122 [self logWithFormat:@" parent: %@", _parent];
128 - (void)setParent:(id)_parent {
130 Not attached to a parent, this is called by WOComponent -dealloc on
131 each child (which can be a fault).
135 - (BOOL)isComponentFault {
141 - (void)encodeWithCoder:(NSCoder *)_coder {
142 [_coder encodeObject:self->pageName];
143 [_coder encodeObject:self->languages];
144 [_coder encodeObject:self->bindings];
146 - (id)initWithCoder:(NSCoder *)_decoder {
147 if ((self = [super init])) {
148 self->pageName = [[_decoder decodeObject] copy];
149 self->languages = [[_decoder decodeObject] retain];
150 self->bindings = [[_decoder decodeObject] retain];
157 - (id)copyWithZone:(NSZone *)_zone {
158 return [self retain];
161 @end /* WOComponentFault */
163 @implementation WOComponent(WOComponentFault)
165 - (BOOL)isComponentFault {
169 @end /* WOComponent(WOComponentFault) */