]> git.ipfire.org Git - thirdparty/squid.git/blame - src/eCAP/ServiceRep.cc
Converted the String implementation itself
[thirdparty/squid.git] / src / eCAP / ServiceRep.cc
CommitLineData
fdc96a39
AR
1#include "squid.h"
2#include <libecap/adapter/service.h>
3#include "TextException.h"
4#include "assert.h"
5#include "eCAP/ServiceRep.h"
6#include "eCAP/XactionRep.h"
7
8Ecap::ServiceRep::ServiceRep(const Adaptation::ServiceConfig &cfg):
26ac0430 9 /*AsyncJob("Ecap::ServiceRep"),*/ Adaptation::Service(cfg)
fdc96a39
AR
10{
11}
12
13Ecap::ServiceRep::~ServiceRep()
14{
15}
16
26ac0430
AJ
17void Ecap::ServiceRep::noteService(const AdapterService &s)
18{
fdc96a39 19 Must(s != NULL);
26ac0430
AJ
20 theService = s;
21 debugs(93,7, "Matched loaded and configured eCAP services: " <<
22 s->uri() << ' ' << cfg().key << "\n");
fdc96a39
AR
23}
24
26ac0430
AJ
25void Ecap::ServiceRep::invalidate()
26{
27 theService->retire();
28 theService.reset();
fdc96a39
AR
29}
30
26ac0430
AJ
31void Ecap::ServiceRep::noteFailure()
32{
33 assert(false); // XXX: should this be ICAP-specific?
fdc96a39
AR
34}
35
36void
37Ecap::ServiceRep::finalize()
38{
26ac0430 39 Adaptation::Service::finalize();
fdc96a39 40 if (!theService) {
26ac0430
AJ
41 debugs(93,1, "Warning: configured ecap_service was not loaded: " <<
42 cfg().uri);
43 }
fdc96a39
AR
44}
45
46bool Ecap::ServiceRep::probed() const
47{
48 return true; // we "probe" the adapter in finalize().
49}
50
51bool Ecap::ServiceRep::up() const
52{
53 return theService != NULL;
54}
55
56bool Ecap::ServiceRep::wantsUrl(const String &urlPath) const
57{
58 Must(up());
99524de7 59 return theService->wantsUrl(urlPath.unsafeBuf());
fdc96a39
AR
60}
61
62Adaptation::Initiate *
63Ecap::ServiceRep::makeXactLauncher(Adaptation::Initiator *initiator,
26ac0430 64 HttpMsg *virgin, HttpRequest *cause)
fdc96a39 65{
26ac0430
AJ
66 Must(up());
67 XactionRep *rep = new XactionRep(initiator, virgin, cause, Pointer(this));
68 XactionRep::AdapterXaction x(theService->makeXaction(rep));
fdc96a39
AR
69 rep->master(x);
70 return rep;
71}
72
73// returns a temporary string depicting service status, for debugging
74const char *Ecap::ServiceRep::status() const
75{
76 assert(false); // move generic stuff from ICAP to Adaptation
77 // add theService->status()?
26ac0430 78 return NULL;
fdc96a39 79}