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 "SoComponent.h"
23
#include "SoProductResourceManager.h"
24
#include "SoProductRegistry.h"
25
#include "SoProduct.h"
26
#include <NGObjWeb/WOApplication.h>
29
@implementation SoComponent
32
return [super version] + 0 /* v2 */;
35
static BOOL didInit = NO;
38
NSAssert2([super version] == 2,
39
@"invalid superclass (%@) version %i !",
40
NSStringFromClass([self superclass]), [super version]);
45
[self->soResourceManager release];
46
[self->soTemplate release];
47
[self->soBaseURL release];
51
/* resource manager */
53
- (NSBundle *)componentBundle {
54
return [NSBundle bundleForClass:[self class]];
56
- (SoProduct *)componentProduct {
57
static SoProductRegistry *reg = nil;
62
reg = [[SoProductRegistry sharedProductRegistry] retain];
64
[self logWithFormat:@"ERROR: missing product registry!"];
66
if ((bundle = [self componentBundle]) == nil)
67
[self logWithFormat:@"WARNING: did not find bundle of component !"];
69
if ((product = [reg productForBundle:bundle]) == nil)
71
@"WARNING: did not find product of component (bundle=%@)", bundle];
75
- (void)setResourceManager:(WOResourceManager *)_rm {
76
ASSIGN(self->soResourceManager, _rm);
78
- (WOResourceManager *)resourceManager {
79
if (self->soResourceManager)
80
return self->soResourceManager;
82
self->soResourceManager = [[[self componentProduct] resourceManager] retain];
83
if (self->soResourceManager)
84
return self->soResourceManager;
86
return [super resourceManager];
89
/* move some extra vars into ivars */
91
- (void)setBaseURL:(NSURL *)_url {
92
ASSIGN(self->soBaseURL, _url);
98
return self->soBaseURL;
100
url = [(WOApplication *)[self application] baseURL];
101
url = [NSURL URLWithString:@"WebServerResources" relativeToURL:url];
102
self->soBaseURL = [url copy];
103
return self->soBaseURL;
106
- (void)setTemplate:(id)_template {
108
WO has private API for this:
109
- (void)setTemplate:(WOElement *)template;
110
As mentioned in the OmniGroup WO mailing list ...
112
ASSIGN(self->soTemplate, _template);
114
- (WOElement *)_woComponentTemplate {
117
if (self->soTemplate)
118
return self->soTemplate;
120
tmpl = [self templateWithName:[self name]];
123
@"WARNING: found not template named '%@' for component.",
129
@end /* SoComponent */