ICE 3.4.2
[php5-ice-freebsdport.git] / java / test / Ice / background / Server.java
blobcef3baf8922b2d2a9c2ec9433bcb32959803e405
1 // **********************************************************************
2 //
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
4 //
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
7 //
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
17 public void
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")));
26 public void
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)
37 return null;
40 LocatorI(BackgroundControllerI controller)
42 _controller = controller;
45 final private BackgroundControllerI _controller;
48 static public class RouterI extends Ice._RouterDisp
50 public Ice.ObjectPrx
51 getClientProxy(Ice.Current current)
53 _controller.checkCallPause(current);
54 return null;
57 public Ice.ObjectPrx
58 getServerProxy(Ice.Current current)
60 _controller.checkCallPause(current);
61 return null;
64 /**
65 * @deprecated addProxy() is deprecated, use addProxies() instead.
66 **/
67 public void
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;
86 public int
87 run(String[] args)
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"));
102 adapter.activate();
104 adapter2.add(backgroundController, communicator().stringToIdentity("backgroundController"));
105 adapter2.activate();
107 return WAIT;
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");
136 return initData;
139 public static void
140 main(String[] args)
142 Server app = new Server();
143 int result = app.main("Server", args);
144 System.gc();
145 System.exit(result);