summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2006-11-24 17:29:58 +0000
committerDwayne Boone <dwayne@zeroc.com>2006-11-24 17:29:58 +0000
commit1126cea5189d035934f98822078f2ae23d9739ec (patch)
tree759430bdf201db72abddcd9bb83bed6fb034a6d2 /java/src
parentCode cleanup (diff)
downloadice-1126cea5189d035934f98822078f2ae23d9739ec.tar.bz2
ice-1126cea5189d035934f98822078f2ae23d9739ec.tar.xz
ice-1126cea5189d035934f98822078f2ae23d9739ec.zip
Added propertyToProxy
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/CommunicatorI.java6
-rw-r--r--java/src/Ice/ObjectAdapterI.java12
-rwxr-xr-xjava/src/IceGridGUI/SessionKeeper.java31
-rw-r--r--java/src/IceInternal/DefaultsAndOverrides.java6
-rw-r--r--java/src/IceInternal/Instance.java14
-rw-r--r--java/src/IceInternal/ProxyFactory.java7
-rw-r--r--java/src/IceInternal/ReferenceFactory.java70
7 files changed, 103 insertions, 43 deletions
diff --git a/java/src/Ice/CommunicatorI.java b/java/src/Ice/CommunicatorI.java
index ee9702979fc..04114b7557a 100644
--- a/java/src/Ice/CommunicatorI.java
+++ b/java/src/Ice/CommunicatorI.java
@@ -41,6 +41,12 @@ public final class CommunicatorI extends LocalObjectImpl implements Communicator
return _instance.proxyFactory().proxyToString(proxy);
}
+ public Ice.ObjectPrx
+ propertyToProxy(String s)
+ {
+ return _instance.proxyFactory().propertyToProxy(s);
+ }
+
public Ice.Identity
stringToIdentity(String s)
{
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java
index 98779683a5a..39d96ea0916 100644
--- a/java/src/Ice/ObjectAdapterI.java
+++ b/java/src/Ice/ObjectAdapterI.java
@@ -702,11 +702,7 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt
{
if(router == null)
{
- String routerStr = _instance.initializationData().properties.getProperty(name + ".Router");
- if(routerStr.length() > 0)
- {
- router = RouterPrxHelper.uncheckedCast(_instance.proxyFactory().stringToProxy(routerStr));
- }
+ router = RouterPrxHelper.uncheckedCast(_instance.proxyFactory().propertyToProxy(name + ".Router"));
}
if(router != null)
{
@@ -821,10 +817,10 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt
}
}
- String locator = _instance.initializationData().properties.getProperty(name + ".Locator");
- if(locator.length() > 0)
+ String locatorProperty = name + ".Locator";
+ if(_instance.initializationData().properties.getProperty(locatorProperty).length() > 0)
{
- setLocator(LocatorPrxHelper.uncheckedCast(_instance.proxyFactory().stringToProxy(locator)));
+ setLocator(LocatorPrxHelper.uncheckedCast(_instance.proxyFactory().propertyToProxy(locatorProperty)));
}
else
{
diff --git a/java/src/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/SessionKeeper.java
index df610dfca8b..6743d6491fe 100755
--- a/java/src/IceGridGUI/SessionKeeper.java
+++ b/java/src/IceGridGUI/SessionKeeper.java
@@ -324,17 +324,14 @@ class SessionKeeper
//
// Registry properties
//
- String defaultLocator = properties.getProperty("Ice.Default.Locator");
Ice.ObjectPrx defaultLocatorProxy = null;
- if(!defaultLocator.equals(""))
+ try
{
- try
- {
- defaultLocatorProxy = coordinator.getCommunicator().stringToProxy(defaultLocator);
- }
- catch(Ice.LocalException e)
- {
- }
+ defaultLocatorProxy = coordinator.getCommunicator().propertyToProxy("Ice.Default.Locator");
+ }
+ catch(Ice.LocalException e)
+ {
+ // Ignored, keep null defaultLocatorProxy
}
if(defaultLocatorProxy != null)
{
@@ -366,18 +363,14 @@ class SessionKeeper
//
// Glacier2 properties
//
- String defaultRouter = properties.getProperty("Ice.Default.Router");
Ice.ObjectPrx defaultRouterProxy = null;
- if(!defaultRouter.equals(""))
+ try
{
- try
- {
- defaultRouterProxy = coordinator.getCommunicator().stringToProxy(defaultRouter);
- }
- catch(Ice.LocalException e)
- {
- // Ignored, keep null defaultRouterProxy
- }
+ defaultRouterProxy = coordinator.getCommunicator().propertyToProxy("Ice.Default.Router");
+ }
+ catch(Ice.LocalException e)
+ {
+ // Ignored, keep null defaultRouterProxy
}
if(defaultRouterProxy != null)
{
diff --git a/java/src/IceInternal/DefaultsAndOverrides.java b/java/src/IceInternal/DefaultsAndOverrides.java
index a19bf426fa1..3de9ef5253d 100644
--- a/java/src/IceInternal/DefaultsAndOverrides.java
+++ b/java/src/IceInternal/DefaultsAndOverrides.java
@@ -27,8 +27,6 @@ public final class DefaultsAndOverrides
defaultHost = null;
}
- defaultRouter = properties.getProperty("Ice.Default.Router");
-
value = properties.getProperty("Ice.Override.Timeout");
if(value.length() > 0)
{
@@ -83,8 +81,6 @@ public final class DefaultsAndOverrides
overrideSecureValue = false;
}
- defaultLocator = properties.getProperty("Ice.Default.Locator");
-
defaultCollocationOptimization =
properties.getPropertyAsIntWithDefault("Ice.Default.CollocationOptimization", 1) > 0;
@@ -95,8 +91,6 @@ public final class DefaultsAndOverrides
final public String defaultHost;
final public String defaultProtocol;
- final public String defaultRouter;
- final public String defaultLocator;
final public boolean defaultCollocationOptimization;
final public int defaultLocatorCacheTimeout;
final public boolean defaultPreferSecure;
diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java
index 1d4e8ec6fec..a3fc3e9ba1e 100644
--- a/java/src/IceInternal/Instance.java
+++ b/java/src/IceInternal/Instance.java
@@ -482,17 +482,11 @@ public final class Instance
// initialization before the plug-in initialization!!! The proxies
// might depend on endpoint factories to be installed by plug-ins.
//
- if(_defaultsAndOverrides.defaultRouter.length() > 0)
- {
- _referenceFactory.setDefaultRouter(Ice.RouterPrxHelper.uncheckedCast(
- _proxyFactory.stringToProxy(_defaultsAndOverrides.defaultRouter)));
- }
+ _referenceFactory.setDefaultRouter(Ice.RouterPrxHelper.uncheckedCast(
+ _proxyFactory.propertyToProxy("Ice.Default.Router")));
- if(_defaultsAndOverrides.defaultLocator.length() > 0)
- {
- _referenceFactory.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(
- _proxyFactory.stringToProxy(_defaultsAndOverrides.defaultLocator)));
- }
+ _referenceFactory.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(
+ _proxyFactory.propertyToProxy("Ice.Default.Locator")));
//
// Start connection monitor if necessary.
diff --git a/java/src/IceInternal/ProxyFactory.java b/java/src/IceInternal/ProxyFactory.java
index 85679e2011b..f126fb77209 100644
--- a/java/src/IceInternal/ProxyFactory.java
+++ b/java/src/IceInternal/ProxyFactory.java
@@ -33,6 +33,13 @@ public final class ProxyFactory
}
public Ice.ObjectPrx
+ propertyToProxy(String prefix)
+ {
+ Reference ref = _instance.referenceFactory().createFromProperties(prefix);
+ return referenceToProxy(ref);
+ }
+
+ public Ice.ObjectPrx
streamToProxy(BasicStream s)
{
Ice.Identity ident = new Ice.Identity();
diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java
index 3c9b9d0db74..0ff5b088c05 100644
--- a/java/src/IceInternal/ReferenceFactory.java
+++ b/java/src/IceInternal/ReferenceFactory.java
@@ -501,6 +501,76 @@ public final class ReferenceFactory
}
public Reference
+ createFromProperties(String propertyPrefix)
+ {
+ Ice.Properties properties = _instance.initializationData().properties;
+
+ Reference ref = create(properties.getProperty(propertyPrefix));
+ if(ref == null)
+ {
+ return null;
+ }
+
+ String property = propertyPrefix + ".Locator";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeLocator(Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)));
+ }
+
+ property = propertyPrefix + ".LocatorCacheTimeout";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeLocatorCacheTimeout(properties.getPropertyAsInt(property));
+ }
+
+ property = propertyPrefix + ".Router";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeRouter(Ice.RouterPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)));
+ }
+
+ property = propertyPrefix + ".PreferSecure";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changePreferSecure(properties.getPropertyAsInt(property) > 0);
+ }
+
+ property = propertyPrefix + ".ConnectionCached";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeCacheConnection(properties.getPropertyAsInt(property) > 0);
+ }
+
+ property = propertyPrefix + ".EndpointSelection";
+ if(properties.getProperty(property).length() != 0)
+ {
+ String type = properties.getProperty(property);
+ if(type.equals("Random"))
+ {
+ ref = ref.changeEndpointSelection(Ice.EndpointSelectionType.Random);
+ }
+ else if(type.equals("Ordered"))
+ {
+ ref = ref.changeEndpointSelection(Ice.EndpointSelectionType.Ordered);
+ }
+ else
+ {
+ Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException();
+ ex.str = type;
+ throw ex;
+ }
+ }
+
+ property = propertyPrefix + ".CollocationOptimization";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeCollocationOptimization(properties.getPropertyAsInt(property) > 0);
+ }
+
+ return ref;
+ }
+
+ public Reference
create(Ice.Identity ident, BasicStream s)
{
//