diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-06-04 15:53:35 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-06-04 15:53:35 +0000 |
commit | 512d5d6ee8737edc9dbc82773532ae9a54a7cfcd (patch) | |
tree | af479386298a1914edec879859341e507d0e7326 /java/src | |
parent | Bug 1597. (diff) | |
download | ice-512d5d6ee8737edc9dbc82773532ae9a54a7cfcd.tar.bz2 ice-512d5d6ee8737edc9dbc82773532ae9a54a7cfcd.tar.xz ice-512d5d6ee8737edc9dbc82773532ae9a54a7cfcd.zip |
Bug 1658 - listen on 0.0.0.0 rather than expanding endpoints
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/ObjectAdapterI.java | 108 | ||||
-rw-r--r-- | java/src/IceInternal/EndpointFactory.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/EndpointFactoryManager.java | 6 | ||||
-rw-r--r-- | java/src/IceInternal/EndpointI.java | 8 | ||||
-rw-r--r-- | java/src/IceInternal/ReferenceFactory.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/TcpEndpointFactory.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/TcpEndpointI.java | 84 | ||||
-rw-r--r-- | java/src/IceInternal/UdpEndpointFactory.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/UdpEndpointI.java | 83 | ||||
-rw-r--r-- | java/src/IceInternal/UnknownEndpointI.java | 15 |
10 files changed, 167 insertions, 151 deletions
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index cfcc8cfcdd6..86fc9f0b6c6 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -565,6 +565,47 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt _locatorInfo = _instance.locatorManager().get(locator); } + public void + refreshPublishedEndpoints() + { + IceInternal.LocatorInfo locatorInfo = null; + boolean registerProcess = false; + java.util.ArrayList oldPublishedEndpoints; + + synchronized(this) + { + checkForDeactivation(); + + oldPublishedEndpoints = _publishedEndpoints; + _publishedEndpoints = parsePublishedEndpoints(); + + locatorInfo = _locatorInfo; + if(!_noConfig) + { + registerProcess = + _instance.initializationData().properties.getPropertyAsInt(_name + ".RegisterProcess") > 0; + } + } + + try + { + Ice.Identity dummy = new Ice.Identity(); + dummy.name = "dummy"; + updateLocatorRegistry(locatorInfo, createDirectProxy(dummy), registerProcess); + } + catch(Ice.LocalException ex) + { + synchronized(this) + { + // + // Restore the old published endpoints. + // + _publishedEndpoints = oldPublishedEndpoints; + throw ex; + } + } + } + public boolean isLocal(ObjectPrx proxy) { @@ -915,33 +956,9 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt } // - // Parse published endpoints. If set, these are used in proxies - // instead of the connection factory Endpoints. - // - String endpts = properties.getProperty(_name + ".PublishedEndpoints"); - _publishedEndpoints = parseEndpoints(endpts); - if(_publishedEndpoints.size() == 0) - { - for(int i = 0; i < _incomingConnectionFactories.size(); ++i) - { - IceInternal.IncomingConnectionFactory factory = - (IceInternal.IncomingConnectionFactory)_incomingConnectionFactories.get(i); - _publishedEndpoints.add(factory.endpoint()); - } - } - - // - // Filter out any endpoints that are not meant to be published. + // Parse the publsihed endpoints. // - java.util.Iterator p = _publishedEndpoints.iterator(); - while(p.hasNext()) - { - IceInternal.EndpointI endpoint = (IceInternal.EndpointI)p.next(); - if(!endpoint.publish()) - { - p.remove(); - } - } + _publishedEndpoints = parsePublishedEndpoints(); } if(properties.getProperty(_name + ".Locator").length() > 0) @@ -1115,15 +1132,14 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt } String s = endpts.substring(beg, end); - IceInternal.EndpointI endp = _instance.endpointFactoryManager().create(s); + IceInternal.EndpointI endp = _instance.endpointFactoryManager().create(s, true); if(endp == null) { Ice.EndpointParseException e = new Ice.EndpointParseException(); e.str = s; throw e; } - java.util.ArrayList endps = endp.expand(true); - endpoints.addAll(endps); + endpoints.add(endp); ++end; } @@ -1131,6 +1147,40 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt return endpoints; } + private java.util.ArrayList + parsePublishedEndpoints() + { + // + // Parse published endpoints. If set, these are used in proxies + // instead of the connection factory Endpoints. + // + String endpts = _instance.initializationData().properties.getProperty(_name + ".PublishedEndpoints"); + java.util.ArrayList endpoints = parseEndpoints(endpts); + if(endpoints.size() == 0) + { + for(int i = 0; i < _incomingConnectionFactories.size(); ++i) + { + IceInternal.IncomingConnectionFactory factory = + (IceInternal.IncomingConnectionFactory)_incomingConnectionFactories.get(i); + endpoints.add(factory.endpoint()); + } + } + + // + // Expand any endpoints that may be listening on INADDR_ANY to + // include actual addresses in the published endpoints. + // + java.util.ArrayList expandedEndpoints = new java.util.ArrayList(); + java.util.Iterator p = endpoints.iterator(); + while(p.hasNext()) + { + IceInternal.EndpointI endp = (IceInternal.EndpointI)p.next(); + java.util.ArrayList endps = endp.expand(); + expandedEndpoints.addAll(endps); + } + return expandedEndpoints; + } + private void updateLocatorRegistry(IceInternal.LocatorInfo locatorInfo, Ice.ObjectPrx proxy, boolean registerProcess) { diff --git a/java/src/IceInternal/EndpointFactory.java b/java/src/IceInternal/EndpointFactory.java index ed7db6721a1..2a55a48a32a 100644 --- a/java/src/IceInternal/EndpointFactory.java +++ b/java/src/IceInternal/EndpointFactory.java @@ -13,7 +13,7 @@ public interface EndpointFactory { short type(); String protocol(); - EndpointI create(String str); + EndpointI create(String str, boolean oaEndpoint); EndpointI read(BasicStream s); void destroy(); } diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java index 3ddbbe42b60..52b2e21888e 100644 --- a/java/src/IceInternal/EndpointFactoryManager.java +++ b/java/src/IceInternal/EndpointFactoryManager.java @@ -45,7 +45,7 @@ public final class EndpointFactoryManager } public synchronized EndpointI - create(String str) + create(String str, boolean server) { String s = str.trim(); if(s.length() == 0) @@ -72,12 +72,12 @@ public final class EndpointFactoryManager EndpointFactory f = (EndpointFactory)_factories.get(i); if(f.protocol().equals(protocol)) { - return f.create(s.substring(m.end())); + return f.create(s.substring(m.end()), server); // Code below left in place for debugging. /* - EndpointI e = f.create(s.substring(m.end())); + EndpointI e = f.create(s.substring(m.end()), server); BasicStream bs = new BasicStream(_instance, true); e.streamWrite(bs); java.nio.ByteBuffer buf = bs.prepareRead(); diff --git a/java/src/IceInternal/EndpointI.java b/java/src/IceInternal/EndpointI.java index f20208d8b44..1781db8a5ea 100644 --- a/java/src/IceInternal/EndpointI.java +++ b/java/src/IceInternal/EndpointI.java @@ -120,13 +120,7 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable // Expand endpoint out in to separate endpoints for each local // host if endpoint was configured with no host set. // - public abstract java.util.ArrayList expand(boolean server); - - // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public abstract boolean publish(); + public abstract java.util.ArrayList expand(); // // Check whether the endpoint is equivalent to a specific diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java index 688c2f76be0..06864aa2092 100644 --- a/java/src/IceInternal/ReferenceFactory.java +++ b/java/src/IceInternal/ReferenceFactory.java @@ -425,10 +425,10 @@ public final class ReferenceFactory } String es = s.substring(beg, end); - EndpointI endp = _instance.endpointFactoryManager().create(es); + EndpointI endp = _instance.endpointFactoryManager().create(es, false); if(endp != null) { - java.util.ArrayList endps = endp.expand(false); + java.util.ArrayList endps = endp.expand(); endpoints.addAll(endps); } else diff --git a/java/src/IceInternal/TcpEndpointFactory.java b/java/src/IceInternal/TcpEndpointFactory.java index ace33a69fe3..1bc9e326d66 100644 --- a/java/src/IceInternal/TcpEndpointFactory.java +++ b/java/src/IceInternal/TcpEndpointFactory.java @@ -29,9 +29,9 @@ final class TcpEndpointFactory implements EndpointFactory } public EndpointI - create(String str) + create(String str, boolean oaEndpoint) { - return new TcpEndpointI(_instance, str); + return new TcpEndpointI(_instance, str, oaEndpoint); } public EndpointI diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java index 3acaa224c59..3929ab77681 100644 --- a/java/src/IceInternal/TcpEndpointI.java +++ b/java/src/IceInternal/TcpEndpointI.java @@ -14,7 +14,7 @@ final class TcpEndpointI extends EndpointI final static short TYPE = 1; public - TcpEndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co, boolean pub) + TcpEndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co, boolean oae) { _instance = instance; _host = ho; @@ -22,19 +22,19 @@ final class TcpEndpointI extends EndpointI _timeout = ti; _connectionId = conId; _compress = co; - _publish = pub; + _oaEndpoint = oae; calcHashValue(); } public - TcpEndpointI(Instance instance, String str) + TcpEndpointI(Instance instance, String str, boolean oaEndpoint) { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; - _publish = true; + _oaEndpoint = oaEndpoint; String[] arr = str.split("[ \t\n\r]+"); @@ -132,6 +132,27 @@ final class TcpEndpointI extends EndpointI } } } + + if(_host == null) + { + _host = _instance.defaultsAndOverrides().defaultHost; + if(_host == null) + { + if(_oaEndpoint) + { + _host = "0.0.0.0"; + } + else + { + _host = "127.0.0.1"; + } + } + } + else if(_host.equals("*")) + { + _host = "0.0.0.0"; + } + calcHashValue(); } public @@ -144,7 +165,7 @@ final class TcpEndpointI extends EndpointI _timeout = s.readInt(); _compress = s.readBool(); s.endReadEncaps(); - _publish = true; + _oaEndpoint = false; calcHashValue(); } @@ -221,7 +242,7 @@ final class TcpEndpointI extends EndpointI } else { - return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish); + return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _oaEndpoint); } } @@ -237,7 +258,7 @@ final class TcpEndpointI extends EndpointI } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish); + return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _oaEndpoint); } } @@ -265,7 +286,7 @@ final class TcpEndpointI extends EndpointI } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish); + return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _oaEndpoint); } } @@ -349,38 +370,17 @@ final class TcpEndpointI extends EndpointI { TcpAcceptor p = new TcpAcceptor(_instance, _host, _port); endpoint.value = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, _connectionId, - _compress, _publish); + _compress, _oaEndpoint); return p; } // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public java.util.ArrayList - expand(boolean server) + expand() { - if(_host == null) - { - _host = _instance.defaultsAndOverrides().defaultHost; - if(_host == null) - { - if(server) - { - _host = "0.0.0.0"; - } - else - { - _host = "127.0.0.1"; - } - } - } - else if(_host.equals("*")) - { - _host = "0.0.0.0"; - } - java.util.ArrayList endps = new java.util.ArrayList(); if(_host.equals("0.0.0.0")) { @@ -389,29 +389,21 @@ final class TcpEndpointI extends EndpointI while(iter.hasNext()) { String host = (String)iter.next(); - endps.add(new TcpEndpointI(_instance, host, _port, _timeout, _connectionId, _compress, - hosts.size() == 1 || !host.equals("127.0.0.1"))); + if(!_oaEndpoint || hosts.size() == 1 || !host.equals("127.0.0.1")) + { + endps.add(new TcpEndpointI(_instance, host, _port, _timeout, _connectionId, _compress, + _oaEndpoint)); + } } } else { - calcHashValue(); endps.add(this); } return endps; } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public boolean - publish() - { - return _publish; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // @@ -585,6 +577,6 @@ final class TcpEndpointI extends EndpointI private int _timeout; private String _connectionId = ""; private boolean _compress; - private boolean _publish; + private boolean _oaEndpoint; private int _hashCode; } diff --git a/java/src/IceInternal/UdpEndpointFactory.java b/java/src/IceInternal/UdpEndpointFactory.java index 95e886c8bd9..76a98188408 100644 --- a/java/src/IceInternal/UdpEndpointFactory.java +++ b/java/src/IceInternal/UdpEndpointFactory.java @@ -29,9 +29,9 @@ final class UdpEndpointFactory implements EndpointFactory } public EndpointI - create(String str) + create(String str, boolean oaEndpoint) { - return new UdpEndpointI(_instance, str); + return new UdpEndpointI(_instance, str, oaEndpoint); } public EndpointI diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java index 70ad6b17f9c..d31833d8630 100644 --- a/java/src/IceInternal/UdpEndpointI.java +++ b/java/src/IceInternal/UdpEndpointI.java @@ -15,7 +15,7 @@ final class UdpEndpointI extends EndpointI public UdpEndpointI(Instance instance, String ho, int po, String mif, int mttl, boolean conn, String conId, boolean co, - boolean pub) + boolean oae) { _instance = instance; _host = ho; @@ -29,12 +29,12 @@ final class UdpEndpointI extends EndpointI _connect = conn; _connectionId = conId; _compress = co; - _publish = pub; + _oaEndpoint = oae; calcHashValue(); } public - UdpEndpointI(Instance instance, String str) + UdpEndpointI(Instance instance, String str, boolean oaEndpoint) { _instance = instance; _host = null; @@ -45,7 +45,7 @@ final class UdpEndpointI extends EndpointI _encodingMinor = Protocol.encodingMinor; _connect = false; _compress = false; - _publish = true; + _oaEndpoint = oaEndpoint; String[] arr = str.split("[ \t\n\r]+"); @@ -245,6 +245,27 @@ final class UdpEndpointI extends EndpointI throw new Ice.EndpointParseException("udp " + str); } } + + if(_host == null) + { + _host = _instance.defaultsAndOverrides().defaultHost; + if(_host == null) + { + if(_oaEndpoint) + { + _host = "0.0.0.0"; + } + else + { + _host = "127.0.0.1"; + } + } + } + else if(_host.equals("*")) + { + _host = "0.0.0.0"; + } + calcHashValue(); } public @@ -281,7 +302,7 @@ final class UdpEndpointI extends EndpointI _connect = false; _compress = s.readBool(); s.endReadEncaps(); - _publish = true; + _oaEndpoint = false; calcHashValue(); } @@ -401,7 +422,7 @@ final class UdpEndpointI extends EndpointI else { return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _connect, _connectionId, - compress, _publish); + compress, _oaEndpoint); } } @@ -418,7 +439,7 @@ final class UdpEndpointI extends EndpointI else { return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _connect, connectionId, - _compress, _publish); + _compress, _oaEndpoint); } } @@ -490,8 +511,7 @@ final class UdpEndpointI extends EndpointI { UdpTransceiver p = new UdpTransceiver(_instance, _host, _port, _mcastInterface, _connect); endpoint.value = new UdpEndpointI(_instance, _host, p.effectivePort(), _mcastInterface, _mcastTtl, _connect, - _connectionId, _compress, - _publish); + _connectionId, _compress, _oaEndpoint); return p; } @@ -521,32 +541,11 @@ final class UdpEndpointI extends EndpointI // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public java.util.ArrayList - expand(boolean server) + expand() { - if(_host == null) - { - _host = _instance.defaultsAndOverrides().defaultHost; - if(_host == null) - { - if(server) - { - _host = "0.0.0.0"; - } - else - { - _host = "127.0.0.1"; - } - } - } - else if(_host.equals("*")) - { - _host = "0.0.0.0"; - } - java.util.ArrayList endps = new java.util.ArrayList(); if(_host.equals("0.0.0.0")) { @@ -555,29 +554,21 @@ final class UdpEndpointI extends EndpointI while(iter.hasNext()) { String host = (String)iter.next(); - endps.add(new UdpEndpointI(_instance, host, _port, _mcastInterface, _mcastTtl, _connect, - _connectionId, _compress, hosts.size() == 1 || !host.equals("127.0.0.1"))); + if(!_oaEndpoint || hosts.size() == 1 || !host.equals("127.0.0.1")) + { + endps.add(new UdpEndpointI(_instance, host, _port, _mcastInterface, _mcastTtl, _connect, + _connectionId, _compress, _oaEndpoint)); + } } } else { - calcHashValue(); endps.add(this); } return endps; } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public boolean - publish() - { - return _publish; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // @@ -810,6 +801,6 @@ final class UdpEndpointI extends EndpointI private boolean _connect; private String _connectionId = ""; private boolean _compress; - private boolean _publish; + private boolean _oaEndpoint; private int _hashCode; } diff --git a/java/src/IceInternal/UnknownEndpointI.java b/java/src/IceInternal/UnknownEndpointI.java index 300da7a056f..8eae6d67a8e 100644 --- a/java/src/IceInternal/UnknownEndpointI.java +++ b/java/src/IceInternal/UnknownEndpointI.java @@ -269,11 +269,10 @@ final class UnknownEndpointI extends EndpointI // // Expand endpoint out in to separate endpoints for each local - // host if endpoint was configured with no host set. This - // only applies for ObjectAdapter endpoints. + // host if endpoint was configured with no host set. // public java.util.ArrayList - expand(boolean server) + expand() { java.util.ArrayList endps = new java.util.ArrayList(); calcHashValue(); @@ -282,16 +281,6 @@ final class UnknownEndpointI extends EndpointI } // - // Return whether endpoint should be published in proxies - // created by Object Adapter. - // - public boolean - publish() - { - return false; - } - - // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor // |