1 // $Id: ApacheWOTransaction.m,v 1.1 2004/06/08 11:06:00 helge Exp $
3 #include "ApacheWOTransaction.h"
6 #include "AWODirectoryConfig.h"
7 #include "AWOServerConfig.h"
8 #include "ApacheResourceManager.h"
9 #include "WORequest+Apache.h"
10 #include "WOResponse+Apache.h"
11 #include <ApacheAPI/ApacheRequest.h>
12 #include <NGObjWeb/WORequest.h>
13 #include <NGObjWeb/WOResponse.h>
14 #include <NGObjWeb/WOApplication.h>
16 @implementation ApacheWOTransaction
18 - (id)initWithApacheRequest:(ApacheRequest *)_rq
19 config:(AWODirectoryConfig *)_cfg
20 serverConfig:(AWOServerConfig *)_srvcfg
26 self->config = RETAIN(_cfg);
27 self->serverConfig = RETAIN(_srvcfg);
28 self->request = RETAIN(_rq);
30 if ((self->woRequest = [[WORequest alloc] initWithApacheRequest:_rq])==nil) {
31 NSLog(@"%s: could not create WO request ...", __PRETTY_FUNCTION__);
36 if ((self->application = [[_cfg application] retain]) == nil) {
37 NSLog(@"%s: no app is configured ...", __PRETTY_FUNCTION__);
42 self->resourceManager =
43 [[ApacheResourceManager alloc] initWithApacheRequest:_rq config:_cfg];
45 if (self->resourceManager == nil) {
46 NSLog(@"%s: could not create resource manager ...", __PRETTY_FUNCTION__);
55 RELEASE(self->resourceManager);
56 RELEASE(self->woRequest);
57 RELEASE(self->woResponse);
58 RELEASE(self->application);
59 RELEASE(self->serverConfig);
60 RELEASE(self->config);
61 RELEASE(self->request);
67 - (WOApplication *)application {
68 return [self->config application];
70 - (WORequest *)request {
71 return self->woRequest;
73 - (WOResponse *)response {
74 return self->woResponse;
77 - (ApacheRequest *)apacheRequest {
84 [self->application activateApplication];
85 // should use stack ??
86 [self->application setResourceManager:self->resourceManager];
89 [self->application setResourceManager:nil];
90 [self->application deactivateApplication];
95 - (int)dispatchUsingHandler:(WORequestHandler *)_handler {
98 response = [self->application
99 dispatchRequest:self->woRequest
100 usingHandler:_handler];
101 return [response sendResponseUsingApacheRequest:self->request];
106 - (NSString *)description {
109 ms = [NSMutableString stringWithCapacity:64];
110 [ms appendFormat:@"<0x%p[%@]:", self, NSStringFromClass([self class])];
111 [ms appendFormat:@" uri=%@", [[self request] uri]];
112 [ms appendString:@">"];
116 @end /* ApacheWOTransaction */