01: package examples;
02:
03: import vicazh.hyperpool.stream.net.http.*;
04:
05: public class ExampleService extends Service implements
06: ExampleServiceMBean {
07: private boolean client;
08:
09: /**
10: * Set the clients parameter
11: */
12: public void setClient(boolean client) {
13: this .client = client;
14: }
15:
16: /**
17: * Return clients parameter
18: */
19: public boolean isClient() {
20: return client;
21: }
22:
23: private boolean server;
24:
25: /**
26: * Set the servers parameter
27: */
28: public void setServer(boolean server) {
29: this .server = server;
30: }
31:
32: /**
33: * Return servers parameter
34: */
35: public boolean isServer() {
36: return server;
37: }
38:
39: synchronized void print(String s) {
40: StringBuffer sb = new StringBuffer();
41: sb
42: .append("---------------------------------------------------\r\n");
43: sb.append("\r\n");
44: sb.append(s + "\r\n");
45: sb
46: .append("---------------------------------------------------\r\n");
47: String result = sb.toString();
48: System.out.println(result);
49: sendAttribute(ExampleServiceMBean.PRINT, result);
50: }
51:
52: public Connection getConnection() {
53: return new ExampleServiceConnection(this );
54: }
55:
56: public void setAttribute(String name, Object value)
57: throws Exception {
58: if (name.equals(ExampleServiceMBean.CLIENT))
59: setClient((Boolean) value);
60: else if (name.equals(ExampleServiceMBean.SERVER))
61: setServer((Boolean) value);
62: super.setAttribute(name, value);
63: }
64: }
|