blob: e2ec029602d8743318638f01e41ca31f34db95d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
// **********************************************************************
//
// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
import Demo.*;
public class Server extends Ice.Application
{
//
// The servant implements the Slice interface Demo::Props as well as the
// native callback interface Ice.PropertiesAdminUpdateCallback.
//
static class PropsI extends Demo._PropsDisp implements Ice.PropertiesAdminUpdateCallback
{
PropsI()
{
_called = false;
}
public synchronized java.util.Map<String, String> getChanges(Ice.Current current)
{
//
// Make sure that we have received the property updates before we
// return the results.
//
while(!_called)
{
try
{
wait();
}
catch(InterruptedException ex)
{
}
}
_called = false;
return _changes;
}
public void shutdown(Ice.Current current)
{
current.adapter.getCommunicator().shutdown();
}
public synchronized void updated(java.util.Map<String, String> changes)
{
_changes = changes;
_called = true;
notify();
}
java.util.Map<String, String> _changes;
private boolean _called;
}
public int
run(String[] args)
{
if(args.length > 0)
{
System.err.println(appName() + ": too many arguments");
return 1;
}
PropsI props = new PropsI();
//
// Retrieve the PropertiesAdmin facet and register the servant as the update callback.
//
Ice.Object obj = communicator().findAdminFacet("Properties");
Ice.NativePropertiesAdmin admin = (Ice.NativePropertiesAdmin)obj;
admin.addUpdateCallback(props);
Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Props");
adapter.add(props, communicator().stringToIdentity("props"));
adapter.activate();
communicator().waitForShutdown();
return 0;
}
public static void
main(String[] args)
{
Server app = new Server();
int status = app.main("Server", args, "config.server");
System.exit(status);
}
}
|