summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Freeze/BackgroundSaveEvictorI.java4
-rw-r--r--java/src/Freeze/ConnectionI.java8
-rw-r--r--java/src/Freeze/EvictorI.java8
-rw-r--r--java/src/Freeze/EvictorIteratorI.java3
-rw-r--r--java/src/Freeze/Index.java12
-rw-r--r--java/src/Freeze/MapDb.java4
-rw-r--r--java/src/Freeze/MapInternal/EntryI.java6
-rw-r--r--java/src/Freeze/MapInternal/Index.java20
-rw-r--r--java/src/Freeze/MapInternal/IndexedSubMap.java22
-rw-r--r--java/src/Freeze/MapInternal/IteratorI.java5
-rw-r--r--java/src/Freeze/MapInternal/KeyCodec.java4
-rw-r--r--java/src/Freeze/MapInternal/MapI.java55
-rw-r--r--java/src/Freeze/MapInternal/SubMap.java16
-rw-r--r--java/src/Freeze/ObjectStore.java51
-rw-r--r--java/src/Freeze/SharedDbEnv.java12
-rw-r--r--java/src/Ice/AMD_Object_ice_invoke.java4
-rw-r--r--java/src/Ice/AMI_Object_ice_invoke.java8
-rw-r--r--java/src/Ice/AsyncResult.java27
-rw-r--r--java/src/Ice/Blobject.java25
-rw-r--r--java/src/Ice/BlobjectAsync.java13
-rw-r--r--java/src/Ice/ConnectionI.java126
-rw-r--r--java/src/Ice/InputStream.java8
-rw-r--r--java/src/Ice/InputStreamI.java11
-rw-r--r--java/src/Ice/ObjectImpl.java20
-rw-r--r--java/src/Ice/ObjectPrx.java16
-rw-r--r--java/src/Ice/ObjectPrxHelperBase.java72
-rw-r--r--java/src/Ice/OutputStream.java7
-rw-r--r--java/src/Ice/OutputStreamI.java11
-rw-r--r--java/src/Ice/Util.java145
-rw-r--r--java/src/Ice/_AMD_Object_ice_invoke.java6
-rw-r--r--java/src/Ice/_ObjectDelM.java40
-rw-r--r--java/src/IceInternal/BasicStream.java166
-rw-r--r--java/src/IceInternal/BatchOutgoing.java4
-rw-r--r--java/src/IceInternal/ConnectRequestHandler.java9
-rw-r--r--java/src/IceInternal/DefaultsAndOverrides.java6
-rw-r--r--java/src/IceInternal/EndpointFactoryManager.java2
-rw-r--r--java/src/IceInternal/EndpointI.java121
-rw-r--r--java/src/IceInternal/FixedReference.java3
-rw-r--r--java/src/IceInternal/Incoming.java207
-rw-r--r--java/src/IceInternal/IncomingAsync.java24
-rw-r--r--java/src/IceInternal/IncomingBase.java82
-rw-r--r--java/src/IceInternal/OpaqueEndpointI.java82
-rw-r--r--java/src/IceInternal/Outgoing.java86
-rw-r--r--java/src/IceInternal/OutgoingAsync.java43
-rw-r--r--java/src/IceInternal/Protocol.java59
-rw-r--r--java/src/IceInternal/Reference.java29
-rw-r--r--java/src/IceInternal/ReferenceFactory.java14
-rw-r--r--java/src/IceInternal/RoutableReference.java15
-rw-r--r--java/src/IceInternal/TcpConnector.java19
-rw-r--r--java/src/IceInternal/TcpEndpointI.java89
-rw-r--r--java/src/IceInternal/ThreadPoolCurrent.java2
-rw-r--r--java/src/IceInternal/UdpConnector.java30
-rw-r--r--java/src/IceInternal/UdpEndpointI.java266
-rw-r--r--java/src/IceSSL/ConnectorI.java19
-rw-r--r--java/src/IceSSL/EndpointI.java89
55 files changed, 1376 insertions, 859 deletions
diff --git a/java/src/Freeze/BackgroundSaveEvictorI.java b/java/src/Freeze/BackgroundSaveEvictorI.java
index 11de32b93df..900f1e87627 100644
--- a/java/src/Freeze/BackgroundSaveEvictorI.java
+++ b/java/src/Freeze/BackgroundSaveEvictorI.java
@@ -1450,12 +1450,12 @@ class BackgroundSaveEvictorI extends EvictorI implements BackgroundSaveEvictor,
obj.status = element.status;
obj.store = element.store;
- obj.key = ObjectStore.marshalKey(element.identity, _communicator);
+ obj.key = ObjectStore.marshalKey(element.identity, _communicator, _encoding);
if(element.status != destroyed)
{
updateStats(element.rec.stats, streamStart);
- obj.value = ObjectStore.marshalValue(element.rec, _communicator);
+ obj.value = ObjectStore.marshalValue(element.rec, _communicator, _encoding);
}
return obj;
}
diff --git a/java/src/Freeze/ConnectionI.java b/java/src/Freeze/ConnectionI.java
index 5bb499461bd..fee70a8faae 100644
--- a/java/src/Freeze/ConnectionI.java
+++ b/java/src/Freeze/ConnectionI.java
@@ -97,6 +97,12 @@ public class ConnectionI implements Connection
return _communicator;
}
+ public Ice.EncodingVersion
+ getEncoding()
+ {
+ return _encoding;
+ }
+
public String
getName()
{
@@ -127,6 +133,7 @@ public class ConnectionI implements Connection
{
_dbEnv = dbEnv;
_communicator = dbEnv.getCommunicator();
+ _encoding = dbEnv.getEncoding();
_logger = _communicator.getLogger();
_envName = dbEnv.getEnvName();
_trace = _communicator.getProperties().getPropertyAsInt("Freeze.Trace.Map");
@@ -228,6 +235,7 @@ public class ConnectionI implements Connection
}
private Ice.Communicator _communicator;
+ private Ice.EncodingVersion _encoding;
private Ice.Logger _logger;
private SharedDbEnv _dbEnv;
private String _envName;
diff --git a/java/src/Freeze/EvictorI.java b/java/src/Freeze/EvictorI.java
index 5e727c84e8a..240778a0a34 100644
--- a/java/src/Freeze/EvictorI.java
+++ b/java/src/Freeze/EvictorI.java
@@ -326,6 +326,7 @@ abstract class EvictorI implements Evictor
new java.util.HashMap<String, String>(facetTypes);
_dbEnv = SharedDbEnv.get(_communicator, envName, dbEnv);
+ _encoding = _dbEnv.getEncoding();
_trace = _communicator.getProperties().getPropertyAsInt("Freeze.Trace.Evictor");
_txTrace = _communicator.getProperties().getPropertyAsInt("Freeze.Trace.Transaction");
@@ -432,6 +433,12 @@ abstract class EvictorI implements Evictor
return _communicator;
}
+ final Ice.EncodingVersion
+ encoding()
+ {
+ return _encoding;
+ }
+
final SharedDbEnv
dbEnv()
{
@@ -567,6 +574,7 @@ abstract class EvictorI implements Evictor
protected final Ice.ObjectAdapter _adapter;
protected final Ice.Communicator _communicator;
+ protected final Ice.EncodingVersion _encoding;
protected final ServantInitializer _initializer;
diff --git a/java/src/Freeze/EvictorIteratorI.java b/java/src/Freeze/EvictorIteratorI.java
index a5c801f3bc9..a3c2516da72 100644
--- a/java/src/Freeze/EvictorIteratorI.java
+++ b/java/src/Freeze/EvictorIteratorI.java
@@ -71,6 +71,7 @@ class EvictorIteratorI implements EvictorIterator
try
{
Ice.Communicator communicator = _store.communicator();
+ Ice.EncodingVersion encoding = _store.encoding();
byte[] firstKey = null;
if(_key.getSize() > 0)
@@ -122,7 +123,7 @@ class EvictorIteratorI implements EvictorIterator
if(_batch.size() < _batchSize)
{
- Ice.Identity ident = ObjectStore.unmarshalKey(_key.getData(), communicator);
+ Ice.Identity ident = ObjectStore.unmarshalKey(_key.getData(), communicator, encoding);
_batch.add(ident);
}
else
diff --git a/java/src/Freeze/Index.java b/java/src/Freeze/Index.java
index 2711dc25ce3..a65dd9cf443 100644
--- a/java/src/Freeze/Index.java
+++ b/java/src/Freeze/Index.java
@@ -23,7 +23,8 @@ public abstract class Index implements com.sleepycat.db.SecondaryKeyCreator
throws com.sleepycat.db.DatabaseException
{
Ice.Communicator communicator = _store.communicator();
- ObjectRecord rec = ObjectStore.unmarshalValue(value.getData(), communicator);
+ Ice.EncodingVersion encoding = _store.encoding();
+ ObjectRecord rec = ObjectStore.unmarshalValue(value.getData(), communicator, encoding);
byte[] secondaryKey = marshalKey(rec.servant);
if(secondaryKey != null)
@@ -86,6 +87,7 @@ public abstract class Index implements com.sleepycat.db.SecondaryKeyCreator
value.setPartial(true);
Ice.Communicator communicator = _store.communicator();
+ Ice.EncodingVersion encoding = _store.encoding();
TransactionI transaction = _store.evictor().beforeQuery();
com.sleepycat.db.Transaction tx = transaction == null ? null : transaction.dbTxn();
@@ -123,7 +125,7 @@ public abstract class Index implements com.sleepycat.db.SecondaryKeyCreator
if(found)
{
- Ice.Identity ident = ObjectStore.unmarshalKey(pkey.getData(), communicator);
+ Ice.Identity ident = ObjectStore.unmarshalKey(pkey.getData(), communicator, encoding);
identities.add(ident);
first = false;
}
@@ -302,6 +304,12 @@ public abstract class Index implements com.sleepycat.db.SecondaryKeyCreator
return _store.communicator();
}
+ protected final Ice.EncodingVersion
+ encoding()
+ {
+ return _store.encoding();
+ }
+
void
associate(ObjectStore store, com.sleepycat.db.Transaction txn, boolean createDb, boolean populateIndex)
throws com.sleepycat.db.DatabaseException, java.io.FileNotFoundException
diff --git a/java/src/Freeze/MapDb.java b/java/src/Freeze/MapDb.java
index b5efbb30b52..17323eebf6d 100644
--- a/java/src/Freeze/MapDb.java
+++ b/java/src/Freeze/MapDb.java
@@ -276,8 +276,8 @@ public class MapDb
// The constructor for catalogs
//
- MapDb(Ice.Communicator communicator, String envName, String dbName, String key, String value,
- com.sleepycat.db.Environment dbEnv)
+ MapDb(Ice.Communicator communicator, String envName, String dbName, String key,
+ String value, com.sleepycat.db.Environment dbEnv)
throws com.sleepycat.db.DatabaseException
{
_communicator = communicator;
diff --git a/java/src/Freeze/MapInternal/EntryI.java b/java/src/Freeze/MapInternal/EntryI.java
index fee039749eb..3096325d70f 100644
--- a/java/src/Freeze/MapInternal/EntryI.java
+++ b/java/src/Freeze/MapInternal/EntryI.java
@@ -19,6 +19,7 @@ class EntryI<K, V> implements java.util.Map.Entry<K, V>
_valueBytes = valueBytes;
_indexBytes = indexBytes;
_communicator = map.connection().getCommunicator();
+ _encoding = map.connection().getEncoding();
_key = key;
_haveKey = key != null;
}
@@ -29,7 +30,7 @@ class EntryI<K, V> implements java.util.Map.Entry<K, V>
if(!_haveKey)
{
assert(_dbKey != null);
- _key = _map.decodeKey(_dbKey.getData(), _communicator);
+ _key = _map.decodeKey(_dbKey.getData(), _communicator, _encoding);
_haveKey = true;
}
return _key;
@@ -41,7 +42,7 @@ class EntryI<K, V> implements java.util.Map.Entry<K, V>
if(!_haveValue)
{
assert(_valueBytes != null);
- _value = _map.decodeValue(_valueBytes, _communicator);
+ _value = _map.decodeValue(_valueBytes, _communicator, _encoding);
_haveValue = true;
//
// Not needed anymore
@@ -123,6 +124,7 @@ class EntryI<K, V> implements java.util.Map.Entry<K, V>
private byte[] _indexBytes;
private Ice.Communicator _communicator;
+ private Ice.EncodingVersion _encoding;
private K _key;
private boolean _haveKey = false;
private V _value;
diff --git a/java/src/Freeze/MapInternal/Index.java b/java/src/Freeze/MapInternal/Index.java
index 43f88b5e787..f5744fbc75b 100644
--- a/java/src/Freeze/MapInternal/Index.java
+++ b/java/src/Freeze/MapInternal/Index.java
@@ -166,7 +166,8 @@ public abstract class Index<K, V, I>
{
assert(_comparator != null);
Ice.Communicator communicator = _map.connection().getCommunicator();
- return _comparator.compare(decodeKey(k1, communicator), decodeKey(k2, communicator));
+ Ice.EncodingVersion encoding = _map.connection().getEncoding();
+ return _comparator.compare(decodeKey(k1, communicator, encoding), decodeKey(k2, communicator, encoding));
}
private class FindModel implements IteratorModel<K, V>
@@ -229,7 +230,7 @@ public abstract class Index<K, V, I>
public int
count(I key)
{
- byte[] k = encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(k);
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry();
@@ -411,7 +412,7 @@ public abstract class Index<K, V, I>
@SuppressWarnings("unchecked")
I key = (I)o;
- byte[] k = encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(k);
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry();
@@ -466,7 +467,7 @@ public abstract class Index<K, V, I>
com.sleepycat.db.SecondaryCursor c = (com.sleepycat.db.SecondaryCursor)cursor;
assert(fromKey != null);
- byte[] k = encodeKey(fromKey, _map.connection().getCommunicator());
+ byte[] k = encodeKey(fromKey, _map.connection().getCommunicator(), _map.connection().getEncoding());
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry();
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry();
@@ -529,7 +530,7 @@ public abstract class Index<K, V, I>
if(fromKey != null)
{
- byte[] k = encodeKey(fromKey, _map.connection().getCommunicator());
+ byte[] k = encodeKey(fromKey, _map.connection().getCommunicator(), _map.connection().getEncoding());
dbIKey.setData(k);
dbIKey.setReuseBuffer(false);
@@ -596,7 +597,7 @@ public abstract class Index<K, V, I>
if(fromKey != null)
{
- byte[] k = encodeKey(fromKey, _map.connection().getCommunicator());
+ byte[] k = encodeKey(fromKey, _map.connection().getCommunicator(), _map.connection().getEncoding());
dbIKey.setData(k);
dbIKey.setReuseBuffer(false);
@@ -652,8 +653,9 @@ public abstract class Index<K, V, I>
protected byte[]
marshalKey(byte[] value)
{
- V decodedValue = _map.decodeValue(value, _map.connection().getCommunicator());
- return encodeKey(extractKey(decodedValue), _map.connection().getCommunicator());
+ V decodedValue = _map.decodeValue(value, _map.connection().getCommunicator(), _map.connection().getEncoding());
+ return encodeKey(extractKey(decodedValue), _map.connection().getCommunicator(),
+ _map.connection().getEncoding());
}
private EntryI<K, V>
@@ -663,7 +665,7 @@ public abstract class Index<K, V, I>
I key = null;
if(fromKey != null || toKey != null)
{
- key = decodeKey(dbIKey.getData(), _map.connection().getCommunicator());
+ key = decodeKey(dbIKey.getData(), _map.connection().getCommunicator(), _map.connection().getEncoding());
if(!checkRange(key, fromKey, fromInclusive, toKey, toInclusive))
{
return null;
diff --git a/java/src/Freeze/MapInternal/IndexedSubMap.java b/java/src/Freeze/MapInternal/IndexedSubMap.java
index 851fdf33c13..74c0bc90096 100644
--- a/java/src/Freeze/MapInternal/IndexedSubMap.java
+++ b/java/src/Freeze/MapInternal/IndexedSubMap.java
@@ -138,7 +138,8 @@ class IndexedSubMap<K, V, I>
next()
{
EntryI<K, V> entry = (EntryI<K, V>)_iterator.next();
- return new Entry(_index.decodeKey(entry.getIndexBytes(), _map.connection().getCommunicator()));
+ return new Entry(_index.decodeKey(entry.getIndexBytes(), _map.connection().getCommunicator(),
+ _map.connection().getEncoding()));
}
public void
@@ -522,7 +523,8 @@ class IndexedSubMap<K, V, I>
if(Search.search(type, _map.connection(), _index.dbName(), _index.db(), dbKey, null, _index, _view,
_index.traceLevels()))
{
- I k = _index.decodeKey(dbKey.getData(), _map.connection().getCommunicator());
+ I k = _index.decodeKey(dbKey.getData(), _map.connection().getCommunicator(),
+ _map.connection().getEncoding());
return new Entry(k);
}
@@ -609,28 +611,28 @@ class IndexedSubMap<K, V, I>
final Entry
ceiling(I key)
{
- byte[] k = _index.encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = _index.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return entrySearch(mapSearchType(Search.Type.CEILING), k);
}
final Entry
floor(I key)
{
- byte[] k = _index.encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = _index.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return entrySearch(mapSearchType(Search.Type.FLOOR), k);
}
final Entry
higher(I key)
{
- byte[] k = _index.encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = _index.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return entrySearch(mapSearchType(Search.Type.HIGHER), k);
}
final Entry
lower(I key)
{
- byte[] k = _index.encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = _index.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return entrySearch(mapSearchType(Search.Type.LOWER), k);
}
@@ -680,7 +682,7 @@ class IndexedSubMap<K, V, I>
final public boolean
keyInRange(byte[] key)
{
- I k = _index.decodeKey(key, _map.connection().getCommunicator());
+ I k = _index.decodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return inRange(k, true);
}
@@ -702,7 +704,8 @@ class IndexedSubMap<K, V, I>
{
if(_fromKey != null && _fromKeyBytes == null)
{
- _fromKeyBytes = _index.encodeKey(_fromKey, _map.connection().getCommunicator());
+ _fromKeyBytes = _index.encodeKey(_fromKey, _map.connection().getCommunicator(),
+ _map.connection().getEncoding());
}
return _fromKeyBytes;
}
@@ -712,7 +715,8 @@ class IndexedSubMap<K, V, I>
{
if(_toKey != null && _toKeyBytes == null)
{
- _toKeyBytes = _index.encodeKey(_toKey, _map.connection().getCommunicator());
+ _toKeyBytes = _index.encodeKey(_toKey, _map.connection().getCommunicator(),
+ _map.connection().getEncoding());
}
return _toKeyBytes;
}
diff --git a/java/src/Freeze/MapInternal/IteratorI.java b/java/src/Freeze/MapInternal/IteratorI.java
index 45b0b383cac..116f95a432e 100644
--- a/java/src/Freeze/MapInternal/IteratorI.java
+++ b/java/src/Freeze/MapInternal/IteratorI.java
@@ -280,7 +280,7 @@ class IteratorI<K, V> implements Freeze.Map.EntryIterator<java.util.Map.Entry<K,
//
// Yes, update it directly
//
- byte[] v = _map.encodeValue(value, _map.connection().getCommunicator());
+ byte[] v = _map.encodeValue(value, _map.connection().getCommunicator(), _map.connection().getEncoding());
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry(v);
try
@@ -326,7 +326,8 @@ class IteratorI<K, V> implements Freeze.Map.EntryIterator<java.util.Map.Entry<K,
throw ex;
}
- byte[] v = _map.encodeValue(value, _map.connection().getCommunicator());
+ byte[] v = _map.encodeValue(value, _map.connection().getCommunicator(),
+ _map.connection().getEncoding());
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry(v);
clone.putCurrent(dbValue);
}
diff --git a/java/src/Freeze/MapInternal/KeyCodec.java b/java/src/Freeze/MapInternal/KeyCodec.java
index e1cbd142e05..fab807356be 100644
--- a/java/src/Freeze/MapInternal/KeyCodec.java
+++ b/java/src/Freeze/MapInternal/KeyCodec.java
@@ -11,6 +11,6 @@ package Freeze.MapInternal;
interface KeyCodec<K>
{
- public abstract byte[] encodeKey(K k, Ice.Communicator communicator);
- public abstract K decodeKey(byte[] b, Ice.Communicator communicator);
+ public abstract byte[] encodeKey(K k, Ice.Communicator communicator, Ice.EncodingVersion encoding);
+ public abstract K decodeKey(byte[] b, Ice.Communicator communicator, Ice.EncodingVersion encoding);
}
diff --git a/java/src/Freeze/MapInternal/MapI.java b/java/src/Freeze/MapInternal/MapI.java
index 95880628678..014340e3e64 100644
--- a/java/src/Freeze/MapInternal/MapI.java
+++ b/java/src/Freeze/MapInternal/MapI.java
@@ -27,8 +27,8 @@ import Freeze.Util;
public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
implements Map<K, V>, KeyCodec<K>, IteratorModel<K, V>
{
- public abstract byte[] encodeValue(V o, Ice.Communicator communicator);
- public abstract V decodeValue(byte[] b, Ice.Communicator communicator);
+ public abstract byte[] encodeValue(V o, Ice.Communicator communicator, Ice.EncodingVersion encoding);
+ public abstract V decodeValue(byte[] b, Ice.Communicator communicator, Ice.EncodingVersion encoding);
protected
MapI(Connection connection, String dbName, String key, String value, boolean createDb,
@@ -277,7 +277,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
public void
fastPut(K key, V value)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(k);
putImpl(dbKey, value);
}
@@ -285,7 +285,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
public boolean
fastRemove(K key)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(k);
return removeImpl(dbKey);
}
@@ -455,35 +455,35 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
public java.util.Map.Entry<K, V>
ceilingEntry(K key)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
return entrySearch(Search.Type.CEILING, k, true);
}
public java.util.Map.Entry<K, V>
floorEntry(K key)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
return entrySearch(Search.Type.FLOOR, k, true);
}
public java.util.Map.Entry<K, V>
higherEntry(K key)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
return entrySearch(Search.Type.HIGHER, k, true);
}
public java.util.Map.Entry<K, V>
lowerEntry(K key)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
return entrySearch(Search.Type.LOWER, k, true);
}
public K
ceilingKey(K key)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
java.util.Map.Entry<K, V> e = entrySearch(Search.Type.CEILING, k, false);
return e != null ? e.getKey() : null;
}
@@ -491,7 +491,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
public K
floorKey(K key)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
java.util.Map.Entry<K, V> e = entrySearch(Search.Type.FLOOR, k, false);
return e != null ? e.getKey() : null;
}
@@ -499,7 +499,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
public K
higherKey(K key)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
java.util.Map.Entry<K, V> e = entrySearch(Search.Type.HIGHER, k, false);
return e != null ? e.getKey() : null;
}
@@ -507,7 +507,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
public K
lowerKey(K key)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
java.util.Map.Entry<K, V> e = entrySearch(Search.Type.LOWER, k, false);
return e != null ? e.getKey() : null;
}
@@ -789,7 +789,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
throw ex;
}
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(k);
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry();
@@ -839,7 +839,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
@SuppressWarnings("unchecked")
K key = (K)o;
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(k);
byte[] v = getImpl(dbKey);
if(v == null)
@@ -848,20 +848,20 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
}
else
{
- return decodeValue(v, _connection.getCommunicator());
+ return decodeValue(v, _connection.getCommunicator(), _connection.getEncoding());
}
}
public V
put(K key, V value)
{
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(k);
byte[] v = getImpl(dbKey);
V old = null;
if(v != null)
{
- old = decodeValue(v, _connection.getCommunicator());
+ old = decodeValue(v, _connection.getCommunicator(), _connection.getEncoding());
}
putImpl(dbKey, value);
return old;
@@ -873,13 +873,13 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
@SuppressWarnings("unchecked")
K key = (K)o;
- byte[] k = encodeKey(key, _connection.getCommunicator());
+ byte[] k = encodeKey(key, _connection.getCommunicator(), _connection.getEncoding());
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(k);
byte[] v = getImpl(dbKey);
if(v != null && removeImpl(dbKey))
{
- return decodeValue(v, _connection.getCommunicator());
+ return decodeValue(v, _connection.getCommunicator(), _connection.getEncoding());
}
else
{
@@ -958,7 +958,8 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
V value = entry.getValue();
byte[] v = getImpl(entry.getDbKey());
- return v != null && valEquals(decodeValue(v, _connection.getCommunicator()), value);
+ return v != null && valEquals(decodeValue(v, _connection.getCommunicator(),
+ _connection.getEncoding()), value);
}
public boolean
@@ -973,7 +974,8 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
V value = entry.getValue();
byte[] v = getImpl(entry.getDbKey());
- if(v != null && valEquals(decodeValue(v, _connection.getCommunicator()), value))
+ if(v != null && valEquals(decodeValue(v, _connection.getCommunicator(), _connection.getEncoding()),
+ value))
{
return removeImpl(entry.getDbKey());
}
@@ -1134,7 +1136,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry();
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry();
- byte[] k = encodeKey(fromKey, _connection.getCommunicator());
+ byte[] k = encodeKey(fromKey, _connection.getCommunicator(), _connection.getEncoding());
dbKey.setData(k);
dbKey.setReuseBuffer(false);
@@ -1194,7 +1196,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
if(fromKey != null)
{
- byte[] k = encodeKey(fromKey, _connection.getCommunicator());
+ byte[] k = encodeKey(fromKey, _connection.getCommunicator(), _connection.getEncoding());
dbKey.setData(k);
dbKey.setReuseBuffer(false);
@@ -1251,7 +1253,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
throw ex;
}
- byte[] v = encodeValue(value, _connection.getCommunicator());
+ byte[] v = encodeValue(value, _connection.getCommunicator(), _connection.getEncoding());
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry(v);
if(_trace.level >= 2)
@@ -1419,7 +1421,7 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
K key = null;
if(fromKey != null || toKey != null)
{
- key = decodeKey(dbKey.getData(), _connection.getCommunicator());
+ key = decodeKey(dbKey.getData(), _connection.getCommunicator(), _connection.getEncoding());
if(!checkRange(key, fromKey, fromInclusive, toKey, toInclusive))
{
return null;
@@ -1474,7 +1476,8 @@ public abstract class MapI<K, V> extends java.util.AbstractMap<K, V>
compare(byte[] d1, byte[] d2)
{
Ice.Communicator communicator = _connection.getCommunicator();
- return _comparator.compare(decodeKey(d1, communicator), decodeKey(d2, communicator));
+ Ice.EncodingVersion encoding = _connection.getEncoding();
+ return _comparator.compare(decodeKey(d1, communicator, encoding), decodeKey(d2, communicator, encoding));
}
//
diff --git a/java/src/Freeze/MapInternal/SubMap.java b/java/src/Freeze/MapInternal/SubMap.java
index 04b3a9cbf20..e17a7ec0aa9 100644
--- a/java/src/Freeze/MapInternal/SubMap.java
+++ b/java/src/Freeze/MapInternal/SubMap.java
@@ -437,28 +437,28 @@ class SubMap<K, V> extends java.util.AbstractMap<K, V> implements NavigableMap<K
final EntryI<K, V>
ceiling(K key)
{
- byte[] k = _map.encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = _map.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return _map.entrySearch(mapSearchType(Search.Type.CEILING), k, true, this);
}
final EntryI<K, V>
floor(K key)
{
- byte[] k = _map.encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = _map.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return _map.entrySearch(mapSearchType(Search.Type.FLOOR), k, true, this);
}
final EntryI<K, V>
higher(K key)
{
- byte[] k = _map.encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = _map.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return _map.entrySearch(mapSearchType(Search.Type.HIGHER), k, true, this);
}
final EntryI<K, V>
lower(K key)
{
- byte[] k = _map.encodeKey(key, _map.connection().getCommunicator());
+ byte[] k = _map.encodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return _map.entrySearch(mapSearchType(Search.Type.LOWER), k, true, this);
}
@@ -508,7 +508,7 @@ class SubMap<K, V> extends java.util.AbstractMap<K, V> implements NavigableMap<K
final public boolean
keyInRange(byte[] key)
{
- K k = _map.decodeKey(key, _map.connection().getCommunicator());
+ K k = _map.decodeKey(key, _map.connection().getCommunicator(), _map.connection().getEncoding());
return inRange(k, true);
}
@@ -530,7 +530,8 @@ class SubMap<K, V> extends java.util.AbstractMap<K, V> implements NavigableMap<K
{
if(_fromKey != null && _fromKeyBytes == null)
{
- _fromKeyBytes = _map.encodeKey(_fromKey, _map.connection().getCommunicator());
+ _fromKeyBytes = _map.encodeKey(_fromKey, _map.connection().getCommunicator(),
+ _map.connection().getEncoding());
}
return _fromKeyBytes;
}
@@ -540,7 +541,8 @@ class SubMap<K, V> extends java.util.AbstractMap<K, V> implements NavigableMap<K
{
if(_toKey != null && _toKeyBytes == null)
{
- _toKeyBytes = _map.encodeKey(_toKey, _map.connection().getCommunicator());
+ _toKeyBytes = _map.encodeKey(_toKey, _map.connection().getCommunicator(),
+ _map.connection().getEncoding());
}
return _toKeyBytes;
}
diff --git a/java/src/Freeze/ObjectStore.java b/java/src/Freeze/ObjectStore.java
index 6f3c94781d0..c7f585e58ff 100644
--- a/java/src/Freeze/ObjectStore.java
+++ b/java/src/Freeze/ObjectStore.java
@@ -21,6 +21,7 @@ class ObjectStore implements IceUtil.Store
_evictor = evictor;
_indices = indices;
_communicator = evictor.communicator();
+ _encoding = evictor.encoding();
if(facet.equals(""))
{
@@ -191,7 +192,7 @@ class ObjectStore implements IceUtil.Store
}
}
- byte[] key = marshalKey(ident, _communicator);
+ byte[] key = marshalKey(ident, _communicator, _encoding);
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(key);
//
@@ -288,10 +289,10 @@ class ObjectStore implements IceUtil.Store
}
static byte[]
- marshalKey(Ice.Identity v, Ice.Communicator communicator)
+ marshalKey(Ice.Identity v, Ice.Communicator communicator, Ice.EncodingVersion encoding)
{
IceInternal.BasicStream os =
- new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), true, false);
+ new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, true, false);
v.__write(os);
IceInternal.Buffer buf = os.prepareWrite();
byte[] r = new byte[buf.size()];
@@ -300,10 +301,10 @@ class ObjectStore implements IceUtil.Store
}
static Ice.Identity
- unmarshalKey(byte[] b, Ice.Communicator communicator)
+ unmarshalKey(byte[] b, Ice.Communicator communicator, Ice.EncodingVersion encoding)
{
IceInternal.BasicStream is =
- new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), true, false);
+ new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, true, false);
is.resize(b.length, true);
IceInternal.Buffer buf = is.getBuffer();
buf.b.position(0);
@@ -315,10 +316,10 @@ class ObjectStore implements IceUtil.Store
}
static byte[]
- marshalValue(ObjectRecord v, Ice.Communicator communicator)
+ marshalValue(ObjectRecord v, Ice.Communicator communicator, Ice.EncodingVersion encoding)
{
IceInternal.BasicStream os =
- new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), true, false);
+ new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, true, false);
os.startWriteEncaps();
v.__write(os);
os.writePendingObjects();
@@ -330,10 +331,10 @@ class ObjectStore implements IceUtil.Store
}
static ObjectRecord
- unmarshalValue(byte[] b, Ice.Communicator communicator)
+ unmarshalValue(byte[] b, Ice.Communicator communicator, Ice.EncodingVersion encoding)
{
IceInternal.BasicStream is =
- new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), true, false);
+ new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), encoding, true, false);
is.sliceObjects(false);
is.resize(b.length, true);
IceInternal.Buffer buf = is.getBuffer();
@@ -366,6 +367,12 @@ class ObjectStore implements IceUtil.Store
return _communicator;
}
+ final Ice.EncodingVersion
+ encoding()
+ {
+ return _encoding;
+ }
+
final EvictorI
evictor()
{
@@ -399,7 +406,7 @@ class ObjectStore implements IceUtil.Store
{
Ice.Identity ident = (Ice.Identity)identObj;
- byte[] key = marshalKey(ident, _communicator);
+ byte[] key = marshalKey(ident, _communicator, _encoding);
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(key);
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry();
@@ -439,7 +446,7 @@ class ObjectStore implements IceUtil.Store
}
}
- ObjectRecord rec = unmarshalValue(dbValue.getData(), _communicator);
+ ObjectRecord rec = unmarshalValue(dbValue.getData(), _communicator, _encoding);
_evictor.initialize(ident, _facet, rec.servant);
Object result = _evictor.createEvictorElement(ident, rec, this);
@@ -463,7 +470,7 @@ class ObjectStore implements IceUtil.Store
throw new DatabaseException(_evictor.errorPrefix() + "inactive transaction");
}
- byte[] key = marshalKey(ident, _communicator);
+ byte[] key = marshalKey(ident, _communicator, _encoding);
com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(key);
com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry();
@@ -497,7 +504,7 @@ class ObjectStore implements IceUtil.Store
throw new DatabaseException(_evictor.errorPrefix() + "Db.get: " + dx.getMessage(), dx);
}
- ObjectRecord rec = unmarshalValue(dbValue.getData(), _communicator);
+ ObjectRecord rec = unmarshalValue(dbValue.getData(), _communicator, _encoding);
_evictor.initialize(ident, _facet, rec.servant);
return rec;
}
@@ -523,9 +530,12 @@ class ObjectStore implements IceUtil.Store
throw new DatabaseException(msg);
}
- com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(marshalKey(ident, _communicator));
- com.sleepycat.db.DatabaseEntry dbValue =
- new com.sleepycat.db.DatabaseEntry(marshalValue(objectRecord, _communicator));
+ com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(marshalKey(ident,
+ _communicator,
+ _encoding));
+ com.sleepycat.db.DatabaseEntry dbValue = new com.sleepycat.db.DatabaseEntry(marshalValue(objectRecord,
+ _communicator,
+ _encoding));
try
{
@@ -565,9 +575,10 @@ class ObjectStore implements IceUtil.Store
}
}
- com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(marshalKey(ident, _communicator));
+ com.sleepycat.db.DatabaseEntry dbKey =
+ new com.sleepycat.db.DatabaseEntry(marshalKey(ident, _communicator, _encoding));
com.sleepycat.db.DatabaseEntry dbValue =
- new com.sleepycat.db.DatabaseEntry(marshalValue(objectRecord, _communicator));
+ new com.sleepycat.db.DatabaseEntry(marshalValue(objectRecord, _communicator, _encoding));
if(_sampleServant != null && !objectRecord.servant.ice_id().equals(_sampleServant.ice_id()))
{
@@ -621,7 +632,8 @@ class ObjectStore implements IceUtil.Store
}
}
- com.sleepycat.db.DatabaseEntry dbKey = new com.sleepycat.db.DatabaseEntry(marshalKey(ident, _communicator));
+ com.sleepycat.db.DatabaseEntry dbKey =
+ new com.sleepycat.db.DatabaseEntry(marshalKey(ident, _communicator, _encoding));
for(;;)
{
@@ -661,6 +673,7 @@ class ObjectStore implements IceUtil.Store
private final EvictorI _evictor;
private final java.util.List<Index> _indices;
private final Ice.Communicator _communicator;
+ private final Ice.EncodingVersion _encoding;
private com.sleepycat.db.Database _db;
private Ice.Object _sampleServant;
diff --git a/java/src/Freeze/SharedDbEnv.java b/java/src/Freeze/SharedDbEnv.java
index 560a9a14b74..4a733458f0e 100644
--- a/java/src/Freeze/SharedDbEnv.java
+++ b/java/src/Freeze/SharedDbEnv.java
@@ -111,6 +111,12 @@ public class SharedDbEnv implements com.sleepycat.db.ErrorHandler, Runnable
return _key.communicator;
}
+ public Ice.EncodingVersion
+ getEncoding()
+ {
+ return _encoding;
+ }
+
public com.sleepycat.db.Environment
getEnv()
{
@@ -274,6 +280,11 @@ public class SharedDbEnv implements com.sleepycat.db.ErrorHandler, Runnable
String propertyPrefix = "Freeze.DbEnv." + _key.envName;
String dbHome = properties.getPropertyWithDefault(propertyPrefix + ".DbHome", _key.envName);
+ String encoding = properties.getPropertyWithDefault(
+ propertyPrefix + ".EncodingVersion", Ice.Util.encodingVersionToString(Ice.Util.currentEncoding()));
+ _encoding = Ice.Util.stringToEncodingVersion(encoding);
+ IceInternal.Protocol.checkSupportedEncoding(_encoding);
+
java.io.File dir = new java.io.File(dbHome);
if(!dir.exists())
{
@@ -549,6 +560,7 @@ public class SharedDbEnv implements com.sleepycat.db.ErrorHandler, Runnable
private long _checkpointPeriod = 0;
private int _kbyte = 0;
private Thread _thread;
+ private Ice.EncodingVersion _encoding;
private java.util.Map<Thread, TransactionalEvictorContext> _ctxMap =
new java.util.HashMap<Thread, TransactionalEvictorContext>();
diff --git a/java/src/Ice/AMD_Object_ice_invoke.java b/java/src/Ice/AMD_Object_ice_invoke.java
index 83d1061ace2..8b60d39122a 100644
--- a/java/src/Ice/AMD_Object_ice_invoke.java
+++ b/java/src/Ice/AMD_Object_ice_invoke.java
@@ -23,10 +23,10 @@ public interface AMD_Object_ice_invoke
* @param ok <code>true</code> indicates that the operation
* completed successfully; <code>false</code> indicates that the
* operation raised a user exception.
- * @param outParams The encoded out-parameters for the operation or,
+ * @param outEncaps The encoded out-parameters for the operation or,
* if <code>ok</code> is <code>false</code>, the encoded user exception.
**/
- void ice_response(boolean ok, byte[] outParams);
+ void ice_response(boolean ok, byte[] outEncaps);
/**
* Indicates to the Ice run time that an operation completed
diff --git a/java/src/Ice/AMI_Object_ice_invoke.java b/java/src/Ice/AMI_Object_ice_invoke.java
index 9b4db13f1d1..251abcd1f73 100644
--- a/java/src/Ice/AMI_Object_ice_invoke.java
+++ b/java/src/Ice/AMI_Object_ice_invoke.java
@@ -19,11 +19,11 @@ public abstract class AMI_Object_ice_invoke extends Callback_Object_ice_invoke
*
* @param ok Indicates the result of the invocation. If <code>true</code>, the operation
* completed succesfully; if <code>false</code>, the operation raised a user exception.
- * @param outParams Contains the encoded out-parameters of the operation (if any) if <code>ok</code>
+ * @param outEncaps Contains the encoded out-parameters of the operation (if any) if <code>ok</code>
* is <code>true</code>; otherwise, if <code>ok</code> is <code>false</code>, contains the
* encoded user exception raised by the operation.
**/
- public abstract void ice_response(boolean ok, byte[] outParams);
+ public abstract void ice_response(boolean ok, byte[] outEncaps);
/**
* Called when the invocation raises an Ice run-time exception.
@@ -32,9 +32,9 @@ public abstract class AMI_Object_ice_invoke extends Callback_Object_ice_invoke
**/
public abstract void ice_exception(LocalException ex);
- public final void response(boolean ok, byte[] outParams)
+ public final void response(boolean ok, byte[] outEncaps)
{
- ice_response(ok, outParams);
+ ice_response(ok, outEncaps);
}
public final void exception(LocalException ex)
diff --git a/java/src/Ice/AsyncResult.java b/java/src/Ice/AsyncResult.java
index d7747c8656c..af263062114 100644
--- a/java/src/Ice/AsyncResult.java
+++ b/java/src/Ice/AsyncResult.java
@@ -23,8 +23,8 @@ public class AsyncResult
_instance = instance;
_operation = op;
// Lazy initialized when response is received.
- //_is = new IceInternal.BasicStream(instance, false, false);
- _os = new IceInternal.BasicStream(instance, false, false);
+ //_is = new IceInternal.BasicStream(instance, IceInternal.Protocol.currentProtocolEncoding);
+ _os = new IceInternal.BasicStream(instance, IceInternal.Protocol.currentProtocolEncoding, false, false);
_state = 0;
_sentSynchronously = false;
_exception = null;
@@ -177,12 +177,31 @@ public class AsyncResult
return _os;
}
- public final IceInternal.BasicStream __getIs()
+ public IceInternal.BasicStream
+ __startReadParams()
{
- assert _is != null; // Can't only be called if response is received.
+ _is.startReadEncaps();
return _is;
}
+ public void
+ __endReadParams()
+ {
+ _is.endReadEncaps();
+ }
+
+ public void
+ __readEmptyParams()
+ {
+ _is.skipEmptyEncaps(null);
+ }
+
+ public byte[]
+ __readParamEncaps()
+ {
+ return _is.readEncaps(null);
+ }
+
public final boolean __wait()
{
synchronized(_monitor)
diff --git a/java/src/Ice/Blobject.java b/java/src/Ice/Blobject.java
index 95d30859bf7..7e96c87ce4d 100644
--- a/java/src/Ice/Blobject.java
+++ b/java/src/Ice/Blobject.java
@@ -19,34 +19,27 @@ public abstract class Blobject extends Ice.ObjectImpl
/**
* Dispatch an incoming request.
*
- * @param inParams The encoded in-parameters for the operation.
- * @param outParams The encoded out-paramaters and return value
+ * @param inEncaps The encoded in-parameters for the operation.
+ * @param outEncaps The encoded out-paramaters and return value
* for the operation. The return value follows any out-parameters.
* @param current The Current object to pass to the operation.
* @return If the operation completed successfully, the return value
* is <code>true</code>. If the operation raises a user exception,
- * the return value is <code>false</code>; in this case, <code>outParams</code>
+ * the return value is <code>false</code>; in this case, <code>outEncaps</code>
* must contain the encoded user exception. If the operation raises an
* Ice run-time exception, it must throw it directly.
**/
public abstract boolean
- ice_invoke(byte[] inParams, ByteSeqHolder outParams, Current current);
+ ice_invoke(byte[] inEncaps, ByteSeqHolder outEncaps, Current current);
public DispatchStatus
__dispatch(IceInternal.Incoming in, Current current)
{
- byte[] inParams;
- ByteSeqHolder outParams = new ByteSeqHolder();
- IceInternal.BasicStream is = in.is();
- is.startReadEncaps();
- int sz = is.getReadEncapsSize();
- inParams = is.readBlob(sz);
- is.endReadEncaps();
- boolean ok = ice_invoke(inParams, outParams, current);
- if(outParams.value != null)
- {
- in.os().writeBlob(outParams.value);
- }
+ byte[] inEncaps;
+ ByteSeqHolder outEncaps = new ByteSeqHolder();
+ inEncaps = in.readParamEncaps();
+ boolean ok = ice_invoke(inEncaps, outEncaps, current);
+ in.__writeParamEncaps(outEncaps.value, ok);
if(ok)
{
return DispatchStatus.DispatchOK;
diff --git a/java/src/Ice/BlobjectAsync.java b/java/src/Ice/BlobjectAsync.java
index 55b8aaeaa6e..4718bcfaddf 100644
--- a/java/src/Ice/BlobjectAsync.java
+++ b/java/src/Ice/BlobjectAsync.java
@@ -23,27 +23,22 @@ public abstract class BlobjectAsync extends Ice.ObjectImpl
*
* @param cb The callback object through which the invocation's results
* must be delivered.
- * @param inParams The encoded input parameters.
+ * @param inEncaps The encoded input parameters.
* @param current The Current object, which provides important information
* about the request, such as the identity of the target object and the
* name of the operation.
**/
public abstract void
- ice_invoke_async(AMD_Object_ice_invoke cb, byte[] inParams, Current current);
+ ice_invoke_async(AMD_Object_ice_invoke cb, byte[] inEncaps, Current current);
public DispatchStatus
__dispatch(IceInternal.Incoming in, Current current)
{
- byte[] inParams;
- IceInternal.BasicStream is = in.is();
- is.startReadEncaps();
- int sz = is.getReadEncapsSize();
- inParams = is.readBlob(sz);
- is.endReadEncaps();
+ byte[] inEncaps = in.readParamEncaps();
AMD_Object_ice_invoke cb = new _AMD_Object_ice_invoke(in);
try
{
- ice_invoke_async(cb, inParams, current);
+ ice_invoke_async(cb, inEncaps, current);
}
catch(java.lang.Exception ex)
{
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java
index 31707b813cb..8934e906bd9 100644
--- a/java/src/Ice/ConnectionI.java
+++ b/java/src/Ice/ConnectionI.java
@@ -546,7 +546,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
//
// Reset the batch stream.
//
- _batchStream = new IceInternal.BasicStream(_instance, _batchAutoFlush);
+ _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding,
+ _batchAutoFlush);
_batchRequestNum = 0;
_batchRequestCompress = false;
_batchMarker = 0;
@@ -600,7 +601,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
public synchronized void
abortBatchRequest()
{
- _batchStream = new IceInternal.BasicStream(_instance, _batchAutoFlush);
+ _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding,
+ _batchAutoFlush);
_batchRequestNum = 0;
_batchRequestCompress = false;
_batchMarker = 0;
@@ -709,7 +711,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
//
// Reset the batch stream.
//
- _batchStream = new IceInternal.BasicStream(_instance, _batchAutoFlush);
+ _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding,
+ _batchAutoFlush);
_batchRequestNum = 0;
_batchRequestCompress = false;
_batchMarker = 0;
@@ -769,7 +772,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
//
// Reset the batch stream.
//
- _batchStream = new IceInternal.BasicStream(_instance, _batchAutoFlush);
+ _batchStream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding,
+ _batchAutoFlush);
_batchRequestNum = 0;
_batchRequestCompress = false;
_batchMarker = 0;
@@ -972,29 +976,11 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
throw ex;
}
- byte pMajor = _readStream.readByte();
- byte pMinor = _readStream.readByte();
- if(pMajor != IceInternal.Protocol.protocolMajor || pMinor > IceInternal.Protocol.protocolMinor)
- {
- Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
- e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor;
- e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor;
- e.major = IceInternal.Protocol.protocolMajor;
- e.minor = IceInternal.Protocol.protocolMinor;
- throw e;
- }
+ _readProtocol.__read(_readStream);
+ IceInternal.Protocol.checkSupportedProtocol(_readProtocol);
- byte eMajor = _readStream.readByte();
- byte eMinor = _readStream.readByte();
- if(eMajor != IceInternal.Protocol.encodingMajor || eMinor > IceInternal.Protocol.encodingMinor)
- {
- Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
- e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor;
- e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor;
- e.major = IceInternal.Protocol.encodingMajor;
- e.minor = IceInternal.Protocol.encodingMinor;
- throw e;
- }
+ _readProtocolEncoding.__read(_readStream);
+ IceInternal.Protocol.checkSupportedProtocolEncoding(_readProtocolEncoding);
_readStream.readByte(); // messageType
_readStream.readByte(); // compress
@@ -1132,7 +1118,7 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
//
assert(info.stream == current.stream);
IceInternal.BasicStream stream = info.stream;
- info.stream = new IceInternal.BasicStream(_instance);
+ info.stream = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding);
info.stream.swap(stream);
}
@@ -1499,14 +1485,15 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
_acmAbsoluteTimeoutMillis = 0;
_nextRequestId = 1;
_batchAutoFlush = initData.properties.getPropertyAsIntWithDefault("Ice.BatchAutoFlush", 1) > 0 ? true : false;
- _batchStream = new IceInternal.BasicStream(instance, _batchAutoFlush);
+ _batchStream = new IceInternal.BasicStream(instance, IceInternal.Protocol.currentProtocolEncoding,
+ _batchAutoFlush);
_batchStreamInUse = false;
_batchRequestNum = 0;
_batchRequestCompress = false;
_batchMarker = 0;
- _readStream = new IceInternal.BasicStream(instance);
+ _readStream = new IceInternal.BasicStream(instance, IceInternal.Protocol.currentProtocolEncoding);
_readHeader = false;
- _writeStream = new IceInternal.BasicStream(instance);
+ _writeStream = new IceInternal.BasicStream(instance, IceInternal.Protocol.currentProtocolEncoding);
_dispatchCount = 0;
_state = StateNotInitialized;
@@ -1819,12 +1806,11 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
// Before we shut down, we send a close connection
// message.
//
- IceInternal.BasicStream os = new IceInternal.BasicStream(_instance, false, false);
+ IceInternal.BasicStream os = new IceInternal.BasicStream(_instance,
+ IceInternal.Protocol.currentProtocolEncoding);
os.writeBlob(IceInternal.Protocol.magic);
- os.writeByte(IceInternal.Protocol.protocolMajor);
- os.writeByte(IceInternal.Protocol.protocolMinor);
- os.writeByte(IceInternal.Protocol.encodingMajor);
- os.writeByte(IceInternal.Protocol.encodingMinor);
+ IceInternal.Protocol.currentProtocol.__write(os);
+ IceInternal.Protocol.currentProtocolEncoding.__write(os);
os.writeByte(IceInternal.Protocol.closeConnectionMsg);
os.writeByte((byte)0); // compression status: always report 0 for CloseConnection in Java.
os.writeInt(IceInternal.Protocol.headerSize); // Message size.
@@ -1880,10 +1866,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
if(_writeStream.size() == 0)
{
_writeStream.writeBlob(IceInternal.Protocol.magic);
- _writeStream.writeByte(IceInternal.Protocol.protocolMajor);
- _writeStream.writeByte(IceInternal.Protocol.protocolMinor);
- _writeStream.writeByte(IceInternal.Protocol.encodingMajor);
- _writeStream.writeByte(IceInternal.Protocol.encodingMinor);
+ IceInternal.Protocol.currentProtocol.__write(_writeStream);
+ IceInternal.Protocol.currentProtocolEncoding.__write(_writeStream);
_writeStream.writeByte(IceInternal.Protocol.validateConnectionMsg);
_writeStream.writeByte((byte)0); // Compression status (always zero for validate connection).
_writeStream.writeInt(IceInternal.Protocol.headerSize); // Message size.
@@ -1923,28 +1907,13 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
ex.badMagic = m;
throw ex;
}
- byte pMajor = _readStream.readByte();
- byte pMinor = _readStream.readByte();
- if(pMajor != IceInternal.Protocol.protocolMajor)
- {
- UnsupportedProtocolException e = new UnsupportedProtocolException();
- e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor;
- e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor;
- e.major = IceInternal.Protocol.protocolMajor;
- e.minor = IceInternal.Protocol.protocolMinor;
- throw e;
- }
- byte eMajor = _readStream.readByte();
- byte eMinor = _readStream.readByte();
- if(eMajor != IceInternal.Protocol.encodingMajor)
- {
- UnsupportedEncodingException e = new UnsupportedEncodingException();
- e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor;
- e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor;
- e.major = IceInternal.Protocol.encodingMajor;
- e.minor = IceInternal.Protocol.encodingMinor;
- throw e;
- }
+
+ _readProtocol.__read(_readStream);
+ IceInternal.Protocol.checkSupportedProtocol(_readProtocol);
+
+ _readProtocolEncoding.__read(_readStream);
+ IceInternal.Protocol.checkSupportedProtocolEncoding(_readProtocolEncoding);
+
byte messageType = _readStream.readByte();
if(messageType != IceInternal.Protocol.validateConnectionMsg)
{
@@ -2362,37 +2331,20 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
//
boolean response = !_endpoint.datagram() && requestId != 0;
in = getIncoming(adapter, response, compress, requestId);
- IceInternal.BasicStream is = in.is();
- stream.swap(is);
- IceInternal.BasicStream os = in.os();
//
- // Prepare the response if necessary.
+ // Dispatch the invocation.
//
- if(response)
- {
- assert(invokeNum == 1); // No further invocations if a response is expected.
- os.writeBlob(IceInternal.Protocol.replyHdr);
+ in.invoke(servantManager, stream);
- //
- // Add the request ID.
- //
- os.writeInt(requestId);
- }
-
- in.invoke(servantManager);
-
- //
- // If there are more invocations, we need the stream back.
- //
- if(--invokeNum > 0)
- {
- stream.swap(is);
- }
+
+ --invokeNum;
reclaimIncoming(in);
in = null;
}
+
+ stream.clear();
}
catch(LocalException ex)
{
@@ -2637,7 +2589,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
{
if(adopt)
{
- IceInternal.BasicStream stream = new IceInternal.BasicStream(this.stream.instance());
+ IceInternal.BasicStream stream =
+ new IceInternal.BasicStream(this.stream.instance(), IceInternal.Protocol.currentProtocolEncoding);
stream.swap(this.stream);
this.stream = stream;
adopt = false;
@@ -2753,5 +2706,8 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
private IceInternal.Outgoing _outgoingCache;
private java.lang.Object _outgoingCacheMutex = new java.lang.Object();
+ private Ice.ProtocolVersion _readProtocol = new Ice.ProtocolVersion();
+ private Ice.EncodingVersion _readProtocolEncoding = new Ice.EncodingVersion();
+
private int _cacheBuffers;
}
diff --git a/java/src/Ice/InputStream.java b/java/src/Ice/InputStream.java
index 247bc7ddbc9..78ce820f118 100644
--- a/java/src/Ice/InputStream.java
+++ b/java/src/Ice/InputStream.java
@@ -217,13 +217,17 @@ public interface InputStream
/**
* Reads the start of an encapsulation.
+ *
+ * @return The encapsulation encoding version.
**/
- void startEncapsulation();
+ Ice.EncodingVersion startEncapsulation();
/**
* Skips over an encapsulation.
+ *
+ * @return The encapsulation encoding version.
**/
- void skipEncapsulation();
+ Ice.EncodingVersion skipEncapsulation();
/**
* Indicates that the end of an encapsulation has been reached.
diff --git a/java/src/Ice/InputStreamI.java b/java/src/Ice/InputStreamI.java
index 1f255e388ed..a788d3643d2 100644
--- a/java/src/Ice/InputStreamI.java
+++ b/java/src/Ice/InputStreamI.java
@@ -16,7 +16,8 @@ public class InputStreamI implements InputStream
{
_communicator = communicator;
- _is = new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), true, false);
+ IceInternal.Instance instance = IceInternal.Util.getInstance(communicator);
+ _is = new IceInternal.BasicStream(instance, instance.defaultsAndOverrides().defaultEncoding, true, false);
_is.closure(this);
_is.resize(data.length, true);
IceInternal.Buffer buf = _is.getBuffer();
@@ -216,16 +217,16 @@ public class InputStreamI implements InputStream
_is.skipSlice();
}
- public void
+ public Ice.EncodingVersion
startEncapsulation()
{
- _is.startReadEncaps();
+ return _is.startReadEncaps();
}
- public void
+ public Ice.EncodingVersion
skipEncapsulation()
{
- _is.skipEncaps();
+ return _is.skipEncaps();
}
public void
diff --git a/java/src/Ice/ObjectImpl.java b/java/src/Ice/ObjectImpl.java
index 0e6510e0722..a8c2bb3f87e 100644
--- a/java/src/Ice/ObjectImpl.java
+++ b/java/src/Ice/ObjectImpl.java
@@ -87,13 +87,13 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io
public static DispatchStatus
___ice_isA(Ice.Object __obj, IceInternal.Incoming __inS, Current __current)
{
- IceInternal.BasicStream __is = __inS.is();
- __is.startReadEncaps();
+ IceInternal.BasicStream __is = __inS.startReadParams();
String __id = __is.readString();
- __is.endReadEncaps();
+ __inS.endReadParams();
boolean __ret = __obj.ice_isA(__id, __current);
- IceInternal.BasicStream __os = __inS.os();
+ IceInternal.BasicStream __os = __inS.__startWriteParams();
__os.writeBool(__ret);
+ __inS.__endWriteParams(true);
return DispatchStatus.DispatchOK;
}
@@ -120,7 +120,7 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io
public static DispatchStatus
___ice_ping(Ice.Object __obj, IceInternal.Incoming __inS, Current __current)
{
- __inS.is().skipEmptyEncaps();
+ __inS.readEmptyParams();
__obj.ice_ping(__current);
return DispatchStatus.DispatchOK;
}
@@ -151,10 +151,11 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io
public static DispatchStatus
___ice_ids(Ice.Object __obj, IceInternal.Incoming __inS, Current __current)
{
- __inS.is().skipEmptyEncaps();
+ __inS.readEmptyParams();
String[] __ret = __obj.ice_ids(__current);
- IceInternal.BasicStream __os = __inS.os();
+ IceInternal.BasicStream __os = __inS.__startWriteParams();
__os.writeStringSeq(__ret);
+ __inS.__endWriteParams(true);
return DispatchStatus.DispatchOK;
}
@@ -184,10 +185,11 @@ public abstract class ObjectImpl implements Object, java.lang.Cloneable, java.io
public static DispatchStatus
___ice_id(Ice.Object __obj, IceInternal.Incoming __inS, Current __current)
{
- __inS.is().skipEmptyEncaps();
+ __inS.readEmptyParams();
String __ret = __obj.ice_id(__current);
- IceInternal.BasicStream __os = __inS.os();
+ IceInternal.BasicStream __os = __inS.__startWriteParams();
__os.writeString(__ret);
+ __inS.__endWriteParams(true);
return DispatchStatus.DispatchOK;
}
diff --git a/java/src/Ice/ObjectPrx.java b/java/src/Ice/ObjectPrx.java
index 02a4f438919..d4ac1ca84f0 100644
--- a/java/src/Ice/ObjectPrx.java
+++ b/java/src/Ice/ObjectPrx.java
@@ -667,6 +667,22 @@ public interface ObjectPrx
ObjectPrx ice_secure(boolean b);
/**
+ * Creates a new proxy that is identical to this proxy, except for the encoding used to marshal
+ * parameters.
+ *
+ * @param e The encoding version to use to marshal requests parameters.
+ * @return The new proxy with the specified encoding version.
+ **/
+ ObjectPrx ice_encodingVersion(Ice.EncodingVersion e);
+
+ /**
+ * Returns the encoding version used to marshal requests parameters.
+ *
+ * @return The encoding version.
+ **/
+ Ice.EncodingVersion ice_getEncodingVersion();
+
+ /**
* Returns whether this proxy prefers secure endpoints.
*
* @return <code>true</code> if the proxy always attempts to invoke via secure endpoints before it
diff --git a/java/src/Ice/ObjectPrxHelperBase.java b/java/src/Ice/ObjectPrxHelperBase.java
index c94b80b5442..d4f713256d2 100644
--- a/java/src/Ice/ObjectPrxHelperBase.java
+++ b/java/src/Ice/ObjectPrxHelperBase.java
@@ -209,9 +209,9 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
try
{
__result.__prepare(__ice_isA_name, OperationMode.Nonmutating, __context, __explicitCtx);
- IceInternal.BasicStream __os = __result.__getOs();
+ IceInternal.BasicStream __os = __result.__startWriteParams();
__os.writeString(__id);
- __os.endWriteEncaps();
+ __result.__endWriteParams();
__result.__send(true);
}
catch(LocalException __ex)
@@ -243,10 +243,9 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
}
boolean __ret;
- IceInternal.BasicStream __is = __result.__getIs();
- __is.startReadEncaps();
+ IceInternal.BasicStream __is = __result.__startReadParams();
__ret = __is.readBool();
- __is.endReadEncaps();
+ __result.__endReadParams();
return __ret;
}
@@ -381,8 +380,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
try
{
__result.__prepare(__ice_ping_name, OperationMode.Nonmutating, __context, __explicitCtx);
- IceInternal.BasicStream __os = __result.__getOs();
- __os.endWriteEncaps();
+ __result.__writeEmptyParams();
__result.__send(true);
}
catch(LocalException __ex)
@@ -540,8 +538,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
try
{
__result.__prepare(__ice_ids_name, OperationMode.Nonmutating, __context, __explicitCtx);
- IceInternal.BasicStream __os = __result.__getOs();
- __os.endWriteEncaps();
+ __result.__writeEmptyParams();
__result.__send(true);
}
catch(LocalException __ex)
@@ -574,10 +571,9 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
}
String[] __ret = null;
- IceInternal.BasicStream __is = __result.__getIs();
- __is.startReadEncaps();
+ IceInternal.BasicStream __is = __result.__startReadParams();
__ret = StringSeqHelper.read(__is);
- __is.endReadEncaps();
+ __result.__endReadParams();
return __ret;
}
@@ -716,8 +712,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
try
{
__result.__prepare(__ice_id_name, OperationMode.Nonmutating, __context, __explicitCtx);
- IceInternal.BasicStream __os = __result.__getOs();
- __os.endWriteEncaps();
+ __result.__writeEmptyParams();
__result.__send(true);
}
catch(LocalException __ex)
@@ -749,10 +744,9 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
}
String __ret = null;
- IceInternal.BasicStream __is = __result.__getIs();
- __is.startReadEncaps();
+ IceInternal.BasicStream __is = __result.__startReadParams();
__ret = __is.readString();
- __is.endReadEncaps();
+ __result.__endReadParams();
return __ret;
}
@@ -965,9 +959,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
try
{
__result.__prepare(operation, mode, __context, __explicitCtx);
- IceInternal.BasicStream __os = __result.__getOs();
- __os.writeBlob(inParams);
- __os.endWriteEncaps();
+ __result.__writeParamEncaps(inParams);
__result.__send(true);
}
catch(LocalException __ex)
@@ -995,14 +987,10 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
boolean ok = __result.__wait();
if(_reference.getMode() == IceInternal.Reference.ModeTwoway)
{
- IceInternal.BasicStream __is = __result.__getIs();
- __is.startReadEncaps();
- int sz = __is.getReadEncapsSize();
if(outParams != null)
{
- outParams.value = __is.readBlob(sz);
+ outParams.value = __result.__readParamEncaps();
}
- __is.endReadEncaps();
}
return ok;
}
@@ -1358,6 +1346,37 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
}
/**
+ * Creates a new proxy that is identical to this proxy, except for the encoding used to marshal
+ * parameters.
+ *
+ * @param e The encoding version to use to marshal requests parameters.
+ * @return The new proxy with the specified encoding version.
+ **/
+ public final ObjectPrx
+ ice_encodingVersion(Ice.EncodingVersion e)
+ {
+ if(e.equals(_reference.getEncoding()))
+ {
+ return this;
+ }
+ else
+ {
+ return newInstance(_reference.changeEncoding(e));
+ }
+ }
+
+ /**
+ * Returns the encoding version used to marshal requests parameters.
+ *
+ * @return The encoding version.
+ **/
+ public final Ice.EncodingVersion
+ ice_getEncodingVersion()
+ {
+ return _reference.getEncoding();
+ }
+
+ /**
* Returns whether this proxy prefers secure endpoints.
*
* @return <code>true</code> if the proxy always attempts to invoke via secure endpoints before it
@@ -2110,8 +2129,7 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable
throw new UnknownUserException(__ex.ice_name(), __ex);
}
}
- IceInternal.BasicStream __is = __result.__getIs();
- __is.skipEmptyEncaps();
+ __result.__readEmptyParams();
}
}
diff --git a/java/src/Ice/OutputStream.java b/java/src/Ice/OutputStream.java
index a24bf946f30..24bbf3263f0 100644
--- a/java/src/Ice/OutputStream.java
+++ b/java/src/Ice/OutputStream.java
@@ -200,6 +200,13 @@ public interface OutputStream
/**
* Writes the start of an encapsulation to the stream.
+ *
+ * @param encoding The encoding version of the encapsulation.
+ **/
+ void startEncapsulation(Ice.EncodingVersion encoding);
+
+ /**
+ * Writes the start of an encapsulation to the stream.
**/
void startEncapsulation();
diff --git a/java/src/Ice/OutputStreamI.java b/java/src/Ice/OutputStreamI.java
index 3d8cfd809d0..a741ef4066b 100644
--- a/java/src/Ice/OutputStreamI.java
+++ b/java/src/Ice/OutputStreamI.java
@@ -14,7 +14,10 @@ public class OutputStreamI implements OutputStream
public
OutputStreamI(Communicator communicator)
{
- this(communicator, new IceInternal.BasicStream(IceInternal.Util.getInstance(communicator), true, false));
+ _communicator = communicator;
+ IceInternal.Instance instance = IceInternal.Util.getInstance(communicator);
+ _os = new IceInternal.BasicStream(instance, instance.defaultsAndOverrides().defaultEncoding, true, false);
+ _os.closure(this);
}
public
@@ -181,6 +184,12 @@ public class OutputStreamI implements OutputStream
}
public void
+ startEncapsulation(Ice.EncodingVersion encoding)
+ {
+ _os.startWriteEncaps(encoding);
+ }
+
+ public void
startEncapsulation()
{
_os.startWriteEncaps();
diff --git a/java/src/Ice/Util.java b/java/src/Ice/Util.java
index 2773c59e546..bcee06ab76f 100644
--- a/java/src/Ice/Util.java
+++ b/java/src/Ice/Util.java
@@ -525,6 +525,151 @@ public final class Util
return 30402; // AABBCC, with AA=major, BB=minor, CC=patch
}
+ /**
+ * Converts a string to a protocol version.
+ *
+ * @param s The string to convert.
+ *
+ * @return The converted protocol version.
+ **/
+ static public Ice.ProtocolVersion
+ stringToProtocolVersion(String version)
+ {
+ return new Ice.ProtocolVersion(stringToMajor(version), stringToMinor(version));
+ }
+
+ /**
+ * Converts a string to an encoding version.
+ *
+ * @param s The string to convert.
+ *
+ * @return The converted object identity.
+ **/
+ static public Ice.EncodingVersion
+ stringToEncodingVersion(String version)
+ {
+ return new Ice.EncodingVersion(stringToMajor(version), stringToMinor(version));
+ }
+
+ /**
+ * Converts a protocol version to a string.
+ *
+ * @param v The protocol version to convert.
+ *
+ * @return The converted string.
+ **/
+ static public String
+ protocolVersionToString(Ice.ProtocolVersion v)
+ {
+ return majorMinorToString(v.major, v.minor);
+ }
+
+ /**
+ * Converts an encoding version to a string.
+ *
+ * @param v The encoding version to convert.
+ *
+ * @return The converted string.
+ **/
+ static public String
+ encodingVersionToString(Ice.EncodingVersion v)
+ {
+ return majorMinorToString(v.major, v.minor);
+ }
+
+ /**
+ * Returns the supported Ice protocol version.
+ *
+ * @return The Ice protocol version.
+ **/
+ static public Ice.ProtocolVersion
+ currentProtocol()
+ {
+ return (Ice.ProtocolVersion)IceInternal.Protocol.currentProtocol.clone();
+ }
+
+ /**
+ * Returns the supported Ice encoding version.
+ *
+ * @return The Ice encoding version.
+ **/
+ static public Ice.EncodingVersion
+ currentEncoding()
+ {
+ return (Ice.EncodingVersion)IceInternal.Protocol.currentEncoding.clone();
+ }
+
+ static private byte
+ stringToMajor(String str)
+ {
+ int pos = str.indexOf('.');
+ if(pos == -1)
+ {
+ throw new Ice.VersionParseException("malformed version value `" + str + "'");
+ }
+
+ String majStr = str.substring(0, pos);
+ int majVersion;
+ try
+ {
+ majVersion = Integer.parseInt(majStr);
+ }
+ catch(NumberFormatException ex)
+ {
+ throw new Ice.EndpointParseException("invalid version value `" + str + "'");
+ }
+
+ if(majVersion < 1 || majVersion > 255)
+ {
+ throw new Ice.EndpointParseException("range error in version `" + str + "'");
+ }
+
+ return (byte)majVersion;
+ }
+
+ static private byte
+ stringToMinor(String str)
+ {
+ int pos = str.indexOf('.');
+ if(pos == -1)
+ {
+ throw new Ice.VersionParseException("malformed version value `" + str + "'");
+ }
+
+ String minStr = str.substring(pos + 1, str.length());
+ int minVersion;
+ try
+ {
+ minVersion = Integer.parseInt(minStr);
+ }
+ catch(NumberFormatException ex)
+ {
+ throw new Ice.EndpointParseException("invalid version value `" + str + "'");
+ }
+
+ if(minVersion < 0 || minVersion > 255)
+ {
+ throw new Ice.EndpointParseException("range error in version `" + str + "'");
+ }
+
+ return (byte)minVersion;
+ }
+
+ static private String
+ majorMinorToString(byte major, byte minor)
+ {
+ StringBuilder str = new StringBuilder();
+ str.append(major < 0 ? (int)major + 255 : (int)major);
+ str.append(".");
+ str.append(minor < 0 ? (int)minor + 255 : (int)minor);
+ return str.toString();
+ }
+
+ public final static Ice.ProtocolVersion Protocol_1_0 = new Ice.ProtocolVersion((byte)1, (byte)0);
+
+ public final static Ice.EncodingVersion Encoding_1_0 = new Ice.EncodingVersion((byte)1, (byte)0);
+ public final static Ice.EncodingVersion Encoding_1_1 = new Ice.EncodingVersion((byte)1, (byte)1);
+
private static String _localAddress = null;
private static java.lang.Object _processLoggerMutex = new java.lang.Object();
private static Logger _processLogger = null;
diff --git a/java/src/Ice/_AMD_Object_ice_invoke.java b/java/src/Ice/_AMD_Object_ice_invoke.java
index f5f8bd6e541..a8ce74d07e4 100644
--- a/java/src/Ice/_AMD_Object_ice_invoke.java
+++ b/java/src/Ice/_AMD_Object_ice_invoke.java
@@ -18,20 +18,20 @@ final class _AMD_Object_ice_invoke extends IceInternal.IncomingAsync implements
}
public void
- ice_response(boolean ok, byte[] outParams)
+ ice_response(boolean ok, byte[] outEncaps)
{
if(__validateResponse(ok))
{
try
{
- __getOs().writeBlob(outParams);
+ __writeParamEncaps(outEncaps, ok);
}
catch(Ice.LocalException ex)
{
__exception(ex);
return;
}
- __response(ok);
+ __response();
}
}
}
diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java
index 0934148873a..09c2bd99750 100644
--- a/java/src/Ice/_ObjectDelM.java
+++ b/java/src/Ice/_ObjectDelM.java
@@ -41,10 +41,9 @@ public class _ObjectDelM implements _ObjectDel
throw new UnknownUserException(__ex.ice_name(), __ex);
}
}
- IceInternal.BasicStream __is = __og.is();
- __is.startReadEncaps();
+ IceInternal.BasicStream __is = __og.startReadParams();
boolean __ret = __is.readBool();
- __is.endReadEncaps();
+ __og.endReadParams();
return __ret;
}
catch(LocalException __ex)
@@ -66,7 +65,7 @@ public class _ObjectDelM implements _ObjectDel
try
{
boolean __ok = __og.invoke();
- if(!__og.is().isEmpty())
+ if(__og.hasResponse())
{
try
{
@@ -81,7 +80,7 @@ public class _ObjectDelM implements _ObjectDel
throw new UnknownUserException(__ex.ice_name(), __ex);
}
}
- __og.is().skipEmptyEncaps();
+ __og.readEmptyParams();
}
catch(LocalException __ex)
{
@@ -116,10 +115,9 @@ public class _ObjectDelM implements _ObjectDel
throw new UnknownUserException(__ex.ice_name(), __ex);
}
}
- IceInternal.BasicStream __is = __og.is();
- __is.startReadEncaps();
+ IceInternal.BasicStream __is = __og.startReadParams();
String[] __ret = __is.readStringSeq();
- __is.endReadEncaps();
+ __og.endReadParams();
return __ret;
}
catch(LocalException __ex)
@@ -154,10 +152,9 @@ public class _ObjectDelM implements _ObjectDel
throw new UnknownUserException(__ex.ice_name(), __ex);
}
}
- IceInternal.BasicStream __is = __og.is();
- __is.startReadEncaps();
+ IceInternal.BasicStream __is = __og.startReadParams();
String __ret = __is.readString();
- __is.endReadEncaps();
+ __og.endReadParams();
return __ret;
}
catch(LocalException __ex)
@@ -178,31 +175,16 @@ public class _ObjectDelM implements _ObjectDel
IceInternal.Outgoing __og = __handler.getOutgoing(operation, mode, __context);
try
{
- if(inParams != null)
- {
- try
- {
- IceInternal.BasicStream __os = __og.os();
- __os.writeBlob(inParams);
- }
- catch(LocalException __ex)
- {
- __og.abort(__ex);
- }
- }
+ __og.writeParamEncaps(inParams);
boolean ok = __og.invoke();
if(__handler.getReference().getMode() == IceInternal.Reference.ModeTwoway)
{
try
{
- IceInternal.BasicStream __is = __og.is();
- __is.startReadEncaps();
- int sz = __is.getReadEncapsSize();
- if(outParams != null)
+ if(outParams != null)
{
- outParams.value = __is.readBlob(sz);
+ outParams.value = __og.readParamEncaps();
}
- __is.endReadEncaps();
}
catch(LocalException __ex)
{
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java
index d7e525387f9..f8df5d93a44 100644
--- a/java/src/IceInternal/BasicStream.java
+++ b/java/src/IceInternal/BasicStream.java
@@ -12,27 +12,28 @@ package IceInternal;
public class BasicStream
{
public
- BasicStream(Instance instance)
+ BasicStream(Instance instance, Ice.EncodingVersion encoding)
{
- this(instance, false);
+ this(instance, encoding, false);
}
public
- BasicStream(Instance instance, boolean unlimited)
+ BasicStream(Instance instance, Ice.EncodingVersion encoding, boolean unlimited)
{
- initialize(instance, unlimited, instance.cacheMessageBuffers() > 1);
+ initialize(instance, encoding, unlimited, instance.cacheMessageBuffers() > 1);
}
public
- BasicStream(Instance instance, boolean unlimited, boolean direct)
+ BasicStream(Instance instance, Ice.EncodingVersion encoding, boolean unlimited, boolean direct)
{
- initialize(instance, unlimited, direct);
+ initialize(instance, encoding, unlimited, direct);
}
private void
- initialize(Instance instance, boolean unlimited, boolean direct)
+ initialize(Instance instance, Ice.EncodingVersion encoding, boolean unlimited, boolean direct)
{
_instance = instance;
+ _encoding = encoding;
_buf = new Buffer(_instance.messageSizeMax(), direct);
_closure = null;
_unlimited = unlimited;
@@ -197,16 +198,30 @@ public class BasicStream
return _buf;
}
- final private static byte[] _encapsBlob =
+ public void
+ startWriteEncaps()
{
- 0, 0, 0, 0, // Placeholder for the encapsulation length.
- Protocol.encodingMajor,
- Protocol.encodingMinor
- };
+ //
+ // If no encoding version is specified, use the current write
+ // encapsulation encoding version if there's a current write
+ // encapsulation, otherwise, use the stream encoding version.
+ //
+
+ if(_writeEncapsStack != null)
+ {
+ startWriteEncaps(_writeEncapsStack.encoding);
+ }
+ else
+ {
+ startWriteEncaps(_encoding);
+ }
+ }
public void
- startWriteEncaps()
+ startWriteEncaps(Ice.EncodingVersion encoding)
{
+ Protocol.checkSupportedEncoding(encoding);
+
{
WriteEncaps curr = _writeEncapsCache;
if(curr != null)
@@ -221,9 +236,11 @@ public class BasicStream
curr.next = _writeEncapsStack;
_writeEncapsStack = curr;
}
-
+ _writeEncapsStack.encoding = encoding;
_writeEncapsStack.start = _buf.size();
- writeBlob(_encapsBlob);
+
+ writeInt(0); // Placeholder for the encapsulation length.
+ _writeEncapsStack.encoding.__write(this);
}
public void
@@ -253,6 +270,31 @@ public class BasicStream
}
public void
+ writeEmptyEncaps(Ice.EncodingVersion encoding)
+ {
+ Protocol.checkSupportedEncoding(encoding);
+ writeInt(6); // Size
+ encoding.__write(this);
+ }
+
+ public void
+ writeEncaps(byte[] v)
+ {
+ if(v.length < 6)
+ {
+ throw new Ice.EncapsulationException();
+ }
+ expand(v.length);
+ _buf.b.put(v);
+ }
+
+ public Ice.EncodingVersion
+ getWriteEncoding()
+ {
+ return _writeEncapsStack != null ? _writeEncapsStack.encoding : _encoding;
+ }
+
+ public Ice.EncodingVersion
startReadEncaps()
{
{
@@ -291,19 +333,10 @@ public class BasicStream
}
_readEncapsStack.sz = sz;
- byte eMajor = readByte();
- byte eMinor = readByte();
- if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor)
- {
- Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
- e.badMajor = eMajor < 0 ? eMajor + 256 : eMajor;
- e.badMinor = eMinor < 0 ? eMinor + 256 : eMinor;
- e.major = Protocol.encodingMajor;
- e.minor = Protocol.encodingMinor;
- throw e;
- }
- // _readEncapsStack.encodingMajor = eMajor; // Currently unused
- // _readEncapsStack.encodingMinor = eMinor; // Currently unused
+ _readEncapsStack.encoding.__read(this);
+ Protocol.checkSupportedEncoding(_readEncapsStack.encoding); // Make sure the encoding is supported.
+
+ return _readEncapsStack.encoding;
}
public void
@@ -341,7 +374,7 @@ public class BasicStream
}
public void
- skipEmptyEncaps()
+ skipEmptyEncaps(Ice.EncodingVersion encoding)
{
int sz = readInt();
if(sz < 6)
@@ -354,13 +387,13 @@ public class BasicStream
throw new Ice.EncapsulationException();
}
- try
+ if(encoding != null)
{
- _buf.b.position(_buf.b.position() + 2);
+ encoding.__read(this);
}
- catch(IllegalArgumentException ex)
+ else
{
- throw new Ice.UnmarshalOutOfBoundsException();
+ _buf.b.position(_buf.b.position() + 2);
}
}
@@ -375,6 +408,48 @@ public class BasicStream
endReadEncaps();
}
+ public byte[]
+ readEncaps(Ice.EncodingVersion encoding)
+ {
+ int sz = readInt();
+ if(sz < 6)
+ {
+ throw new Ice.UnmarshalOutOfBoundsException();
+ }
+
+ if(sz - 4 > _buf.b.remaining())
+ {
+ throw new Ice.UnmarshalOutOfBoundsException();
+ }
+
+ if(encoding != null)
+ {
+ encoding.__read(this);
+ _buf.b.position(_buf.b.position() - 6);
+ }
+ else
+ {
+ _buf.b.position(_buf.b.position() - 4);
+ }
+
+ byte[] v = new byte[sz];
+ try
+ {
+ _buf.b.get(v);
+ return v;
+ }
+ catch(java.nio.BufferUnderflowException ex)
+ {
+ throw new Ice.UnmarshalOutOfBoundsException();
+ }
+ }
+
+ public Ice.EncodingVersion
+ getReadEncoding()
+ {
+ return _readEncapsStack != null ? _readEncapsStack.encoding : _encoding;
+ }
+
public int
getReadEncapsSize()
{
@@ -382,7 +457,7 @@ public class BasicStream
return _readEncapsStack.sz - 6;
}
- public void
+ public Ice.EncodingVersion
skipEncaps()
{
int sz = readInt();
@@ -390,6 +465,8 @@ public class BasicStream
{
throw new Ice.UnmarshalOutOfBoundsException();
}
+ Ice.EncodingVersion encoding = new Ice.EncodingVersion();
+ encoding.__read(this);
try
{
_buf.b.position(_buf.b.position() + sz - 4);
@@ -398,6 +475,7 @@ public class BasicStream
{
throw new Ice.UnmarshalOutOfBoundsException();
}
+ return encoding;
}
public void
@@ -407,13 +485,15 @@ public class BasicStream
_writeSlice = _buf.size();
}
- public void endWriteSlice()
+ public void
+ endWriteSlice()
{
final int sz = _buf.size() - _writeSlice + 4;
_buf.b.putInt(_writeSlice - 4, sz);
}
- public void startReadSlice()
+ public void
+ startReadSlice()
{
int sz = readInt();
if(sz < 4)
@@ -423,11 +503,13 @@ public class BasicStream
_readSlice = _buf.b.position();
}
- public void endReadSlice()
+ public void
+ endReadSlice()
{
}
- public void skipSlice()
+ public void
+ skipSlice()
{
int sz = readInt();
if(sz < 4)
@@ -1932,7 +2014,7 @@ public class BasicStream
return null;
}
- BasicStream cstream = new BasicStream(_instance);
+ BasicStream cstream = new BasicStream(_instance, _encoding);
cstream.resize(headerSize + 4 + compressedLen, false);
cstream.pos(0);
@@ -1991,7 +2073,7 @@ public class BasicStream
_buf.b.get(compressed);
}
- BasicStream ucStream = new BasicStream(_instance);
+ BasicStream ucStream = new BasicStream(_instance, _encoding);
ucStream.resize(uncompressedSize, false);
try
@@ -2341,6 +2423,7 @@ public class BasicStream
java.util.TreeMap<Integer, Ice.Object> unmarshaledMap;
int typeIdIndex;
java.util.TreeMap<Integer, String> typeIdMap;
+ Ice.EncodingVersion encoding;
ReadEncaps next;
void
@@ -2365,6 +2448,7 @@ public class BasicStream
java.util.IdentityHashMap<Ice.Object, Integer> marshaledMap;
int typeIdIndex;
java.util.TreeMap<String, Integer> typeIdMap;
+ Ice.EncodingVersion encoding;
WriteEncaps next;
void
@@ -2381,6 +2465,8 @@ public class BasicStream
}
}
+ private Ice.EncodingVersion _encoding;
+
private ReadEncaps _readEncapsStack;
private WriteEncaps _writeEncapsStack;
private ReadEncaps _readEncapsCache;
diff --git a/java/src/IceInternal/BatchOutgoing.java b/java/src/IceInternal/BatchOutgoing.java
index 1b8889caf0a..70ceda9ebfc 100644
--- a/java/src/IceInternal/BatchOutgoing.java
+++ b/java/src/IceInternal/BatchOutgoing.java
@@ -16,7 +16,7 @@ public final class BatchOutgoing implements OutgoingMessageCallback
{
_connection = connection;
_sent = false;
- _os = new BasicStream(instance);
+ _os = new BasicStream(instance, Protocol.currentProtocolEncoding);
}
public
@@ -24,7 +24,7 @@ public final class BatchOutgoing implements OutgoingMessageCallback
{
_handler = handler;
_sent = false;
- _os = new BasicStream(handler.getReference().getInstance());
+ _os = new BasicStream(handler.getReference().getInstance(), Protocol.currentProtocolEncoding);
}
public void
diff --git a/java/src/IceInternal/ConnectRequestHandler.java b/java/src/IceInternal/ConnectRequestHandler.java
index 26edbb3560f..9e332788e70 100644
--- a/java/src/IceInternal/ConnectRequestHandler.java
+++ b/java/src/IceInternal/ConnectRequestHandler.java
@@ -16,7 +16,7 @@ public class ConnectRequestHandler
{
Request(BasicStream os)
{
- this.os = new BasicStream(os.instance());
+ this.os = new BasicStream(os.instance(), Protocol.currentProtocolEncoding);
this.os.swap(os);
}
@@ -121,7 +121,8 @@ public class ConnectRequestHandler
_batchRequestInProgress = false;
notifyAll();
- BasicStream dummy = new BasicStream(_reference.getInstance(), _batchAutoFlush);
+ BasicStream dummy = new BasicStream(_reference.getInstance(), Protocol.currentProtocolEncoding,
+ _batchAutoFlush);
_batchStream.swap(dummy);
_batchRequestsSize = Protocol.requestBatchHdr.length;
@@ -334,7 +335,7 @@ public class ConnectRequestHandler
_flushing = false;
_batchRequestInProgress = false;
_batchRequestsSize = Protocol.requestBatchHdr.length;
- _batchStream = new BasicStream(ref.getInstance(), _batchAutoFlush);
+ _batchStream = new BasicStream(ref.getInstance(), Protocol.currentProtocolEncoding, _batchAutoFlush);
_updateRequestHandler = false;
}
@@ -424,7 +425,7 @@ public class ConnectRequestHandler
}
else
{
- BasicStream os = new BasicStream(request.os.instance());
+ BasicStream os = new BasicStream(request.os.instance(), Protocol.currentProtocolEncoding);
_connection.prepareBatchRequest(os);
try
{
diff --git a/java/src/IceInternal/DefaultsAndOverrides.java b/java/src/IceInternal/DefaultsAndOverrides.java
index 54bd7c2f5c5..a0765a4ab75 100644
--- a/java/src/IceInternal/DefaultsAndOverrides.java
+++ b/java/src/IceInternal/DefaultsAndOverrides.java
@@ -115,6 +115,11 @@ public final class DefaultsAndOverrides
defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
+
+ value = properties.getPropertyWithDefault("Ice.Default.EncodingVersion",
+ Ice.Util.encodingVersionToString(Protocol.currentEncoding));
+ defaultEncoding = Ice.Util.stringToEncodingVersion(value);
+ Protocol.checkSupportedEncoding(defaultEncoding);
}
final public String defaultHost;
@@ -123,6 +128,7 @@ public final class DefaultsAndOverrides
final public Ice.EndpointSelectionType defaultEndpointSelection;
final public int defaultLocatorCacheTimeout;
final public boolean defaultPreferSecure;
+ final public Ice.EncodingVersion defaultEncoding;
final public boolean overrideTimeout;
final public int overrideTimeoutValue;
diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java
index 4fc683bebc8..3c95066685d 100644
--- a/java/src/IceInternal/EndpointFactoryManager.java
+++ b/java/src/IceInternal/EndpointFactoryManager.java
@@ -108,7 +108,7 @@ public final class EndpointFactoryManager
// and ask the factory to read the endpoint data from that stream to create
// the actual endpoint.
//
- BasicStream bs = new BasicStream(_instance, true, false);
+ BasicStream bs = new BasicStream(_instance, Protocol.currentEncoding, true, false);
ue.streamWrite(bs);
Buffer buf = bs.getBuffer();
buf.b.position(0);
diff --git a/java/src/IceInternal/EndpointI.java b/java/src/IceInternal/EndpointI.java
index 8006b7701a3..c93db0cf5f2 100644
--- a/java/src/IceInternal/EndpointI.java
+++ b/java/src/IceInternal/EndpointI.java
@@ -11,6 +11,18 @@ package IceInternal;
abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<EndpointI>
{
+ public EndpointI(Ice.ProtocolVersion protocol, Ice.EncodingVersion encoding)
+ {
+ _protocol = protocol;
+ _encoding = encoding;
+ }
+
+ public EndpointI()
+ {
+ _protocol = Protocol.currentProtocol;
+ _encoding = Protocol.currentEncoding;
+ }
+
public String
toString()
{
@@ -68,6 +80,16 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<En
//
public abstract boolean secure();
+ public Ice.ProtocolVersion protocol()
+ {
+ return _protocol;
+ }
+
+ public Ice.EncodingVersion encoding()
+ {
+ return _encoding;
+ }
+
//
// Return a server side transceiver for this endpoint, or null if a
// transceiver can only be created by an acceptor. In case a
@@ -107,8 +129,55 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<En
//
// Compare endpoints for sorting purposes.
//
- public abstract boolean equals(java.lang.Object obj);
- public abstract int compareTo(EndpointI obj); // From java.lang.Comparable.
+ public boolean equals(java.lang.Object obj)
+ {
+ if(!(obj instanceof EndpointI))
+ {
+ return false;
+ }
+ return compareTo((EndpointI)obj) == 0;
+ }
+
+ public int compareTo(EndpointI p) // From java.lang.Comparable.
+ {
+ if(_protocol.major < p._protocol.major)
+ {
+ return -1;
+ }
+ else if(p._protocol.major < _protocol.major)
+ {
+ return 1;
+ }
+
+ if(_protocol.minor < p._protocol.minor)
+ {
+ return -1;
+ }
+ else if(p._protocol.minor < _protocol.minor)
+ {
+ return 1;
+ }
+
+ if(_encoding.major < p._encoding.major)
+ {
+ return -1;
+ }
+ else if(p._encoding.major < _encoding.major)
+ {
+ return 1;
+ }
+
+ if(_encoding.minor < p._encoding.minor)
+ {
+ return -1;
+ }
+ else if(p._encoding.minor < _encoding.minor)
+ {
+ return 1;
+ }
+
+ return 0;
+ }
public java.util.List<Connector>
connectors(java.util.List<java.net.InetSocketAddress> addresses)
@@ -120,4 +189,52 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable<En
assert(false);
return null;
}
+
+ protected void
+ parseOption(String option, String arg, String desc, String str)
+ {
+ if(option.equals("-v"))
+ {
+ if(arg == null)
+ {
+ throw new Ice.EndpointParseException("no argument provided for -v option in endpoint `" +
+ desc + " "+ str + "'");
+ }
+
+ try
+ {
+ _protocol = Ice.Util.stringToProtocolVersion(str);
+ }
+ catch(Ice.VersionParseException e)
+ {
+ throw new Ice.EndpointParseException("invalid protocol version `" + arg + "' in endpoint `" +
+ desc + " "+ str + "':\n" + e.str);
+ }
+ }
+ else if(option.equals("-e"))
+ {
+ if(arg == null)
+ {
+ throw new Ice.EndpointParseException("no argument provided for -e option in endpoint `" +
+ desc + " " + str + "'");
+ }
+
+ try
+ {
+ _encoding = Ice.Util.stringToEncodingVersion(str);
+ }
+ catch(Ice.VersionParseException e)
+ {
+ throw new Ice.EndpointParseException("invalid encoding version `" + arg + "' in endpoint `" +
+ desc + " "+ str + "':\n" + e.str);
+ }
+ }
+ else
+ {
+ throw new Ice.EndpointParseException("unknown option `" + option + "' in `" + desc + " " + str + "'");
+ }
+ }
+
+ protected Ice.ProtocolVersion _protocol;
+ protected Ice.EncodingVersion _encoding;
}
diff --git a/java/src/IceInternal/FixedReference.java b/java/src/IceInternal/FixedReference.java
index 34858aee547..387ad165133 100644
--- a/java/src/IceInternal/FixedReference.java
+++ b/java/src/IceInternal/FixedReference.java
@@ -18,9 +18,10 @@ public class FixedReference extends Reference
String facet,
int mode,
boolean secure,
+ Ice.EncodingVersion encoding,
Ice.ConnectionI connection)
{
- super(instance, communicator, identity, facet, mode, secure);
+ super(instance, communicator, identity, facet, mode, secure, encoding);
_fixedConnection = connection;
}
diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java
index 628f363833a..74a55346689 100644
--- a/java/src/IceInternal/Incoming.java
+++ b/java/src/IceInternal/Incoming.java
@@ -17,7 +17,18 @@ final public class Incoming extends IncomingBase implements Ice.Request
{
super(instance, connection, adapter, response, compress, requestId);
- _is = new BasicStream(instance);
+ //
+ // Prepare the response if necessary.
+ //
+ if(response)
+ {
+ _os.writeBlob(IceInternal.Protocol.replyHdr);
+
+ //
+ // Add the request ID.
+ //
+ _os.writeInt(requestId);
+ }
}
//
@@ -45,11 +56,6 @@ final public class Incoming extends IncomingBase implements Ice.Request
_cb = null;
_inParamPos = -1;
- if(_is == null)
- {
- _is = new BasicStream(instance);
- }
-
super.reset(instance, connection, adapter, response, compress, requestId);
}
@@ -59,17 +65,14 @@ final public class Incoming extends IncomingBase implements Ice.Request
_cb = null;
_inParamPos = -1;
- if(_is != null)
- {
- _is.reset();
- }
-
super.reclaim();
}
public void
- invoke(ServantManager servantManager)
+ invoke(ServantManager servantManager, BasicStream stream)
{
+ _is = stream;
+
//
// Read the current.
//
@@ -103,17 +106,6 @@ final public class Incoming extends IncomingBase implements Ice.Request
_current.ctx.put(first, second);
}
- if(_response)
- {
- assert(_os.size() == Protocol.headerSize + 4); // Reply status position.
- _os.writeByte(ReplyStatus.replyOK);
- _os.startWriteEncaps();
- }
-
- byte replyStatus = ReplyStatus.replyOK;
-
- Ice.DispatchStatus dispatchStatus = Ice.DispatchStatus.DispatchOK;
-
//
// Don't put the code above into the try block below. Exceptions
// in the code above are considered fatal, and must propagate to
@@ -139,11 +131,27 @@ final public class Incoming extends IncomingBase implements Ice.Request
}
catch(Ice.UserException ex)
{
- _os.writeUserException(ex);
- replyStatus = ReplyStatus.replyUserException;
+ Ice.EncodingVersion encoding = _is.skipEncaps(); // Required for batch requests.
+
+ if(_response)
+ {
+ _os.writeByte(ReplyStatus.replyUserException);
+ _os.startWriteEncaps(encoding);
+ _os.writeUserException(ex);
+ _os.endWriteEncaps();
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
+
+ _connection = null;
+ return;
}
catch(java.lang.Exception ex)
{
+ _is.skipEncaps(); // Required for batch requests.
__handleException(ex);
return;
}
@@ -151,45 +159,54 @@ final public class Incoming extends IncomingBase implements Ice.Request
}
}
- if(_servant != null)
+ try
{
- try
+ if(_servant != null)
{
- assert(replyStatus == ReplyStatus.replyOK);
- dispatchStatus = _servant.__dispatch(this, _current);
- if(dispatchStatus == Ice.DispatchStatus.DispatchUserException)
+ //
+ // DispatchAsync is a "pseudo dispatch status", used internally only
+ // to indicate async dispatch.
+ //
+ if(_servant.__dispatch(this, _current) == Ice.DispatchStatus.DispatchAsync)
{
- replyStatus = ReplyStatus.replyUserException;
+ //
+ // If this was an asynchronous dispatch, we're done here.
+ //
+ return;
+
}
- if(dispatchStatus != Ice.DispatchStatus.DispatchAsync)
+ if(_locator != null && !__servantLocatorFinished())
{
- if(_locator != null && !__servantLocatorFinished())
- {
- return;
- }
+ return;
}
}
- catch(java.lang.Exception ex)
+ else
{
- if(_locator != null && !__servantLocatorFinished())
+ //
+ // Skip the input parameters, this is required for reading
+ // the next batch request if dispatching batch requests.
+ //
+ _is.skipEncaps();
+
+ if(servantManager != null && servantManager.hasServant(_current.id))
{
- return;
+ throw new Ice.FacetNotExistException(_current.id, _current.facet, _current.operation);
+ }
+ else
+ {
+ throw new Ice.ObjectNotExistException(_current.id, _current.facet, _current.operation);
}
- __handleException(ex);
- return;
}
}
- else if(replyStatus == ReplyStatus.replyOK)
+ catch(java.lang.Exception ex)
{
- if(servantManager != null && servantManager.hasServant(_current.id))
- {
- replyStatus = ReplyStatus.replyFacetNotExist;
- }
- else
+ if(_locator != null && !__servantLocatorFinished())
{
- replyStatus = ReplyStatus.replyObjectNotExist;
+ return;
}
+ __handleException(ex);
+ return;
}
//
@@ -198,57 +215,10 @@ final public class Incoming extends IncomingBase implements Ice.Request
// the caller of this operation.
//
- //
- // DispatchAsync is "pseudo dispatch status", used internally
- // only to indicate async dispatch.
- //
- if(dispatchStatus == Ice.DispatchStatus.DispatchAsync)
- {
- //
- // If this was an asynchronous dispatch, we're done here.
- //
- return;
- }
-
assert(_connection != null);
if(_response)
{
- _os.endWriteEncaps();
-
- if(replyStatus != ReplyStatus.replyOK && replyStatus != ReplyStatus.replyUserException)
- {
- assert(replyStatus == ReplyStatus.replyObjectNotExist ||
- replyStatus == ReplyStatus.replyFacetNotExist);
-
- _os.resize(Protocol.headerSize + 4, false); // Reply status position.
- _os.writeByte(replyStatus);
-
- _current.id.__write(_os);
-
- //
- // For compatibility with the old FacetPath.
- //
- if(_current.facet == null || _current.facet.length() == 0)
- {
- _os.writeStringSeq(null);
- }
- else
- {
- String[] facetPath2 = { _current.facet };
- _os.writeStringSeq(facetPath2);
- }
-
- _os.writeString(_current.operation);
- }
- else
- {
- int save = _os.pos();
- _os.pos(Protocol.headerSize + 4); // Reply status position.
- _os.writeByte(replyStatus);
- _os.pos(save);
- }
-
_connection.sendResponse(_os, _compress);
}
else
@@ -259,18 +229,6 @@ final public class Incoming extends IncomingBase implements Ice.Request
_connection = null;
}
- public BasicStream
- is()
- {
- return _is;
- }
-
- public BasicStream
- os()
- {
- return _os;
- }
-
public final void
push(Ice.DispatchInterceptorAsyncCallback cb)
{
@@ -307,13 +265,9 @@ final public class Incoming extends IncomingBase implements Ice.Request
// Let's rewind _is and clean-up _os
//
_is.pos(_inParamPos);
-
if(_response)
{
- _os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false);
- _os.writeByte(ReplyStatus.replyOK);
- _os.startWriteEncaps();
}
}
}
@@ -334,6 +288,37 @@ final public class Incoming extends IncomingBase implements Ice.Request
}
}
+ public final BasicStream
+ startReadParams()
+ {
+ //
+ // Remember the encoding used by the input parameters, we'll
+ // encode the response parameters with the same encoding.
+ //
+ _current.encoding = _is.startReadEncaps();
+ return _is;
+ }
+
+ public final void
+ endReadParams()
+ {
+ _is.endReadEncaps();
+ }
+
+ public final void
+ readEmptyParams()
+ {
+ _current.encoding = new Ice.EncodingVersion();
+ _is.skipEmptyEncaps(_current.encoding);
+ }
+
+ public final byte[]
+ readParamEncaps()
+ {
+ _current.encoding = new Ice.EncodingVersion();
+ return _is.readEncaps(_current.encoding);
+ }
+
final void
setActive(IncomingAsync cb)
{
diff --git a/java/src/IceInternal/IncomingAsync.java b/java/src/IceInternal/IncomingAsync.java
index a8c696a175a..7674a42db55 100644
--- a/java/src/IceInternal/IncomingAsync.java
+++ b/java/src/IceInternal/IncomingAsync.java
@@ -101,7 +101,7 @@ public class IncomingAsync extends IncomingBase implements Ice.AMDCallback
}
final protected void
- __response(boolean ok)
+ __response()
{
try
{
@@ -114,22 +114,6 @@ public class IncomingAsync extends IncomingBase implements Ice.AMDCallback
if(_response)
{
- _os.endWriteEncaps();
-
- int save = _os.pos();
- _os.pos(Protocol.headerSize + 4); // Reply status position.
-
- if(ok)
- {
- _os.writeByte(ReplyStatus.replyOK);
- }
- else
- {
- _os.writeByte(ReplyStatus.replyUserException);
- }
-
- _os.pos(save);
-
_connection.sendResponse(_os, _compress);
}
else
@@ -205,12 +189,6 @@ public class IncomingAsync extends IncomingBase implements Ice.AMDCallback
return true;
}
- final protected BasicStream
- __getOs()
- {
- return _os;
- }
-
private final boolean _retriable;
private boolean _active = false; // only meaningful when _retriable == true
}
diff --git a/java/src/IceInternal/IncomingBase.java b/java/src/IceInternal/IncomingBase.java
index b2faf727049..9dffce65cf9 100644
--- a/java/src/IceInternal/IncomingBase.java
+++ b/java/src/IceInternal/IncomingBase.java
@@ -18,7 +18,10 @@ public class IncomingBase
_instance = instance;
_response = response;
_compress = compress;
- _os = new BasicStream(instance);
+ if(_response)
+ {
+ _os = new BasicStream(instance, Protocol.currentProtocolEncoding);
+ }
_connection = connection;
_current = new Ice.Current();
@@ -84,6 +87,71 @@ public class IncomingBase
other._connection = null;
}
+ public BasicStream
+ __startWriteParams()
+ {
+ if(_response)
+ {
+ assert(_os.size() == Protocol.headerSize + 4); // Reply status position.
+ assert(_current.encoding != null); // Encoding for reply is known.
+ _os.writeByte((byte)0);
+ _os.startWriteEncaps(_current.encoding);
+ }
+
+ //
+ // We still return the stream even if no response is expected. The
+ // servant code might still write some out parameters if for
+ // example a method with out parameters somehow and erroneously
+ // invoked as oneway (or if the invocation is invoked on a
+ // blobject and the blobject erroneously writes a response).
+ //
+ return _os;
+ }
+
+ public void
+ __endWriteParams(boolean ok)
+ {
+ if(_response)
+ {
+ int save = _os.pos();
+ _os.pos(Protocol.headerSize + 4); // Reply status position.
+ _os.writeByte(ok ? ReplyStatus.replyOK : ReplyStatus.replyUserException);
+ _os.pos(save);
+ _os.endWriteEncaps();
+ }
+ }
+
+ public void
+ __writeEmptyParams()
+ {
+ if(_response)
+ {
+ assert(_os.size() == Protocol.headerSize + 4); // Reply status position.
+ assert(_current.encoding != null); // Encoding for reply is known.
+ _os.writeByte(ReplyStatus.replyOK);
+ _os.writeEmptyEncaps(_current.encoding);
+ }
+ }
+
+ public void
+ __writeParamEncaps(byte[] v, boolean ok)
+ {
+ if(_response)
+ {
+ assert(_os.size() == Protocol.headerSize + 4); // Reply status position.
+ assert(_current.encoding != null); // Encoding for reply is known.
+ _os.writeByte(ok ? ReplyStatus.replyOK : ReplyStatus.replyUserException);
+ if(v == null || v.length == 0)
+ {
+ _os.writeEmptyEncaps(_current.encoding);
+ }
+ else
+ {
+ _os.writeEncaps(v);
+ }
+ }
+ }
+
//
// These functions allow this object to be reused, rather than reallocated.
//
@@ -111,9 +179,9 @@ public class IncomingBase
_compress = compress;
- if(_os == null)
+ if(_response && _os == null)
{
- _os = new BasicStream(instance);
+ _os = new BasicStream(instance, Protocol.currentProtocolEncoding);
}
_connection = connection;
@@ -188,7 +256,6 @@ public class IncomingBase
//
if(_response)
{
- _os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Reply status position.
_os.writeByte(ReplyStatus.replyUserException);
_os.startWriteEncaps();
@@ -243,7 +310,6 @@ public class IncomingBase
if(_response)
{
- _os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Reply status position.
if(ex instanceof Ice.ObjectNotExistException)
{
@@ -294,7 +360,6 @@ public class IncomingBase
if(_response)
{
- _os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Reply status position.
_os.writeByte(ReplyStatus.replyUnknownLocalException);
_os.writeString(ex.unknown);
@@ -314,7 +379,6 @@ public class IncomingBase
if(_response)
{
- _os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Reply status position.
_os.writeByte(ReplyStatus.replyUnknownUserException);
_os.writeString(ex.unknown);
@@ -334,7 +398,6 @@ public class IncomingBase
if(_response)
{
- _os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Reply status position.
_os.writeByte(ReplyStatus.replyUnknownException);
_os.writeString(ex.unknown);
@@ -354,7 +417,6 @@ public class IncomingBase
if(_response)
{
- _os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Reply status position.
_os.writeByte(ReplyStatus.replyUnknownLocalException);
//_os.writeString(ex.toString());
@@ -380,7 +442,6 @@ public class IncomingBase
if(_response)
{
- _os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Reply status position.
_os.writeByte(ReplyStatus.replyUnknownUserException);
//_os.writeString(ex.toString());
@@ -406,7 +467,6 @@ public class IncomingBase
if(_response)
{
- _os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Reply status position.
_os.writeByte(ReplyStatus.replyUnknownException);
//_os.writeString(ex.toString());
diff --git a/java/src/IceInternal/OpaqueEndpointI.java b/java/src/IceInternal/OpaqueEndpointI.java
index 973bac70e94..09a89d48638 100644
--- a/java/src/IceInternal/OpaqueEndpointI.java
+++ b/java/src/IceInternal/OpaqueEndpointI.java
@@ -14,6 +14,10 @@ final class OpaqueEndpointI extends EndpointI
public
OpaqueEndpointI(String str)
{
+ super(Protocol_0_0, Encoding_0_0);
+
+ _rawEncoding = Protocol.currentEncoding;
+
int topt = 0;
int vopt = 0;
@@ -57,13 +61,13 @@ final class OpaqueEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("invalid timeout value `" + argument +
+ throw new Ice.EndpointParseException("invalid type value `" + argument +
"' in endpoint `opaque " + str + "'");
}
if(t < 0 || t > 65535)
{
- throw new Ice.EndpointParseException("timeout value `" + argument +
+ throw new Ice.EndpointParseException("type value `" + argument +
"' out of range in endpoint `opaque " + str + "'");
}
@@ -76,6 +80,25 @@ final class OpaqueEndpointI extends EndpointI
break;
}
+ case 'e':
+ {
+ if(argument == null)
+ {
+ throw new Ice.EndpointParseException("no argument provided for -e option in endpoint `opaque "
+ + str + "'");
+ }
+
+ try
+ {
+ _rawEncoding = Ice.Util.stringToEncodingVersion(str);
+ }
+ catch(Ice.VersionParseException e)
+ {
+ throw new Ice.EndpointParseException("invalid encoding version `" + argument +
+ "' in endpoint `opaque " + str + "':\n" + e.str);
+ }
+ }
+
case 'v':
{
if(argument == null)
@@ -83,6 +106,7 @@ final class OpaqueEndpointI extends EndpointI
throw new Ice.EndpointParseException("no argument provided for -v option in endpoint `opaque "
+ str + "'");
}
+
for(int j = 0; j < argument.length(); ++j)
{
if(!IceUtilInternal.Base64.isBase64(argument.charAt(j)))
@@ -123,8 +147,9 @@ final class OpaqueEndpointI extends EndpointI
public
OpaqueEndpointI(short type, BasicStream s)
{
+ super(Protocol_0_0, Encoding_0_0);
_type = type;
- s.startReadEncaps();
+ _rawEncoding = s.startReadEncaps();
int sz = s.getReadEncapsSize();
_rawBytes = s.readBlob(sz);
s.endReadEncaps();
@@ -138,7 +163,7 @@ final class OpaqueEndpointI extends EndpointI
streamWrite(BasicStream s)
{
s.writeShort(_type);
- s.startWriteEncaps();
+ s.startWriteEncaps(_rawEncoding);
s.writeBlob(_rawBytes);
s.endWriteEncaps();
}
@@ -150,7 +175,7 @@ final class OpaqueEndpointI extends EndpointI
_toString()
{
String val = IceUtilInternal.Base64.encode(_rawBytes);
- return "opaque -t " + _type + " -v " + val;
+ return "opaque -t " + _type + " -e " + Ice.Util.encodingVersionToString(_rawEncoding) + " -v " + val;
}
//
@@ -159,7 +184,7 @@ final class OpaqueEndpointI extends EndpointI
public Ice.EndpointInfo
getInfo()
{
- return new Ice.OpaqueEndpointInfo(-1, false, _rawBytes)
+ return new Ice.OpaqueEndpointInfo(_protocol, _encoding, -1, false, _rawEncoding, _rawBytes)
{
public short type()
{
@@ -340,44 +365,43 @@ final class OpaqueEndpointI extends EndpointI
//
// Compare endpoints for sorting purposes
//
- public boolean
- equals(java.lang.Object obj)
+ public int
+ compareTo(EndpointI obj) // From java.lang.Comparable
{
- try
+ if(!(obj instanceof OpaqueEndpointI))
{
- return compareTo((EndpointI)obj) == 0;
+ return type() < obj.type() ? -1 : 1;
}
- catch(ClassCastException ee)
+
+ OpaqueEndpointI p = (OpaqueEndpointI)obj;
+ if(this == p)
{
- assert(false);
- return false;
+ return 0;
}
- }
-
- public int
- compareTo(EndpointI obj) // From java.lang.Comparable
- {
- OpaqueEndpointI p = null;
- try
+ if(_type < p._type)
{
- p = (OpaqueEndpointI)obj;
+ return -1;
}
- catch(ClassCastException ex)
+ else if(p._type < _type)
{
return 1;
}
- if(this == p)
+ if(_rawEncoding.major < p._rawEncoding.major)
{
- return 0;
+ return -1;
+ }
+ else if(p._rawEncoding.major < _rawEncoding.major)
+ {
+ return 1;
}
- if(_type < p._type)
+ if(_rawEncoding.minor < p._rawEncoding.minor)
{
return -1;
}
- else if(p._type < _type)
+ else if(p._rawEncoding.minor < _rawEncoding.minor)
{
return 1;
}
@@ -409,6 +433,8 @@ final class OpaqueEndpointI extends EndpointI
calcHashValue()
{
_hashCode = _type;
+ _hashCode = 5 * _hashCode + _rawEncoding.major;
+ _hashCode = 5 * _hashCode + _rawEncoding.minor;
for(int i = 0; i < _rawBytes.length; i++)
{
_hashCode = 5 * _hashCode + _rawBytes[i];
@@ -416,6 +442,10 @@ final class OpaqueEndpointI extends EndpointI
}
private short _type;
+ private Ice.EncodingVersion _rawEncoding;
private byte[] _rawBytes;
private int _hashCode;
+
+ private final static Ice.ProtocolVersion Protocol_0_0 = new Ice.ProtocolVersion((byte)0, (byte)0);
+ private final static Ice.EncodingVersion Encoding_0_0 = new Ice.EncodingVersion((byte)0, (byte)0);
}
diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java
index c8b2e0e6258..500f8217230 100644
--- a/java/src/IceInternal/Outgoing.java
+++ b/java/src/IceInternal/Outgoing.java
@@ -18,10 +18,11 @@ public final class Outgoing implements OutgoingMessageCallback
_state = StateUnsent;
_sent = false;
_handler = handler;
+ _encoding = handler.getReference().getEncoding();
Instance instance = _handler.getReference().getInstance();
- _is = new BasicStream(instance);
- _os = new BasicStream(instance);
+ //_is = new BasicStream(instance, Protocol.currentProtocolEncoding);
+ _os = new BasicStream(instance, Protocol.currentProtocolEncoding);
writeHeader(operation, mode, context);
}
@@ -37,6 +38,7 @@ public final class Outgoing implements OutgoingMessageCallback
_exception = null;
_sent = false;
_handler = handler;
+ _encoding = handler.getReference().getEncoding();
writeHeader(operation, mode, context);
}
@@ -44,7 +46,10 @@ public final class Outgoing implements OutgoingMessageCallback
public void
reclaim()
{
- _is.reset();
+ if(_is != null)
+ {
+ _is.reset();
+ }
_os.reset();
}
@@ -55,8 +60,6 @@ public final class Outgoing implements OutgoingMessageCallback
{
assert(_state == StateUnsent);
- _os.endWriteEncaps();
-
switch(_handler.getReference().getMode())
{
case Reference.ModeTwoway:
@@ -285,6 +288,10 @@ public final class Outgoing implements OutgoingMessageCallback
assert(_state <= StateInProgress);
+ if(_is == null)
+ {
+ _is = new IceInternal.BasicStream(_handler.getReference().getInstance(), Protocol.currentProtocolEncoding);
+ }
_is.swap(is);
byte replyStatus = _is.readByte();
@@ -422,17 +429,74 @@ public final class Outgoing implements OutgoingMessageCallback
}
public BasicStream
- is()
+ os()
+ {
+ return _os;
+ }
+
+ public BasicStream
+ startReadParams()
{
+ _is.startReadEncaps();
return _is;
}
+ public void
+ endReadParams()
+ {
+ _is.endReadEncaps();
+ }
+
+ public void
+ readEmptyParams()
+ {
+ _is.skipEmptyEncaps(null);
+ }
+
+ public byte[]
+ readParamEncaps()
+ {
+ return _is.readEncaps(null);
+ }
+
public BasicStream
- os()
+ startWriteParams()
{
+ _os.startWriteEncaps(_encoding);
return _os;
}
+ public void
+ endWriteParams()
+ {
+ _os.endWriteEncaps();
+ }
+
+ public void
+ writeEmptyParams()
+ {
+ _os.writeEmptyEncaps(_encoding);
+ }
+
+ public void
+ writeParamEncaps(byte[] encaps)
+ {
+ if(encaps.length == 0)
+ {
+ _os.writeEmptyEncaps(_encoding);
+ }
+ else
+ {
+ _os.writeEncaps(encaps);
+ }
+ }
+
+ public boolean
+ hasResponse()
+ {
+ return !_is.isEmpty();
+ }
+
public void
throwUserException()
throws Ice.UserException
@@ -517,13 +581,6 @@ public final class Outgoing implements OutgoingMessageCallback
implicitContext.write(prxContext, _os);
}
}
-
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward requests as
- // blobs.
- //
- _os.startWriteEncaps();
}
catch(Ice.LocalException ex)
{
@@ -532,6 +589,7 @@ public final class Outgoing implements OutgoingMessageCallback
}
private RequestHandler _handler;
+ private Ice.EncodingVersion _encoding;
private BasicStream _is;
private BasicStream _os;
private boolean _sent;
diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java
index 736f873f278..ba38613b7e1 100644
--- a/java/src/IceInternal/OutgoingAsync.java
+++ b/java/src/IceInternal/OutgoingAsync.java
@@ -11,11 +11,11 @@ package IceInternal;
public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessageCallback
{
- public OutgoingAsync(Ice.ObjectPrx prx, String operation, CallbackBase callback)
+ public OutgoingAsync(Ice.ObjectPrx prx, String operation, CallbackBase cb)
{
- super(prx.ice_getCommunicator(), ((Ice.ObjectPrxHelperBase)prx).__reference().getInstance(), operation,
- callback);
+ super(prx.ice_getCommunicator(), ((Ice.ObjectPrxHelperBase)prx).__reference().getInstance(), operation, cb);
_proxy = (Ice.ObjectPrxHelperBase)prx;
+ _encoding = _proxy.__reference().getEncoding();
}
public void __prepare(String operation, Ice.OperationMode mode, java.util.Map<String, String> ctx,
@@ -87,8 +87,6 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa
implicitContext.write(prxContext, _os);
}
}
-
- _os.startWriteEncaps();
}
@Override
@@ -216,7 +214,7 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa
}
assert _is == null;
- _is = new IceInternal.BasicStream(_instance);
+ _is = new IceInternal.BasicStream(_instance, IceInternal.Protocol.currentProtocolEncoding);
_is.swap(is);
replyStatus = _is.readByte();
@@ -398,6 +396,38 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa
return _sentSynchronously;
}
+ public BasicStream
+ __startWriteParams()
+ {
+ _os.startWriteEncaps(_encoding);
+ return _os;
+ }
+
+ public void
+ __endWriteParams()
+ {
+ _os.endWriteEncaps();
+ }
+
+ public void
+ __writeEmptyParams()
+ {
+ _os.writeEmptyEncaps(_encoding);
+ }
+
+ public void
+ __writeParamEncaps(byte[] encaps)
+ {
+ if(encaps == null || encaps.length == 0)
+ {
+ _os.writeEmptyEncaps(_encoding);
+ }
+ else
+ {
+ _os.writeEncaps(encaps);
+ }
+ }
+
private int handleException(Ice.LocalException exc, boolean sent)
{
Ice.IntHolder interval = new Ice.IntHolder(0);
@@ -481,6 +511,7 @@ public class OutgoingAsync extends Ice.AsyncResult implements OutgoingAsyncMessa
private TimerTask _timerTask;
private Ice._ObjectDel _delegate;
+ private Ice.EncodingVersion _encoding;
private int _cnt;
private Ice.OperationMode _mode;
diff --git a/java/src/IceInternal/Protocol.java b/java/src/IceInternal/Protocol.java
index 443550211ca..81f44cdccba 100644
--- a/java/src/IceInternal/Protocol.java
+++ b/java/src/IceInternal/Protocol.java
@@ -35,6 +35,9 @@ final public class Protocol
//
public final static byte protocolMajor = 1;
public final static byte protocolMinor = 0;
+ public final static byte protocolEncodingMajor = 1;
+ public final static byte protocolEncodingMinor = 0;
+
public final static byte encodingMajor = 1;
public final static byte encodingMinor = 0;
@@ -55,8 +58,8 @@ final public class Protocol
IceInternal.Protocol.magic[3],
IceInternal.Protocol.protocolMajor,
IceInternal.Protocol.protocolMinor,
- IceInternal.Protocol.encodingMajor,
- IceInternal.Protocol.encodingMinor,
+ IceInternal.Protocol.protocolEncodingMajor,
+ IceInternal.Protocol.protocolEncodingMinor,
IceInternal.Protocol.requestMsg,
(byte)0, // Compression status.
(byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder).
@@ -71,8 +74,8 @@ final public class Protocol
IceInternal.Protocol.magic[3],
IceInternal.Protocol.protocolMajor,
IceInternal.Protocol.protocolMinor,
- IceInternal.Protocol.encodingMajor,
- IceInternal.Protocol.encodingMinor,
+ IceInternal.Protocol.protocolEncodingMajor,
+ IceInternal.Protocol.protocolEncodingMinor,
IceInternal.Protocol.requestBatchMsg,
0, // Compression status.
(byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder).
@@ -87,11 +90,55 @@ final public class Protocol
IceInternal.Protocol.magic[3],
IceInternal.Protocol.protocolMajor,
IceInternal.Protocol.protocolMinor,
- IceInternal.Protocol.encodingMajor,
- IceInternal.Protocol.encodingMinor,
+ IceInternal.Protocol.protocolEncodingMajor,
+ IceInternal.Protocol.protocolEncodingMinor,
IceInternal.Protocol.replyMsg,
(byte)0, // Compression status.
(byte)0, (byte)0, (byte)0, (byte)0 // Message size (placeholder).
};
+ static final public Ice.ProtocolVersion currentProtocol = new Ice.ProtocolVersion(protocolMajor, protocolMinor);
+ static final public Ice.EncodingVersion currentProtocolEncoding = new Ice.EncodingVersion(protocolEncodingMajor,
+ protocolEncodingMinor);
+
+ static final public Ice.EncodingVersion currentEncoding = new Ice.EncodingVersion(encodingMajor, encodingMinor);
+
+ static public void
+ checkSupportedProtocol(Ice.ProtocolVersion v)
+ {
+ if(v.major != currentProtocol.major || v.minor > currentProtocol.minor)
+ {
+ throw new Ice.UnsupportedProtocolException("", v, currentProtocol);
+ }
+ }
+
+ static public void
+ checkSupportedProtocolEncoding(Ice.EncodingVersion v)
+ {
+ if(v.major != currentProtocolEncoding.major || v.minor > currentProtocolEncoding.minor)
+ {
+ throw new Ice.UnsupportedEncodingException("", v, currentProtocolEncoding);
+ }
+ }
+
+ static public void
+ checkSupportedEncoding(Ice.EncodingVersion v)
+ {
+ if(v.major != currentEncoding.major || v.minor > currentEncoding.minor)
+ {
+ throw new Ice.UnsupportedEncodingException("", v, currentEncoding);
+ }
+ }
+
+ static public boolean
+ isSupported(Ice.ProtocolVersion version, Ice.ProtocolVersion supported)
+ {
+ return version.major == supported.major && version.minor <= supported.minor;
+ }
+
+ static public boolean
+ isSupported(Ice.EncodingVersion version, Ice.EncodingVersion supported)
+ {
+ return version.major == supported.major && version.minor <= supported.minor;
+ }
}
diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java
index 32a0c523dac..261c833259f 100644
--- a/java/src/IceInternal/Reference.java
+++ b/java/src/IceInternal/Reference.java
@@ -36,6 +36,12 @@ public abstract class Reference implements Cloneable
return _secure;
}
+ public final Ice.EncodingVersion
+ getEncoding()
+ {
+ return _encoding;
+ }
+
public final Ice.Identity
getIdentity()
{
@@ -149,6 +155,19 @@ public abstract class Reference implements Cloneable
return r;
}
+ public final Reference
+ changeEncoding(Ice.EncodingVersion newEncoding)
+ {
+ if(newEncoding.equals(_encoding))
+ {
+ return this;
+ }
+ Reference r = _instance.referenceFactory().copy(this);
+ r._encoding = newEncoding;
+ return r;
+ }
+
+
public Reference
changeCompress(boolean newCompress)
{
@@ -383,6 +402,11 @@ public abstract class Reference implements Cloneable
return false;
}
+ if(!_encoding.equals(r._encoding))
+ {
+ return false;
+ }
+
return true;
}
@@ -414,6 +438,7 @@ public abstract class Reference implements Cloneable
private Ice.Identity _identity;
private java.util.Map<String, String> _context;
private String _facet;
+ private Ice.EncodingVersion _encoding;
protected boolean _overrideCompress;
protected boolean _compress; // Only used if _overrideCompress == true
@@ -423,7 +448,8 @@ public abstract class Reference implements Cloneable
Ice.Identity identity,
String facet,
int mode,
- boolean secure)
+ boolean secure,
+ Ice.EncodingVersion encoding)
{
//
// Validate string arguments.
@@ -439,6 +465,7 @@ public abstract class Reference implements Cloneable
_identity = identity;
_context = _emptyContext;
_facet = facet;
+ _encoding = encoding;
_hashInitialized = false;
_overrideCompress = false;
_compress = false;
diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java
index 6388ebe5f45..21902f03703 100644
--- a/java/src/IceInternal/ReferenceFactory.java
+++ b/java/src/IceInternal/ReferenceFactory.java
@@ -41,6 +41,8 @@ public final class ReferenceFactory
return null;
}
+ DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
+
//
// Create new reference
//
@@ -51,6 +53,7 @@ public final class ReferenceFactory
"", // Facet
fixedConnection.endpoint().datagram() ? Reference.ModeDatagram : Reference.ModeTwoway,
fixedConnection.endpoint().secure(),
+ defaultsAndOverrides.defaultEncoding,
fixedConnection);
return updateCache(ref);
}
@@ -655,6 +658,7 @@ public final class ReferenceFactory
"EndpointSelection",
"ConnectionCached",
"PreferSecure",
+ "EncodingVersion",
"LocatorCacheTimeout",
"Locator",
"Router",
@@ -726,6 +730,7 @@ public final class ReferenceFactory
boolean collocationOptimized = defaultsAndOverrides.defaultCollocationOptimization;
boolean cacheConnection = true;
boolean preferSecure = defaultsAndOverrides.defaultPreferSecure;
+ Ice.EncodingVersion encoding = defaultsAndOverrides.defaultEncoding;
Ice.EndpointSelectionType endpointSelection = defaultsAndOverrides.defaultEndpointSelection;
int locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout;
@@ -778,6 +783,14 @@ public final class ReferenceFactory
property = propertyPrefix + ".PreferSecure";
preferSecure = properties.getPropertyAsIntWithDefault(property, preferSecure ? 1 : 0) > 0;
+ property = propertyPrefix + ".EncodingVersion";
+ String encodingStr = properties.getProperty(property);
+ if(!encodingStr.isEmpty())
+ {
+ encoding = Ice.Util.stringToEncodingVersion(encodingStr);
+ Protocol.checkSupportedEncoding(encoding);
+ }
+
property = propertyPrefix + ".EndpointSelection";
if(properties.getProperty(property).length() > 0)
{
@@ -810,6 +823,7 @@ public final class ReferenceFactory
facet,
mode,
secure,
+ encoding,
endpoints,
adapterId,
locatorInfo,
diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java
index c90a57f082a..efd9658dc6b 100644
--- a/java/src/IceInternal/RoutableReference.java
+++ b/java/src/IceInternal/RoutableReference.java
@@ -334,6 +334,7 @@ public class RoutableReference extends Reference
properties.put(prefix + ".PreferSecure", _preferSecure ? "1" : "0");
properties.put(prefix + ".EndpointSelection",
_endpointSelection == Ice.EndpointSelectionType.Random ? "Random" : "Ordered");
+ properties.put(prefix + ".EncodingVersion", Ice.Util.encodingVersionToString(getEncoding()));
StringBuffer s = new StringBuffer();
s.append(_locatorCacheTimeout);
@@ -631,6 +632,7 @@ public class RoutableReference extends Reference
String facet,
int mode,
boolean secure,
+ Ice.EncodingVersion encoding,
EndpointI[] endpoints,
String adapterId,
LocatorInfo locatorInfo,
@@ -641,7 +643,7 @@ public class RoutableReference extends Reference
Ice.EndpointSelectionType endpointSelection,
int locatorCacheTimeout)
{
- super(instance, communicator, identity, facet, mode, secure);
+ super(instance, communicator, identity, facet, mode, secure, encoding);
_endpoints = endpoints;
_adapterId = adapterId;
_locatorInfo = locatorInfo;
@@ -691,13 +693,16 @@ public class RoutableReference extends Reference
java.util.List<EndpointI> endpoints = new java.util.ArrayList<EndpointI>();
//
- // Filter out opaque endpoints.
+ // Filter out incompatible endpoints (whose encoding/protocol
+ // versions aren't supported by this runtime, or are opaque).
//
- for(EndpointI endpoint : allEndpoints)
+ final Ice.EncodingVersion encoding = getEncoding();
+ for(EndpointI p : allEndpoints)
{
- if(!(endpoint instanceof IceInternal.OpaqueEndpointI))
+ if(Protocol.isSupported(encoding, p.encoding()) &&
+ Protocol.isSupported(Protocol.currentProtocol, p.protocol()))
{
- endpoints.add(endpoint);
+ endpoints.add(p);
}
}
diff --git a/java/src/IceInternal/TcpConnector.java b/java/src/IceInternal/TcpConnector.java
index e0c4139215b..bb993442932 100644
--- a/java/src/IceInternal/TcpConnector.java
+++ b/java/src/IceInternal/TcpConnector.java
@@ -68,18 +68,23 @@ final class TcpConnector implements Connector
//
// Only for use by TcpEndpoint
//
- TcpConnector(Instance instance, java.net.InetSocketAddress addr, int timeout, String connectionId)
+ TcpConnector(Instance instance, java.net.InetSocketAddress addr, int timeout, Ice.ProtocolVersion protocol,
+ Ice.EncodingVersion encoding, String connectionId)
{
_instance = instance;
_traceLevels = instance.traceLevels();
_logger = instance.initializationData().logger;
_addr = addr;
_timeout = timeout;
+ _protocol = protocol;
+ _encoding = encoding;
_connectionId = connectionId;
_hashCode = _addr.getAddress().getHostAddress().hashCode();
_hashCode = 5 * _hashCode + _addr.getPort();
_hashCode = 5 * _hashCode + _timeout;
+ _hashCode = 5 * _hashCode + _protocol.hashCode();
+ _hashCode = 5 * _hashCode + _encoding.hashCode();
_hashCode = 5 * _hashCode + _connectionId.hashCode();
}
@@ -107,6 +112,16 @@ final class TcpConnector implements Connector
return false;
}
+ if(!_protocol.equals(p._protocol))
+ {
+ return false;
+ }
+
+ if(!_encoding.equals(p._encoding))
+ {
+ return false;
+ }
+
if(!_connectionId.equals(p._connectionId))
{
return false;
@@ -120,6 +135,8 @@ final class TcpConnector implements Connector
private Ice.Logger _logger;
private java.net.InetSocketAddress _addr;
private int _timeout;
+ private Ice.ProtocolVersion _protocol;
+ private Ice.EncodingVersion _encoding;
private String _connectionId = "";
private int _hashCode;
}
diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java
index 6e9f73190aa..9935d546fd7 100644
--- a/java/src/IceInternal/TcpEndpointI.java
+++ b/java/src/IceInternal/TcpEndpointI.java
@@ -12,8 +12,10 @@ package IceInternal;
final class TcpEndpointI extends EndpointI
{
public
- TcpEndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co)
+ TcpEndpointI(Instance instance, String ho, int po, int ti, Ice.ProtocolVersion pv, Ice.EncodingVersion ev,
+ String conId, boolean co)
{
+ super(pv, ev);
_instance = instance;
_host = ho;
_port = po;
@@ -136,7 +138,7 @@ final class TcpEndpointI extends EndpointI
default:
{
- throw new Ice.EndpointParseException("unknown option `" + option + "' in `tcp " + str + "'");
+ parseOption(option, argument, "tcp", str);
}
}
}
@@ -174,6 +176,16 @@ final class TcpEndpointI extends EndpointI
_port = s.readInt();
_timeout = s.readInt();
_compress = s.readBool();
+ if(!s.getReadEncoding().equals(Ice.Util.Encoding_1_0))
+ {
+ _protocol.__read(s);
+ _encoding.__read(s);
+ }
+ else
+ {
+ _protocol = Ice.Util.Protocol_1_0;
+ _encoding = Ice.Util.Encoding_1_0;
+ }
s.endReadEncaps();
calcHashValue();
}
@@ -190,6 +202,11 @@ final class TcpEndpointI extends EndpointI
s.writeInt(_port);
s.writeInt(_timeout);
s.writeBool(_compress);
+ if(!s.getWriteEncoding().equals(Ice.Util.Encoding_1_0))
+ {
+ _protocol.__write(s);
+ _encoding.__write(s);
+ }
s.endWriteEncaps();
}
@@ -208,6 +225,16 @@ final class TcpEndpointI extends EndpointI
//
String s = "tcp";
+ if(!_protocol.equals(Ice.Util.Protocol_1_0))
+ {
+ s += " -v " + Ice.Util.protocolVersionToString(_protocol);
+ }
+
+ if(!_encoding.equals(Ice.Util.Encoding_1_0))
+ {
+ s += " -e " + Ice.Util.encodingVersionToString(_encoding);
+ }
+
if(_host != null && _host.length() > 0)
{
s += " -h ";
@@ -242,7 +269,7 @@ final class TcpEndpointI extends EndpointI
public Ice.EndpointInfo
getInfo()
{
- return new Ice.TCPEndpointInfo(_timeout, _compress, _host, _port)
+ return new Ice.TCPEndpointInfo(_protocol, _encoding, _timeout, _compress, _host, _port)
{
public short type()
{
@@ -294,7 +321,7 @@ final class TcpEndpointI extends EndpointI
}
else
{
- return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress);
+ return new TcpEndpointI(_instance, _host, _port, timeout, _protocol, _encoding, _connectionId, _compress);
}
}
@@ -310,7 +337,7 @@ final class TcpEndpointI extends EndpointI
}
else
{
- return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress);
+ return new TcpEndpointI(_instance, _host, _port, _timeout, _protocol, _encoding, connectionId, _compress);
}
}
@@ -338,7 +365,7 @@ final class TcpEndpointI extends EndpointI
}
else
{
- return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress);
+ return new TcpEndpointI(_instance, _host, _port, _timeout, _protocol, _encoding, _connectionId, compress);
}
}
@@ -401,8 +428,8 @@ final class TcpEndpointI extends EndpointI
acceptor(EndpointIHolder endpoint, String adapterName)
{
TcpAcceptor p = new TcpAcceptor(_instance, _host, _port);
- endpoint.value =
- new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, _connectionId, _compress);
+ endpoint.value = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, _protocol, _encoding,
+ _connectionId, _compress);
return p;
}
@@ -423,7 +450,8 @@ final class TcpEndpointI extends EndpointI
{
for(String h : hosts)
{
- endps.add(new TcpEndpointI(_instance, h, _port, _timeout, _connectionId, _compress));
+ endps.add(new TcpEndpointI(_instance, h, _port, _timeout, _protocol, _encoding, _connectionId,
+ _compress));
}
}
return endps;
@@ -435,15 +463,11 @@ final class TcpEndpointI extends EndpointI
public boolean
equivalent(EndpointI endpoint)
{
- TcpEndpointI tcpEndpointI = null;
- try
- {
- tcpEndpointI = (TcpEndpointI)endpoint;
- }
- catch(ClassCastException ex)
+ if(!(endpoint instanceof TcpEndpointI))
{
return false;
}
+ TcpEndpointI tcpEndpointI = (TcpEndpointI)endpoint;
return tcpEndpointI._host.equals(_host) && tcpEndpointI._port == _port;
}
@@ -456,38 +480,27 @@ final class TcpEndpointI extends EndpointI
//
// Compare endpoints for sorting purposes
//
- public boolean
- equals(java.lang.Object obj)
- {
- try
- {
- return compareTo((EndpointI)obj) == 0;
- }
- catch(ClassCastException ee)
- {
- assert(false);
- return false;
- }
- }
-
public int
compareTo(EndpointI obj) // From java.lang.Comparable
{
- TcpEndpointI p = null;
-
- try
- {
- p = (TcpEndpointI)obj;
- }
- catch(ClassCastException ex)
+ if(!(obj instanceof TcpEndpointI))
{
return type() < obj.type() ? -1 : 1;
}
+ TcpEndpointI p = (TcpEndpointI)obj;
if(this == p)
{
return 0;
}
+ else
+ {
+ int r = super.compareTo(p);
+ if(r != 0)
+ {
+ return r;
+ }
+ }
if(_port < p._port)
{
@@ -530,7 +543,7 @@ final class TcpEndpointI extends EndpointI
java.util.List<Connector> connectors = new java.util.ArrayList<Connector>();
for(java.net.InetSocketAddress p : addresses)
{
- connectors.add(new TcpConnector(_instance, p, _timeout, _connectionId));
+ connectors.add(new TcpConnector(_instance, p, _timeout, _protocol, _encoding, _connectionId));
}
return connectors;
}
@@ -541,6 +554,8 @@ final class TcpEndpointI extends EndpointI
_hashCode = _host.hashCode();
_hashCode = 5 * _hashCode + _port;
_hashCode = 5 * _hashCode + _timeout;
+ _hashCode = 5 * _hashCode + _protocol.hashCode();
+ _hashCode = 5 * _hashCode + _encoding.hashCode();
_hashCode = 5 * _hashCode + _connectionId.hashCode();
_hashCode = 5 * _hashCode + (_compress ? 1 : 0);
}
diff --git a/java/src/IceInternal/ThreadPoolCurrent.java b/java/src/IceInternal/ThreadPoolCurrent.java
index ed4e6b85919..c7d0e59bf35 100644
--- a/java/src/IceInternal/ThreadPoolCurrent.java
+++ b/java/src/IceInternal/ThreadPoolCurrent.java
@@ -14,7 +14,7 @@ public final class ThreadPoolCurrent
ThreadPoolCurrent(Instance instance, ThreadPool threadPool)
{
operation = SocketOperation.None;
- stream = new BasicStream(instance);
+ stream = new BasicStream(instance, Protocol.currentProtocolEncoding);
_threadPool = threadPool;
_ioCompleted = false;
diff --git a/java/src/IceInternal/UdpConnector.java b/java/src/IceInternal/UdpConnector.java
index 89995171c63..340cdf98da4 100644
--- a/java/src/IceInternal/UdpConnector.java
+++ b/java/src/IceInternal/UdpConnector.java
@@ -46,21 +46,21 @@ final class UdpConnector implements Connector
// Only for use by TcpEndpoint
//
UdpConnector(Instance instance, java.net.InetSocketAddress addr, String mcastInterface, int mcastTtl,
- byte protocolMajor, byte protocolMinor, byte encodingMajor, byte encodingMinor, String connectionId)
+ Ice.ProtocolVersion protocol, Ice.EncodingVersion encoding, String connectionId)
{
_instance = instance;
_addr = addr;
_mcastInterface = mcastInterface;
_mcastTtl = mcastTtl;
- _protocolMajor = protocolMajor;
- _protocolMinor = protocolMinor;
- _encodingMajor = encodingMajor;
- _encodingMinor = encodingMinor;
+ _protocol = protocol;
+ _encoding = encoding;
_connectionId = connectionId;
_hashCode = _addr.getAddress().getHostAddress().hashCode();
_hashCode = 5 * _hashCode + _addr.getPort();
_hashCode = 5 * _hashCode + _mcastInterface.hashCode();
+ _hashCode = 5 * _hashCode + _protocol.hashCode();
+ _hashCode = 5 * _hashCode + _encoding.hashCode();
_hashCode = 5 * _hashCode + _mcastTtl;
_hashCode = 5 * _hashCode + _connectionId.hashCode();
}
@@ -89,22 +89,12 @@ final class UdpConnector implements Connector
return false;
}
- if(_protocolMajor != p._protocolMajor)
+ if(!_protocol.equals(p._protocol))
{
return false;
}
- if(_protocolMinor != p._protocolMinor)
- {
- return false;
- }
-
- if(_encodingMajor != p._encodingMajor)
- {
- return false;
- }
-
- if(_encodingMinor != p._encodingMinor)
+ if(!_encoding.equals(p._encoding))
{
return false;
}
@@ -126,10 +116,8 @@ final class UdpConnector implements Connector
private java.net.InetSocketAddress _addr;
private String _mcastInterface;
private int _mcastTtl;
- private byte _protocolMajor;
- private byte _protocolMinor;
- private byte _encodingMajor;
- private byte _encodingMinor;
+ private Ice.ProtocolVersion _protocol;
+ private Ice.EncodingVersion _encoding;
private String _connectionId;
private int _hashCode;
}
diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java
index 17c283f1a1f..6604470e085 100644
--- a/java/src/IceInternal/UdpEndpointI.java
+++ b/java/src/IceInternal/UdpEndpointI.java
@@ -12,18 +12,15 @@ package IceInternal;
final class UdpEndpointI extends EndpointI
{
public
- UdpEndpointI(Instance instance, String ho, int po, String mif, int mttl, byte pma, byte pmi, byte ema, byte emi,
- boolean conn, String conId, boolean co)
+ UdpEndpointI(Instance instance, String ho, int po, String mif, int mttl, Ice.ProtocolVersion p,
+ Ice.EncodingVersion e, boolean conn, String conId, boolean co)
{
+ super(p, e);
_instance = instance;
_host = ho;
_port = po;
_mcastInterface = mif;
_mcastTtl = mttl;
- _protocolMajor = pma;
- _protocolMinor = pmi;
- _encodingMajor = ema;
- _encodingMinor = emi;
_connect = conn;
_connectionId = conId;
_compress = co;
@@ -36,10 +33,6 @@ final class UdpEndpointI extends EndpointI
_instance = instance;
_host = null;
_port = 0;
- _protocolMajor = Protocol.protocolMajor;
- _protocolMinor = Protocol.protocolMinor;
- _encodingMajor = Protocol.encodingMajor;
- _encodingMinor = Protocol.encodingMinor;
_connect = false;
_compress = false;
@@ -71,105 +64,7 @@ final class UdpEndpointI extends EndpointI
}
}
- if(option.equals("-v"))
- {
- if(argument == null)
- {
- throw new Ice.EndpointParseException("no argument provided for -v option in endpoint `udp "
- + str + "'");
- }
-
- int pos = argument.indexOf('.');
- if(pos == -1)
- {
- throw new Ice.EndpointParseException("malformed protocol version `" + argument +
- "' in endpoint `udp " + str + "'");
- }
-
- String majStr = argument.substring(0, pos);
- String minStr = argument.substring(pos + 1, argument.length());
- int majVersion;
- int minVersion;
- try
- {
- majVersion = Integer.parseInt(majStr);
- minVersion = Integer.parseInt(minStr);
- }
- catch(NumberFormatException ex)
- {
- throw new Ice.EndpointParseException("invalid protocol version `" + argument +
- "' in endpoint `udp " + str + "'");
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- throw new Ice.EndpointParseException("range error in protocol version `" + argument +
- "' in endpoint `udp " + str + "'");
- }
-
- if(majVersion != Protocol.protocolMajor)
- {
- Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
- e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion;
- e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion;
- e.major = Protocol.protocolMajor;
- e.minor = Protocol.protocolMinor;
- throw e;
- }
-
- _protocolMajor = (byte)majVersion;
- _protocolMinor = (byte)minVersion;
- }
- else if(option.equals("-e"))
- {
- if(argument == null)
- {
- throw new Ice.EndpointParseException("no argument provided for -e option in endpoint `udp "
- + str + "'");
- }
-
- int pos = argument.indexOf('.');
- if(pos == -1)
- {
- throw new Ice.EndpointParseException("malformed encoding version `" + argument +
- "' in endpoint `udp " + str + "'");
- }
-
- String majStr = argument.substring(0, pos);
- String minStr = argument.substring(pos + 1, argument.length());
- int majVersion;
- int minVersion;
- try
- {
- majVersion = Integer.parseInt(majStr);
- minVersion = Integer.parseInt(minStr);
- }
- catch(NumberFormatException ex)
- {
- throw new Ice.EndpointParseException("invalid encoding version `" + argument +
- "' in endpoint `udp " + str + "'");
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- throw new Ice.EndpointParseException("range error in encoding version `" + argument +
- "' in endpoint `udp " + str + "'");
- }
-
- if(majVersion != Protocol.encodingMajor)
- {
- Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
- e.badMajor = majVersion < 0 ? majVersion + 255 : majVersion;
- e.badMinor = minVersion < 0 ? minVersion + 255 : minVersion;
- e.major = Protocol.encodingMajor;
- e.minor = Protocol.encodingMinor;
- throw e;
- }
-
- _encodingMajor = (byte)majVersion;
- _encodingMinor = (byte)minVersion;
- }
- else if(option.equals("-h"))
+ if(option.equals("-h"))
{
if(argument == null)
{
@@ -261,7 +156,7 @@ final class UdpEndpointI extends EndpointI
}
else
{
- throw new Ice.EndpointParseException("unknown option `" + option + "' in `udp " + str + "'");
+ parseOption(option, argument, "udp", str);
}
}
@@ -296,28 +191,8 @@ final class UdpEndpointI extends EndpointI
s.startReadEncaps();
_host = s.readString();
_port = s.readInt();
- _protocolMajor = s.readByte();
- _protocolMinor = s.readByte();
- _encodingMajor = s.readByte();
- _encodingMinor = s.readByte();
- if(_protocolMajor != Protocol.protocolMajor)
- {
- Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
- e.badMajor = _protocolMajor < 0 ? _protocolMajor + 255 : _protocolMajor;
- e.badMinor = _protocolMinor < 0 ? _protocolMinor + 255 : _protocolMinor;
- e.major = Protocol.protocolMajor;
- e.minor = Protocol.protocolMinor;
- throw e;
- }
- if(_encodingMajor != Protocol.encodingMajor)
- {
- Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
- e.badMajor = _encodingMajor < 0 ? _encodingMajor + 255 : _encodingMajor;
- e.badMinor = _encodingMinor < 0 ? _encodingMinor + 255 : _encodingMinor;
- e.major = Protocol.encodingMajor;
- e.minor = Protocol.encodingMinor;
- throw e;
- }
+ _protocol.__read(s);
+ _encoding.__read(s);
// Not transmitted.
//_connect = s.readBool();
_connect = false;
@@ -336,10 +211,8 @@ final class UdpEndpointI extends EndpointI
s.startWriteEncaps();
s.writeString(_host);
s.writeInt(_port);
- s.writeByte(_protocolMajor);
- s.writeByte(_protocolMinor);
- s.writeByte(_encodingMajor);
- s.writeByte(_encodingMinor);
+ _protocol.__write(s);
+ _encoding.__write(s);
// Not transmitted.
//s.writeBool(_connect);
s.writeBool(_compress);
@@ -361,16 +234,14 @@ final class UdpEndpointI extends EndpointI
//
String s = "udp";
- if((int)_protocolMajor != 1 || (int)_protocolMinor != 0)
+ if(!_protocol.equals(Ice.Util.Protocol_1_0))
{
- s += " -v " + (_protocolMajor < 0 ? (int)_protocolMajor + 255 : _protocolMajor)
- + "." + (_protocolMinor < 0 ? (int)_protocolMinor + 255 : _protocolMinor);
+ s += " -v " + Ice.Util.protocolVersionToString(_protocol);
}
-
- if((int)_encodingMajor != 1 || (int)_encodingMinor != 0)
+
+ if(!_encoding.equals(Ice.Util.Encoding_1_0))
{
- s += " -e " + (_encodingMajor < 0 ? (int)_encodingMajor + 255 : _encodingMajor)
- + "." + (_encodingMinor < 0 ? (int)_encodingMinor + 255 : _encodingMinor);
+ s += " -e " + Ice.Util.encodingVersionToString(_encoding);
}
if(_host != null && _host.length() > 0)
@@ -419,8 +290,7 @@ final class UdpEndpointI extends EndpointI
public Ice.EndpointInfo
getInfo()
{
- return new Ice.UDPEndpointInfo(-1, _compress, _host, _port, _protocolMajor, _protocolMinor, _encodingMajor,
- _encodingMinor, _mcastInterface, _mcastTtl)
+ return new Ice.UDPEndpointInfo(_protocol, _encoding, -1, _compress, _host, _port, _mcastInterface, _mcastTtl)
{
public short type()
{
@@ -482,9 +352,8 @@ final class UdpEndpointI extends EndpointI
}
else
{
- return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _protocolMajor,
- _protocolMinor, _encodingMajor, _encodingMinor, _connect, _connectionId,
- compress);
+ return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _protocol, _encoding,
+ _connect, _connectionId, compress);
}
}
@@ -500,9 +369,8 @@ final class UdpEndpointI extends EndpointI
}
else
{
- return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _protocolMajor,
- _protocolMinor, _encodingMajor, _encodingMinor, _connect, connectionId,
- _compress);
+ return new UdpEndpointI(_instance, _host, _port, _mcastInterface, _mcastTtl, _protocol, _encoding,
+ _connect, connectionId, _compress);
}
}
@@ -547,8 +415,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,
- _protocolMajor, _protocolMinor, _encodingMajor, _encodingMinor, _connect,
- _connectionId, _compress);
+ _protocol, _encoding, _connect, _connectionId, _compress);
return p;
}
@@ -601,8 +468,7 @@ final class UdpEndpointI extends EndpointI
for(String host : hosts)
{
endps.add(new UdpEndpointI(_instance, host, _port, _mcastInterface, _mcastTtl,
- _protocolMajor, _protocolMinor, _encodingMajor, _encodingMinor,
- _connect, _connectionId, _compress));
+ _protocol, _encoding, _connect, _connectionId, _compress));
}
}
return endps;
@@ -614,16 +480,11 @@ final class UdpEndpointI extends EndpointI
public boolean
equivalent(EndpointI endpoint)
{
- UdpEndpointI udpEndpointI = null;
- try
- {
- udpEndpointI = (UdpEndpointI)endpoint;
- }
- catch(ClassCastException ex)
+ if(!(endpoint instanceof UdpEndpointI))
{
return false;
}
-
+ UdpEndpointI udpEndpointI = (UdpEndpointI)endpoint;
return udpEndpointI._host.equals(_host) && udpEndpointI._port == _port;
}
@@ -633,41 +494,27 @@ final class UdpEndpointI extends EndpointI
return _hashCode;
}
- //
- // Compare endpoints for sorting purposes
- //
- public boolean
- equals(java.lang.Object obj)
- {
- try
- {
- return compareTo((EndpointI)obj) == 0;
- }
- catch(ClassCastException ee)
- {
- assert(false);
- return false;
- }
- }
-
public int
compareTo(EndpointI obj) // From java.lang.Comparable
{
- UdpEndpointI p = null;
-
- try
- {
- p = (UdpEndpointI)obj;
- }
- catch(ClassCastException ex)
+ if(!(obj instanceof UdpEndpointI))
{
return type() < obj.type() ? -1 : 1;
}
+ UdpEndpointI p = (UdpEndpointI)obj;
if(this == p)
{
return 0;
}
+ else
+ {
+ int r = super.compareTo(p);
+ if(r != 0)
+ {
+ return r;
+ }
+ }
if(_port < p._port)
{
@@ -701,42 +548,6 @@ final class UdpEndpointI extends EndpointI
return 1;
}
- if(_protocolMajor < p._protocolMajor)
- {
- return -1;
- }
- else if(p._protocolMajor < _protocolMajor)
- {
- return 1;
- }
-
- if(_protocolMinor < p._protocolMinor)
- {
- return -1;
- }
- else if(p._protocolMinor < _protocolMinor)
- {
- return 1;
- }
-
- if(_encodingMajor < p._encodingMajor)
- {
- return -1;
- }
- else if(p._encodingMajor < _encodingMajor)
- {
- return 1;
- }
-
- if(_encodingMinor < p._encodingMinor)
- {
- return -1;
- }
- else if(p._encodingMinor < _encodingMinor)
- {
- return 1;
- }
-
if(_mcastTtl < p._mcastTtl)
{
return -1;
@@ -761,9 +572,8 @@ final class UdpEndpointI extends EndpointI
java.util.ArrayList<Connector> connectors = new java.util.ArrayList<Connector>();
for(java.net.InetSocketAddress p : addresses)
{
- connectors.add(
- new UdpConnector(_instance, p, _mcastInterface, _mcastTtl, _protocolMajor, _protocolMinor,
- _encodingMajor, _encodingMinor, _connectionId));
+ connectors.add(new UdpConnector(_instance, p, _mcastInterface, _mcastTtl, _protocol, _encoding,
+ _connectionId));
}
return connectors;
}
@@ -776,6 +586,8 @@ final class UdpEndpointI extends EndpointI
_hashCode = 5 * _hashCode + _mcastInterface.hashCode();
_hashCode = 5 * _hashCode + _mcastTtl;
_hashCode = 5 * _hashCode + (_connect ? 1 : 0);
+ _hashCode = 5 * _hashCode + _protocol.hashCode();
+ _hashCode = 5 * _hashCode + _encoding.hashCode();
_hashCode = 5 * _hashCode + _connectionId.hashCode();
_hashCode = 5 * _hashCode + (_compress ? 1 : 0);
}
@@ -785,10 +597,6 @@ final class UdpEndpointI extends EndpointI
private int _port;
private String _mcastInterface = "";
private int _mcastTtl = -1;
- private byte _protocolMajor;
- private byte _protocolMinor;
- private byte _encodingMajor;
- private byte _encodingMinor;
private boolean _connect;
private String _connectionId = "";
private boolean _compress;
diff --git a/java/src/IceSSL/ConnectorI.java b/java/src/IceSSL/ConnectorI.java
index 5b50a79e1db..4af8740e0a2 100644
--- a/java/src/IceSSL/ConnectorI.java
+++ b/java/src/IceSSL/ConnectorI.java
@@ -79,18 +79,23 @@ final class ConnectorI implements IceInternal.Connector
//
// Only for use by EndpointI.
//
- ConnectorI(Instance instance, String host, java.net.InetSocketAddress addr, int timeout, String connectionId)
+ ConnectorI(Instance instance, String host, java.net.InetSocketAddress addr, int timeout,
+ Ice.ProtocolVersion protocol, Ice.EncodingVersion encoding, String connectionId)
{
_instance = instance;
_logger = instance.communicator().getLogger();
_host = host;
_addr = addr;
_timeout = timeout;
+ _protocol = protocol;
+ _encoding = encoding;
_connectionId = connectionId;
_hashCode = _addr.getAddress().getHostAddress().hashCode();
_hashCode = 5 * _hashCode + _addr.getPort();
_hashCode = 5 * _hashCode + _timeout;
+ _hashCode = 5 * _hashCode + _protocol.hashCode();
+ _hashCode = 5 * _hashCode + _encoding.hashCode();
_hashCode = 5 * _hashCode + _connectionId.hashCode();
}
@@ -118,6 +123,16 @@ final class ConnectorI implements IceInternal.Connector
return false;
}
+ if(!_protocol.equals(p._protocol))
+ {
+ return false;
+ }
+
+ if(!_encoding.equals(p._encoding))
+ {
+ return false;
+ }
+
if(!_connectionId.equals(p._connectionId))
{
return false;
@@ -131,6 +146,8 @@ final class ConnectorI implements IceInternal.Connector
private String _host;
private java.net.InetSocketAddress _addr;
private int _timeout;
+ private Ice.ProtocolVersion _protocol;
+ private Ice.EncodingVersion _encoding;
private String _connectionId;
private int _hashCode;
}
diff --git a/java/src/IceSSL/EndpointI.java b/java/src/IceSSL/EndpointI.java
index 69bae7bfad7..c3390c58eb4 100644
--- a/java/src/IceSSL/EndpointI.java
+++ b/java/src/IceSSL/EndpointI.java
@@ -12,8 +12,10 @@ package IceSSL;
final class EndpointI extends IceInternal.EndpointI
{
public
- EndpointI(Instance instance, String ho, int po, int ti, String conId, boolean co)
+ EndpointI(Instance instance, String ho, int po, int ti, Ice.ProtocolVersion pv, Ice.EncodingVersion ev,
+ String conId, boolean co)
{
+ super(pv, ev);
_instance = instance;
_host = ho;
_port = po;
@@ -136,7 +138,7 @@ final class EndpointI extends IceInternal.EndpointI
default:
{
- throw new Ice.EndpointParseException("unknown option `" + option + "' in `ssl " + str + "'");
+ parseOption(option, argument, "ssl", str);
}
}
}
@@ -174,6 +176,16 @@ final class EndpointI extends IceInternal.EndpointI
_port = s.readInt();
_timeout = s.readInt();
_compress = s.readBool();
+ if(!s.getReadEncoding().equals(Ice.Util.Encoding_1_0))
+ {
+ _protocol.__read(s);
+ _encoding.__read(s);
+ }
+ else
+ {
+ _protocol = Ice.Util.Protocol_1_0;
+ _encoding = Ice.Util.Encoding_1_0;
+ }
s.endReadEncaps();
calcHashValue();
}
@@ -190,6 +202,11 @@ final class EndpointI extends IceInternal.EndpointI
s.writeInt(_port);
s.writeInt(_timeout);
s.writeBool(_compress);
+ if(!s.getWriteEncoding().equals(Ice.Util.Encoding_1_0))
+ {
+ _protocol.__write(s);
+ _encoding.__write(s);
+ }
s.endWriteEncaps();
}
@@ -208,6 +225,16 @@ final class EndpointI extends IceInternal.EndpointI
//
String s = "ssl";
+ if(!_protocol.equals(Ice.Util.Protocol_1_0))
+ {
+ s += " -v " + Ice.Util.protocolVersionToString(_protocol);
+ }
+
+ if(!_encoding.equals(Ice.Util.Encoding_1_0))
+ {
+ s += " -e " + Ice.Util.encodingVersionToString(_encoding);
+ }
+
if(_host != null && _host.length() > 0)
{
s += " -h ";
@@ -242,7 +269,7 @@ final class EndpointI extends IceInternal.EndpointI
public Ice.EndpointInfo
getInfo()
{
- return new IceSSL.EndpointInfo(_timeout, _compress, _host, _port)
+ return new IceSSL.EndpointInfo(_protocol, _encoding, _timeout, _compress, _host, _port)
{
public short type()
{
@@ -294,7 +321,7 @@ final class EndpointI extends IceInternal.EndpointI
}
else
{
- return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress);
+ return new EndpointI(_instance, _host, _port, timeout, _protocol, _encoding, _connectionId, _compress);
}
}
@@ -310,7 +337,7 @@ final class EndpointI extends IceInternal.EndpointI
}
else
{
- return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress);
+ return new EndpointI(_instance, _host, _port, _timeout, _protocol, _encoding, connectionId, _compress);
}
}
@@ -338,7 +365,7 @@ final class EndpointI extends IceInternal.EndpointI
}
else
{
- return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress);
+ return new EndpointI(_instance, _host, _port, _timeout, _protocol, _encoding, _connectionId, compress);
}
}
@@ -401,8 +428,8 @@ final class EndpointI extends IceInternal.EndpointI
acceptor(IceInternal.EndpointIHolder endpoint, String adapterName)
{
AcceptorI p = new AcceptorI(_instance, adapterName, _host, _port);
- endpoint.value =
- new EndpointI(_instance, _host, p.effectivePort(), _timeout, _connectionId, _compress);
+ endpoint.value = new EndpointI(_instance, _host, p.effectivePort(), _timeout, _protocol, _encoding,
+ _connectionId, _compress);
return p;
}
@@ -424,7 +451,8 @@ final class EndpointI extends IceInternal.EndpointI
{
for(String host : hosts)
{
- endps.add(new EndpointI(_instance, host, _port, _timeout, _connectionId, _compress));
+ endps.add(new EndpointI(_instance, host, _port, _timeout, _protocol, _encoding, _connectionId,
+ _compress));
}
}
return endps;
@@ -436,15 +464,11 @@ final class EndpointI extends IceInternal.EndpointI
public boolean
equivalent(IceInternal.EndpointI endpoint)
{
- EndpointI sslEndpointI = null;
- try
- {
- sslEndpointI = (EndpointI)endpoint;
- }
- catch(ClassCastException ex)
+ if(!(endpoint instanceof EndpointI))
{
return false;
}
+ EndpointI sslEndpointI = (EndpointI)endpoint;
return sslEndpointI._host.equals(_host) && sslEndpointI._port == _port;
}
@@ -457,38 +481,27 @@ final class EndpointI extends IceInternal.EndpointI
//
// Compare endpoints for sorting purposes
//
- public boolean
- equals(java.lang.Object obj)
- {
- try
- {
- return compareTo((IceInternal.EndpointI)obj) == 0;
- }
- catch(ClassCastException ee)
- {
- assert(false);
- return false;
- }
- }
-
public int
compareTo(IceInternal.EndpointI obj) // From java.lang.Comparable
{
- EndpointI p = null;
-
- try
- {
- p = (EndpointI)obj;
- }
- catch(ClassCastException ex)
+ if(!(obj instanceof EndpointI))
{
return type() < obj.type() ? -1 : 1;
}
+ EndpointI p = (EndpointI)obj;
if(this == p)
{
return 0;
}
+ else
+ {
+ int r = super.compareTo(p);
+ if(r != 0)
+ {
+ return r;
+ }
+ }
if(_port < p._port)
{
@@ -531,7 +544,7 @@ final class EndpointI extends IceInternal.EndpointI
java.util.List<IceInternal.Connector> connectors = new java.util.ArrayList<IceInternal.Connector>();
for(java.net.InetSocketAddress p : addresses)
{
- connectors.add(new ConnectorI(_instance, _host, p, _timeout, _connectionId));
+ connectors.add(new ConnectorI(_instance, _host, p, _timeout, _protocol, _encoding, _connectionId));
}
return connectors;
}
@@ -542,6 +555,8 @@ final class EndpointI extends IceInternal.EndpointI
_hashCode = _host.hashCode();
_hashCode = 5 * _hashCode + _port;
_hashCode = 5 * _hashCode + _timeout;
+ _hashCode = 5 * _hashCode + _protocol.hashCode();
+ _hashCode = 5 * _hashCode + _encoding.hashCode();
_hashCode = 5 * _hashCode + _connectionId.hashCode();
_hashCode = 5 * _hashCode + (_compress ? 1 : 0);
}