01: /*
02: * de.schlund.pfixcore.example.webservices.CounterImpl
03: */
04: package de.schlund.pfixcore.example.webservices;
05:
06: import de.schlund.pfixcore.example.ContextCounter;
07: import de.schlund.pfixcore.webservice.AbstractService;
08:
09: /**
10: * CounterImpl.java
11: *
12: * Created: 29.06.2004
13: *
14: * @author mleidig
15: */
16: public class CounterImpl extends AbstractService implements Counter {
17:
18: public int getValue() throws Exception {
19: ContextCounter counter = (ContextCounter) getContextResourceManager()
20: .getResource(ContextCounter.class.getName());
21: return counter.getCounter();
22: }
23:
24: public boolean setValue(int value) throws Exception {
25: ContextCounter counter = (ContextCounter) getContextResourceManager()
26: .getResource(ContextCounter.class.getName());
27: counter.setCounter(value);
28: return true;
29: }
30:
31: public int addValue(int value) throws Exception {
32: ContextCounter counter = (ContextCounter) getContextResourceManager()
33: .getResource(ContextCounter.class.getName());
34: counter.addToCounter(value);
35: return counter.getCounter();
36: }
37:
38: public int subtractValue(int value) throws Exception {
39: ContextCounter counter = (ContextCounter) getContextResourceManager()
40: .getResource(ContextCounter.class.getName());
41: counter.setCounter(counter.getCounter() - value);
42: return counter.getCounter();
43: }
44:
45: public boolean reset() throws Exception {
46: ContextCounter counter = (ContextCounter) getContextResourceManager()
47: .getResource(ContextCounter.class.getName());
48: counter.setCounter(0);
49: return true;
50: }
51:
52: }
|