diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/ObjectAdapterI.java | 53 | ||||
-rw-r--r-- | java/src/IceInternal/DefaultsAndOverrides.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/EndpointFactory.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/EndpointFactoryManager.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/EndpointI.java | 13 | ||||
-rw-r--r-- | java/src/IceInternal/Network.java | 13 | ||||
-rw-r--r-- | java/src/IceInternal/ReferenceFactory.java | 2 | ||||
-rw-r--r-- | java/src/IceInternal/TcpEndpointFactory.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/TcpEndpointI.java | 62 | ||||
-rw-r--r-- | java/src/IceInternal/UdpEndpointFactory.java | 4 | ||||
-rw-r--r-- | java/src/IceInternal/UdpEndpointI.java | 60 | ||||
-rw-r--r-- | java/src/IceInternal/UnknownEndpointI.java | 22 | ||||
-rw-r--r-- | java/src/IceSSL/SslEndpointFactory.java | 4 | ||||
-rw-r--r-- | java/src/IceSSL/SslEndpointI.java | 62 |
14 files changed, 258 insertions, 49 deletions
diff --git a/java/src/Ice/ObjectAdapterI.java b/java/src/Ice/ObjectAdapterI.java index 4a3383caf86..a704ecb4f9c 100644 --- a/java/src/Ice/ObjectAdapterI.java +++ b/java/src/Ice/ObjectAdapterI.java @@ -796,11 +796,33 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt } // - // Parse published endpoints. These are used in proxies - // instead of the connection factory endpoints. + // Parse published endpoints. If set, these are used in proxies + // instead of the connection factory Endpoints. // String endpts = _instance.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. + // + java.util.Iterator p = _publishedEndpoints.iterator(); + while(p.hasNext()) + { + IceInternal.EndpointI endpoint = (IceInternal.EndpointI)p.next(); + if(!endpoint.publish()) + { + p.remove(); + } + } String router = _instance.properties().getProperty(name + ".Router"); if(router.length() > 0) @@ -898,27 +920,9 @@ public final class ObjectAdapterI extends LocalObjectImpl implements ObjectAdapt { IceInternal.EndpointI[] endpoints; - // - // Use the published endpoints, otherwise use the endpoints from all - // incoming connection factories. - // int sz = _publishedEndpoints.size(); - if(sz > 0) - { - endpoints = new IceInternal.EndpointI[sz + _routerEndpoints.size()]; - _publishedEndpoints.toArray(endpoints); - } - else - { - sz = _incomingConnectionFactories.size(); - endpoints = new IceInternal.EndpointI[sz + _routerEndpoints.size()]; - for(int i = 0; i < sz; ++i) - { - IceInternal.IncomingConnectionFactory factory = - (IceInternal.IncomingConnectionFactory)_incomingConnectionFactories.get(i); - endpoints[i] = factory.endpoint(); - } - } + endpoints = new IceInternal.EndpointI[sz + _routerEndpoints.size()]; + _publishedEndpoints.toArray(endpoints); // // Now we also add the endpoints of the router's server proxy, if @@ -1000,14 +1004,15 @@ 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; } - endpoints.add(endp); + java.util.ArrayList endps = endp.expand(); + endpoints.addAll(endps); ++end; } diff --git a/java/src/IceInternal/DefaultsAndOverrides.java b/java/src/IceInternal/DefaultsAndOverrides.java index f68a83830af..29919584fa7 100644 --- a/java/src/IceInternal/DefaultsAndOverrides.java +++ b/java/src/IceInternal/DefaultsAndOverrides.java @@ -24,7 +24,7 @@ public final class DefaultsAndOverrides } else { - defaultHost = Network.getLocalHost(true); + defaultHost = null; } defaultRouter = properties.getProperty("Ice.Default.Router"); diff --git a/java/src/IceInternal/EndpointFactory.java b/java/src/IceInternal/EndpointFactory.java index 26211045eea..f4797838a5f 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 adapterEndp); EndpointI read(BasicStream s); void destroy(); } diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java index 944405f2bb3..9823c98d001 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 adapterEndp) { String s = str.trim(); if(s.length() == 0) @@ -72,7 +72,7 @@ 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()), adapterEndp); } } diff --git a/java/src/IceInternal/EndpointI.java b/java/src/IceInternal/EndpointI.java index 7d0078af9c6..d0beb53107c 100644 --- a/java/src/IceInternal/EndpointI.java +++ b/java/src/IceInternal/EndpointI.java @@ -112,6 +112,19 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable public abstract Acceptor acceptor(EndpointIHolder endpoint); // + // 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. + // + public abstract java.util.ArrayList expand(); + + // + // Return whether endpoint should be published in proxies + // created by Object Adapter. + // + public abstract boolean publish(); + + // // Check whether the endpoint is equivalent to a specific // Transceiver or Acceptor. // diff --git a/java/src/IceInternal/Network.java b/java/src/IceInternal/Network.java index 98d34bb0567..490a8de7554 100644 --- a/java/src/IceInternal/Network.java +++ b/java/src/IceInternal/Network.java @@ -600,6 +600,19 @@ public final class Network } public static java.util.ArrayList + getLocalHosts() + { + java.util.ArrayList hosts = new java.util.ArrayList(); + java.util.ArrayList addrs = getLocalAddresses(); + java.util.Iterator iter = addrs.iterator(); + while(iter.hasNext()) + { + hosts.add(((java.net.InetAddress)iter.next()).getHostAddress()); + } + return hosts; + } + + public static java.util.ArrayList getLocalAddresses() { java.util.ArrayList result = new java.util.ArrayList(); diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java index 394c6d0ef94..c9eb407239f 100644 --- a/java/src/IceInternal/ReferenceFactory.java +++ b/java/src/IceInternal/ReferenceFactory.java @@ -410,7 +410,7 @@ 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) { endpoints.add(endp); diff --git a/java/src/IceInternal/TcpEndpointFactory.java b/java/src/IceInternal/TcpEndpointFactory.java index 2f03dbe382f..b180698b39c 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 adapterEndp) { - return new TcpEndpointI(_instance, str); + return new TcpEndpointI(_instance, str, adapterEndp); } public EndpointI diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java index 57055b6597a..a7bc5680163 100644 --- a/java/src/IceInternal/TcpEndpointI.java +++ b/java/src/IceInternal/TcpEndpointI.java @@ -14,24 +14,26 @@ final class TcpEndpointI extends EndpointI final static short TYPE = 1; public - TcpEndpointI(Instance instance, String ho, int po, int ti, boolean co) + TcpEndpointI(Instance instance, String ho, int po, int ti, boolean co, boolean pub) { _instance = instance; _host = ho; _port = po; _timeout = ti; _compress = co; + _publish = pub; calcHashValue(); } public - TcpEndpointI(Instance instance, String str) + TcpEndpointI(Instance instance, String str, boolean adapterEndp) { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; + _publish = true; String[] arr = str.split("[ \t\n\r]+"); @@ -144,6 +146,17 @@ final class TcpEndpointI extends EndpointI if(_host == null) { _host = _instance.defaultsAndOverrides().defaultHost; + if(_host == null) + { + if(adapterEndp) + { + _host = "0.0.0.0"; + } + else + { + _host = Network.getLocalHost(true); + } + } } calcHashValue(); @@ -159,6 +172,7 @@ final class TcpEndpointI extends EndpointI _timeout = s.readInt(); _compress = s.readBool(); s.endReadEncaps(); + _publish = true; calcHashValue(); } @@ -228,7 +242,7 @@ final class TcpEndpointI extends EndpointI } else { - return new TcpEndpointI(_instance, _host, _port, timeout, _compress); + return new TcpEndpointI(_instance, _host, _port, timeout, _compress, _publish); } } @@ -256,7 +270,7 @@ final class TcpEndpointI extends EndpointI } else { - return new TcpEndpointI(_instance, _host, _port, _timeout, compress); + return new TcpEndpointI(_instance, _host, _port, _timeout, compress, _publish); } } @@ -332,11 +346,48 @@ final class TcpEndpointI extends EndpointI acceptor(EndpointIHolder endpoint) { TcpAcceptor p = new TcpAcceptor(_instance, _host, _port); - endpoint.value = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, _compress); + endpoint.value = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, _compress, _publish); 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. + // + public java.util.ArrayList + expand() + { + java.util.ArrayList endps = new java.util.ArrayList(); + if(_host.equals("0.0.0.0")) + { + java.util.ArrayList hosts = Network.getLocalHosts(); + java.util.Iterator iter = hosts.iterator(); + while(iter.hasNext()) + { + String host = (String)iter.next(); + endps.add(new TcpEndpointI(_instance, host, _port, _timeout, _compress, + hosts.size() == 1 || !host.equals("127.0.0.1"))); + } + } + else + { + 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 // @@ -489,5 +540,6 @@ final class TcpEndpointI extends EndpointI private int _port; private int _timeout; private boolean _compress; + private boolean _publish; private int _hashCode; } diff --git a/java/src/IceInternal/UdpEndpointFactory.java b/java/src/IceInternal/UdpEndpointFactory.java index 241dd90d29f..3a4826a4b53 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 adapterEndp) { - return new UdpEndpointI(_instance, str); + return new UdpEndpointI(_instance, str, adapterEndp); } public EndpointI diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java index d6fd929c23c..bb0c0e5d172 100644 --- a/java/src/IceInternal/UdpEndpointI.java +++ b/java/src/IceInternal/UdpEndpointI.java @@ -14,7 +14,7 @@ final class UdpEndpointI extends EndpointI final static short TYPE = 3; public - UdpEndpointI(Instance instance, String ho, int po, boolean co) + UdpEndpointI(Instance instance, String ho, int po, boolean co, boolean pub) { _instance = instance; _host = ho; @@ -25,11 +25,12 @@ final class UdpEndpointI extends EndpointI _encodingMinor = Protocol.encodingMinor; _connect = false; _compress = co; + _publish = pub; calcHashValue(); } public - UdpEndpointI(Instance instance, String str) + UdpEndpointI(Instance instance, String str, boolean adapterEndp) { _instance = instance; _host = null; @@ -40,6 +41,7 @@ final class UdpEndpointI extends EndpointI _encodingMinor = Protocol.encodingMinor; _connect = false; _compress = false; + _publish = true; String[] arr = str.split("[ \t\n\r]+"); @@ -254,6 +256,17 @@ final class UdpEndpointI extends EndpointI if(_host == null) { _host = instance.defaultsAndOverrides().defaultHost; + if(_host == null) + { + if(adapterEndp) + { + _host = "0.0.0.0"; + } + else + { + _host = Network.getLocalHost(true); + } + } } calcHashValue(); @@ -293,6 +306,7 @@ final class UdpEndpointI extends EndpointI _connect = false; _compress = s.readBool(); s.endReadEncaps(); + _publish = true; calcHashValue(); } @@ -394,7 +408,7 @@ final class UdpEndpointI extends EndpointI } else { - return new UdpEndpointI(_instance, _host, _port, compress); + return new UdpEndpointI(_instance, _host, _port, compress, _publish); } } @@ -457,7 +471,7 @@ final class UdpEndpointI extends EndpointI serverTransceiver(EndpointIHolder endpoint) { UdpTransceiver p = new UdpTransceiver(_instance, _host, _port, _connect); - endpoint.value = new UdpEndpointI(_instance, _host, p.effectivePort(), _compress); + endpoint.value = new UdpEndpointI(_instance, _host, p.effectivePort(), _compress, _publish); return p; } @@ -486,6 +500,43 @@ 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. + // + public java.util.ArrayList + expand() + { + java.util.ArrayList endps = new java.util.ArrayList(); + if(_host.equals("0.0.0.0")) + { + java.util.ArrayList hosts = Network.getLocalHosts(); + java.util.Iterator iter = hosts.iterator(); + while(iter.hasNext()) + { + String host = (String)iter.next(); + endps.add(new UdpEndpointI(_instance, host, _port, _compress, + hosts.size() == 1 || !host.equals("127.0.0.1"))); + } + } + else + { + 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 // @@ -678,5 +729,6 @@ final class UdpEndpointI extends EndpointI private byte _encodingMinor; private boolean _connect; private boolean _compress; + private boolean _publish; private int _hashCode; } diff --git a/java/src/IceInternal/UnknownEndpointI.java b/java/src/IceInternal/UnknownEndpointI.java index 7e1f0eca123..747f9e54f17 100644 --- a/java/src/IceInternal/UnknownEndpointI.java +++ b/java/src/IceInternal/UnknownEndpointI.java @@ -171,6 +171,28 @@ 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. + // + public java.util.ArrayList + expand() + { + assert(false); + return null; + } + + // + // 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 // diff --git a/java/src/IceSSL/SslEndpointFactory.java b/java/src/IceSSL/SslEndpointFactory.java index 89c4f8072bd..6a4d36efeb6 100644 --- a/java/src/IceSSL/SslEndpointFactory.java +++ b/java/src/IceSSL/SslEndpointFactory.java @@ -29,9 +29,9 @@ final class SslEndpointFactory implements IceInternal.EndpointFactory } public IceInternal.EndpointI - create(String str) + create(String str, boolean adapterEndp) { - return new SslEndpointI(_instance, str); + return new SslEndpointI(_instance, str, adapterEndp); } public IceInternal.EndpointI diff --git a/java/src/IceSSL/SslEndpointI.java b/java/src/IceSSL/SslEndpointI.java index d865d1db123..a81cc887f02 100644 --- a/java/src/IceSSL/SslEndpointI.java +++ b/java/src/IceSSL/SslEndpointI.java @@ -14,24 +14,26 @@ final class SslEndpointI extends IceInternal.EndpointI final static short TYPE = 2; public - SslEndpointI(Instance instance, String ho, int po, int ti, boolean co) + SslEndpointI(Instance instance, String ho, int po, int ti, boolean co, boolean pub) { _instance = instance; _host = ho; _port = po; _timeout = ti; _compress = co; + _publish = pub; calcHashValue(); } public - SslEndpointI(Instance instance, String str) + SslEndpointI(Instance instance, String str, boolean adapterEndp) { _instance = instance; _host = null; _port = 0; _timeout = -1; _compress = false; + _publish = true; String[] arr = str.split("[ \t\n\r]+"); @@ -144,6 +146,17 @@ final class SslEndpointI extends IceInternal.EndpointI if(_host == null) { _host = _instance.defaultHost(); + if(_host == null) + { + if(adapterEndp) + { + _host = "0.0.0.0"; + } + else + { + _host = IceInternal.Network.getLocalHost(true); + } + } } calcHashValue(); @@ -159,6 +172,7 @@ final class SslEndpointI extends IceInternal.EndpointI _timeout = s.readInt(); _compress = s.readBool(); s.endReadEncaps(); + _publish = true; calcHashValue(); } @@ -228,7 +242,7 @@ final class SslEndpointI extends IceInternal.EndpointI } else { - return new SslEndpointI(_instance, _host, _port, timeout, _compress); + return new SslEndpointI(_instance, _host, _port, timeout, _compress, _publish); } } @@ -256,7 +270,7 @@ final class SslEndpointI extends IceInternal.EndpointI } else { - return new SslEndpointI(_instance, _host, _port, _timeout, compress); + return new SslEndpointI(_instance, _host, _port, _timeout, compress, _publish); } } @@ -332,11 +346,48 @@ final class SslEndpointI extends IceInternal.EndpointI acceptor(IceInternal.EndpointIHolder endpoint) { SslAcceptor p = new SslAcceptor(_instance, _host, _port); - endpoint.value = new SslEndpointI(_instance, _host, p.effectivePort(), _timeout, _compress); + endpoint.value = new SslEndpointI(_instance, _host, p.effectivePort(), _timeout, _compress, _publish); 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. + // + public java.util.ArrayList + expand() + { + java.util.ArrayList endps = new java.util.ArrayList(); + if(_host.equals("0.0.0.0")) + { + java.util.ArrayList hosts = IceInternal.Network.getLocalHosts(); + java.util.Iterator iter = hosts.iterator(); + while(iter.hasNext()) + { + String host = (String)iter.next(); + endps.add(new SslEndpointI(_instance, host, _port, _timeout, _compress, + hosts.size() == 1 || !host.equals("127.0.0.1"))); + } + } + else + { + 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 // @@ -489,5 +540,6 @@ final class SslEndpointI extends IceInternal.EndpointI private int _port; private int _timeout; private boolean _compress; + private boolean _publish; private int _hashCode; } |