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 "OFSWebMethodRenderer.h"
23 #include "OFSWebMethod.h"
24 #include <NGObjWeb/WOResponse.h>
27 @interface OFSWebMethod(Privates)
28 - (WOComponent *)componentInContext:(WOContext *)_ctx;
31 @implementation OFSWebMethodRenderer
33 + (id)sharedRenderer {
34 static OFSWebMethodRenderer *singleton = nil;
36 singleton = [[OFSWebMethodRenderer alloc] init];
42 - (NSException *)renderComponent:(WOComponent *)_c inContext:(WOContext *)_ctx{
43 WOResponse *r = [_ctx response];
45 [r setHeader:@"text/html" forKey:@"content-type"];
47 [_ctx enterComponent:_c content:nil];
48 [_c appendToResponse:r inContext:_ctx];
49 [_ctx leaveComponent:_c];
53 - (NSException *)renderObject:(id)_object inContext:(WOContext *)_ctx {
54 WOComponent *component;
56 if (![_object isOFSWebMethod])
57 return [NSException exceptionWithHTTPStatus:500 /* server error */];
59 if ((component = [_object componentInContext:_ctx]) == nil)
60 return [NSException exceptionWithHTTPStatus:500 /* server error */];
62 return [self renderComponent:component inContext:_ctx];
65 - (BOOL)canRenderObject:(id)_object inContext:(WOContext *)_ctx {
66 return [_object isOFSWebMethod];
71 - (NSString *)loggingPrefix {
72 return @"[so-component-renderer]";
75 @end /* OFSWebMethodRenderer */