diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2009-04-22 14:31:06 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2009-04-22 14:31:06 -0230 |
commit | b1d5e83f544f252d9718ec4e8d2be7f0ad6ccbe9 (patch) | |
tree | c1ff69a157ceeea884655ce652f5d63044f6ba1e /java | |
parent | Fixed couple of windows build issues (diff) | |
download | ice-b1d5e83f544f252d9718ec4e8d2be7f0ad6ccbe9.tar.bz2 ice-b1d5e83f544f252d9718ec4e8d2be7f0ad6ccbe9.tar.xz ice-b1d5e83f544f252d9718ec4e8d2be7f0ad6ccbe9.zip |
Bug 3137 - createObjectAdpter methods write properties
Diffstat (limited to 'java')
-rw-r--r-- | java/src/Ice/CommunicatorI.java | 38 | ||||
-rw-r--r-- | java/src/Ice/ObjectAdapterI.java | 26 | ||||
-rw-r--r-- | java/src/IceInternal/Instance.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/ObjectAdapterFactory.java | 13 | ||||
-rw-r--r-- | java/test/Ice/exceptions/AllTests.java | 1 |
5 files changed, 54 insertions, 26 deletions
diff --git a/java/src/Ice/CommunicatorI.java b/java/src/Ice/CommunicatorI.java index e300297cc3b..9263a1a2970 100644 --- a/java/src/Ice/CommunicatorI.java +++ b/java/src/Ice/CommunicatorI.java @@ -68,19 +68,51 @@ public final class CommunicatorI implements Communicator public ObjectAdapter createObjectAdapter(String name) { - return _instance.objectAdapterFactory().createObjectAdapter(name, "", null); + return _instance.objectAdapterFactory().createObjectAdapter(name, null); } public ObjectAdapter createObjectAdapterWithEndpoints(String name, String endpoints) { - return _instance.objectAdapterFactory().createObjectAdapter(name, endpoints, null); + if(name.length() == 0) + { + Ice.InitializationException ex = new Ice.InitializationException(); + ex.reason = "Cannot configure endpoints with nameless object adapter"; + throw ex; + } + + getProperties().setProperty(name + ".Endpoints", endpoints); + return _instance.objectAdapterFactory().createObjectAdapter(name, null); } public ObjectAdapter createObjectAdapterWithRouter(String name, RouterPrx router) { - return _instance.objectAdapterFactory().createObjectAdapter(name, "", router); + if(name.length() == 0) + { + Ice.InitializationException ex = new Ice.InitializationException(); + ex.reason = "Cannot configure router with nameless object adapter"; + throw ex; + } + + // + // We set the proxy properties here, although we still use the proxy supplied. + // + getProperties().setProperty(name + ".Router", proxyToString(router)); + if(router.ice_getLocator() != null) + { + ObjectPrx locator = router.ice_getLocator(); + getProperties().setProperty(name + ".Router.Locator", proxyToString(locator)); + } + getProperties().setProperty(name + ".Router.CollocationOptimized", + router.ice_isCollocationOptimized() ? "0" : "1"); + getProperties().setProperty(name + ".Router.ConnectionCached", router.ice_isConnectionCached() ? "0" : "1"); + getProperties().setProperty(name + ".Router.PreferSecure", router.ice_isPreferSecure() ? "0" : "1"); + getProperties().setProperty(name + ".Router.EndpointSelection", + router.ice_getEndpointSelection() == EndpointSelectionType.Random ? "Random" : "Ordered"); + getProperties().setProperty(name + ".Router.LocatorCacheTimeout", "" + router.ice_getLocatorCacheTimeout()); + + return _instance.objectAdapterFactory().createObjectAdapter(name, router); } public void diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index a78323d4532..0f6c0dccac5 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -747,7 +747,7 @@ public final class ObjectAdapterI implements ObjectAdapter // public ObjectAdapterI(IceInternal.Instance instance, Communicator communicator, - IceInternal.ObjectAdapterFactory objectAdapterFactory, String name, String endpointInfo, + IceInternal.ObjectAdapterFactory objectAdapterFactory, String name, RouterPrx router, boolean noConfig) { _deactivated = false; @@ -791,7 +791,7 @@ public final class ObjectAdapterI implements ObjectAdapter // // Make sure named adapter has some configuration. // - if(endpointInfo.length() == 0 && router == null && noProps) + if(router == null && noProps) { // // These need to be set to prevent finalizer from complaining. @@ -907,15 +907,8 @@ public final class ObjectAdapterI implements ObjectAdapter // Parse the endpoints, but don't store them in the adapter. The connection // factory might change it, for example, to fill in the real port number. // - java.util.List<IceInternal.EndpointI> endpoints; - if(endpointInfo.length() == 0) - { - endpoints = parseEndpoints(properties.getProperty(_name + ".Endpoints"), true); - } - else - { - endpoints = parseEndpoints(endpointInfo, true); - } + java.util.List<IceInternal.EndpointI> endpoints = + parseEndpoints(properties.getProperty(_name + ".Endpoints"), true); for(int i = 0; i < endpoints.size(); ++i) { IceInternal.EndpointI endp = endpoints.get(i); @@ -1382,10 +1375,21 @@ public final class ObjectAdapterI implements ObjectAdapter "AdapterId", "Endpoints", "Locator", + "Locator.EndpointSelection", + "Locator.ConnectionCached", + "Locator.PreferSecure", + "Locator.CollocationOptimized", + "Locator.Router", "PublishedEndpoints", "RegisterProcess", "ReplicaGroupId", "Router", + "Router.EndpointSelection", + "Router.ConnectionCached", + "Router.PreferSecure", + "Router.CollocationOptimized", + "Router.Locator", + "Router.LocatorCacheTimeout", "ProxyOptions", "ThreadPool.Size", "ThreadPool.SizeMax", diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index 952869183cc..85aae48493c 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -385,7 +385,7 @@ public final class Instance // // Create OA // - _adminAdapter = _objectAdapterFactory.createObjectAdapter(adminOA, "", null); + _adminAdapter = _objectAdapterFactory.createObjectAdapter(adminOA, null); // // Add all facets to OA diff --git a/java/src/IceInternal/ObjectAdapterFactory.java b/java/src/IceInternal/ObjectAdapterFactory.java index 8d88340d0b0..672a0c100bd 100644 --- a/java/src/IceInternal/ObjectAdapterFactory.java +++ b/java/src/IceInternal/ObjectAdapterFactory.java @@ -146,7 +146,7 @@ public final class ObjectAdapterFactory } public synchronized Ice.ObjectAdapter - createObjectAdapter(String name, String endpoints, Ice.RouterPrx router) + createObjectAdapter(String name, Ice.RouterPrx router) { if(_instance == null) { @@ -159,22 +159,15 @@ public final class ObjectAdapterFactory throw new Ice.AlreadyRegisteredException("object adapter", name); } - if(name.length() == 0 && (endpoints.length() != 0 || router != null)) - { - Ice.InitializationException ex = new Ice.InitializationException(); - ex.reason = "Cannot configure endpoints or router with nameless object adapter"; - throw ex; - } - if(name.length() == 0) { String uuid = java.util.UUID.randomUUID().toString(); - adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, uuid, "", null, true); + adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, uuid, null, true); _adapters.put(uuid, adapter); } else { - adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, name, endpoints, router, false); + adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, name, router, false); _adapters.put(name, adapter); } return adapter; diff --git a/java/test/Ice/exceptions/AllTests.java b/java/test/Ice/exceptions/AllTests.java index 49edf3613a0..91fa3437917 100644 --- a/java/test/Ice/exceptions/AllTests.java +++ b/java/test/Ice/exceptions/AllTests.java @@ -769,7 +769,6 @@ public class AllTests { // Expected } - test(communicator.getProperties().getProperty("TestAdapter0.Endpoints").equals("default")); first.deactivate(); out.println("ok"); } |