1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
9 package test
.Ice
.background
;
11 import test
.Ice
.background
.PluginFactory
.PluginI
;
13 public class Server
extends test
.Util
.Application
15 static public class LocatorI
extends Ice
._LocatorDisp
18 findAdapterById_async(Ice
.AMD_Locator_findAdapterById response
, String adapter
, Ice
.Current current
)
19 throws Ice
.AdapterNotFoundException
21 _controller
.checkCallPause(current
);
22 Ice
.Communicator communicator
= current
.adapter
.getCommunicator();
23 response
.ice_response(current
.adapter
.createDirectProxy(communicator
.stringToIdentity("dummy")));
27 findObjectById_async(Ice
.AMD_Locator_findObjectById response
, Ice
.Identity id
, Ice
.Current current
)
28 throws Ice
.ObjectNotFoundException
30 _controller
.checkCallPause(current
);
31 response
.ice_response(current
.adapter
.createDirectProxy(id
));
34 public Ice
.LocatorRegistryPrx
35 getRegistry(Ice
.Current current
)
40 LocatorI(BackgroundControllerI controller
)
42 _controller
= controller
;
45 final private BackgroundControllerI _controller
;
48 static public class RouterI
extends Ice
._RouterDisp
51 getClientProxy(Ice
.Current current
)
53 _controller
.checkCallPause(current
);
58 getServerProxy(Ice
.Current current
)
60 _controller
.checkCallPause(current
);
65 * @deprecated addProxy() is deprecated, use addProxies() instead.
68 addProxy(Ice
.ObjectPrx proxy
, Ice
.Current current
)
72 public Ice
.ObjectPrx
[]
73 addProxies(Ice
.ObjectPrx
[] proxies
, Ice
.Current current
)
75 return new Ice
.ObjectPrx
[0];
78 RouterI(BackgroundControllerI controller
)
80 _controller
= controller
;
83 final private BackgroundControllerI _controller
;
89 Configuration configuration
= new Configuration();
90 PluginI plugin
= (PluginI
)communicator().getPluginManager().getPlugin("Test");
91 plugin
.setConfiguration(configuration
);
92 communicator().getPluginManager().initializePlugins();
94 Ice
.ObjectAdapter adapter
= communicator().createObjectAdapter("TestAdapter");
95 Ice
.ObjectAdapter adapter2
= communicator().createObjectAdapter("ControllerAdapter");
97 BackgroundControllerI backgroundController
= new BackgroundControllerI(configuration
, adapter
);
99 adapter
.add(new BackgroundI(backgroundController
), communicator().stringToIdentity("background"));
100 adapter
.add(new LocatorI(backgroundController
), communicator().stringToIdentity("locator"));
101 adapter
.add(new RouterI(backgroundController
), communicator().stringToIdentity("router"));
104 adapter2
.add(backgroundController
, communicator().stringToIdentity("backgroundController"));
110 protected Ice
.InitializationData
getInitData(Ice
.StringSeqHolder argsH
)
112 Ice
.InitializationData initData
= new Ice
.InitializationData();
113 initData
.properties
= Ice
.Util
.createProperties(argsH
);
116 // This test kills connections, so we don't want warnings.
118 initData
.properties
.setProperty("Ice.Warn.Connections", "0");
121 // Setup the test transport plug-in.
123 initData
.properties
.setProperty("Ice.Plugin.Test", "test.Ice.background.PluginFactory");
124 String defaultProtocol
= initData
.properties
.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
125 initData
.properties
.setProperty("Ice.Default.Protocol", "test-" + defaultProtocol
);
127 initData
.properties
.setProperty("Ice.Package.Test", "test.Ice.background");
129 initData
.properties
.setProperty("TestAdapter.Endpoints", "default -p 12010");
130 initData
.properties
.setProperty("ControllerAdapter.Endpoints", "tcp -p 12011");
131 initData
.properties
.setProperty("ControllerAdapter.ThreadPool.Size", "1");
133 // Don't initialize the plugin until I've set the configuration.
134 initData
.properties
.setProperty("Ice.InitPlugins", "0");
142 Server app
= new Server();
143 int result
= app
.main("Server", args
);