summaryrefslogtreecommitdiff
path: root/java/src/IceInternal
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/IceInternal')
-rw-r--r--java/src/IceInternal/BasicStream.java1870
-rw-r--r--java/src/IceInternal/ConnectionMonitor.java214
-rw-r--r--java/src/IceInternal/DefaultsAndOverrides.java134
-rw-r--r--java/src/IceInternal/Direct.java112
-rw-r--r--java/src/IceInternal/DirectReference.java244
-rw-r--r--java/src/IceInternal/DispatchStatus.java6
-rw-r--r--java/src/IceInternal/EndpointFactoryManager.java8
-rw-r--r--java/src/IceInternal/EndpointI.java2
-rw-r--r--java/src/IceInternal/FixedReference.java152
-rw-r--r--java/src/IceInternal/Incoming.java276
-rw-r--r--java/src/IceInternal/IncomingAsync.java116
-rw-r--r--java/src/IceInternal/IncomingBase.java402
-rw-r--r--java/src/IceInternal/IncomingConnectionFactory.java1014
-rw-r--r--java/src/IceInternal/IndirectReference.java314
-rw-r--r--java/src/IceInternal/Instance.java698
-rw-r--r--java/src/IceInternal/LocalExceptionWrapper.java4
-rw-r--r--java/src/IceInternal/LocatorInfo.java540
-rw-r--r--java/src/IceInternal/LocatorManager.java40
-rw-r--r--java/src/IceInternal/LocatorTable.java102
-rw-r--r--java/src/IceInternal/Network.java628
-rw-r--r--java/src/IceInternal/ObjectAdapterFactory.java290
-rw-r--r--java/src/IceInternal/ObjectFactoryManager.java54
-rw-r--r--java/src/IceInternal/Outgoing.java584
-rw-r--r--java/src/IceInternal/OutgoingAsync.java546
-rw-r--r--java/src/IceInternal/OutgoingConnectionFactory.java906
-rw-r--r--java/src/IceInternal/Protocol.java26
-rw-r--r--java/src/IceInternal/ProtocolPluginFacadeI.java14
-rw-r--r--java/src/IceInternal/ProxyFactory.java140
-rw-r--r--java/src/IceInternal/Reference.java150
-rw-r--r--java/src/IceInternal/ReferenceFactory.java492
-rw-r--r--java/src/IceInternal/RoutableReference.java542
-rw-r--r--java/src/IceInternal/RouterInfo.java120
-rw-r--r--java/src/IceInternal/RouterManager.java24
-rw-r--r--java/src/IceInternal/ServantManager.java170
-rw-r--r--java/src/IceInternal/TcpAcceptor.java210
-rw-r--r--java/src/IceInternal/TcpConnector.java2
-rw-r--r--java/src/IceInternal/TcpEndpointI.java212
-rw-r--r--java/src/IceInternal/TcpTransceiver.java428
-rw-r--r--java/src/IceInternal/ThreadPool.java1528
-rw-r--r--java/src/IceInternal/TraceLevels.java10
-rw-r--r--java/src/IceInternal/TraceUtil.java224
-rw-r--r--java/src/IceInternal/Transceiver.java4
-rw-r--r--java/src/IceInternal/UdpEndpointI.java470
-rw-r--r--java/src/IceInternal/UdpTransceiver.java490
-rw-r--r--java/src/IceInternal/UnknownEndpointI.java4
-rw-r--r--java/src/IceInternal/ValueWriter.java32
46 files changed, 7274 insertions, 7274 deletions
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java
index da2ac8453a7..a581f75d590 100644
--- a/java/src/IceInternal/BasicStream.java
+++ b/java/src/IceInternal/BasicStream.java
@@ -27,8 +27,8 @@ public class BasicStream
initialize(IceInternal.Instance instance, boolean unlimited)
{
_instance = instance;
- _unlimited = unlimited;
- allocate(1500);
+ _unlimited = unlimited;
+ allocate(1500);
_capacity = _buf.capacity();
_limit = 0;
assert(_buf.limit() == _capacity);
@@ -37,14 +37,14 @@ public class BasicStream
_writeEncapsStack = null;
_readEncapsCache = null;
_writeEncapsCache = null;
-
- _traceSlicing = -1;
+
+ _traceSlicing = -1;
_sliceObjects = true;
- _messageSizeMax = _instance.messageSizeMax(); // Cached for efficiency.
+ _messageSizeMax = _instance.messageSizeMax(); // Cached for efficiency.
- _seqDataStack = null;
+ _seqDataStack = null;
_objectList = null;
}
@@ -65,7 +65,7 @@ public class BasicStream
_readEncapsStack.next = _readEncapsCache;
_readEncapsCache = _readEncapsStack;
_readEncapsStack = null;
- _readEncapsCache.reset();
+ _readEncapsCache.reset();
}
if(_objectList != null)
@@ -113,17 +113,17 @@ public class BasicStream
other._writeEncapsCache = _writeEncapsCache;
_writeEncapsCache = tmpWrite;
- int tmpReadSlice = other._readSlice;
- other._readSlice = _readSlice;
- _readSlice = tmpReadSlice;
+ int tmpReadSlice = other._readSlice;
+ other._readSlice = _readSlice;
+ _readSlice = tmpReadSlice;
- int tmpWriteSlice = other._writeSlice;
- other._writeSlice = _writeSlice;
- _writeSlice = tmpWriteSlice;
+ int tmpWriteSlice = other._writeSlice;
+ other._writeSlice = _writeSlice;
+ _writeSlice = tmpWriteSlice;
- SeqData tmpSeqDataStack = other._seqDataStack;
- other._seqDataStack = _seqDataStack;
- _seqDataStack = tmpSeqDataStack;
+ SeqData tmpSeqDataStack = other._seqDataStack;
+ other._seqDataStack = _seqDataStack;
+ _seqDataStack = tmpSeqDataStack;
java.util.ArrayList tmpObjectList = other._objectList;
other._objectList = _objectList;
@@ -230,33 +230,33 @@ public class BasicStream
public void
startSeq(int numElements, int minSize)
{
- if(numElements == 0) // Optimization to avoid pushing a useless stack frame.
- {
- return;
- }
-
- //
- // Push the current sequence details on the stack.
- //
- SeqData sd = new SeqData(numElements, minSize);
- sd.previous = _seqDataStack;
- _seqDataStack = sd;
-
- int bytesLeft = _buf.remaining();
- if(_seqDataStack.previous == null) // Outermost sequence
- {
- //
- // The sequence must fit within the message.
- //
- if(numElements * minSize > bytesLeft)
- {
- throw new Ice.UnmarshalOutOfBoundsException();
- }
- }
- else // Nested sequence
- {
- checkSeq(bytesLeft);
- }
+ if(numElements == 0) // Optimization to avoid pushing a useless stack frame.
+ {
+ return;
+ }
+
+ //
+ // Push the current sequence details on the stack.
+ //
+ SeqData sd = new SeqData(numElements, minSize);
+ sd.previous = _seqDataStack;
+ _seqDataStack = sd;
+
+ int bytesLeft = _buf.remaining();
+ if(_seqDataStack.previous == null) // Outermost sequence
+ {
+ //
+ // The sequence must fit within the message.
+ //
+ if(numElements * minSize > bytesLeft)
+ {
+ throw new Ice.UnmarshalOutOfBoundsException();
+ }
+ }
+ else // Nested sequence
+ {
+ checkSeq(bytesLeft);
+ }
}
//
@@ -268,97 +268,97 @@ public class BasicStream
public void
checkSeq()
{
- checkSeq(_buf.remaining());
+ checkSeq(_buf.remaining());
}
public void
checkSeq(int bytesLeft)
{
- int size = 0;
- SeqData sd = _seqDataStack;
- do
- {
- size += (sd.numElements - 1) * sd.minSize;
- sd = sd.previous;
- }
- while(sd != null);
+ int size = 0;
+ SeqData sd = _seqDataStack;
+ do
+ {
+ size += (sd.numElements - 1) * sd.minSize;
+ sd = sd.previous;
+ }
+ while(sd != null);
- if(size > bytesLeft)
- {
- throw new Ice.UnmarshalOutOfBoundsException();
- }
+ if(size > bytesLeft)
+ {
+ throw new Ice.UnmarshalOutOfBoundsException();
+ }
}
public void
checkFixedSeq(int numElements, int elemSize)
{
- int bytesLeft = _buf.remaining();
- if(_seqDataStack == null) // Outermost sequence
- {
- //
- // The sequence must fit within the message.
- //
- if(numElements * elemSize > bytesLeft)
- {
- throw new Ice.UnmarshalOutOfBoundsException();
- }
- }
- else // Nested sequence
- {
- checkSeq(bytesLeft - numElements * elemSize);
- }
+ int bytesLeft = _buf.remaining();
+ if(_seqDataStack == null) // Outermost sequence
+ {
+ //
+ // The sequence must fit within the message.
+ //
+ if(numElements * elemSize > bytesLeft)
+ {
+ throw new Ice.UnmarshalOutOfBoundsException();
+ }
+ }
+ else // Nested sequence
+ {
+ checkSeq(bytesLeft - numElements * elemSize);
+ }
}
public void
endSeq(int sz)
{
- if(sz == 0) // Pop only if something was pushed previously.
- {
- return;
- }
+ if(sz == 0) // Pop only if something was pushed previously.
+ {
+ return;
+ }
- //
- // Pop the sequence stack.
- //
- SeqData oldSeqData = _seqDataStack;
- assert(oldSeqData != null);
- _seqDataStack = oldSeqData.previous;
+ //
+ // Pop the sequence stack.
+ //
+ SeqData oldSeqData = _seqDataStack;
+ assert(oldSeqData != null);
+ _seqDataStack = oldSeqData.previous;
}
public void
endElement()
{
assert(_seqDataStack != null);
- --_seqDataStack.numElements;
+ --_seqDataStack.numElements;
}
final private static byte[] _encapsBlob =
{
- 0, 0, 0, 0, // Placeholder for the encapsulation length.
- Protocol.encodingMajor,
- Protocol.encodingMinor
+ 0, 0, 0, 0, // Placeholder for the encapsulation length.
+ Protocol.encodingMajor,
+ Protocol.encodingMinor
};
public void
startWriteEncaps()
{
- {
- WriteEncaps curr = _writeEncapsCache;
- if(curr != null)
- {
- curr.reset();
- _writeEncapsCache = _writeEncapsCache.next;
- }
- else
- {
- curr = new WriteEncaps();
- }
- curr.next = _writeEncapsStack;
- _writeEncapsStack = curr;
- }
+ {
+ WriteEncaps curr = _writeEncapsCache;
+ if(curr != null)
+ {
+ curr.reset();
+ _writeEncapsCache = _writeEncapsCache.next;
+ }
+ else
+ {
+ curr = new WriteEncaps();
+ }
+ curr.next = _writeEncapsStack;
+ _writeEncapsStack = curr;
+ }
_writeEncapsStack.start = _buf.position();
- writeBlob(_encapsBlob);
+ writeBlob(_encapsBlob);
}
public void
@@ -367,65 +367,65 @@ public class BasicStream
assert(_writeEncapsStack != null);
int start = _writeEncapsStack.start;
int sz = _buf.position() - start; // Size includes size and version.
- _buf.putInt(start, sz);
+ _buf.putInt(start, sz);
- WriteEncaps curr = _writeEncapsStack;
- _writeEncapsStack = curr.next;
- curr.next = _writeEncapsCache;
- _writeEncapsCache = curr;
- _writeEncapsCache.reset();
+ WriteEncaps curr = _writeEncapsStack;
+ _writeEncapsStack = curr.next;
+ curr.next = _writeEncapsCache;
+ _writeEncapsCache = curr;
+ _writeEncapsCache.reset();
}
public void
startReadEncaps()
{
- {
- ReadEncaps curr = _readEncapsCache;
- if(curr != null)
- {
- curr.reset();
- _readEncapsCache = _readEncapsCache.next;
- }
- else
- {
- curr = new ReadEncaps();
- }
- curr.next = _readEncapsStack;
- _readEncapsStack = curr;
- }
+ {
+ ReadEncaps curr = _readEncapsCache;
+ if(curr != null)
+ {
+ curr.reset();
+ _readEncapsCache = _readEncapsCache.next;
+ }
+ else
+ {
+ curr = new ReadEncaps();
+ }
+ curr.next = _readEncapsStack;
+ _readEncapsStack = curr;
+ }
_readEncapsStack.start = _buf.position();
-
- //
- // I don't use readSize() and writeSize() for encapsulations,
- // because when creating an encapsulation, I must know in
- // advance how many bytes the size information will require in
- // the data stream. If I use an Int, it is always 4 bytes. For
- // readSize()/writeSize(), it could be 1 or 5 bytes.
- //
+
+ //
+ // I don't use readSize() and writeSize() for encapsulations,
+ // because when creating an encapsulation, I must know in
+ // advance how many bytes the size information will require in
+ // the data stream. If I use an Int, it is always 4 bytes. For
+ // readSize()/writeSize(), it could be 1 or 5 bytes.
+ //
int sz = readInt();
- if(sz < 0)
- {
- throw new Ice.NegativeSizeException();
- }
+ if(sz < 0)
+ {
+ throw new Ice.NegativeSizeException();
+ }
- if(sz - 4 > _buf.limit())
- {
- throw new Ice.UnmarshalOutOfBoundsException();
- }
- _readEncapsStack.sz = sz;
+ if(sz - 4 > _buf.limit())
+ {
+ throw new Ice.UnmarshalOutOfBoundsException();
+ }
+ _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;
- }
+ 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;
_readEncapsStack.encodingMinor = eMinor;
}
@@ -433,7 +433,7 @@ public class BasicStream
public void
endReadEncaps()
{
- assert(_readEncapsStack != null);
+ assert(_readEncapsStack != null);
int start = _readEncapsStack.start;
int sz = _readEncapsStack.sz;
try
@@ -445,17 +445,17 @@ public class BasicStream
throw new Ice.UnmarshalOutOfBoundsException();
}
- ReadEncaps curr = _readEncapsStack;
- _readEncapsStack = curr.next;
- curr.next = _readEncapsCache;
- _readEncapsCache = curr;
- _readEncapsCache.reset();
+ ReadEncaps curr = _readEncapsStack;
+ _readEncapsStack = curr.next;
+ curr.next = _readEncapsCache;
+ _readEncapsCache = curr;
+ _readEncapsCache.reset();
}
public void
checkReadEncaps()
{
- assert(_readEncapsStack != null);
+ assert(_readEncapsStack != null);
int start = _readEncapsStack.start;
int sz = _readEncapsStack.sz;
if(_buf.position() != start + sz)
@@ -468,17 +468,17 @@ public class BasicStream
getReadEncapsSize()
{
assert(_readEncapsStack != null);
- return _readEncapsStack.sz - 6;
+ return _readEncapsStack.sz - 6;
}
public void
skipEncaps()
{
int sz = readInt();
- if(sz < 0)
- {
- throw new Ice.NegativeSizeException();
- }
+ if(sz < 0)
+ {
+ throw new Ice.NegativeSizeException();
+ }
try
{
_buf.position(_buf.position() + sz - 4);
@@ -505,10 +505,10 @@ public class BasicStream
public void startReadSlice()
{
int sz = readInt();
- if(sz < 0)
- {
- throw new Ice.NegativeSizeException();
- }
+ if(sz < 0)
+ {
+ throw new Ice.NegativeSizeException();
+ }
_readSlice = _buf.position();
}
@@ -519,10 +519,10 @@ public class BasicStream
public void skipSlice()
{
int sz = readInt();
- if(sz < 0)
- {
- throw new Ice.NegativeSizeException();
- }
+ if(sz < 0)
+ {
+ throw new Ice.NegativeSizeException();
+ }
try
{
_buf.position(_buf.position() + sz - 4);
@@ -536,17 +536,17 @@ public class BasicStream
public void
writeSize(int v)
{
- if(v > 254)
- {
- expand(5);
- _buf.put((byte)-1);
- _buf.putInt(v);
- }
- else
- {
- expand(1);
- _buf.put((byte)v);
- }
+ if(v > 254)
+ {
+ expand(5);
+ _buf.put((byte)-1);
+ _buf.putInt(v);
+ }
+ else
+ {
+ expand(1);
+ _buf.put((byte)v);
+ }
}
public int
@@ -554,20 +554,20 @@ public class BasicStream
{
try
{
- byte b = _buf.get();
- if(b == -1)
- {
- int v = _buf.getInt();
- if(v < 0)
- {
- throw new Ice.NegativeSizeException();
- }
- return v;
- }
- else
- {
- return (int)(b < 0 ? b + 256 : b);
- }
+ byte b = _buf.get();
+ if(b == -1)
+ {
+ int v = _buf.getInt();
+ if(v < 0)
+ {
+ throw new Ice.NegativeSizeException();
+ }
+ return v;
+ }
+ else
+ {
+ return (int)(b < 0 ? b + 256 : b);
+ }
}
catch(java.nio.BufferUnderflowException ex)
{
@@ -578,43 +578,43 @@ public class BasicStream
public void
writeTypeId(String id)
{
- Integer index = (Integer)_writeEncapsStack.typeIdMap.get(id);
- if(index != null)
- {
- writeBool(true);
- writeSize(index.intValue());
- }
- else
- {
- index = new Integer(++_writeEncapsStack.typeIdIndex);
- _writeEncapsStack.typeIdMap.put(id, index);
- writeBool(false);
- writeString(id);
- }
+ Integer index = (Integer)_writeEncapsStack.typeIdMap.get(id);
+ if(index != null)
+ {
+ writeBool(true);
+ writeSize(index.intValue());
+ }
+ else
+ {
+ index = new Integer(++_writeEncapsStack.typeIdIndex);
+ _writeEncapsStack.typeIdMap.put(id, index);
+ writeBool(false);
+ writeString(id);
+ }
}
public String
readTypeId()
{
- String id;
- Integer index;
+ String id;
+ Integer index;
final boolean isIndex = readBool();
- if(isIndex)
- {
- index = new Integer(readSize());
- id = (String)_readEncapsStack.typeIdMap.get(index);
- if(id == null)
- {
- throw new Ice.UnmarshalOutOfBoundsException();
- }
- }
- else
- {
- id = readString();
- index = new Integer(++_readEncapsStack.typeIdIndex);
- _readEncapsStack.typeIdMap.put(index, id);
- }
- return id;
+ if(isIndex)
+ {
+ index = new Integer(readSize());
+ id = (String)_readEncapsStack.typeIdMap.get(index);
+ if(id == null)
+ {
+ throw new Ice.UnmarshalOutOfBoundsException();
+ }
+ }
+ else
+ {
+ id = readString();
+ index = new Integer(++_readEncapsStack.typeIdIndex);
+ _readEncapsStack.typeIdMap.put(index, id);
+ }
+ return id;
}
public void
@@ -656,16 +656,16 @@ public class BasicStream
public void
writeByteSeq(byte[] v)
{
- if(v == null)
- {
- writeSize(0);
- }
- else
- {
- writeSize(v.length);
- expand(v.length);
- _buf.put(v);
- }
+ if(v == null)
+ {
+ writeSize(0);
+ }
+ else
+ {
+ writeSize(v.length);
+ expand(v.length);
+ _buf.put(v);
+ }
}
public byte
@@ -687,7 +687,7 @@ public class BasicStream
try
{
final int sz = readSize();
- checkFixedSeq(sz, 1);
+ checkFixedSeq(sz, 1);
byte[] v = new byte[sz];
_buf.get(v);
return v;
@@ -708,19 +708,19 @@ public class BasicStream
public void
writeBoolSeq(boolean[] v)
{
- if(v == null)
- {
- writeSize(0);
- }
- else
- {
- writeSize(v.length);
- expand(v.length);
- for(int i = 0; i < v.length; i++)
- {
- _buf.put(v[i] ? (byte)1 : (byte)0);
- }
- }
+ if(v == null)
+ {
+ writeSize(0);
+ }
+ else
+ {
+ writeSize(v.length);
+ expand(v.length);
+ for(int i = 0; i < v.length; i++)
+ {
+ _buf.put(v[i] ? (byte)1 : (byte)0);
+ }
+ }
}
public boolean
@@ -742,7 +742,7 @@ public class BasicStream
try
{
final int sz = readSize();
- checkFixedSeq(sz, 1);
+ checkFixedSeq(sz, 1);
boolean[] v = new boolean[sz];
for(int i = 0; i < sz; i++)
{
@@ -766,18 +766,18 @@ public class BasicStream
public void
writeShortSeq(short[] v)
{
- if(v == null)
- {
- writeSize(0);
- }
- else
- {
- writeSize(v.length);
- expand(v.length * 2);
- java.nio.ShortBuffer shortBuf = _buf.asShortBuffer();
- shortBuf.put(v);
- _buf.position(_buf.position() + v.length * 2);
- }
+ if(v == null)
+ {
+ writeSize(0);
+ }
+ else
+ {
+ writeSize(v.length);
+ expand(v.length * 2);
+ java.nio.ShortBuffer shortBuf = _buf.asShortBuffer();
+ shortBuf.put(v);
+ _buf.position(_buf.position() + v.length * 2);
+ }
}
public short
@@ -799,7 +799,7 @@ public class BasicStream
try
{
final int sz = readSize();
- checkFixedSeq(sz, 2);
+ checkFixedSeq(sz, 2);
short[] v = new short[sz];
java.nio.ShortBuffer shortBuf = _buf.asShortBuffer();
shortBuf.get(v);
@@ -822,18 +822,18 @@ public class BasicStream
public void
writeIntSeq(int[] v)
{
- if(v == null)
- {
- writeSize(0);
- }
- else
- {
- writeSize(v.length);
- expand(v.length * 4);
- java.nio.IntBuffer intBuf = _buf.asIntBuffer();
- intBuf.put(v);
- _buf.position(_buf.position() + v.length * 4);
- }
+ if(v == null)
+ {
+ writeSize(0);
+ }
+ else
+ {
+ writeSize(v.length);
+ expand(v.length * 4);
+ java.nio.IntBuffer intBuf = _buf.asIntBuffer();
+ intBuf.put(v);
+ _buf.position(_buf.position() + v.length * 4);
+ }
}
public int
@@ -855,7 +855,7 @@ public class BasicStream
try
{
final int sz = readSize();
- checkFixedSeq(sz, 4);
+ checkFixedSeq(sz, 4);
int[] v = new int[sz];
java.nio.IntBuffer intBuf = _buf.asIntBuffer();
intBuf.get(v);
@@ -878,18 +878,18 @@ public class BasicStream
public void
writeLongSeq(long[] v)
{
- if(v == null)
- {
- writeSize(0);
- }
- else
- {
- writeSize(v.length);
- expand(v.length * 8);
- java.nio.LongBuffer longBuf = _buf.asLongBuffer();
- longBuf.put(v);
- _buf.position(_buf.position() + v.length * 8);
- }
+ if(v == null)
+ {
+ writeSize(0);
+ }
+ else
+ {
+ writeSize(v.length);
+ expand(v.length * 8);
+ java.nio.LongBuffer longBuf = _buf.asLongBuffer();
+ longBuf.put(v);
+ _buf.position(_buf.position() + v.length * 8);
+ }
}
public long
@@ -911,7 +911,7 @@ public class BasicStream
try
{
final int sz = readSize();
- checkFixedSeq(sz, 8);
+ checkFixedSeq(sz, 8);
long[] v = new long[sz];
java.nio.LongBuffer longBuf = _buf.asLongBuffer();
longBuf.get(v);
@@ -934,18 +934,18 @@ public class BasicStream
public void
writeFloatSeq(float[] v)
{
- if(v == null)
- {
- writeSize(0);
- }
- else
- {
- writeSize(v.length);
- expand(v.length * 4);
- java.nio.FloatBuffer floatBuf = _buf.asFloatBuffer();
- floatBuf.put(v);
- _buf.position(_buf.position() + v.length * 4);
- }
+ if(v == null)
+ {
+ writeSize(0);
+ }
+ else
+ {
+ writeSize(v.length);
+ expand(v.length * 4);
+ java.nio.FloatBuffer floatBuf = _buf.asFloatBuffer();
+ floatBuf.put(v);
+ _buf.position(_buf.position() + v.length * 4);
+ }
}
public float
@@ -967,7 +967,7 @@ public class BasicStream
try
{
final int sz = readSize();
- checkFixedSeq(sz, 4);
+ checkFixedSeq(sz, 4);
float[] v = new float[sz];
java.nio.FloatBuffer floatBuf = _buf.asFloatBuffer();
floatBuf.get(v);
@@ -990,18 +990,18 @@ public class BasicStream
public void
writeDoubleSeq(double[] v)
{
- if(v == null)
- {
- writeSize(0);
- }
- else
- {
- writeSize(v.length);
- expand(v.length * 8);
- java.nio.DoubleBuffer doubleBuf = _buf.asDoubleBuffer();
- doubleBuf.put(v);
- _buf.position(_buf.position() + v.length * 8);
- }
+ if(v == null)
+ {
+ writeSize(0);
+ }
+ else
+ {
+ writeSize(v.length);
+ expand(v.length * 8);
+ java.nio.DoubleBuffer doubleBuf = _buf.asDoubleBuffer();
+ doubleBuf.put(v);
+ _buf.position(_buf.position() + v.length * 8);
+ }
}
public double
@@ -1023,7 +1023,7 @@ public class BasicStream
try
{
final int sz = readSize();
- checkFixedSeq(sz, 8);
+ checkFixedSeq(sz, 8);
double[] v = new double[sz];
java.nio.DoubleBuffer doubleBuf = _buf.asDoubleBuffer();
doubleBuf.get(v);
@@ -1051,51 +1051,51 @@ public class BasicStream
final int len = v.length();
if(len > 0)
{
- if(_stringBytes == null || len > _stringBytes.length)
- {
- _stringBytes = new byte[len];
- }
- if(_stringChars == null || len > _stringChars.length)
- {
- _stringChars = new char[len];
- }
- //
- // If the string contains only 7-bit characters, it's more efficient
- // to perform the conversion to UTF-8 manually.
- //
- v.getChars(0, len, _stringChars, 0);
- for(int i = 0; i < len; ++i)
- {
- if(_stringChars[i] > (char)127)
- {
- //
- // Found a multibyte character.
- //
- if(_charEncoder == null)
- {
- _charEncoder = _utf8.newEncoder();
- }
- java.nio.ByteBuffer b = null;
- try
- {
- b = _charEncoder.encode(java.nio.CharBuffer.wrap(_stringChars, 0, len));
- }
- catch(java.nio.charset.CharacterCodingException ex)
- {
- Ice.MarshalException e = new Ice.MarshalException();
- e.initCause(ex);
- throw e;
- }
- writeSize(b.limit());
- expand(b.limit());
- _buf.put(b);
- return;
- }
- _stringBytes[i] = (byte)_stringChars[i];
- }
- writeSize(len);
- expand(len);
- _buf.put(_stringBytes, 0, len);
+ if(_stringBytes == null || len > _stringBytes.length)
+ {
+ _stringBytes = new byte[len];
+ }
+ if(_stringChars == null || len > _stringChars.length)
+ {
+ _stringChars = new char[len];
+ }
+ //
+ // If the string contains only 7-bit characters, it's more efficient
+ // to perform the conversion to UTF-8 manually.
+ //
+ v.getChars(0, len, _stringChars, 0);
+ for(int i = 0; i < len; ++i)
+ {
+ if(_stringChars[i] > (char)127)
+ {
+ //
+ // Found a multibyte character.
+ //
+ if(_charEncoder == null)
+ {
+ _charEncoder = _utf8.newEncoder();
+ }
+ java.nio.ByteBuffer b = null;
+ try
+ {
+ b = _charEncoder.encode(java.nio.CharBuffer.wrap(_stringChars, 0, len));
+ }
+ catch(java.nio.charset.CharacterCodingException ex)
+ {
+ Ice.MarshalException e = new Ice.MarshalException();
+ e.initCause(ex);
+ throw e;
+ }
+ writeSize(b.limit());
+ expand(b.limit());
+ _buf.put(b);
+ return;
+ }
+ _stringBytes[i] = (byte)_stringChars[i];
+ }
+ writeSize(len);
+ expand(len);
+ _buf.put(_stringBytes, 0, len);
}
else
{
@@ -1107,18 +1107,18 @@ public class BasicStream
public void
writeStringSeq(String[] v)
{
- if(v == null)
- {
- writeSize(0);
- }
- else
- {
- writeSize(v.length);
- for(int i = 0; i < v.length; i++)
- {
- writeString(v[i]);
- }
- }
+ if(v == null)
+ {
+ writeSize(0);
+ }
+ else
+ {
+ writeSize(v.length);
+ for(int i = 0; i < v.length; i++)
+ {
+ writeString(v[i]);
+ }
+ }
}
public String
@@ -1161,15 +1161,15 @@ public class BasicStream
// Multi-byte character found - we must use
// conversion.
//
- // TODO: If the string contains garbage bytes
- // that won't correctly decode as UTF, the
- // behavior of this constructor is
- // undefined. It would be better to explicitly
- // decode using
- // java.nio.charset.CharsetDecoder and to
- // throw MarshalException if the string won't
- // decode.
- //
+ // TODO: If the string contains garbage bytes
+ // that won't correctly decode as UTF, the
+ // behavior of this constructor is
+ // undefined. It would be better to explicitly
+ // decode using
+ // java.nio.charset.CharsetDecoder and to
+ // throw MarshalException if the string won't
+ // decode.
+ //
return new String(_stringBytes, 0, len, "UTF8");
}
else
@@ -1195,15 +1195,15 @@ public class BasicStream
readStringSeq()
{
final int sz = readSize();
- startSeq(sz, 1);
+ startSeq(sz, 1);
String[] v = new String[sz];
for(int i = 0; i < sz; i++)
{
v[i] = readString();
- checkSeq();
- endElement();
+ checkSeq();
+ endElement();
}
- endSeq(sz);
+ endSeq(sz);
return v;
}
@@ -1235,42 +1235,42 @@ public class BasicStream
}
}
- if(_writeEncapsStack.toBeMarshaledMap == null) // Lazy initialization
- {
- _writeEncapsStack.toBeMarshaledMap = new java.util.IdentityHashMap();
- _writeEncapsStack.marshaledMap = new java.util.IdentityHashMap();
- _writeEncapsStack.typeIdMap = new java.util.TreeMap();
- }
- if(v != null)
- {
- //
- // Look for this instance in the to-be-marshaled map.
- //
- Integer p = (Integer)_writeEncapsStack.toBeMarshaledMap.get(v);
- if(p == null)
- {
- //
- // Didn't find it, try the marshaled map next.
- //
- Integer q = (Integer)_writeEncapsStack.marshaledMap.get(v);
- if(q == null)
- {
- //
- // We haven't seen this instance previously,
- // create a new index, and insert it into the
- // to-be-marshaled map.
- //
- q = new Integer(++_writeEncapsStack.writeIndex);
- _writeEncapsStack.toBeMarshaledMap.put(v, q);
- }
- p = q;
- }
- writeInt(-p.intValue());
- }
- else
- {
- writeInt(0); // Write null reference
- }
+ if(_writeEncapsStack.toBeMarshaledMap == null) // Lazy initialization
+ {
+ _writeEncapsStack.toBeMarshaledMap = new java.util.IdentityHashMap();
+ _writeEncapsStack.marshaledMap = new java.util.IdentityHashMap();
+ _writeEncapsStack.typeIdMap = new java.util.TreeMap();
+ }
+ if(v != null)
+ {
+ //
+ // Look for this instance in the to-be-marshaled map.
+ //
+ Integer p = (Integer)_writeEncapsStack.toBeMarshaledMap.get(v);
+ if(p == null)
+ {
+ //
+ // Didn't find it, try the marshaled map next.
+ //
+ Integer q = (Integer)_writeEncapsStack.marshaledMap.get(v);
+ if(q == null)
+ {
+ //
+ // We haven't seen this instance previously,
+ // create a new index, and insert it into the
+ // to-be-marshaled map.
+ //
+ q = new Integer(++_writeEncapsStack.writeIndex);
+ _writeEncapsStack.toBeMarshaledMap.put(v, q);
+ }
+ p = q;
+ }
+ writeInt(-p.intValue());
+ }
+ else
+ {
+ writeInt(0); // Write null reference
+ }
}
public void
@@ -1291,58 +1291,58 @@ public class BasicStream
}
}
- if(_readEncapsStack.patchMap == null) // Lazy initialization
- {
- _readEncapsStack.patchMap = new java.util.TreeMap();
- _readEncapsStack.unmarshaledMap = new java.util.TreeMap();
- _readEncapsStack.typeIdMap = new java.util.TreeMap();
- }
-
- int index = readInt();
-
- if(index == 0)
- {
- patcher.patch(null);
- return;
- }
-
- if(index < 0 && patcher != null)
- {
- Integer i = new Integer(-index);
- java.util.LinkedList patchlist = (java.util.LinkedList)_readEncapsStack.patchMap.get(i);
- if(patchlist == null)
- {
- //
- // We have no outstanding instances to be patched for
- // this index, so make a new entry in the patch map.
- //
- patchlist = new java.util.LinkedList();
- _readEncapsStack.patchMap.put(i, patchlist);
- }
- //
- // Append a patcher for this instance and see if we can
- // patch the instance. (The instance may have been
- // unmarshaled previously.)
- //
- patchlist.add(patcher);
- patchReferences(null, i);
- return;
- }
-
- String mostDerivedId = readTypeId();
- String id = new String(mostDerivedId);
-
- while(true)
- {
- //
- // If we slice all the way down to Ice::Object, we throw
- // because Ice::Object is abstract.
- //
- if(id.equals(Ice.ObjectImpl.ice_staticId()))
- {
- throw new Ice.NoObjectFactoryException("class sliced to Ice.Object, which is abstract",
- mostDerivedId);
- }
+ if(_readEncapsStack.patchMap == null) // Lazy initialization
+ {
+ _readEncapsStack.patchMap = new java.util.TreeMap();
+ _readEncapsStack.unmarshaledMap = new java.util.TreeMap();
+ _readEncapsStack.typeIdMap = new java.util.TreeMap();
+ }
+
+ int index = readInt();
+
+ if(index == 0)
+ {
+ patcher.patch(null);
+ return;
+ }
+
+ if(index < 0 && patcher != null)
+ {
+ Integer i = new Integer(-index);
+ java.util.LinkedList patchlist = (java.util.LinkedList)_readEncapsStack.patchMap.get(i);
+ if(patchlist == null)
+ {
+ //
+ // We have no outstanding instances to be patched for
+ // this index, so make a new entry in the patch map.
+ //
+ patchlist = new java.util.LinkedList();
+ _readEncapsStack.patchMap.put(i, patchlist);
+ }
+ //
+ // Append a patcher for this instance and see if we can
+ // patch the instance. (The instance may have been
+ // unmarshaled previously.)
+ //
+ patchlist.add(patcher);
+ patchReferences(null, i);
+ return;
+ }
+
+ String mostDerivedId = readTypeId();
+ String id = new String(mostDerivedId);
+
+ while(true)
+ {
+ //
+ // If we slice all the way down to Ice::Object, we throw
+ // because Ice::Object is abstract.
+ //
+ if(id.equals(Ice.ObjectImpl.ice_staticId()))
+ {
+ throw new Ice.NoObjectFactoryException("class sliced to Ice.Object, which is abstract",
+ mostDerivedId);
+ }
//
// Try to find a factory registered for the specific type.
@@ -1398,7 +1398,7 @@ public class BasicStream
TraceUtil.traceSlicing("class", id, _slicingCat, _instance.initializationData().logger);
}
skipSlice(); // Slice off this derived part -- we don't understand it.
- id = readTypeId(); // Read next id for next iteration.
+ id = readTypeId(); // Read next id for next iteration.
continue;
}
else
@@ -1409,8 +1409,8 @@ public class BasicStream
}
}
- Integer i = new Integer(index);
- _readEncapsStack.unmarshaledMap.put(i, v);
+ Integer i = new Integer(index);
+ _readEncapsStack.unmarshaledMap.put(i, v);
//
// Record each object instance so that readPendingObjects
@@ -1423,21 +1423,21 @@ public class BasicStream
}
_objectList.add(v);
- v.__read(this, false);
- patchReferences(i, null);
- return;
- }
+ v.__read(this, false);
+ patchReferences(i, null);
+ return;
+ }
}
public void
writeUserException(Ice.UserException v)
{
writeBool(v.__usesClasses());
- v.__write(this);
- if(v.__usesClasses())
- {
- writePendingObjects();
- }
+ v.__write(this);
+ if(v.__usesClasses())
+ {
+ writePendingObjects();
+ }
}
public void
@@ -1448,113 +1448,113 @@ public class BasicStream
String id = readString();
- for(;;)
- {
+ for(;;)
+ {
//
// Look for a factory for this ID.
//
- UserExceptionFactory factory = getUserExceptionFactory(id);
+ UserExceptionFactory factory = getUserExceptionFactory(id);
- if(factory != null)
- {
+ if(factory != null)
+ {
//
// Got factory -- get the factory to instantiate the
// exception, initialize the exception members, and
// throw the exception.
//
- try
- {
- factory.createAndThrow();
- }
- catch(Ice.UserException ex)
- {
- ex.__read(this, false);
- if(usesClasses)
- {
- readPendingObjects();
- }
- throw ex;
- }
- }
- else
- {
- //
- // Performance sensitive, so we use lazy
- // initialization for tracing.
- //
- if(_traceSlicing == -1)
- {
- _traceSlicing = _instance.traceLevels().slicing;
- _slicingCat = _instance.traceLevels().slicingCat;
- }
- if(_traceSlicing > 0)
- {
- TraceUtil.traceSlicing("exception", id, _slicingCat, _instance.initializationData().logger);
- }
- skipSlice(); // Slice off what we don't understand.
- id = readString(); // Read type id for next slice.
- }
- }
-
- //
- // The only way out of the loop above is to find an exception
- // for which the receiver has a factory. If this does not
- // happen, sender and receiver disagree about the Slice
- // definitions they use. In that case, the receiver will
- // eventually fail to read another type ID and throw a
- // MarshalException.
- //
+ try
+ {
+ factory.createAndThrow();
+ }
+ catch(Ice.UserException ex)
+ {
+ ex.__read(this, false);
+ if(usesClasses)
+ {
+ readPendingObjects();
+ }
+ throw ex;
+ }
+ }
+ else
+ {
+ //
+ // Performance sensitive, so we use lazy
+ // initialization for tracing.
+ //
+ if(_traceSlicing == -1)
+ {
+ _traceSlicing = _instance.traceLevels().slicing;
+ _slicingCat = _instance.traceLevels().slicingCat;
+ }
+ if(_traceSlicing > 0)
+ {
+ TraceUtil.traceSlicing("exception", id, _slicingCat, _instance.initializationData().logger);
+ }
+ skipSlice(); // Slice off what we don't understand.
+ id = readString(); // Read type id for next slice.
+ }
+ }
+
+ //
+ // The only way out of the loop above is to find an exception
+ // for which the receiver has a factory. If this does not
+ // happen, sender and receiver disagree about the Slice
+ // definitions they use. In that case, the receiver will
+ // eventually fail to read another type ID and throw a
+ // MarshalException.
+ //
}
public void
writePendingObjects()
{
- if(_writeEncapsStack != null && _writeEncapsStack.toBeMarshaledMap != null)
- {
- while(_writeEncapsStack.toBeMarshaledMap.size() > 0)
- {
- java.util.IdentityHashMap savedMap = new java.util.IdentityHashMap(_writeEncapsStack.toBeMarshaledMap);
- writeSize(savedMap.size());
- for(java.util.Iterator p = savedMap.entrySet().iterator(); p.hasNext(); )
- {
- //
- // Add an instance from the old to-be-marshaled
- // map to the marshaled map and then ask the
- // instance to marshal itself. Any new class
- // instances that are triggered by the classes
- // marshaled are added to toBeMarshaledMap.
- //
- java.util.Map.Entry e = (java.util.Map.Entry)p.next();
- _writeEncapsStack.marshaledMap.put(e.getKey(), e.getValue());
- writeInstance((Ice.Object)e.getKey(), (Integer)e.getValue());
- }
-
- //
- // We have marshaled all the instances for this pass,
- // substract what we have marshaled from the
- // toBeMarshaledMap.
- //
- for(java.util.Iterator p = savedMap.keySet().iterator(); p.hasNext(); )
- {
- _writeEncapsStack.toBeMarshaledMap.remove(p.next());
- }
- }
- }
- writeSize(0); // Zero marker indicates end of sequence of sequences of instances.
+ if(_writeEncapsStack != null && _writeEncapsStack.toBeMarshaledMap != null)
+ {
+ while(_writeEncapsStack.toBeMarshaledMap.size() > 0)
+ {
+ java.util.IdentityHashMap savedMap = new java.util.IdentityHashMap(_writeEncapsStack.toBeMarshaledMap);
+ writeSize(savedMap.size());
+ for(java.util.Iterator p = savedMap.entrySet().iterator(); p.hasNext(); )
+ {
+ //
+ // Add an instance from the old to-be-marshaled
+ // map to the marshaled map and then ask the
+ // instance to marshal itself. Any new class
+ // instances that are triggered by the classes
+ // marshaled are added to toBeMarshaledMap.
+ //
+ java.util.Map.Entry e = (java.util.Map.Entry)p.next();
+ _writeEncapsStack.marshaledMap.put(e.getKey(), e.getValue());
+ writeInstance((Ice.Object)e.getKey(), (Integer)e.getValue());
+ }
+
+ //
+ // We have marshaled all the instances for this pass,
+ // substract what we have marshaled from the
+ // toBeMarshaledMap.
+ //
+ for(java.util.Iterator p = savedMap.keySet().iterator(); p.hasNext(); )
+ {
+ _writeEncapsStack.toBeMarshaledMap.remove(p.next());
+ }
+ }
+ }
+ writeSize(0); // Zero marker indicates end of sequence of sequences of instances.
}
public void
readPendingObjects()
{
- int num;
- do
+ int num;
+ do
{
- num = readSize();
- for(int k = num; k > 0; --k)
- {
- readObject(null);
- }
- }
+ num = readSize();
+ for(int k = num; k > 0; --k)
+ {
+ readObject(null);
+ }
+ }
while(num > 0);
//
@@ -1621,70 +1621,70 @@ public class BasicStream
{
//
// Called whenever we have unmarshaled a new instance or an
- // index. The instanceIndex is the index of the instance just
- // unmarshaled and patchIndex is the index just
- // unmarshaled. (Exactly one of the two parameters must be
- // null.) Patch any pointers in the patch map with the new
- // address.
+ // index. The instanceIndex is the index of the instance just
+ // unmarshaled and patchIndex is the index just
+ // unmarshaled. (Exactly one of the two parameters must be
+ // null.) Patch any pointers in the patch map with the new
+ // address.
//
- assert((instanceIndex != null && patchIndex == null) || (instanceIndex == null && patchIndex != null));
-
- java.util.LinkedList patchlist;
- Ice.Object v;
- if(instanceIndex != null)
- {
- //
- // We have just unmarshaled an instance -- check if
- // something needs patching for that instance.
- //
- patchlist = (java.util.LinkedList)_readEncapsStack.patchMap.get(instanceIndex);
- if(patchlist == null)
- {
- return; // We don't have anything to patch for the instance just unmarshaled
- }
- v = (Ice.Object)_readEncapsStack.unmarshaledMap.get(instanceIndex);
- patchIndex = instanceIndex;
- }
- else
- {
- //
- // We have just unmarshaled an index -- check if we have
- // unmarshaled the instance for that index yet.
- //
- v = (Ice.Object)_readEncapsStack.unmarshaledMap.get(patchIndex);
- if(v == null)
- {
- return; // We haven't unmarshaled the instance for this index yet
- }
- patchlist = (java.util.LinkedList)_readEncapsStack.patchMap.get(patchIndex);
- }
- assert(patchlist != null && patchlist.size() > 0);
- assert(v != null);
-
- //
- // Patch all references that refer to the instance.
- //
- for(java.util.Iterator i = patchlist.iterator(); i.hasNext(); )
- {
- IceInternal.Patcher p = (IceInternal.Patcher)i.next();
- try
- {
- p.patch(v);
- }
- catch(ClassCastException ex)
- {
- Ice.NoObjectFactoryException nof = new Ice.NoObjectFactoryException();
- nof.type = p.type();
+ assert((instanceIndex != null && patchIndex == null) || (instanceIndex == null && patchIndex != null));
+
+ java.util.LinkedList patchlist;
+ Ice.Object v;
+ if(instanceIndex != null)
+ {
+ //
+ // We have just unmarshaled an instance -- check if
+ // something needs patching for that instance.
+ //
+ patchlist = (java.util.LinkedList)_readEncapsStack.patchMap.get(instanceIndex);
+ if(patchlist == null)
+ {
+ return; // We don't have anything to patch for the instance just unmarshaled
+ }
+ v = (Ice.Object)_readEncapsStack.unmarshaledMap.get(instanceIndex);
+ patchIndex = instanceIndex;
+ }
+ else
+ {
+ //
+ // We have just unmarshaled an index -- check if we have
+ // unmarshaled the instance for that index yet.
+ //
+ v = (Ice.Object)_readEncapsStack.unmarshaledMap.get(patchIndex);
+ if(v == null)
+ {
+ return; // We haven't unmarshaled the instance for this index yet
+ }
+ patchlist = (java.util.LinkedList)_readEncapsStack.patchMap.get(patchIndex);
+ }
+ assert(patchlist != null && patchlist.size() > 0);
+ assert(v != null);
+
+ //
+ // Patch all references that refer to the instance.
+ //
+ for(java.util.Iterator i = patchlist.iterator(); i.hasNext(); )
+ {
+ IceInternal.Patcher p = (IceInternal.Patcher)i.next();
+ try
+ {
+ p.patch(v);
+ }
+ catch(ClassCastException ex)
+ {
+ Ice.NoObjectFactoryException nof = new Ice.NoObjectFactoryException();
+ nof.type = p.type();
nof.initCause(ex);
- throw nof;
- }
- }
+ throw nof;
+ }
+ }
- //
- // Clear out the patch map for that index -- there is nothing
- // left to patch for that index for the time being.
- //
- _readEncapsStack.patchMap.remove(patchIndex);
+ //
+ // Clear out the patch map for that index -- there is nothing
+ // left to patch for that index for the time being.
+ //
+ _readEncapsStack.patchMap.remove(patchIndex);
}
public int
@@ -1713,235 +1713,235 @@ public class BasicStream
private static class BufferedOutputStream extends java.io.OutputStream
{
- BufferedOutputStream(byte[] data)
- {
- _data = data;
- }
-
- public void
- close()
- throws java.io.IOException
- {
- }
-
- public void
- flush()
- throws java.io.IOException
- {
- }
-
- public void
- write(byte[] b)
- throws java.io.IOException
- {
- assert(_data.length - _pos >= b.length);
- System.arraycopy(b, 0, _data, _pos, b.length);
- _pos += b.length;
- }
-
- public void
- write(byte[] b, int off, int len)
- throws java.io.IOException
- {
- assert(_data.length - _pos >= len);
- System.arraycopy(b, off, _data, _pos, len);
- _pos += len;
- }
-
- public void
- write(int b)
- throws java.io.IOException
- {
- assert(_data.length - _pos >= 1);
- _data[_pos] = (byte)b;
- ++_pos;
- }
-
- int
- pos()
- {
- return _pos;
- }
-
- private byte[] _data;
- private int _pos;
+ BufferedOutputStream(byte[] data)
+ {
+ _data = data;
+ }
+
+ public void
+ close()
+ throws java.io.IOException
+ {
+ }
+
+ public void
+ flush()
+ throws java.io.IOException
+ {
+ }
+
+ public void
+ write(byte[] b)
+ throws java.io.IOException
+ {
+ assert(_data.length - _pos >= b.length);
+ System.arraycopy(b, 0, _data, _pos, b.length);
+ _pos += b.length;
+ }
+
+ public void
+ write(byte[] b, int off, int len)
+ throws java.io.IOException
+ {
+ assert(_data.length - _pos >= len);
+ System.arraycopy(b, off, _data, _pos, len);
+ _pos += len;
+ }
+
+ public void
+ write(int b)
+ throws java.io.IOException
+ {
+ assert(_data.length - _pos >= 1);
+ _data[_pos] = (byte)b;
+ ++_pos;
+ }
+
+ int
+ pos()
+ {
+ return _pos;
+ }
+
+ private byte[] _data;
+ private int _pos;
}
public BasicStream
compress(int headerSize, int compressionLevel)
{
- assert(compressible());
-
- int uncompressedLen = size() - headerSize;
- int compressedLen = (int)(uncompressedLen * 1.01 + 600);
- byte[] compressed = new byte[compressedLen];
-
- byte[] data = null;
- int offset = 0;
- try
- {
- //
- // If the ByteBuffer is backed by an array then we can avoid
- // an extra copy by using the array directly.
- //
- data = _buf.array();
- offset = _buf.arrayOffset();
- }
- catch(Exception ex)
- {
- //
- // Otherwise, allocate an array to hold a copy of the uncompressed data.
- //
- data = new byte[size()];
- _buf.get(data);
- }
-
- try
- {
- //
- // Compress the data using the class org.apache.tools.bzip2.CBZip2OutputStream.
- // Its constructor requires an OutputStream argument, therefore we pass the
- // compressed BasicStream in an OutputStream wrapper.
- //
- BufferedOutputStream bos = new BufferedOutputStream(compressed);
- //
- // For interoperability with the bzip2 C library, we insert the magic bytes
- // 'B', 'Z' before invoking the Java implementation.
- //
- bos.write((int)'B');
- bos.write((int)'Z');
- java.lang.Object[] args = new java.lang.Object[]{ bos, new Integer(compressionLevel) };
- java.io.OutputStream os = (java.io.OutputStream)_bzOutputStreamCtor.newInstance(args);
- os.write(data, offset + headerSize, uncompressedLen);
- os.close();
- compressedLen = bos.pos();
- }
- catch(Exception ex)
- {
- Ice.CompressionException e = new Ice.CompressionException();
- e.reason = "bzip2 compression failure";
- e.initCause(ex);
- throw e;
- }
-
- //
- // Don't bother if the compressed data is larger than the
- // uncompressed data.
- //
- if(compressedLen >= uncompressedLen)
- {
- return null;
- }
-
- BasicStream cstream = new BasicStream(_instance);
- cstream.resize(headerSize + 4 + compressedLen, false);
- cstream.pos(0);
-
- //
- // Copy the header from the uncompressed stream to the
- // compressed one.
- //
- cstream._buf.put(data, offset, headerSize);
-
- //
- // Add the size of the uncompressed stream before the
- // message body.
- //
- cstream.writeInt(size());
-
- //
- // Add the compressed message body.
- //
- cstream._buf.put(compressed, 0, compressedLen);
-
- return cstream;
+ assert(compressible());
+
+ int uncompressedLen = size() - headerSize;
+ int compressedLen = (int)(uncompressedLen * 1.01 + 600);
+ byte[] compressed = new byte[compressedLen];
+
+ byte[] data = null;
+ int offset = 0;
+ try
+ {
+ //
+ // If the ByteBuffer is backed by an array then we can avoid
+ // an extra copy by using the array directly.
+ //
+ data = _buf.array();
+ offset = _buf.arrayOffset();
+ }
+ catch(Exception ex)
+ {
+ //
+ // Otherwise, allocate an array to hold a copy of the uncompressed data.
+ //
+ data = new byte[size()];
+ _buf.get(data);
+ }
+
+ try
+ {
+ //
+ // Compress the data using the class org.apache.tools.bzip2.CBZip2OutputStream.
+ // Its constructor requires an OutputStream argument, therefore we pass the
+ // compressed BasicStream in an OutputStream wrapper.
+ //
+ BufferedOutputStream bos = new BufferedOutputStream(compressed);
+ //
+ // For interoperability with the bzip2 C library, we insert the magic bytes
+ // 'B', 'Z' before invoking the Java implementation.
+ //
+ bos.write((int)'B');
+ bos.write((int)'Z');
+ java.lang.Object[] args = new java.lang.Object[]{ bos, new Integer(compressionLevel) };
+ java.io.OutputStream os = (java.io.OutputStream)_bzOutputStreamCtor.newInstance(args);
+ os.write(data, offset + headerSize, uncompressedLen);
+ os.close();
+ compressedLen = bos.pos();
+ }
+ catch(Exception ex)
+ {
+ Ice.CompressionException e = new Ice.CompressionException();
+ e.reason = "bzip2 compression failure";
+ e.initCause(ex);
+ throw e;
+ }
+
+ //
+ // Don't bother if the compressed data is larger than the
+ // uncompressed data.
+ //
+ if(compressedLen >= uncompressedLen)
+ {
+ return null;
+ }
+
+ BasicStream cstream = new BasicStream(_instance);
+ cstream.resize(headerSize + 4 + compressedLen, false);
+ cstream.pos(0);
+
+ //
+ // Copy the header from the uncompressed stream to the
+ // compressed one.
+ //
+ cstream._buf.put(data, offset, headerSize);
+
+ //
+ // Add the size of the uncompressed stream before the
+ // message body.
+ //
+ cstream.writeInt(size());
+
+ //
+ // Add the compressed message body.
+ //
+ cstream._buf.put(compressed, 0, compressedLen);
+
+ return cstream;
}
public BasicStream
uncompress(int headerSize)
{
- assert(compressible());
-
- pos(headerSize);
- int uncompressedSize = readInt();
- if(uncompressedSize <= headerSize)
- {
- throw new Ice.IllegalMessageSizeException();
- }
-
- int compressedLen = size() - headerSize - 4;
-
- byte[] compressed = null;
- int offset = 0;
- try
- {
- //
- // If the ByteBuffer is backed by an array then we can avoid
- // an extra copy by using the array directly.
- //
- compressed = _buf.array();
- offset = _buf.arrayOffset();
- }
- catch(Exception ex)
- {
- //
- // Otherwise, allocate an array to hold a copy of the compressed data.
- //
- compressed = new byte[size()];
- _buf.get(compressed);
- }
-
- BasicStream ucStream = new BasicStream(_instance);
- ucStream.resize(uncompressedSize, false);
-
- try
- {
- //
- // Uncompress the data using the class org.apache.tools.bzip2.CBZip2InputStream.
- // Its constructor requires an InputStream argument, therefore we pass the
- // compressed data in a ByteArrayInputStream.
- //
- java.io.ByteArrayInputStream bais =
- new java.io.ByteArrayInputStream(compressed, offset + headerSize + 4, compressedLen);
- //
- // For interoperability with the bzip2 C library, we insert the magic bytes
- // 'B', 'Z' during compression and therefore must extract them before we
- // invoke the Java implementation.
- //
- byte magicB = (byte)bais.read();
- byte magicZ = (byte)bais.read();
- if(magicB != (byte)'B' || magicZ != (byte)'Z')
- {
- Ice.CompressionException e = new Ice.CompressionException();
- e.reason = "bzip2 uncompression failure: invalid magic bytes";
- throw e;
- }
- java.lang.Object[] args = new java.lang.Object[]{ bais };
- java.io.InputStream is = (java.io.InputStream)_bzInputStreamCtor.newInstance(args);
- ucStream.pos(headerSize);
- byte[] arr = new byte[8 * 1024];
- int n;
- while((n = is.read(arr)) != -1)
- {
- ucStream.writeBlob(arr, 0, n);
- }
- is.close();
- }
- catch(Exception ex)
- {
- Ice.CompressionException e = new Ice.CompressionException();
- e.reason = "bzip2 uncompression failure";
- e.initCause(ex);
- throw e;
- }
-
- //
- // Copy the header from the compressed stream to the uncompressed one.
- //
- ucStream.pos(0);
- ucStream._buf.put(compressed, offset, headerSize);
-
- return ucStream;
+ assert(compressible());
+
+ pos(headerSize);
+ int uncompressedSize = readInt();
+ if(uncompressedSize <= headerSize)
+ {
+ throw new Ice.IllegalMessageSizeException();
+ }
+
+ int compressedLen = size() - headerSize - 4;
+
+ byte[] compressed = null;
+ int offset = 0;
+ try
+ {
+ //
+ // If the ByteBuffer is backed by an array then we can avoid
+ // an extra copy by using the array directly.
+ //
+ compressed = _buf.array();
+ offset = _buf.arrayOffset();
+ }
+ catch(Exception ex)
+ {
+ //
+ // Otherwise, allocate an array to hold a copy of the compressed data.
+ //
+ compressed = new byte[size()];
+ _buf.get(compressed);
+ }
+
+ BasicStream ucStream = new BasicStream(_instance);
+ ucStream.resize(uncompressedSize, false);
+
+ try
+ {
+ //
+ // Uncompress the data using the class org.apache.tools.bzip2.CBZip2InputStream.
+ // Its constructor requires an InputStream argument, therefore we pass the
+ // compressed data in a ByteArrayInputStream.
+ //
+ java.io.ByteArrayInputStream bais =
+ new java.io.ByteArrayInputStream(compressed, offset + headerSize + 4, compressedLen);
+ //
+ // For interoperability with the bzip2 C library, we insert the magic bytes
+ // 'B', 'Z' during compression and therefore must extract them before we
+ // invoke the Java implementation.
+ //
+ byte magicB = (byte)bais.read();
+ byte magicZ = (byte)bais.read();
+ if(magicB != (byte)'B' || magicZ != (byte)'Z')
+ {
+ Ice.CompressionException e = new Ice.CompressionException();
+ e.reason = "bzip2 uncompression failure: invalid magic bytes";
+ throw e;
+ }
+ java.lang.Object[] args = new java.lang.Object[]{ bais };
+ java.io.InputStream is = (java.io.InputStream)_bzInputStreamCtor.newInstance(args);
+ ucStream.pos(headerSize);
+ byte[] arr = new byte[8 * 1024];
+ int n;
+ while((n = is.read(arr)) != -1)
+ {
+ ucStream.writeBlob(arr, 0, n);
+ }
+ is.close();
+ }
+ catch(Exception ex)
+ {
+ Ice.CompressionException e = new Ice.CompressionException();
+ e.reason = "bzip2 uncompression failure";
+ e.initCause(ex);
+ throw e;
+ }
+
+ //
+ // Copy the header from the compressed stream to the uncompressed one.
+ //
+ ucStream.pos(0);
+ ucStream._buf.put(compressed, offset, headerSize);
+
+ return ucStream;
}
private void
@@ -2089,10 +2089,10 @@ public class BasicStream
{
UserExceptionFactory factory = null;
- synchronized(_factoryMutex)
- {
- factory = (UserExceptionFactory)_exceptionFactories.get(id);
- }
+ synchronized(_factoryMutex)
+ {
+ factory = (UserExceptionFactory)_exceptionFactories.get(id);
+ }
if(factory == null)
{
@@ -2256,42 +2256,42 @@ public class BasicStream
private void
allocate(int size)
{
- java.nio.ByteBuffer buf = null;
- try
- {
- //buf = java.nio.ByteBuffer.allocateDirect(size);
- buf = java.nio.ByteBuffer.allocate(size);
- }
- catch(OutOfMemoryError ex)
- {
- Ice.MarshalException e = new Ice.MarshalException();
- e.reason = "OutOfMemoryError occurred while allocating a ByteBuffer";
- e.initCause(ex);
- throw e;
- }
- buf.order(java.nio.ByteOrder.LITTLE_ENDIAN);
- _buf = buf;
+ java.nio.ByteBuffer buf = null;
+ try
+ {
+ //buf = java.nio.ByteBuffer.allocateDirect(size);
+ buf = java.nio.ByteBuffer.allocate(size);
+ }
+ catch(OutOfMemoryError ex)
+ {
+ Ice.MarshalException e = new Ice.MarshalException();
+ e.reason = "OutOfMemoryError occurred while allocating a ByteBuffer";
+ e.initCause(ex);
+ throw e;
+ }
+ buf.order(java.nio.ByteOrder.LITTLE_ENDIAN);
+ _buf = buf;
}
private void
reallocate(int size)
{
//
- // Limit the buffer size to MessageSizeMax
- //
- if(!_unlimited)
- {
+ // Limit the buffer size to MessageSizeMax
+ //
+ if(!_unlimited)
+ {
size = size > _messageSizeMax ? _messageSizeMax : size;
- }
+ }
- java.nio.ByteBuffer old = _buf;
- assert(old != null);
+ java.nio.ByteBuffer old = _buf;
+ assert(old != null);
- allocate(size);
- assert(_buf != null);
+ allocate(size);
+ assert(_buf != null);
- old.position(0);
- _buf.put(old);
+ old.position(0);
+ _buf.put(old);
}
private IceInternal.Instance _instance;
@@ -2304,53 +2304,53 @@ public class BasicStream
private static final class ReadEncaps
{
int start;
- int sz;
+ int sz;
byte encodingMajor;
byte encodingMinor;
java.util.TreeMap patchMap;
- java.util.TreeMap unmarshaledMap;
- int typeIdIndex;
- java.util.TreeMap typeIdMap;
+ java.util.TreeMap unmarshaledMap;
+ int typeIdIndex;
+ java.util.TreeMap typeIdMap;
ReadEncaps next;
- void
- reset()
- {
- if(patchMap != null)
- {
- patchMap.clear();
- unmarshaledMap.clear();
- typeIdIndex = 0;
- typeIdMap.clear();
- }
- }
+ void
+ reset()
+ {
+ if(patchMap != null)
+ {
+ patchMap.clear();
+ unmarshaledMap.clear();
+ typeIdIndex = 0;
+ typeIdMap.clear();
+ }
+ }
}
private static final class WriteEncaps
{
int start;
- int writeIndex;
- java.util.IdentityHashMap toBeMarshaledMap;
- java.util.IdentityHashMap marshaledMap;
- int typeIdIndex;
- java.util.TreeMap typeIdMap;
+ int writeIndex;
+ java.util.IdentityHashMap toBeMarshaledMap;
+ java.util.IdentityHashMap marshaledMap;
+ int typeIdIndex;
+ java.util.TreeMap typeIdMap;
WriteEncaps next;
- void
- reset()
- {
- if(toBeMarshaledMap != null)
- {
- writeIndex = 0;
- toBeMarshaledMap.clear();
- marshaledMap.clear();
- typeIdIndex = 0;
- typeIdMap.clear();
- }
- }
+ void
+ reset()
+ {
+ if(toBeMarshaledMap != null)
+ {
+ writeIndex = 0;
+ toBeMarshaledMap.clear();
+ marshaledMap.clear();
+ typeIdIndex = 0;
+ typeIdMap.clear();
+ }
+ }
}
private ReadEncaps _readEncapsStack;
@@ -2372,14 +2372,14 @@ public class BasicStream
private static final class SeqData
{
public SeqData(int numElements, int minSize)
- {
- this.numElements = numElements;
- this.minSize = minSize;
- }
+ {
+ this.numElements = numElements;
+ this.minSize = minSize;
+ }
- public int numElements;
- public int minSize;
- public SeqData previous;
+ public int numElements;
+ public int minSize;
+ public SeqData previous;
}
SeqData _seqDataStack;
@@ -2398,22 +2398,22 @@ public class BasicStream
private static java.lang.reflect.Constructor _bzOutputStreamCtor;
static
{
- try
- {
- Class cls;
- Class[] types = new Class[1];
- cls = Class.forName("org.apache.tools.bzip2.CBZip2InputStream");
- types[0] = java.io.InputStream.class;
- _bzInputStreamCtor = cls.getDeclaredConstructor(types);
- cls = Class.forName("org.apache.tools.bzip2.CBZip2OutputStream");
- types = new Class[2];
- types[0] = java.io.OutputStream.class;
- types[1] = Integer.TYPE;
- _bzOutputStreamCtor = cls.getDeclaredConstructor(types);
- }
- catch(Exception ex)
- {
- // Ignore - bzip2 compression not available.
- }
+ try
+ {
+ Class cls;
+ Class[] types = new Class[1];
+ cls = Class.forName("org.apache.tools.bzip2.CBZip2InputStream");
+ types[0] = java.io.InputStream.class;
+ _bzInputStreamCtor = cls.getDeclaredConstructor(types);
+ cls = Class.forName("org.apache.tools.bzip2.CBZip2OutputStream");
+ types = new Class[2];
+ types[0] = java.io.OutputStream.class;
+ types[1] = Integer.TYPE;
+ _bzOutputStreamCtor = cls.getDeclaredConstructor(types);
+ }
+ catch(Exception ex)
+ {
+ // Ignore - bzip2 compression not available.
+ }
}
}
diff --git a/java/src/IceInternal/ConnectionMonitor.java b/java/src/IceInternal/ConnectionMonitor.java
index 22f5c671e3f..de44f64fe71 100644
--- a/java/src/IceInternal/ConnectionMonitor.java
+++ b/java/src/IceInternal/ConnectionMonitor.java
@@ -18,42 +18,42 @@ public final class ConnectionMonitor extends Thread
public void
_destroy()
{
- synchronized(this)
- {
- assert(_instance != null);
-
- _instance = null;
- _connections = null;
-
- notify();
- }
-
- while(true)
- {
- try
- {
- join();
- break;
- }
- catch(java.lang.InterruptedException ex)
- {
- continue;
- }
- }
+ synchronized(this)
+ {
+ assert(_instance != null);
+
+ _instance = null;
+ _connections = null;
+
+ notify();
+ }
+
+ while(true)
+ {
+ try
+ {
+ join();
+ break;
+ }
+ catch(java.lang.InterruptedException ex)
+ {
+ continue;
+ }
+ }
}
public synchronized void
add(Ice.ConnectionI connection)
{
- assert(_instance != null);
- _connections.add(connection);
+ assert(_instance != null);
+ _connections.add(connection);
}
public synchronized void
remove(Ice.ConnectionI connection)
{
- assert(_instance != null);
- _connections.remove(connection);
+ assert(_instance != null);
+ _connections.remove(connection);
}
//
@@ -61,111 +61,111 @@ public final class ConnectionMonitor extends Thread
//
ConnectionMonitor(Instance instance, int interval)
{
- _instance = instance;
- _interval = interval;
+ _instance = instance;
+ _interval = interval;
String threadName = _instance.initializationData().properties.getProperty("Ice.ProgramName");
if(threadName.length() > 0)
{
threadName += "-";
}
- setName(threadName + "Ice.ConnectionMonitor");
+ setName(threadName + "Ice.ConnectionMonitor");
- assert(_interval > 0);
- start();
+ assert(_interval > 0);
+ start();
}
protected synchronized void
finalize()
throws Throwable
{
- IceUtil.Assert.FinalizerAssert(_instance == null);
- IceUtil.Assert.FinalizerAssert(_connections == null);
-
+ IceUtil.Assert.FinalizerAssert(_instance == null);
+ IceUtil.Assert.FinalizerAssert(_connections == null);
+
super.finalize();
}
public void
run()
{
- java.util.HashSet connections = new java.util.HashSet();
+ java.util.HashSet connections = new java.util.HashSet();
- while(true)
- {
- synchronized(this)
- {
- if(_instance != null)
- {
- try
- {
- wait(_interval * 1000);
- }
- catch(InterruptedException ex)
- {
- continue;
- }
- }
+ while(true)
+ {
+ synchronized(this)
+ {
+ if(_instance != null)
+ {
+ try
+ {
+ wait(_interval * 1000);
+ }
+ catch(InterruptedException ex)
+ {
+ continue;
+ }
+ }
- if(_instance == null)
- {
- return;
- }
+ if(_instance == null)
+ {
+ return;
+ }
- connections.clear();
- connections.addAll(_connections);
- }
-
- //
- // Monitor connections outside the thread synchronization,
- // so that connections can be added or removed during
- // monitoring.
- //
- java.util.Iterator iter = connections.iterator();
- while(iter.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)iter.next();
+ connections.clear();
+ connections.addAll(_connections);
+ }
+
+ //
+ // Monitor connections outside the thread synchronization,
+ // so that connections can be added or removed during
+ // monitoring.
+ //
+ java.util.Iterator iter = connections.iterator();
+ while(iter.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)iter.next();
- try
- {
- connection.monitor();
- }
- catch(Ice.LocalException ex)
- {
- synchronized(this)
- {
- if(_instance == null)
- {
- return;
- }
+ try
+ {
+ connection.monitor();
+ }
+ catch(Ice.LocalException ex)
+ {
+ synchronized(this)
+ {
+ if(_instance == null)
+ {
+ return;
+ }
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "exception in connection monitor thread " + getName() + ":\n" +
- sw.toString();
- _instance.initializationData().logger.error(s);
- }
- }
- catch(java.lang.Exception ex)
- {
- synchronized(this)
- {
- if(_instance == null)
- {
- return;
- }
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "unknown exception in connection monitor thread " + getName() + ":\n" +
- sw.toString();
- _instance.initializationData().logger.error(s);
- }
- }
- }
- }
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "exception in connection monitor thread " + getName() + ":\n" +
+ sw.toString();
+ _instance.initializationData().logger.error(s);
+ }
+ }
+ catch(java.lang.Exception ex)
+ {
+ synchronized(this)
+ {
+ if(_instance == null)
+ {
+ return;
+ }
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "unknown exception in connection monitor thread " + getName() + ":\n" +
+ sw.toString();
+ _instance.initializationData().logger.error(s);
+ }
+ }
+ }
+ }
}
private Instance _instance;
diff --git a/java/src/IceInternal/DefaultsAndOverrides.java b/java/src/IceInternal/DefaultsAndOverrides.java
index 5b4a6ad1cfe..ad0db01c2ca 100644
--- a/java/src/IceInternal/DefaultsAndOverrides.java
+++ b/java/src/IceInternal/DefaultsAndOverrides.java
@@ -13,76 +13,76 @@ public final class DefaultsAndOverrides
{
DefaultsAndOverrides(Ice.Properties properties)
{
- String value;
-
- defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
+ String value;
+
+ defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp");
- value = properties.getProperty("Ice.Default.Host");
- if(value.length() != 0)
- {
- defaultHost = value;
- }
- else
- {
- defaultHost = null;
- }
-
- value = properties.getProperty("Ice.Override.Timeout");
- if(value.length() > 0)
- {
- overrideTimeout = true;
- overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout");
- }
- else
- {
- overrideTimeout = false;
- overrideTimeoutValue = -1;
- }
+ value = properties.getProperty("Ice.Default.Host");
+ if(value.length() != 0)
+ {
+ defaultHost = value;
+ }
+ else
+ {
+ defaultHost = null;
+ }
+
+ value = properties.getProperty("Ice.Override.Timeout");
+ if(value.length() > 0)
+ {
+ overrideTimeout = true;
+ overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout");
+ }
+ else
+ {
+ overrideTimeout = false;
+ overrideTimeoutValue = -1;
+ }
- value = properties.getProperty("Ice.Override.ConnectTimeout");
- if(value.length() > 0)
- {
- overrideConnectTimeout = true;
- overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout");
- }
- else
- {
- overrideConnectTimeout = false;
- overrideConnectTimeoutValue = -1;
- }
+ value = properties.getProperty("Ice.Override.ConnectTimeout");
+ if(value.length() > 0)
+ {
+ overrideConnectTimeout = true;
+ overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout");
+ }
+ else
+ {
+ overrideConnectTimeout = false;
+ overrideConnectTimeoutValue = -1;
+ }
- value = properties.getProperty("Ice.Override.Compress");
- if(value.length() > 0)
- {
- overrideCompress = true;
- boolean b = properties.getPropertyAsInt("Ice.Override.Compress") > 0;
- if(!BasicStream.compressible() && b)
- {
- System.err.println("warning: bzip2 support not available, Ice.Override.Compress ignored");
- b = false;
- }
- overrideCompressValue = b;
- }
- else
- {
- overrideCompress = !BasicStream.compressible();
- overrideCompressValue = false;
- }
+ value = properties.getProperty("Ice.Override.Compress");
+ if(value.length() > 0)
+ {
+ overrideCompress = true;
+ boolean b = properties.getPropertyAsInt("Ice.Override.Compress") > 0;
+ if(!BasicStream.compressible() && b)
+ {
+ System.err.println("warning: bzip2 support not available, Ice.Override.Compress ignored");
+ b = false;
+ }
+ overrideCompressValue = b;
+ }
+ else
+ {
+ overrideCompress = !BasicStream.compressible();
+ overrideCompressValue = false;
+ }
- value = properties.getProperty("Ice.Override.Secure");
- if(value.length() > 0)
- {
- overrideSecure = true;
- overrideSecureValue = properties.getPropertyAsInt("Ice.Override.Secure") > 0;
- }
- else
- {
- overrideSecure = false;
- overrideSecureValue = false;
- }
+ value = properties.getProperty("Ice.Override.Secure");
+ if(value.length() > 0)
+ {
+ overrideSecure = true;
+ overrideSecureValue = properties.getPropertyAsInt("Ice.Override.Secure") > 0;
+ }
+ else
+ {
+ overrideSecure = false;
+ overrideSecureValue = false;
+ }
- defaultCollocationOptimization =
- properties.getPropertyAsIntWithDefault("Ice.Default.CollocationOptimization", 1) > 0;
+ defaultCollocationOptimization =
+ properties.getPropertyAsIntWithDefault("Ice.Default.CollocationOptimization", 1) > 0;
value = properties.getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
if(value.equals("Random"))
@@ -100,9 +100,9 @@ public final class DefaultsAndOverrides
throw ex;
}
- defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
+ defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
- defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
+ defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
}
final public String defaultHost;
diff --git a/java/src/IceInternal/Direct.java b/java/src/IceInternal/Direct.java
index 65ff8678eea..616c91193e1 100644
--- a/java/src/IceInternal/Direct.java
+++ b/java/src/IceInternal/Direct.java
@@ -16,39 +16,39 @@ public final class Direct
{
_current = current;
- Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter;
- assert(adapter != null);
-
- //
- // Must call incDirectCount() first, because it checks for
- // adapter deactivation, and prevents deactivation completion
- // until decDirectCount() is called. This is important,
- // because getServantManager() may not be called afer
- // deactivation completion.
- //
- adapter.incDirectCount();
+ Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter;
+ assert(adapter != null);
+
+ //
+ // Must call incDirectCount() first, because it checks for
+ // adapter deactivation, and prevents deactivation completion
+ // until decDirectCount() is called. This is important,
+ // because getServantManager() may not be called afer
+ // deactivation completion.
+ //
+ adapter.incDirectCount();
- ServantManager servantManager = adapter.getServantManager();
- assert(servantManager != null);
+ ServantManager servantManager = adapter.getServantManager();
+ assert(servantManager != null);
try
{
- _servant = servantManager.findServant(_current.id, _current.facet);
- if(_servant == null)
- {
- _locator = servantManager.findServantLocator(_current.id.category);
- if(_locator == null && _current.id.category.length() > 0)
- {
- _locator = servantManager.findServantLocator("");
- }
- if(_locator != null)
- {
- _cookie = new Ice.LocalObjectHolder(); // Lazy creation.
- _servant = _locator.locate(_current, _cookie);
- }
- }
- if(_servant == null)
- {
+ _servant = servantManager.findServant(_current.id, _current.facet);
+ if(_servant == null)
+ {
+ _locator = servantManager.findServantLocator(_current.id.category);
+ if(_locator == null && _current.id.category.length() > 0)
+ {
+ _locator = servantManager.findServantLocator("");
+ }
+ if(_locator != null)
+ {
+ _cookie = new Ice.LocalObjectHolder(); // Lazy creation.
+ _servant = _locator.locate(_current, _cookie);
+ }
+ }
+ if(_servant == null)
+ {
if(servantManager != null && servantManager.hasServant(_current.id))
{
Ice.FacetNotExistException ex = new Ice.FacetNotExistException();
@@ -65,42 +65,42 @@ public final class Direct
ex.operation = _current.operation;
throw ex;
}
- }
+ }
}
catch(RuntimeException ex)
{
- try
- {
- if(_locator != null && _servant != null)
- {
- _locator.finished(_current, _servant, _cookie.value);
- }
- throw ex;
- }
- finally
- {
- adapter.decDirectCount();
- }
+ try
+ {
+ if(_locator != null && _servant != null)
+ {
+ _locator.finished(_current, _servant, _cookie.value);
+ }
+ throw ex;
+ }
+ finally
+ {
+ adapter.decDirectCount();
+ }
}
}
public void
destroy()
{
- Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter;
- assert(adapter != null);
-
- try
- {
- if(_locator != null && _servant != null)
- {
- _locator.finished(_current, _servant, _cookie.value);
- }
- }
- finally
- {
- adapter.decDirectCount();
- }
+ Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)_current.adapter;
+ assert(adapter != null);
+
+ try
+ {
+ if(_locator != null && _servant != null)
+ {
+ _locator.finished(_current, _servant, _cookie.value);
+ }
+ }
+ finally
+ {
+ adapter.decDirectCount();
+ }
}
public Ice.Object
diff --git a/java/src/IceInternal/DirectReference.java b/java/src/IceInternal/DirectReference.java
index ba7a73058b9..56224453de5 100644
--- a/java/src/IceInternal/DirectReference.java
+++ b/java/src/IceInternal/DirectReference.java
@@ -13,21 +13,21 @@ public class DirectReference extends RoutableReference
{
public
DirectReference(Instance inst,
- Ice.Communicator com,
- Ice.Identity ident,
- java.util.Map ctx,
- String fs,
- int md,
- boolean sec,
- boolean prefSec,
- EndpointI[] endpts,
- RouterInfo rtrInfo,
- boolean collocationOpt,
+ Ice.Communicator com,
+ Ice.Identity ident,
+ java.util.Map ctx,
+ String fs,
+ int md,
+ boolean sec,
+ boolean prefSec,
+ EndpointI[] endpts,
+ RouterInfo rtrInfo,
+ boolean collocationOpt,
boolean cacheConnection,
Ice.EndpointSelectionType endpointSelection,
boolean threadPerConnection)
{
- super(inst, com, ident, ctx, fs, md, sec, prefSec, rtrInfo, collocationOpt, cacheConnection, endpointSelection,
+ super(inst, com, ident, ctx, fs, md, sec, prefSec, rtrInfo, collocationOpt, cacheConnection, endpointSelection,
threadPerConnection);
_endpoints = endpts;
}
@@ -35,7 +35,7 @@ public class DirectReference extends RoutableReference
public String
getAdapterId()
{
- return "";
+ return "";
}
public EndpointI[]
@@ -47,75 +47,75 @@ public class DirectReference extends RoutableReference
public int
getLocatorCacheTimeout()
{
- return 0;
+ return 0;
}
public Reference
changeLocator(Ice.LocatorPrx newLocator)
{
- return this;
+ return this;
}
public Reference
changeCompress(boolean newCompress)
{
DirectReference r = (DirectReference)super.changeCompress(newCompress);
- if(r != this) // Also override the compress flag on the endpoints if it was updated.
- {
- EndpointI[] newEndpoints = new EndpointI[_endpoints.length];
- for(int i = 0; i < _endpoints.length; i++)
- {
- newEndpoints[i] = _endpoints[i].compress(newCompress);
- }
- r._endpoints = newEndpoints;
- }
- return r;
+ if(r != this) // Also override the compress flag on the endpoints if it was updated.
+ {
+ EndpointI[] newEndpoints = new EndpointI[_endpoints.length];
+ for(int i = 0; i < _endpoints.length; i++)
+ {
+ newEndpoints[i] = _endpoints[i].compress(newCompress);
+ }
+ r._endpoints = newEndpoints;
+ }
+ return r;
}
public Reference
changeTimeout(int newTimeout)
{
DirectReference r = (DirectReference)super.changeTimeout(newTimeout);
- if(r != this) // Also override the timeout on the endpoints if it was updated.
- {
- EndpointI[] newEndpoints = new EndpointI[_endpoints.length];
- for(int i = 0; i < _endpoints.length; i++)
- {
- newEndpoints[i] = _endpoints[i].timeout(newTimeout);
- }
- r._endpoints = newEndpoints;
- }
- return r;
+ if(r != this) // Also override the timeout on the endpoints if it was updated.
+ {
+ EndpointI[] newEndpoints = new EndpointI[_endpoints.length];
+ for(int i = 0; i < _endpoints.length; i++)
+ {
+ newEndpoints[i] = _endpoints[i].timeout(newTimeout);
+ }
+ r._endpoints = newEndpoints;
+ }
+ return r;
}
public Reference
changeConnectionId(String connectionId)
{
DirectReference r = (DirectReference)super.changeConnectionId(connectionId);
- if(r != this) // Also override the connection id on the endpoints if it was updated.
- {
- EndpointI[] newEndpoints = new EndpointI[_endpoints.length];
- for(int i = 0; i < _endpoints.length; i++)
- {
- newEndpoints[i] = _endpoints[i].connectionId(connectionId);
- }
- r._endpoints = newEndpoints;
- }
- return r;
+ if(r != this) // Also override the connection id on the endpoints if it was updated.
+ {
+ EndpointI[] newEndpoints = new EndpointI[_endpoints.length];
+ for(int i = 0; i < _endpoints.length; i++)
+ {
+ newEndpoints[i] = _endpoints[i].connectionId(connectionId);
+ }
+ r._endpoints = newEndpoints;
+ }
+ return r;
}
public Reference
changeAdapterId(String newAdapterId)
{
- if(newAdapterId == null || newAdapterId.length() == 0)
- {
- return this;
- }
- LocatorInfo locatorInfo =
- getInstance().locatorManager().get(getInstance().referenceFactory().getDefaultLocator());
- return getInstance().referenceFactory().create(getIdentity(), getContext(), getFacet(), getMode(),
- getSecure(), getPreferSecure(), newAdapterId, getRouterInfo(),
- locatorInfo, getCollocationOptimization(), getCacheConnection(),
+ if(newAdapterId == null || newAdapterId.length() == 0)
+ {
+ return this;
+ }
+ LocatorInfo locatorInfo =
+ getInstance().locatorManager().get(getInstance().referenceFactory().getDefaultLocator());
+ return getInstance().referenceFactory().create(getIdentity(), getContext(), getFacet(), getMode(),
+ getSecure(), getPreferSecure(), newAdapterId, getRouterInfo(),
+ locatorInfo, getCollocationOptimization(), getCacheConnection(),
getEndpointSelection(), getThreadPerConnection(),
getLocatorCacheTimeout());
}
@@ -123,15 +123,15 @@ public class DirectReference extends RoutableReference
public Reference
changeEndpoints(EndpointI[] newEndpoints)
{
- if(java.util.Arrays.equals(newEndpoints, _endpoints))
- {
- return this;
- }
+ if(java.util.Arrays.equals(newEndpoints, _endpoints))
+ {
+ return this;
+ }
DirectReference r = (DirectReference)getInstance().referenceFactory().copy(this);
- r._endpoints = newEndpoints;
- r.applyOverrides(r._endpoints);
- return r;
+ r._endpoints = newEndpoints;
+ r.applyOverrides(r._endpoints);
+ return r;
}
public Reference
@@ -142,93 +142,93 @@ public class DirectReference extends RoutableReference
public void
streamWrite(BasicStream s)
- throws Ice.MarshalException
+ throws Ice.MarshalException
{
super.streamWrite(s);
- s.writeSize(_endpoints.length);
- if(_endpoints.length > 0)
- {
- for(int i = 0; i < _endpoints.length; i++)
- {
- _endpoints[i].streamWrite(s);
- }
- }
- else
- {
- s.writeString(""); // Adapter id.
- }
+ s.writeSize(_endpoints.length);
+ if(_endpoints.length > 0)
+ {
+ for(int i = 0; i < _endpoints.length; i++)
+ {
+ _endpoints[i].streamWrite(s);
+ }
+ }
+ else
+ {
+ s.writeString(""); // Adapter id.
+ }
}
public String
toString()
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
- StringBuffer s = new StringBuffer();
- s.append(super.toString());
-
- for(int i = 0; i < _endpoints.length; i++)
- {
- String endp = _endpoints[i].toString();
- if(endp != null && endp.length() > 0)
- {
- s.append(':');
- s.append(endp);
- }
- }
- return s.toString();
+ //
+ // WARNING: Certain features, such as proxy validation in Glacier2,
+ // depend on the format of proxy strings. Changes to toString() and
+ // methods called to generate parts of the reference string could break
+ // these features. Please review for all features that depend on the
+ // format of proxyToString() before changing this and related code.
+ //
+ StringBuffer s = new StringBuffer();
+ s.append(super.toString());
+
+ for(int i = 0; i < _endpoints.length; i++)
+ {
+ String endp = _endpoints[i].toString();
+ if(endp != null && endp.length() > 0)
+ {
+ s.append(':');
+ s.append(endp);
+ }
+ }
+ return s.toString();
}
public Ice.ConnectionI
getConnection(Ice.BooleanHolder comp)
{
EndpointI[] endpts = super.getRoutedEndpoints();
- applyOverrides(endpts);
-
- if(endpts.length == 0)
- {
- endpts = _endpoints; // Endpoint overrides are already applied on these endpoints.
- }
-
- Ice.ConnectionI connection = createConnection(endpts, comp);
-
- //
- // If we have a router, set the object adapter for this router
- // (if any) to the new connection, so that callbacks from the
- // router can be received over this new connection.
- //
- if(getRouterInfo() != null)
- {
- connection.setAdapter(getRouterInfo().getAdapter());
- }
-
- assert(connection != null);
- return connection;
+ applyOverrides(endpts);
+
+ if(endpts.length == 0)
+ {
+ endpts = _endpoints; // Endpoint overrides are already applied on these endpoints.
+ }
+
+ Ice.ConnectionI connection = createConnection(endpts, comp);
+
+ //
+ // If we have a router, set the object adapter for this router
+ // (if any) to the new connection, so that callbacks from the
+ // router can be received over this new connection.
+ //
+ if(getRouterInfo() != null)
+ {
+ connection.setAdapter(getRouterInfo().getAdapter());
+ }
+
+ assert(connection != null);
+ return connection;
}
public boolean
equals(java.lang.Object obj)
{
if(this == obj)
- {
- return true;
- }
- if(!(obj instanceof DirectReference))
- {
- return false;
- }
+ {
+ return true;
+ }
+ if(!(obj instanceof DirectReference))
+ {
+ return false;
+ }
DirectReference rhs = (DirectReference)obj;
if(!super.equals(rhs))
{
return false;
}
- return java.util.Arrays.equals(_endpoints, rhs._endpoints);
+ return java.util.Arrays.equals(_endpoints, rhs._endpoints);
}
private EndpointI[] _endpoints;
diff --git a/java/src/IceInternal/DispatchStatus.java b/java/src/IceInternal/DispatchStatus.java
index ea5d71ebc7f..ddf2813cd5f 100644
--- a/java/src/IceInternal/DispatchStatus.java
+++ b/java/src/IceInternal/DispatchStatus.java
@@ -64,13 +64,13 @@ public final class DispatchStatus
public int
value()
{
- return __value;
+ return __value;
}
private
DispatchStatus(int val)
{
- __value = val;
- __values[val] = this;
+ __value = val;
+ __values[val] = this;
}
}
diff --git a/java/src/IceInternal/EndpointFactoryManager.java b/java/src/IceInternal/EndpointFactoryManager.java
index 6d9b5da6662..b2d341b04ba 100644
--- a/java/src/IceInternal/EndpointFactoryManager.java
+++ b/java/src/IceInternal/EndpointFactoryManager.java
@@ -50,9 +50,9 @@ public final class EndpointFactoryManager
String s = str.trim();
if(s.length() == 0)
{
- Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = str;
- throw e;
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = str;
+ throw e;
}
java.util.regex.Pattern p = java.util.regex.Pattern.compile("([ \t\n\r]+)|$");
@@ -76,7 +76,7 @@ public final class EndpointFactoryManager
}
}
- return null;
+ return null;
}
public synchronized EndpointI
diff --git a/java/src/IceInternal/EndpointI.java b/java/src/IceInternal/EndpointI.java
index 3e874f3ad33..8b8ac0528bb 100644
--- a/java/src/IceInternal/EndpointI.java
+++ b/java/src/IceInternal/EndpointI.java
@@ -27,7 +27,7 @@ abstract public class EndpointI implements Ice.Endpoint, java.lang.Comparable
public String
toString()
{
- return _toString();
+ return _toString();
}
//
diff --git a/java/src/IceInternal/FixedReference.java b/java/src/IceInternal/FixedReference.java
index fca9ee84b3b..c3c64a0ee2e 100644
--- a/java/src/IceInternal/FixedReference.java
+++ b/java/src/IceInternal/FixedReference.java
@@ -13,14 +13,14 @@ public class FixedReference extends Reference
{
public
FixedReference(Instance inst,
- Ice.Communicator com,
- Ice.Identity ident,
- java.util.Map ctx,
- String fs,
- int md,
- Ice.ConnectionI[] fixedConns)
+ Ice.Communicator com,
+ Ice.Identity ident,
+ java.util.Map ctx,
+ String fs,
+ int md,
+ Ice.ConnectionI[] fixedConns)
{
- super(inst, com, ident, ctx, fs, md);
+ super(inst, com, ident, ctx, fs, md);
_fixedConnections = fixedConns;
}
@@ -33,19 +33,19 @@ public class FixedReference extends Reference
public boolean
getSecure()
{
- return false;
+ return false;
}
public boolean
getPreferSecure()
{
- return false;
+ return false;
}
public String
getAdapterId()
{
- return "";
+ return "";
}
public EndpointI[]
@@ -63,19 +63,19 @@ public class FixedReference extends Reference
public int
getLocatorCacheTimeout()
{
- return 0;
+ return 0;
}
public final boolean
getCacheConnection()
{
- return false;
+ return false;
}
public final Ice.EndpointSelectionType
getEndpointSelection()
{
- return Ice.EndpointSelectionType.Random;
+ return Ice.EndpointSelectionType.Random;
}
public boolean
@@ -87,61 +87,61 @@ public class FixedReference extends Reference
public Reference
changeSecure(boolean sec)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public Reference
changePreferSecure(boolean prefSec)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public Reference
changeRouter(Ice.RouterPrx newRouter)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public Reference
changeLocator(Ice.LocatorPrx newLocator)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public Reference
changeCollocationOptimization(boolean newCollocationOptimization)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public Reference
changeAdapterId(String newAdapterId)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public Reference
changeEndpoints(EndpointI[] newEndpoints)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public Reference
changeLocatorCacheTimeout(int newTimeout)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public final Reference
changeCacheConnection(boolean newCache)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public final Reference
changeEndpointSelection(Ice.EndpointSelectionType newType)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public final Reference
@@ -153,74 +153,74 @@ public class FixedReference extends Reference
public Reference
changeCompress(boolean newCompress)
{
- // TODO: FixedReferences should probably have a _compress flag,
- // that gets its default from the fixed connection this reference
- // refers to. This should be changable with changeCompress().
- throw new Ice.FixedProxyException();
+ // TODO: FixedReferences should probably have a _compress flag,
+ // that gets its default from the fixed connection this reference
+ // refers to. This should be changable with changeCompress().
+ throw new Ice.FixedProxyException();
}
public Reference
changeTimeout(int newTimeout)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public Reference
changeConnectionId(String connectionId)
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public void
streamWrite(BasicStream s)
- throws Ice.MarshalException
+ throws Ice.MarshalException
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public String
toString()
- throws Ice.MarshalException
+ throws Ice.MarshalException
{
- throw new Ice.FixedProxyException();
+ throw new Ice.FixedProxyException();
}
public Ice.ConnectionI
getConnection(Ice.BooleanHolder compress)
{
Ice.ConnectionI[] filteredConns = filterConnections(_fixedConnections);
- if(filteredConns.length == 0)
- {
- Ice.NoEndpointException ex = new Ice.NoEndpointException();
- ex.proxy = ""; // No stringified representation for fixed proxies.
- throw ex;
- }
-
- Ice.ConnectionI connection = filteredConns[0];
- assert(connection != null);
- connection.throwException(); // Throw in case our connection is already destroyed.
- compress.value = connection.endpoint().compress();
-
- return connection;
+ if(filteredConns.length == 0)
+ {
+ Ice.NoEndpointException ex = new Ice.NoEndpointException();
+ ex.proxy = ""; // No stringified representation for fixed proxies.
+ throw ex;
+ }
+
+ Ice.ConnectionI connection = filteredConns[0];
+ assert(connection != null);
+ connection.throwException(); // Throw in case our connection is already destroyed.
+ compress.value = connection.endpoint().compress();
+
+ return connection;
}
public boolean
equals(java.lang.Object obj)
{
if(this == obj)
- {
- return true;
- }
- if(!(obj instanceof FixedReference))
- {
- return false;
- }
+ {
+ return true;
+ }
+ if(!(obj instanceof FixedReference))
+ {
+ return false;
+ }
FixedReference rhs = (FixedReference)obj;
if(!super.equals(rhs))
{
return false;
}
- return java.util.Arrays.equals(_fixedConnections, rhs._fixedConnections);
+ return java.util.Arrays.equals(_fixedConnections, rhs._fixedConnections);
}
//
@@ -281,8 +281,8 @@ public class FixedReference extends Reference
// partitioning the endpoint vector, so that non-secure
// endpoints come first.
//
- DefaultsAndOverrides overrides = getInstance().defaultsAndOverrides();
- if(overrides.overrideSecure ? overrides.overrideSecureValue : getSecure())
+ DefaultsAndOverrides overrides = getInstance().defaultsAndOverrides();
+ if(overrides.overrideSecure ? overrides.overrideSecureValue : getSecure())
{
java.util.Iterator i = connections.iterator();
while(i.hasNext())
@@ -306,26 +306,26 @@ public class FixedReference extends Reference
static class ConnectionComparator implements java.util.Comparator
{
- public int
- compare(java.lang.Object l, java.lang.Object r)
- {
- Ice.ConnectionI lc = (Ice.ConnectionI)l;
- Ice.ConnectionI rc = (Ice.ConnectionI)r;
- boolean ls = lc.endpoint().secure();
- boolean rs = rc.endpoint().secure();
- if((ls && rs) || (!ls && !rs))
- {
- return 0;
- }
- else if(!ls && rs)
- {
- return -1;
- }
- else
- {
- return 1;
- }
- }
+ public int
+ compare(java.lang.Object l, java.lang.Object r)
+ {
+ Ice.ConnectionI lc = (Ice.ConnectionI)l;
+ Ice.ConnectionI rc = (Ice.ConnectionI)r;
+ boolean ls = lc.endpoint().secure();
+ boolean rs = rc.endpoint().secure();
+ if((ls && rs) || (!ls && !rs))
+ {
+ return 0;
+ }
+ else if(!ls && rs)
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
}
private static ConnectionComparator _connectionComparator = new ConnectionComparator();
diff --git a/java/src/IceInternal/Incoming.java b/java/src/IceInternal/Incoming.java
index 8b8b1f1619a..75075840fc5 100644
--- a/java/src/IceInternal/Incoming.java
+++ b/java/src/IceInternal/Incoming.java
@@ -13,9 +13,9 @@ final public class Incoming extends IncomingBase
{
public
Incoming(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, boolean response, byte compress,
- int requestId)
+ int requestId)
{
- super(instance, connection, adapter, response, compress, requestId);
+ super(instance, connection, adapter, response, compress, requestId);
_is = new BasicStream(instance);
}
@@ -25,33 +25,33 @@ final public class Incoming extends IncomingBase
//
public void
reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, boolean response, byte compress,
- int requestId)
+ int requestId)
{
- if(_is == null)
- {
- _is = new BasicStream(instance);
- }
+ if(_is == null)
+ {
+ _is = new BasicStream(instance);
+ }
- super.reset(instance, connection, adapter, response, compress, requestId);
+ super.reset(instance, connection, adapter, response, compress, requestId);
}
public void
reclaim()
{
- if(_is != null)
- {
- _is.reset();
- }
+ if(_is != null)
+ {
+ _is.reset();
+ }
- super.reclaim();
+ super.reclaim();
}
public void
invoke(ServantManager servantManager)
{
- //
- // Read the current.
- //
+ //
+ // Read the current.
+ //
_current.id.__read(_is);
//
@@ -60,16 +60,16 @@ final public class Incoming extends IncomingBase
String[] facetPath = _is.readStringSeq();
if(facetPath.length > 0)
{
- if(facetPath.length > 1)
- {
- throw new Ice.MarshalException();
- }
+ if(facetPath.length > 1)
+ {
+ throw new Ice.MarshalException();
+ }
_current.facet = facetPath[0];
}
- else
- {
+ else
+ {
_current.facet = "";
- }
+ }
_current.operation = _is.readString();
_current.mode = Ice.OperationMode.convert(_is.readByte());
@@ -94,114 +94,114 @@ final public class Incoming extends IncomingBase
_os.startWriteEncaps();
}
- // Initialize status to some value, to keep the compiler happy.
- DispatchStatus status = 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
- // the caller of this operation.
- //
+ // Initialize status to some value, to keep the compiler happy.
+ DispatchStatus status = 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
+ // the caller of this operation.
+ //
try
{
- try
- {
- if(servantManager != null)
- {
- _servant = servantManager.findServant(_current.id, _current.facet);
- if(_servant == null)
- {
- _locator = servantManager.findServantLocator(_current.id.category);
- if(_locator == null && _current.id.category.length() > 0)
- {
- _locator = servantManager.findServantLocator("");
- }
- if(_locator != null)
- {
- _servant = _locator.locate(_current, _cookie);
- }
- }
- if(_servant == null)
- {
- _locator = servantManager.findServantLocator("");
- if(_locator != null)
- {
- _servant = _locator.locate(_current, _cookie);
- }
- }
- }
- if(_servant == null)
- {
- if(servantManager != null && servantManager.hasServant(_current.id))
- {
- status = DispatchStatus.DispatchFacetNotExist;
- }
- else
- {
- status = DispatchStatus.DispatchObjectNotExist;
- }
- }
- else
- {
- status = _servant.__dispatch(this, _current);
- }
- }
- finally
- {
- if(_locator != null && _servant != null && status != DispatchStatus.DispatchAsync)
- {
- _locator.finished(_current, _servant, _cookie.value);
- }
- }
- }
+ try
+ {
+ if(servantManager != null)
+ {
+ _servant = servantManager.findServant(_current.id, _current.facet);
+ if(_servant == null)
+ {
+ _locator = servantManager.findServantLocator(_current.id.category);
+ if(_locator == null && _current.id.category.length() > 0)
+ {
+ _locator = servantManager.findServantLocator("");
+ }
+ if(_locator != null)
+ {
+ _servant = _locator.locate(_current, _cookie);
+ }
+ }
+ if(_servant == null)
+ {
+ _locator = servantManager.findServantLocator("");
+ if(_locator != null)
+ {
+ _servant = _locator.locate(_current, _cookie);
+ }
+ }
+ }
+ if(_servant == null)
+ {
+ if(servantManager != null && servantManager.hasServant(_current.id))
+ {
+ status = DispatchStatus.DispatchFacetNotExist;
+ }
+ else
+ {
+ status = DispatchStatus.DispatchObjectNotExist;
+ }
+ }
+ else
+ {
+ status = _servant.__dispatch(this, _current);
+ }
+ }
+ finally
+ {
+ if(_locator != null && _servant != null && status != DispatchStatus.DispatchAsync)
+ {
+ _locator.finished(_current, _servant, _cookie.value);
+ }
+ }
+ }
/* Not possible in Java - UserExceptions are checked exceptions
catch(Ice.UserException ex)
{
- // ...
- }
- */
+ // ...
+ }
+ */
catch(java.lang.Exception ex)
{
- _is.endReadEncaps();
- __handleException(ex);
- return;
+ _is.endReadEncaps();
+ __handleException(ex);
+ return;
+ }
+
+ //
+ // Don't put the code below into the try block above. Exceptions
+ // in the code below are considered fatal, and must propagate to
+ // the caller of this operation.
+ //
+
+ _is.endReadEncaps();
+
+ //
+ // DispatchAsync is "pseudo dispatch status", used internally
+ // only to indicate async dispatch.
+ //
+ if(status == DispatchStatus.DispatchAsync)
+ {
+ //
+ // If this was an asynchronous dispatch, we're done here.
+ //
+ return;
}
-
- //
- // Don't put the code below into the try block above. Exceptions
- // in the code below are considered fatal, and must propagate to
- // the caller of this operation.
- //
-
- _is.endReadEncaps();
-
- //
- // DispatchAsync is "pseudo dispatch status", used internally
- // only to indicate async dispatch.
- //
- if(status == DispatchStatus.DispatchAsync)
- {
- //
- // If this was an asynchronous dispatch, we're done here.
- //
- return;
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
-
- if(status != DispatchStatus.DispatchOK && status != DispatchStatus.DispatchUserException)
- {
- assert(status == DispatchStatus.DispatchObjectNotExist ||
- status == DispatchStatus.DispatchFacetNotExist ||
- status == DispatchStatus.DispatchOperationNotExist);
-
- _os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
- _os.writeByte((byte)status.value());
-
- _current.id.__write(_os);
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+
+ if(status != DispatchStatus.DispatchOK && status != DispatchStatus.DispatchUserException)
+ {
+ assert(status == DispatchStatus.DispatchObjectNotExist ||
+ status == DispatchStatus.DispatchFacetNotExist ||
+ status == DispatchStatus.DispatchOperationNotExist);
+
+ _os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
+ _os.writeByte((byte)status.value());
+
+ _current.id.__write(_os);
//
// For compatibility with the old FacetPath.
@@ -216,22 +216,22 @@ final public class Incoming extends IncomingBase
_os.writeStringSeq(facetPath2);
}
- _os.writeString(_current.operation);
- }
- else
- {
- int save = _os.pos();
- _os.pos(Protocol.headerSize + 4); // Dispatch status position.
- _os.writeByte((byte)status.value());
- _os.pos(save);
- }
-
- _connection.sendResponse(_os, _compress);
- }
- else
- {
- _connection.sendNoResponse();
- }
+ _os.writeString(_current.operation);
+ }
+ else
+ {
+ int save = _os.pos();
+ _os.pos(Protocol.headerSize + 4); // Dispatch status position.
+ _os.writeByte((byte)status.value());
+ _os.pos(save);
+ }
+
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
}
public BasicStream
diff --git a/java/src/IceInternal/IncomingAsync.java b/java/src/IceInternal/IncomingAsync.java
index 7a7bb90678f..d985797169d 100644
--- a/java/src/IceInternal/IncomingAsync.java
+++ b/java/src/IceInternal/IncomingAsync.java
@@ -14,89 +14,89 @@ public class IncomingAsync extends IncomingBase
public
IncomingAsync(Incoming in) // Adopts the argument. It must not be used afterwards.
{
- super(in);
+ super(in);
}
final protected void
__response(boolean ok)
{
- try
- {
- if(!__servantLocatorFinished())
- {
- return;
- }
+ try
+ {
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
- if(_response)
- {
- _os.endWriteEncaps();
-
- int save = _os.pos();
- _os.pos(Protocol.headerSize + 4); // Dispatch status position.
-
- if(ok)
- {
- _os.writeByte((byte)DispatchStatus._DispatchOK);
- }
- else
- {
- _os.writeByte((byte)DispatchStatus._DispatchUserException);
- }
-
- _os.pos(save);
+ if(_response)
+ {
+ _os.endWriteEncaps();
+
+ int save = _os.pos();
+ _os.pos(Protocol.headerSize + 4); // Dispatch status position.
+
+ if(ok)
+ {
+ _os.writeByte((byte)DispatchStatus._DispatchOK);
+ }
+ else
+ {
+ _os.writeByte((byte)DispatchStatus._DispatchUserException);
+ }
+
+ _os.pos(save);
- _connection.sendResponse(_os, _compress);
- }
- else
- {
- _connection.sendNoResponse();
- }
- }
- catch(Ice.LocalException ex)
- {
- _connection.invokeException(ex, 1);
- }
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
+ }
+ catch(Ice.LocalException ex)
+ {
+ _connection.invokeException(ex, 1);
+ }
}
final protected void
__exception(java.lang.Exception exc)
{
- try
- {
- if(!__servantLocatorFinished())
- {
- return;
- }
+ try
+ {
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
- __handleException(exc);
- }
- catch(Ice.LocalException ex)
- {
- _connection.invokeException(ex, 1);
- }
+ __handleException(exc);
+ }
+ catch(Ice.LocalException ex)
+ {
+ _connection.invokeException(ex, 1);
+ }
}
final private boolean
__servantLocatorFinished()
{
- try
- {
- if(_locator != null && _servant != null)
- {
- _locator.finished(_current, _servant, _cookie.value);
- }
- return true;
- }
+ try
+ {
+ if(_locator != null && _servant != null)
+ {
+ _locator.finished(_current, _servant, _cookie.value);
+ }
+ return true;
+ }
catch(java.lang.Exception ex)
{
- __handleException(ex);
- return false;
+ __handleException(ex);
+ return false;
}
}
final protected BasicStream
__os()
{
- return _os;
+ return _os;
}
}
diff --git a/java/src/IceInternal/IncomingBase.java b/java/src/IceInternal/IncomingBase.java
index 98b6777ed05..10477586c49 100644
--- a/java/src/IceInternal/IncomingBase.java
+++ b/java/src/IceInternal/IncomingBase.java
@@ -15,16 +15,16 @@ public class IncomingBase
IncomingBase(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, boolean response,
byte compress, int requestId)
{
- _response = response;
+ _response = response;
_compress = compress;
_os = new BasicStream(instance);
- _connection = connection;
+ _connection = connection;
_current = new Ice.Current();
_current.id = new Ice.Identity();
_current.adapter = adapter;
_current.con = _connection;
- _current.requestId = requestId;
+ _current.requestId = requestId;
_cookie = new Ice.LocalObjectHolder();
@@ -33,29 +33,29 @@ public class IncomingBase
protected
IncomingBase(IncomingBase in) // Adopts the argument. It must not be used afterwards.
{
- _current = in._current;
- in._current = null;
+ _current = in._current;
+ in._current = null;
- _servant = in._servant;
- in._servant = null;
+ _servant = in._servant;
+ in._servant = null;
- _locator = in._locator;
- in._locator = null;
+ _locator = in._locator;
+ in._locator = null;
- _cookie = in._cookie;
- in._cookie = null;
+ _cookie = in._cookie;
+ in._cookie = null;
- _response = in._response;
- in._response = false;
+ _response = in._response;
+ in._response = false;
- _compress = in._compress;
- in._compress = 0;
+ _compress = in._compress;
+ in._compress = 0;
- _os = in._os;
- in._os = null;
+ _os = in._os;
+ in._os = null;
- _connection = in._connection;
- in._connection = null;
+ _connection = in._connection;
+ in._connection = null;
}
//
@@ -63,7 +63,7 @@ public class IncomingBase
//
public void
reset(Instance instance, Ice.ConnectionI connection, Ice.ObjectAdapter adapter, boolean response, byte compress,
- int requestId)
+ int requestId)
{
//
// Don't recycle the Current object, because servants may keep a reference to it.
@@ -72,60 +72,60 @@ public class IncomingBase
_current.id = new Ice.Identity();
_current.adapter = adapter;
_current.con = connection;
- _current.requestId = requestId;
+ _current.requestId = requestId;
- if(_cookie == null)
- {
- _cookie = new Ice.LocalObjectHolder();
- }
+ if(_cookie == null)
+ {
+ _cookie = new Ice.LocalObjectHolder();
+ }
- _response = response;
+ _response = response;
_compress = compress;
- if(_os == null)
- {
- _os = new BasicStream(instance);
- }
+ if(_os == null)
+ {
+ _os = new BasicStream(instance);
+ }
- _connection = connection;
+ _connection = connection;
}
public void
reclaim()
{
- _servant = null;
+ _servant = null;
- _locator = null;
+ _locator = null;
- if(_cookie != null)
- {
- _cookie.value = null;
- }
+ if(_cookie != null)
+ {
+ _cookie.value = null;
+ }
- if(_os != null)
- {
- _os.reset();
- }
+ if(_os != null)
+ {
+ _os.reset();
+ }
}
final protected void
__warning(java.lang.Exception ex)
{
- assert(_os != null);
-
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- IceUtil.OutputBase out = new IceUtil.OutputBase(pw);
- out.setUseTab(false);
- out.print("dispatch exception:");
- out.print("\nidentity: " + _os.instance().identityToString(_current.id));
- out.print("\nfacet: " + IceUtil.StringUtil.escapeString(_current.facet, ""));
- out.print("\noperation: " + _current.operation);
- out.print("\n");
- ex.printStackTrace(pw);
- pw.flush();
- _os.instance().initializationData().logger.warning(sw.toString());
+ assert(_os != null);
+
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ IceUtil.OutputBase out = new IceUtil.OutputBase(pw);
+ out.setUseTab(false);
+ out.print("dispatch exception:");
+ out.print("\nidentity: " + _os.instance().identityToString(_current.id));
+ out.print("\nfacet: " + IceUtil.StringUtil.escapeString(_current.facet, ""));
+ out.print("\noperation: " + _current.operation);
+ out.print("\n");
+ ex.printStackTrace(pw);
+ pw.flush();
+ _os.instance().initializationData().logger.warning(sw.toString());
}
final protected void
@@ -133,51 +133,51 @@ public class IncomingBase
{
try
{
- throw exc;
- }
- catch(Ice.RequestFailedException ex)
- {
- if(ex.id == null)
- {
- ex.id = _current.id;
- }
-
- if(ex.facet == null)
- {
- ex.facet = _current.facet;
- }
-
- if(ex.operation == null || ex.operation.length() == 0)
- {
- ex.operation = _current.operation;
- }
-
- if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
- {
- __warning(ex);
- }
+ throw exc;
+ }
+ catch(Ice.RequestFailedException ex)
+ {
+ if(ex.id == null)
+ {
+ ex.id = _current.id;
+ }
+
+ if(ex.facet == null)
+ {
+ ex.facet = _current.facet;
+ }
+
+ if(ex.operation == null || ex.operation.length() == 0)
+ {
+ ex.operation = _current.operation;
+ }
+
+ if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
+ {
+ __warning(ex);
+ }
if(_response)
{
_os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
- if(ex instanceof Ice.ObjectNotExistException)
- {
- _os.writeByte((byte)DispatchStatus._DispatchObjectNotExist);
- }
- else if(ex instanceof Ice.FacetNotExistException)
- {
- _os.writeByte((byte)DispatchStatus._DispatchFacetNotExist);
- }
- else if(ex instanceof Ice.OperationNotExistException)
- {
- _os.writeByte((byte)DispatchStatus._DispatchOperationNotExist);
- }
- else
- {
- assert(false);
- }
- ex.id.__write(_os);
+ if(ex instanceof Ice.ObjectNotExistException)
+ {
+ _os.writeByte((byte)DispatchStatus._DispatchObjectNotExist);
+ }
+ else if(ex instanceof Ice.FacetNotExistException)
+ {
+ _os.writeByte((byte)DispatchStatus._DispatchFacetNotExist);
+ }
+ else if(ex instanceof Ice.OperationNotExistException)
+ {
+ _os.writeByte((byte)DispatchStatus._DispatchOperationNotExist);
+ }
+ else
+ {
+ assert(false);
+ }
+ ex.id.__write(_os);
//
// For compatibility with the old FacetPath.
@@ -192,150 +192,150 @@ public class IncomingBase
_os.writeStringSeq(facetPath2);
}
- _os.writeString(ex.operation);
+ _os.writeString(ex.operation);
- _connection.sendResponse(_os, _compress);
- }
- else
- {
- _connection.sendNoResponse();
- }
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
}
catch(Ice.UnknownLocalException ex)
{
- if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
+ if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
if(_response)
{
_os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
_os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException);
- _os.writeString(ex.unknown);
- _connection.sendResponse(_os, _compress);
- }
- else
- {
- _connection.sendNoResponse();
- }
+ _os.writeString(ex.unknown);
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
}
catch(Ice.UnknownUserException ex)
{
- if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
+ if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
if(_response)
{
_os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
_os.writeByte((byte)DispatchStatus._DispatchUnknownUserException);
- _os.writeString(ex.unknown);
- _connection.sendResponse(_os, _compress);
- }
- else
- {
- _connection.sendNoResponse();
- }
+ _os.writeString(ex.unknown);
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
}
catch(Ice.UnknownException ex)
{
- if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
+ if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
if(_response)
{
_os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
_os.writeByte((byte)DispatchStatus._DispatchUnknownException);
- _os.writeString(ex.unknown);
- _connection.sendResponse(_os, _compress);
- }
- else
- {
- _connection.sendNoResponse();
- }
+ _os.writeString(ex.unknown);
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
}
catch(Ice.LocalException ex)
{
- if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
+ if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
if(_response)
{
_os.endWriteEncaps();
_os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
_os.writeByte((byte)DispatchStatus._DispatchUnknownLocalException);
- //_os.writeString(ex.toString());
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- _os.writeString(sw.toString());
- _connection.sendResponse(_os, _compress);
- }
- else
- {
- _connection.sendNoResponse();
- }
+ //_os.writeString(ex.toString());
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ _os.writeString(sw.toString());
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
+ }
+ catch(Ice.UserException ex)
+ {
+ if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
+ _os.writeByte((byte)DispatchStatus._DispatchUnknownUserException);
+ //_os.writeString(ex.toString());
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ _os.writeString(sw.toString());
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
+ }
+ catch(java.lang.Exception ex)
+ {
+ if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
+ _os.writeByte((byte)DispatchStatus._DispatchUnknownException);
+ //_os.writeString(ex.toString());
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ _os.writeString(sw.toString());
+ _connection.sendResponse(_os, _compress);
+ }
+ else
+ {
+ _connection.sendNoResponse();
+ }
}
- catch(Ice.UserException ex)
- {
- if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
- _os.writeByte((byte)DispatchStatus._DispatchUnknownUserException);
- //_os.writeString(ex.toString());
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- _os.writeString(sw.toString());
- _connection.sendResponse(_os, _compress);
- }
- else
- {
- _connection.sendNoResponse();
- }
- }
- catch(java.lang.Exception ex)
- {
- if(_os.instance().initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.resize(Protocol.headerSize + 4, false); // Dispatch status position.
- _os.writeByte((byte)DispatchStatus._DispatchUnknownException);
- //_os.writeString(ex.toString());
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- _os.writeString(sw.toString());
- _connection.sendResponse(_os, _compress);
- }
- else
- {
- _connection.sendNoResponse();
- }
- }
}
protected Ice.Current _current;
diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java
index 4c57ff4c51a..68fa8177fb3 100644
--- a/java/src/IceInternal/IncomingConnectionFactory.java
+++ b/java/src/IceInternal/IncomingConnectionFactory.java
@@ -32,110 +32,110 @@ public final class IncomingConnectionFactory extends EventHandler
public void
waitUntilHolding()
{
- java.util.LinkedList connections;
-
- synchronized(this)
- {
- //
- // First we wait until the connection factory itself is in holding
- // state.
- //
- while(_state < StateHolding)
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- //
- // We want to wait until all connections are in holding state
- // outside the thread synchronization.
- //
- connections = (java.util.LinkedList)_connections.clone();
- }
-
- //
- // Now we wait until each connection is in holding state.
- //
- java.util.ListIterator p = connections.listIterator();
- while(p.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
- connection.waitUntilHolding();
- }
+ java.util.LinkedList connections;
+
+ synchronized(this)
+ {
+ //
+ // First we wait until the connection factory itself is in holding
+ // state.
+ //
+ while(_state < StateHolding)
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ //
+ // We want to wait until all connections are in holding state
+ // outside the thread synchronization.
+ //
+ connections = (java.util.LinkedList)_connections.clone();
+ }
+
+ //
+ // Now we wait until each connection is in holding state.
+ //
+ java.util.ListIterator p = connections.listIterator();
+ while(p.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
+ connection.waitUntilHolding();
+ }
}
public void
waitUntilFinished()
{
- Thread threadPerIncomingConnectionFactory = null;
- java.util.LinkedList connections;
-
- synchronized(this)
- {
- //
- // First we wait until the factory is destroyed. If we are using
- // an acceptor, we also wait for it to be closed.
- //
- while(_state != StateClosed || _acceptor != null)
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- threadPerIncomingConnectionFactory = _threadPerIncomingConnectionFactory;
- _threadPerIncomingConnectionFactory = null;
+ Thread threadPerIncomingConnectionFactory = null;
+ java.util.LinkedList connections;
+
+ synchronized(this)
+ {
+ //
+ // First we wait until the factory is destroyed. If we are using
+ // an acceptor, we also wait for it to be closed.
+ //
+ while(_state != StateClosed || _acceptor != null)
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ threadPerIncomingConnectionFactory = _threadPerIncomingConnectionFactory;
+ _threadPerIncomingConnectionFactory = null;
//
// Clear the OA. See bug 1673 for the details of why this is necessary.
//
_adapter = null;
- //
- // We want to wait until all connections are finished outside the
- // thread synchronization.
- //
- // For consistency with C#, we set _connections to null rather than to a
- // new empty list so that our finalizer does not try to invoke any
- // methods on member objects.
- //
- connections = _connections;
- _connections = null;
- }
-
- if(threadPerIncomingConnectionFactory != null)
- {
- while(true)
- {
- try
- {
- threadPerIncomingConnectionFactory.join();
- break;
- }
- catch(InterruptedException ex)
- {
- }
- }
- }
-
- if(connections != null)
- {
- java.util.ListIterator p = connections.listIterator();
- while(p.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
- connection.waitUntilFinished();
- }
- }
+ //
+ // We want to wait until all connections are finished outside the
+ // thread synchronization.
+ //
+ // For consistency with C#, we set _connections to null rather than to a
+ // new empty list so that our finalizer does not try to invoke any
+ // methods on member objects.
+ //
+ connections = _connections;
+ _connections = null;
+ }
+
+ if(threadPerIncomingConnectionFactory != null)
+ {
+ while(true)
+ {
+ try
+ {
+ threadPerIncomingConnectionFactory.join();
+ break;
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+ }
+
+ if(connections != null)
+ {
+ java.util.ListIterator p = connections.listIterator();
+ while(p.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
+ connection.waitUntilFinished();
+ }
+ }
}
public EndpointI
@@ -160,11 +160,11 @@ public final class IncomingConnectionFactory extends EventHandler
public synchronized Ice.ConnectionI[]
connections()
{
- java.util.LinkedList connections = new java.util.LinkedList();
+ java.util.LinkedList connections = new java.util.LinkedList();
- //
- // Only copy connections which have not been destroyed.
- //
+ //
+ // Only copy connections which have not been destroyed.
+ //
java.util.ListIterator p = _connections.listIterator();
while(p.hasNext())
{
@@ -184,17 +184,17 @@ public final class IncomingConnectionFactory extends EventHandler
flushBatchRequests()
{
Ice.ConnectionI[] c = connections(); // connections() is synchronized, so no need to synchronize here.
- for(int i = 0; i < c.length; i++)
- {
- try
- {
- c[i].flushBatchRequests();
- }
- catch(Ice.LocalException ex)
- {
- // Ignore.
- }
- }
+ for(int i = 0; i < c.length; i++)
+ {
+ try
+ {
+ c[i].flushBatchRequests();
+ }
+ catch(Ice.LocalException ex)
+ {
+ // Ignore.
+ }
+ }
}
//
@@ -204,141 +204,141 @@ public final class IncomingConnectionFactory extends EventHandler
public boolean
datagram()
{
- assert(!_threadPerConnection); // Only for use with a thread pool.
+ assert(!_threadPerConnection); // Only for use with a thread pool.
return _endpoint.datagram();
}
public boolean
readable()
{
- assert(!_threadPerConnection); // Only for use with a thread pool.
+ assert(!_threadPerConnection); // Only for use with a thread pool.
return false;
}
public boolean
read(BasicStream unused)
{
- assert(!_threadPerConnection); // Only for use with a thread pool.
+ assert(!_threadPerConnection); // Only for use with a thread pool.
assert(false); // Must not be called.
- return false;
+ return false;
}
public void
message(BasicStream unused, ThreadPool threadPool)
{
- assert(!_threadPerConnection); // Only for use with a thread pool.
-
- Ice.ConnectionI connection = null;
-
- synchronized(this)
- {
- try
- {
- if(_state != StateActive)
- {
- Thread.yield();
- return;
- }
-
- //
- // Reap connections for which destruction has completed.
- //
- java.util.ListIterator p = _connections.listIterator();
- while(p.hasNext())
- {
- Ice.ConnectionI con = (Ice.ConnectionI)p.next();
- if(con.isFinished())
- {
- p.remove();
- }
- }
-
- //
- // Now accept a new connection.
- //
- Transceiver transceiver;
- try
- {
- transceiver = _acceptor.accept(0);
- }
- catch(Ice.TimeoutException ex)
- {
- // Ignore timeouts.
- return;
- }
- catch(Ice.LocalException ex)
- {
- // Warn about other Ice local exceptions.
- if(_warn)
- {
- warning(ex);
- }
- return;
- }
-
- assert(transceiver != null);
-
- try
- {
- connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection);
- }
- catch(Ice.LocalException ex)
- {
- return;
- }
-
- _connections.add(connection);
- }
- finally
- {
- //
- // This makes sure that we promote a follower before
- // we leave the scope of the mutex above, but after we
- // call accept() (if we call it).
- //
- threadPool.promoteFollower();
- }
- }
-
- assert(connection != null);
-
- //
- // We validate and activate outside the thread
- // synchronization, to not block the factory.
- //
- try
- {
- connection.validate();
- }
+ assert(!_threadPerConnection); // Only for use with a thread pool.
+
+ Ice.ConnectionI connection = null;
+
+ synchronized(this)
+ {
+ try
+ {
+ if(_state != StateActive)
+ {
+ Thread.yield();
+ return;
+ }
+
+ //
+ // Reap connections for which destruction has completed.
+ //
+ java.util.ListIterator p = _connections.listIterator();
+ while(p.hasNext())
+ {
+ Ice.ConnectionI con = (Ice.ConnectionI)p.next();
+ if(con.isFinished())
+ {
+ p.remove();
+ }
+ }
+
+ //
+ // Now accept a new connection.
+ //
+ Transceiver transceiver;
+ try
+ {
+ transceiver = _acceptor.accept(0);
+ }
+ catch(Ice.TimeoutException ex)
+ {
+ // Ignore timeouts.
+ return;
+ }
+ catch(Ice.LocalException ex)
+ {
+ // Warn about other Ice local exceptions.
+ if(_warn)
+ {
+ warning(ex);
+ }
+ return;
+ }
+
+ assert(transceiver != null);
+
+ try
+ {
+ connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection);
+ }
+ catch(Ice.LocalException ex)
+ {
+ return;
+ }
+
+ _connections.add(connection);
+ }
+ finally
+ {
+ //
+ // This makes sure that we promote a follower before
+ // we leave the scope of the mutex above, but after we
+ // call accept() (if we call it).
+ //
+ threadPool.promoteFollower();
+ }
+ }
+
+ assert(connection != null);
+
+ //
+ // We validate and activate outside the thread
+ // synchronization, to not block the factory.
+ //
+ try
+ {
+ connection.validate();
+ }
catch(Ice.LocalException ex)
- {
- synchronized(this)
- {
- connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
- _connections.remove(connection);
- return;
- }
- }
-
- connection.activate();
+ {
+ synchronized(this)
+ {
+ connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
+ _connections.remove(connection);
+ return;
+ }
+ }
+
+ connection.activate();
}
public synchronized void
finished(ThreadPool threadPool)
{
- assert(!_threadPerConnection); // Only for use with a thread pool.
+ assert(!_threadPerConnection); // Only for use with a thread pool.
threadPool.promoteFollower();
assert(threadPool == ((Ice.ObjectAdapterI)_adapter).getThreadPool());
- --_finishedCount;
+ --_finishedCount;
- if(_finishedCount == 0 && _state == StateClosed)
- {
- _acceptor.close();
- _acceptor = null;
- notifyAll();
- }
+ if(_finishedCount == 0 && _state == StateClosed)
+ {
+ _acceptor.close();
+ _acceptor = null;
+ notifyAll();
+ }
}
public void
@@ -352,141 +352,141 @@ public final class IncomingConnectionFactory extends EventHandler
{
if(_transceiver != null)
{
- return _transceiver.toString();
+ return _transceiver.toString();
}
- assert(_acceptor != null);
- return _acceptor.toString();
+ assert(_acceptor != null);
+ return _acceptor.toString();
}
public
IncomingConnectionFactory(Instance instance, EndpointI endpoint, Ice.ObjectAdapter adapter,
- String adapterName)
+ String adapterName)
{
super(instance);
_endpoint = endpoint;
_adapter = adapter;
- _registeredWithPool = false;
- _finishedCount = 0;
- _warn = _instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Connections") > 0 ? true : false;
+ _registeredWithPool = false;
+ _finishedCount = 0;
+ _warn = _instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Connections") > 0 ? true : false;
_state = StateHolding;
- DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
- if(defaultsAndOverrides.overrideTimeout)
- {
- _endpoint = _endpoint.timeout(defaultsAndOverrides.overrideTimeoutValue);
- }
+ DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
+ if(defaultsAndOverrides.overrideTimeout)
+ {
+ _endpoint = _endpoint.timeout(defaultsAndOverrides.overrideTimeoutValue);
+ }
- if(defaultsAndOverrides.overrideCompress)
- {
- _endpoint = _endpoint.compress(defaultsAndOverrides.overrideCompressValue);
- }
+ if(defaultsAndOverrides.overrideCompress)
+ {
+ _endpoint = _endpoint.compress(defaultsAndOverrides.overrideCompressValue);
+ }
Ice.ObjectAdapterI adapterImpl = (Ice.ObjectAdapterI)_adapter;
_threadPerConnection = adapterImpl.getThreadPerConnection();
- EndpointIHolder h = new EndpointIHolder();
- h.value = _endpoint;
- _transceiver = _endpoint.serverTransceiver(h);
-
- try
- {
- if(_transceiver != null)
- {
- _endpoint = h.value;
-
- Ice.ConnectionI connection = null;
-
- try
- {
- connection = new Ice.ConnectionI(_instance, _transceiver, _endpoint, _adapter,
+ EndpointIHolder h = new EndpointIHolder();
+ h.value = _endpoint;
+ _transceiver = _endpoint.serverTransceiver(h);
+
+ try
+ {
+ if(_transceiver != null)
+ {
+ _endpoint = h.value;
+
+ Ice.ConnectionI connection = null;
+
+ try
+ {
+ connection = new Ice.ConnectionI(_instance, _transceiver, _endpoint, _adapter,
_threadPerConnection);
- connection.validate();
- }
- catch(Ice.LocalException ex)
- {
- //
- // If a connection object was constructed, then
- // validate() must have raised the exception.
- //
- if(connection != null)
- {
- connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
- }
-
- return;
- }
-
- _connections.add(connection);
- }
- else
- {
- h.value = _endpoint;
- _acceptor = _endpoint.acceptor(h, adapterName);
- _endpoint = h.value;
- assert(_acceptor != null);
- _acceptor.listen();
-
- if(_threadPerConnection)
- {
- //
- // If we are in thread per connection mode, we also use
- // one thread per incoming connection factory, that
- // accepts new connections on this endpoint.
- //
- try
- {
- _threadPerIncomingConnectionFactory = new ThreadPerIncomingConnectionFactory();
- _threadPerIncomingConnectionFactory.start();
- }
- catch(java.lang.Exception ex)
- {
- error("cannot create thread for incoming connection factory", ex);
- throw ex;
- }
- }
- }
- }
- catch(java.lang.Exception ex)
- {
- //
- // Clean up for finalizer.
- //
-
- if(_acceptor != null)
- {
- try
- {
- _acceptor.close();
- }
- catch(Ice.LocalException e)
- {
- // Here we ignore any exceptions in close().
- }
- }
-
- synchronized(this)
- {
- _state = StateClosed;
- _acceptor = null;
- _connections = null;
- _threadPerIncomingConnectionFactory = null;
- }
-
- Ice.SyscallException e = new Ice.SyscallException();
- e.initCause(ex);
- throw e;
- }
+ connection.validate();
+ }
+ catch(Ice.LocalException ex)
+ {
+ //
+ // If a connection object was constructed, then
+ // validate() must have raised the exception.
+ //
+ if(connection != null)
+ {
+ connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
+ }
+
+ return;
+ }
+
+ _connections.add(connection);
+ }
+ else
+ {
+ h.value = _endpoint;
+ _acceptor = _endpoint.acceptor(h, adapterName);
+ _endpoint = h.value;
+ assert(_acceptor != null);
+ _acceptor.listen();
+
+ if(_threadPerConnection)
+ {
+ //
+ // If we are in thread per connection mode, we also use
+ // one thread per incoming connection factory, that
+ // accepts new connections on this endpoint.
+ //
+ try
+ {
+ _threadPerIncomingConnectionFactory = new ThreadPerIncomingConnectionFactory();
+ _threadPerIncomingConnectionFactory.start();
+ }
+ catch(java.lang.Exception ex)
+ {
+ error("cannot create thread for incoming connection factory", ex);
+ throw ex;
+ }
+ }
+ }
+ }
+ catch(java.lang.Exception ex)
+ {
+ //
+ // Clean up for finalizer.
+ //
+
+ if(_acceptor != null)
+ {
+ try
+ {
+ _acceptor.close();
+ }
+ catch(Ice.LocalException e)
+ {
+ // Here we ignore any exceptions in close().
+ }
+ }
+
+ synchronized(this)
+ {
+ _state = StateClosed;
+ _acceptor = null;
+ _connections = null;
+ _threadPerIncomingConnectionFactory = null;
+ }
+
+ Ice.SyscallException e = new Ice.SyscallException();
+ e.initCause(ex);
+ throw e;
+ }
}
protected synchronized void
finalize()
throws Throwable
{
- IceUtil.Assert.FinalizerAssert(_state == StateClosed);
- IceUtil.Assert.FinalizerAssert(_acceptor == null);
- IceUtil.Assert.FinalizerAssert(_connections == null);
- IceUtil.Assert.FinalizerAssert(_threadPerIncomingConnectionFactory == null);
+ IceUtil.Assert.FinalizerAssert(_state == StateClosed);
+ IceUtil.Assert.FinalizerAssert(_acceptor == null);
+ IceUtil.Assert.FinalizerAssert(_connections == null);
+ IceUtil.Assert.FinalizerAssert(_threadPerIncomingConnectionFactory == null);
super.finalize();
}
@@ -511,10 +511,10 @@ public final class IncomingConnectionFactory extends EventHandler
{
return;
}
- if(!_threadPerConnection && _acceptor != null)
- {
- registerWithPool();
- }
+ if(!_threadPerConnection && _acceptor != null)
+ {
+ registerWithPool();
+ }
java.util.ListIterator p = _connections.listIterator();
while(p.hasNext())
@@ -531,10 +531,10 @@ public final class IncomingConnectionFactory extends EventHandler
{
return;
}
- if(!_threadPerConnection && _acceptor != null)
- {
- unregisterWithPool();
- }
+ if(!_threadPerConnection && _acceptor != null)
+ {
+ unregisterWithPool();
+ }
java.util.ListIterator p = _connections.listIterator();
while(p.hasNext())
@@ -547,28 +547,28 @@ public final class IncomingConnectionFactory extends EventHandler
case StateClosed:
{
- if(_acceptor != null)
- {
- if(_threadPerConnection)
- {
- //
- // If we are in thread per connection mode, we connect
- // to our own acceptor, which unblocks our thread per
- // incoming connection factory stuck in accept().
- //
- _acceptor.connectToSelf();
- }
- else
- {
- //
- // Otherwise we first must make sure that we are
- // registered, then we unregister, and let finished()
- // do the close.
- //
- registerWithPool();
- unregisterWithPool();
- }
- }
+ if(_acceptor != null)
+ {
+ if(_threadPerConnection)
+ {
+ //
+ // If we are in thread per connection mode, we connect
+ // to our own acceptor, which unblocks our thread per
+ // incoming connection factory stuck in accept().
+ //
+ _acceptor.connectToSelf();
+ }
+ else
+ {
+ //
+ // Otherwise we first must make sure that we are
+ // registered, then we unregister, and let finished()
+ // do the close.
+ //
+ registerWithPool();
+ unregisterWithPool();
+ }
+ }
java.util.ListIterator p = _connections.listIterator();
while(p.hasNext())
@@ -576,38 +576,38 @@ public final class IncomingConnectionFactory extends EventHandler
Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
connection.destroy(Ice.ConnectionI.ObjectAdapterDeactivated);
}
- break;
+ break;
}
}
_state = state;
- notifyAll();
+ notifyAll();
}
private void
registerWithPool()
{
- assert(!_threadPerConnection); // Only for use with a thread pool.
- assert(_acceptor != null);
+ assert(!_threadPerConnection); // Only for use with a thread pool.
+ assert(_acceptor != null);
if(!_registeredWithPool)
- {
- ((Ice.ObjectAdapterI)_adapter).getThreadPool()._register(_acceptor.fd(), this);
- _registeredWithPool = true;
+ {
+ ((Ice.ObjectAdapterI)_adapter).getThreadPool()._register(_acceptor.fd(), this);
+ _registeredWithPool = true;
}
}
private void
unregisterWithPool()
{
- assert(!_threadPerConnection); // Only for use with a thread pool.
- assert(_acceptor != null);
+ assert(!_threadPerConnection); // Only for use with a thread pool.
+ assert(_acceptor != null);
if(_registeredWithPool)
- {
- ((Ice.ObjectAdapterI)_adapter).getThreadPool().unregister(_acceptor.fd());
- _registeredWithPool = false;
- ++_finishedCount; // For each unregistration, finished() is called once.
+ {
+ ((Ice.ObjectAdapterI)_adapter).getThreadPool().unregister(_acceptor.fd());
+ _registeredWithPool = false;
+ ++_finishedCount; // For each unregistration, finished() is called once.
}
}
@@ -625,155 +625,155 @@ public final class IncomingConnectionFactory extends EventHandler
private void
error(String msg, Exception ex)
{
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = msg + ":\n" + toString() + "\n" + sw.toString();
- _instance.initializationData().logger.error(s);
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = msg + ":\n" + toString() + "\n" + sw.toString();
+ _instance.initializationData().logger.error(s);
}
private void
run()
{
- assert(_acceptor != null);
-
- while(true)
- {
- //
- // We must accept new connections outside the thread
- // synchronization, because we use blocking accept.
- //
- Transceiver transceiver = null;
- try
- {
- transceiver = _acceptor.accept(-1);
- }
- catch(Ice.SocketException ex)
- {
- // Do not ignore SocketException in Java.
- throw ex;
- }
- catch(Ice.TimeoutException ex)
- {
- // Ignore timeouts.
- }
- catch(Ice.LocalException ex)
- {
- // Warn about other Ice local exceptions.
- if(_warn)
- {
- warning(ex);
- }
- }
-
- Ice.ConnectionI connection = null;
-
- synchronized(this)
- {
- while(_state == StateHolding)
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- if(_state == StateClosed)
- {
- if(transceiver != null)
- {
- try
- {
- transceiver.close();
- }
- catch(Ice.LocalException ex)
- {
- // Here we ignore any exceptions in close().
- }
- }
-
- try
- {
- _acceptor.close();
- }
- catch(Ice.LocalException ex)
- {
- _acceptor = null;
- notifyAll();
- throw ex;
- }
-
- _acceptor = null;
- notifyAll();
- return;
- }
-
- assert(_state == StateActive);
-
- //
- // Reap connections for which destruction has completed.
- //
- java.util.ListIterator p = _connections.listIterator();
- while(p.hasNext())
- {
- Ice.ConnectionI con = (Ice.ConnectionI)p.next();
- if(con.isFinished())
- {
- p.remove();
- }
- }
-
- //
- // Create a connection object for the connection.
- //
- if(transceiver != null)
- {
- try
- {
- connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter,
+ assert(_acceptor != null);
+
+ while(true)
+ {
+ //
+ // We must accept new connections outside the thread
+ // synchronization, because we use blocking accept.
+ //
+ Transceiver transceiver = null;
+ try
+ {
+ transceiver = _acceptor.accept(-1);
+ }
+ catch(Ice.SocketException ex)
+ {
+ // Do not ignore SocketException in Java.
+ throw ex;
+ }
+ catch(Ice.TimeoutException ex)
+ {
+ // Ignore timeouts.
+ }
+ catch(Ice.LocalException ex)
+ {
+ // Warn about other Ice local exceptions.
+ if(_warn)
+ {
+ warning(ex);
+ }
+ }
+
+ Ice.ConnectionI connection = null;
+
+ synchronized(this)
+ {
+ while(_state == StateHolding)
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ if(_state == StateClosed)
+ {
+ if(transceiver != null)
+ {
+ try
+ {
+ transceiver.close();
+ }
+ catch(Ice.LocalException ex)
+ {
+ // Here we ignore any exceptions in close().
+ }
+ }
+
+ try
+ {
+ _acceptor.close();
+ }
+ catch(Ice.LocalException ex)
+ {
+ _acceptor = null;
+ notifyAll();
+ throw ex;
+ }
+
+ _acceptor = null;
+ notifyAll();
+ return;
+ }
+
+ assert(_state == StateActive);
+
+ //
+ // Reap connections for which destruction has completed.
+ //
+ java.util.ListIterator p = _connections.listIterator();
+ while(p.hasNext())
+ {
+ Ice.ConnectionI con = (Ice.ConnectionI)p.next();
+ if(con.isFinished())
+ {
+ p.remove();
+ }
+ }
+
+ //
+ // Create a connection object for the connection.
+ //
+ if(transceiver != null)
+ {
+ try
+ {
+ connection = new Ice.ConnectionI(_instance, transceiver, _endpoint, _adapter,
_threadPerConnection);
- }
- catch(Ice.LocalException ex)
- {
- return;
- }
-
- _connections.add(connection);
- }
- }
-
- //
- // In thread per connection mode, the connection's thread
- // will take care of connection validation and activation
- // (for non-datagram connections). We don't want to block
- // this thread waiting until validation is complete,
- // because in contrast to thread pool mode, it is the only
- // thread that can accept connections with this factory's
- // acceptor. Therefore we don't call validate() and
- // activate() from the connection factory in thread per
- // connection mode.
- //
- }
+ }
+ catch(Ice.LocalException ex)
+ {
+ return;
+ }
+
+ _connections.add(connection);
+ }
+ }
+
+ //
+ // In thread per connection mode, the connection's thread
+ // will take care of connection validation and activation
+ // (for non-datagram connections). We don't want to block
+ // this thread waiting until validation is complete,
+ // because in contrast to thread pool mode, it is the only
+ // thread that can accept connections with this factory's
+ // acceptor. Therefore we don't call validate() and
+ // activate() from the connection factory in thread per
+ // connection mode.
+ //
+ }
}
private class ThreadPerIncomingConnectionFactory extends Thread
{
- public void
- run()
- {
- try
- {
- IncomingConnectionFactory.this.run();
- }
- catch(Exception ex)
- {
- IncomingConnectionFactory.this.error("exception in thread per incoming connection factory", ex);
- }
- }
+ public void
+ run()
+ {
+ try
+ {
+ IncomingConnectionFactory.this.run();
+ }
+ catch(Exception ex)
+ {
+ IncomingConnectionFactory.this.error("exception in thread per incoming connection factory", ex);
+ }
+ }
}
private Thread _threadPerIncomingConnectionFactory;
diff --git a/java/src/IceInternal/IndirectReference.java b/java/src/IceInternal/IndirectReference.java
index 0d118427797..004d63350dc 100644
--- a/java/src/IceInternal/IndirectReference.java
+++ b/java/src/IceInternal/IndirectReference.java
@@ -13,27 +13,27 @@ public class IndirectReference extends RoutableReference
{
public
IndirectReference(Instance inst,
- Ice.Communicator com,
- Ice.Identity ident,
- java.util.Map ctx,
- String fs,
- int md,
- boolean sec,
- boolean prefSec,
- String adptid,
- RouterInfo rtrInfo,
- LocatorInfo locInfo,
- boolean collocationOpt,
+ Ice.Communicator com,
+ Ice.Identity ident,
+ java.util.Map ctx,
+ String fs,
+ int md,
+ boolean sec,
+ boolean prefSec,
+ String adptid,
+ RouterInfo rtrInfo,
+ LocatorInfo locInfo,
+ boolean collocationOpt,
boolean cacheConnection,
Ice.EndpointSelectionType endpointSelection,
boolean threadPerConnection,
- int locatorCacheTimeout)
+ int locatorCacheTimeout)
{
- super(inst, com, ident, ctx, fs, md, sec, prefSec, rtrInfo, collocationOpt, cacheConnection, endpointSelection,
+ super(inst, com, ident, ctx, fs, md, sec, prefSec, rtrInfo, collocationOpt, cacheConnection, endpointSelection,
threadPerConnection);
_adapterId = adptid;
- _locatorInfo = locInfo;
- _locatorCacheTimeout = locatorCacheTimeout;
+ _locatorInfo = locInfo;
+ _locatorCacheTimeout = locatorCacheTimeout;
}
public final LocatorInfo
@@ -57,217 +57,217 @@ public class IndirectReference extends RoutableReference
public int
getLocatorCacheTimeout()
{
- return _locatorCacheTimeout;
+ return _locatorCacheTimeout;
}
public Reference
changeLocator(Ice.LocatorPrx newLocator)
{
- LocatorInfo newLocatorInfo = getInstance().locatorManager().get(newLocator);
- if(_locatorInfo != null && newLocatorInfo != null && newLocatorInfo.equals(_locatorInfo))
- {
- return this;
- }
- IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this);
- r._locatorInfo = newLocatorInfo;
- return r;
+ LocatorInfo newLocatorInfo = getInstance().locatorManager().get(newLocator);
+ if(_locatorInfo != null && newLocatorInfo != null && newLocatorInfo.equals(_locatorInfo))
+ {
+ return this;
+ }
+ IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this);
+ r._locatorInfo = newLocatorInfo;
+ return r;
}
public Reference
changeAdapterId(String newAdapterId)
{
- if(_adapterId.equals(newAdapterId))
- {
- return this;
- }
+ if(_adapterId.equals(newAdapterId))
+ {
+ return this;
+ }
IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this);
- r._adapterId = newAdapterId;
- return r;
+ r._adapterId = newAdapterId;
+ return r;
}
public Reference
changeEndpoints(EndpointI[] newEndpoints)
{
- if(newEndpoints == null || newEndpoints.length == 0)
- {
- return this;
- }
- return getInstance().referenceFactory().create(getIdentity(), getContext(), getFacet(), getMode(),
- getSecure(), getPreferSecure(), newEndpoints, getRouterInfo(),
- getCollocationOptimization(), getCacheConnection(),
+ if(newEndpoints == null || newEndpoints.length == 0)
+ {
+ return this;
+ }
+ return getInstance().referenceFactory().create(getIdentity(), getContext(), getFacet(), getMode(),
+ getSecure(), getPreferSecure(), newEndpoints, getRouterInfo(),
+ getCollocationOptimization(), getCacheConnection(),
getEndpointSelection(), getThreadPerConnection());
}
public Reference
changeLocatorCacheTimeout(int newTimeout)
{
- if(_locatorCacheTimeout == newTimeout)
- {
- return this;
- }
+ if(_locatorCacheTimeout == newTimeout)
+ {
+ return this;
+ }
IndirectReference r = (IndirectReference)getInstance().referenceFactory().copy(this);
- r._locatorCacheTimeout = newTimeout;
- return r;
+ r._locatorCacheTimeout = newTimeout;
+ return r;
}
public void
streamWrite(BasicStream s)
- throws Ice.MarshalException
+ throws Ice.MarshalException
{
super.streamWrite(s);
- s.writeSize(0);
- s.writeString(_adapterId);
+ s.writeSize(0);
+ s.writeString(_adapterId);
}
public String
toString()
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
+ //
+ // WARNING: Certain features, such as proxy validation in Glacier2,
+ // depend on the format of proxy strings. Changes to toString() and
+ // methods called to generate parts of the reference string could break
+ // these features. Please review for all features that depend on the
+ // format of proxyToString() before changing this and related code.
+ //
String result = super.toString();
- if(_adapterId.length() == 0)
- {
- return result;
- }
+ if(_adapterId.length() == 0)
+ {
+ return result;
+ }
- StringBuffer s = new StringBuffer();
- s.append(result);
- s.append(" @ ");
+ StringBuffer s = new StringBuffer();
+ s.append(result);
+ s.append(" @ ");
- //
- // If the encoded adapter id string contains characters which
- // the reference parser uses as separators, then we enclose
- // the adapter id string in quotes.
- //
- String a = IceUtil.StringUtil.escapeString(_adapterId, null);
- if(IceUtil.StringUtil.findFirstOf(a, " \t\n\r") != -1)
- {
- s.append('"');
- s.append(a);
- s.append('"');
- }
- else
- {
- s.append(a);
- }
- return s.toString();
+ //
+ // If the encoded adapter id string contains characters which
+ // the reference parser uses as separators, then we enclose
+ // the adapter id string in quotes.
+ //
+ String a = IceUtil.StringUtil.escapeString(_adapterId, null);
+ if(IceUtil.StringUtil.findFirstOf(a, " \t\n\r") != -1)
+ {
+ s.append('"');
+ s.append(a);
+ s.append('"');
+ }
+ else
+ {
+ s.append(a);
+ }
+ return s.toString();
}
public Ice.ConnectionI
getConnection(Ice.BooleanHolder comp)
{
- Ice.ConnectionI connection;
+ Ice.ConnectionI connection;
- while(true)
- {
- EndpointI[] endpts = super.getRoutedEndpoints();
- Ice.BooleanHolder cached = new Ice.BooleanHolder(false);
- if(endpts.length == 0 && _locatorInfo != null)
- {
- endpts = _locatorInfo.getEndpoints(this, _locatorCacheTimeout, cached);
- }
+ while(true)
+ {
+ EndpointI[] endpts = super.getRoutedEndpoints();
+ Ice.BooleanHolder cached = new Ice.BooleanHolder(false);
+ if(endpts.length == 0 && _locatorInfo != null)
+ {
+ endpts = _locatorInfo.getEndpoints(this, _locatorCacheTimeout, cached);
+ }
- applyOverrides(endpts);
+ applyOverrides(endpts);
- try
- {
- connection = createConnection(endpts, comp);
- assert(connection != null);
- }
- catch(Ice.NoEndpointException ex)
- {
- throw ex; // No need to retry if there's no endpoints.
- }
- catch(Ice.LocalException ex)
- {
- if(getRouterInfo() == null)
- {
- assert(_locatorInfo != null);
- _locatorInfo.clearCache(this);
+ try
+ {
+ connection = createConnection(endpts, comp);
+ assert(connection != null);
+ }
+ catch(Ice.NoEndpointException ex)
+ {
+ throw ex; // No need to retry if there's no endpoints.
+ }
+ catch(Ice.LocalException ex)
+ {
+ if(getRouterInfo() == null)
+ {
+ assert(_locatorInfo != null);
+ _locatorInfo.clearCache(this);
- if(cached.value)
- {
- TraceLevels traceLevels = getInstance().traceLevels();
-
- if(traceLevels.retry >= 2)
- {
- String s = "connection to cached endpoints failed\n" +
- "removing endpoints from cache and trying one more time\n" + ex;
- getInstance().initializationData().logger.trace(traceLevels.retryCat, s);
- }
-
- continue;
- }
- }
+ if(cached.value)
+ {
+ TraceLevels traceLevels = getInstance().traceLevels();
+
+ if(traceLevels.retry >= 2)
+ {
+ String s = "connection to cached endpoints failed\n" +
+ "removing endpoints from cache and trying one more time\n" + ex;
+ getInstance().initializationData().logger.trace(traceLevels.retryCat, s);
+ }
+
+ continue;
+ }
+ }
- throw ex;
- }
+ throw ex;
+ }
- break;
- }
+ break;
+ }
- //
- // If we have a router, set the object adapter for this router
- // (if any) to the new connection, so that callbacks from the
- // router can be received over this new connection.
- //
- if(getRouterInfo() != null)
- {
- connection.setAdapter(getRouterInfo().getAdapter());
- }
+ //
+ // If we have a router, set the object adapter for this router
+ // (if any) to the new connection, so that callbacks from the
+ // router can be received over this new connection.
+ //
+ if(getRouterInfo() != null)
+ {
+ connection.setAdapter(getRouterInfo().getAdapter());
+ }
- assert(connection != null);
- return connection;
+ assert(connection != null);
+ return connection;
}
public synchronized int
hashCode()
{
if(_hashInitialized)
- {
- return _hashValue;
- }
- super.hashCode(); // Initializes _hashValue.
- int sz = _adapterId.length(); // Add hash of adapter ID to base hash.
- for(int i = 0; i < sz; i++)
- {
- _hashValue = 5 * _hashValue + (int)_adapterId.charAt(i);
- }
- return _hashValue;
+ {
+ return _hashValue;
+ }
+ super.hashCode(); // Initializes _hashValue.
+ int sz = _adapterId.length(); // Add hash of adapter ID to base hash.
+ for(int i = 0; i < sz; i++)
+ {
+ _hashValue = 5 * _hashValue + (int)_adapterId.charAt(i);
+ }
+ return _hashValue;
}
public boolean
equals(java.lang.Object obj)
{
if(this == obj)
- {
- return true;
- }
- if(!(obj instanceof IndirectReference))
- {
- return false;
- }
+ {
+ return true;
+ }
+ if(!(obj instanceof IndirectReference))
+ {
+ return false;
+ }
IndirectReference rhs = (IndirectReference)obj;
if(!super.equals(rhs))
{
return false;
}
- if(!_adapterId.equals(rhs._adapterId))
- {
- return false;
- }
- if(_locatorInfo == null ? rhs._locatorInfo != null : !_locatorInfo.equals(rhs._locatorInfo))
- {
- return false;
- }
- return _locatorCacheTimeout == rhs._locatorCacheTimeout;
+ if(!_adapterId.equals(rhs._adapterId))
+ {
+ return false;
+ }
+ if(_locatorInfo == null ? rhs._locatorInfo != null : !_locatorInfo.equals(rhs._locatorInfo))
+ {
+ return false;
+ }
+ return _locatorCacheTimeout == rhs._locatorCacheTimeout;
}
private String _adapterId;
diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java
index dc27bf0e7f9..da3c96dfc0f 100644
--- a/java/src/IceInternal/Instance.java
+++ b/java/src/IceInternal/Instance.java
@@ -14,36 +14,36 @@ public final class Instance
public Ice.InitializationData
initializationData()
{
- //
- // No check for destruction. It must be possible to access the
- // initialization data after destruction.
- //
- // No mutex lock, immutable.
- //
+ //
+ // No check for destruction. It must be possible to access the
+ // initialization data after destruction.
+ //
+ // No mutex lock, immutable.
+ //
return _initData;
}
public TraceLevels
traceLevels()
{
- // No mutex lock, immutable.
+ // No mutex lock, immutable.
return _traceLevels;
}
public DefaultsAndOverrides
defaultsAndOverrides()
{
- // No mutex lock, immutable.
+ // No mutex lock, immutable.
return _defaultsAndOverrides;
}
public synchronized RouterManager
routerManager()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _routerManager;
}
@@ -51,10 +51,10 @@ public final class Instance
public synchronized LocatorManager
locatorManager()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _locatorManager;
}
@@ -62,10 +62,10 @@ public final class Instance
public synchronized ReferenceFactory
referenceFactory()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _referenceFactory;
}
@@ -73,10 +73,10 @@ public final class Instance
public synchronized ProxyFactory
proxyFactory()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _proxyFactory;
}
@@ -84,10 +84,10 @@ public final class Instance
public synchronized OutgoingConnectionFactory
outgoingConnectionFactory()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _outgoingConnectionFactory;
}
@@ -95,10 +95,10 @@ public final class Instance
public synchronized ConnectionMonitor
connectionMonitor()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _connectionMonitor;
}
@@ -106,10 +106,10 @@ public final class Instance
public synchronized ObjectFactoryManager
servantFactoryManager()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _servantFactoryManager;
}
@@ -117,10 +117,10 @@ public final class Instance
public synchronized ObjectAdapterFactory
objectAdapterFactory()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _objectAdapterFactory;
}
@@ -128,14 +128,14 @@ public final class Instance
public synchronized ThreadPool
clientThreadPool()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
-
- if(_clientThreadPool == null) // Lazy initialization.
- {
- _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
+
+ if(_clientThreadPool == null) // Lazy initialization.
+ {
+ _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);
}
return _clientThreadPool;
@@ -144,16 +144,16 @@ public final class Instance
public synchronized ThreadPool
serverThreadPool()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
-
- if(_serverThreadPool == null) // Lazy initialization.
- {
- int timeout = _initData.properties.getPropertyAsInt("Ice.ServerIdleTime");
- _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
+
+ if(_serverThreadPool == null) // Lazy initialization.
+ {
+ int timeout = _initData.properties.getPropertyAsInt("Ice.ServerIdleTime");
+ _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
+ }
return _serverThreadPool;
}
@@ -161,22 +161,22 @@ public final class Instance
public boolean
threadPerConnection()
{
- return _threadPerConnection;
+ return _threadPerConnection;
}
public int
threadPerConnectionStackSize()
{
- return _threadPerConnectionStackSize;
+ return _threadPerConnectionStackSize;
}
public synchronized EndpointFactoryManager
endpointFactoryManager()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _endpointFactoryManager;
}
@@ -184,10 +184,10 @@ public final class Instance
public synchronized Ice.PluginManager
pluginManager()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return _pluginManager;
}
@@ -196,48 +196,48 @@ public final class Instance
messageSizeMax()
{
// No mutex lock, immutable.
- return _messageSizeMax;
+ return _messageSizeMax;
}
public int
clientACM()
{
- // No mutex lock, immutable.
- return _clientACM;
+ // No mutex lock, immutable.
+ return _clientACM;
}
public int
serverACM()
{
- // No mutex lock, immutable.
- return _serverACM;
+ // No mutex lock, immutable.
+ return _serverACM;
}
public synchronized void
setDefaultContext(java.util.Map ctx)
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
-
- if(ctx == null || ctx.isEmpty())
- {
- _defaultContext = _emptyContext;
- }
- else
- {
- _defaultContext = new java.util.HashMap(ctx);
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
+
+ if(ctx == null || ctx.isEmpty())
+ {
+ _defaultContext = _emptyContext;
+ }
+ else
+ {
+ _defaultContext = new java.util.HashMap(ctx);
+ }
}
public synchronized java.util.Map
getDefaultContext()
{
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
return new java.util.HashMap(_defaultContext);
}
@@ -245,29 +245,29 @@ public final class Instance
public Ice.ImplicitContextI
getImplicitContext()
{
- return _implicitContext;
+ return _implicitContext;
}
public void
flushBatchRequests()
{
- OutgoingConnectionFactory connectionFactory;
- ObjectAdapterFactory adapterFactory;
-
- synchronized(this)
- {
- if(_state == StateDestroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
-
- connectionFactory = _outgoingConnectionFactory;
- adapterFactory = _objectAdapterFactory;
- }
-
- connectionFactory.flushBatchRequests();
- adapterFactory.flushBatchRequests();
+ OutgoingConnectionFactory connectionFactory;
+ ObjectAdapterFactory adapterFactory;
+
+ synchronized(this)
+ {
+ if(_state == StateDestroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
+
+ connectionFactory = _outgoingConnectionFactory;
+ adapterFactory = _objectAdapterFactory;
+ }
+
+ connectionFactory.flushBatchRequests();
+ adapterFactory.flushBatchRequests();
}
public Ice.Identity
@@ -289,88 +289,88 @@ public final class Instance
Instance(Ice.Communicator communicator, Ice.InitializationData initData)
{
_state = StateActive;
- _initData = initData;
+ _initData = initData;
try
{
- if(_initData.properties == null)
- {
- _initData.properties = Ice.Util.createProperties();
- }
-
- synchronized(Instance.class)
- {
- if(!_oneOffDone)
- {
- String stdOut = _initData.properties.getProperty("Ice.StdOut");
- String stdErr = _initData.properties.getProperty("Ice.StdErr");
-
- java.io.PrintStream outStream = null;
-
- if(stdOut.length() > 0)
- {
- //
- // We need to close the existing stdout for JVM thread dump to go
- // to the new file
- //
- System.out.close();
-
- try
- {
- outStream = new java.io.PrintStream(new java.io.FileOutputStream(stdOut, true));
- }
- catch(java.io.FileNotFoundException ex)
- {
- Ice.FileException fe = new Ice.FileException();
- fe.path = stdOut;
- fe.initCause(ex);
- throw fe;
- }
-
- System.setOut(outStream);
- }
- if(stdErr.length() > 0)
- {
- //
- // close for consistency with stdout
- //
- System.err.close();
-
- if(stdErr.equals(stdOut))
- {
- System.setErr(outStream);
- }
- else
- {
- try
- {
- System.setErr(new java.io.PrintStream(new java.io.FileOutputStream(stdErr, true)));
- }
- catch(java.io.FileNotFoundException ex)
- {
- Ice.FileException fe = new Ice.FileException();
- fe.path = stdErr;
- fe.initCause(ex);
- throw fe;
- }
-
- }
- }
- _oneOffDone = true;
- }
- }
-
- if(_initData.logger == null)
- {
- if(_initData.properties.getPropertyAsInt("Ice.UseSyslog") > 0)
- {
- _initData.logger = new Ice.SysLoggerI(_initData.properties.getProperty("Ice.ProgramName"));
- }
- else
- {
- _initData.logger = Ice.Util.getProcessLogger();
- }
- }
+ if(_initData.properties == null)
+ {
+ _initData.properties = Ice.Util.createProperties();
+ }
+
+ synchronized(Instance.class)
+ {
+ if(!_oneOffDone)
+ {
+ String stdOut = _initData.properties.getProperty("Ice.StdOut");
+ String stdErr = _initData.properties.getProperty("Ice.StdErr");
+
+ java.io.PrintStream outStream = null;
+
+ if(stdOut.length() > 0)
+ {
+ //
+ // We need to close the existing stdout for JVM thread dump to go
+ // to the new file
+ //
+ System.out.close();
+
+ try
+ {
+ outStream = new java.io.PrintStream(new java.io.FileOutputStream(stdOut, true));
+ }
+ catch(java.io.FileNotFoundException ex)
+ {
+ Ice.FileException fe = new Ice.FileException();
+ fe.path = stdOut;
+ fe.initCause(ex);
+ throw fe;
+ }
+
+ System.setOut(outStream);
+ }
+ if(stdErr.length() > 0)
+ {
+ //
+ // close for consistency with stdout
+ //
+ System.err.close();
+
+ if(stdErr.equals(stdOut))
+ {
+ System.setErr(outStream);
+ }
+ else
+ {
+ try
+ {
+ System.setErr(new java.io.PrintStream(new java.io.FileOutputStream(stdErr, true)));
+ }
+ catch(java.io.FileNotFoundException ex)
+ {
+ Ice.FileException fe = new Ice.FileException();
+ fe.path = stdErr;
+ fe.initCause(ex);
+ throw fe;
+ }
+
+ }
+ }
+ _oneOffDone = true;
+ }
+ }
+
+ if(_initData.logger == null)
+ {
+ if(_initData.properties.getPropertyAsInt("Ice.UseSyslog") > 0)
+ {
+ _initData.logger = new Ice.SysLoggerI(_initData.properties.getProperty("Ice.ProgramName"));
+ }
+ else
+ {
+ _initData.logger = Ice.Util.getProcessLogger();
+ }
+ }
validatePackages();
@@ -378,43 +378,43 @@ public final class Instance
_defaultsAndOverrides = new DefaultsAndOverrides(_initData.properties);
- {
- final int defaultMessageSizeMax = 1024;
- int num = _initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
- if(num < 1)
- {
- _messageSizeMax = defaultMessageSizeMax * 1024; // Ignore stupid values.
- }
- else if(num > 0x7fffffff / 1024)
- {
- _messageSizeMax = 0x7fffffff;
- }
- else
- {
- _messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes
- }
- }
-
- //
- // Client ACM enabled by default. Server ACM disabled by default.
- //
- _clientACM = _initData.properties.getPropertyAsIntWithDefault("Ice.ACM.Client", 60);
- _serverACM = _initData.properties.getPropertyAsInt("Ice.ACM.Server");
-
- _implicitContext = Ice.ImplicitContextI.create(
- _initData.properties.getProperty("Ice.ImplicitContext"));
-
-
- _threadPerConnection = _initData.properties.getPropertyAsInt("Ice.ThreadPerConnection") > 0;
-
- {
- int stackSize = _initData.properties.getPropertyAsInt("Ice.ThreadPerConnection.StackSize");
- if(stackSize < 0)
- {
- stackSize = 0;
- }
- _threadPerConnectionStackSize = stackSize;
- }
+ {
+ final int defaultMessageSizeMax = 1024;
+ int num = _initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
+ if(num < 1)
+ {
+ _messageSizeMax = defaultMessageSizeMax * 1024; // Ignore stupid values.
+ }
+ else if(num > 0x7fffffff / 1024)
+ {
+ _messageSizeMax = 0x7fffffff;
+ }
+ else
+ {
+ _messageSizeMax = num * 1024; // Property is in kilobytes, _messageSizeMax in bytes
+ }
+ }
+
+ //
+ // Client ACM enabled by default. Server ACM disabled by default.
+ //
+ _clientACM = _initData.properties.getPropertyAsIntWithDefault("Ice.ACM.Client", 60);
+ _serverACM = _initData.properties.getPropertyAsInt("Ice.ACM.Server");
+
+ _implicitContext = Ice.ImplicitContextI.create(
+ _initData.properties.getProperty("Ice.ImplicitContext"));
+
+
+ _threadPerConnection = _initData.properties.getPropertyAsInt("Ice.ThreadPerConnection") > 0;
+
+ {
+ int stackSize = _initData.properties.getPropertyAsInt("Ice.ThreadPerConnection.StackSize");
+ if(stackSize < 0)
+ {
+ stackSize = 0;
+ }
+ _threadPerConnectionStackSize = stackSize;
+ }
_routerManager = new RouterManager();
@@ -431,9 +431,9 @@ public final class Instance
_endpointFactoryManager.add(udpEndpointFactory);
_pluginManager = new Ice.PluginManagerI(communicator);
-
- _defaultContext = _emptyContext;
-
+
+ _defaultContext = _emptyContext;
+
_outgoingConnectionFactory = new OutgoingConnectionFactory(this);
_servantFactoryManager = new ObjectFactoryManager();
@@ -451,19 +451,19 @@ public final class Instance
finalize()
throws Throwable
{
- IceUtil.Assert.FinalizerAssert(_state == StateDestroyed);
- IceUtil.Assert.FinalizerAssert(_referenceFactory == null);
- IceUtil.Assert.FinalizerAssert(_proxyFactory == null);
- IceUtil.Assert.FinalizerAssert(_outgoingConnectionFactory == null);
- IceUtil.Assert.FinalizerAssert(_connectionMonitor == null);
- IceUtil.Assert.FinalizerAssert(_servantFactoryManager == null);
- IceUtil.Assert.FinalizerAssert(_objectAdapterFactory == null);
- IceUtil.Assert.FinalizerAssert(_clientThreadPool == null);
- IceUtil.Assert.FinalizerAssert(_serverThreadPool == null);
- IceUtil.Assert.FinalizerAssert(_routerManager == null);
- IceUtil.Assert.FinalizerAssert(_locatorManager == null);
- IceUtil.Assert.FinalizerAssert(_endpointFactoryManager == null);
- IceUtil.Assert.FinalizerAssert(_pluginManager == null);
+ IceUtil.Assert.FinalizerAssert(_state == StateDestroyed);
+ IceUtil.Assert.FinalizerAssert(_referenceFactory == null);
+ IceUtil.Assert.FinalizerAssert(_proxyFactory == null);
+ IceUtil.Assert.FinalizerAssert(_outgoingConnectionFactory == null);
+ IceUtil.Assert.FinalizerAssert(_connectionMonitor == null);
+ IceUtil.Assert.FinalizerAssert(_servantFactoryManager == null);
+ IceUtil.Assert.FinalizerAssert(_objectAdapterFactory == null);
+ IceUtil.Assert.FinalizerAssert(_clientThreadPool == null);
+ IceUtil.Assert.FinalizerAssert(_serverThreadPool == null);
+ IceUtil.Assert.FinalizerAssert(_routerManager == null);
+ IceUtil.Assert.FinalizerAssert(_locatorManager == null);
+ IceUtil.Assert.FinalizerAssert(_endpointFactoryManager == null);
+ IceUtil.Assert.FinalizerAssert(_pluginManager == null);
super.finalize();
}
@@ -474,53 +474,53 @@ public final class Instance
//
// Load plug-ins.
//
- Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI)_pluginManager;
+ Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI)_pluginManager;
pluginManagerImpl.loadPlugins(args);
- Ice.Logger logger = pluginManagerImpl.getLogger();
- if(logger != null)
- {
- _initData.logger = logger;
- }
-
- //
- // Get default router and locator proxies. Don't move this
- // initialization before the plug-in initialization!!! The proxies
- // might depend on endpoint factories to be installed by plug-ins.
- //
- _referenceFactory.setDefaultRouter(Ice.RouterPrxHelper.uncheckedCast(
- _proxyFactory.propertyToProxy("Ice.Default.Router")));
-
- _referenceFactory.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(
- _proxyFactory.propertyToProxy("Ice.Default.Locator")));
-
- //
- // Start connection monitor if necessary.
- //
- int interval = 0;
- if(_clientACM > 0 && _serverACM > 0)
- {
- if(_clientACM < _serverACM)
- {
- interval = _clientACM;
- }
- else
- {
- interval = _serverACM;
- }
- }
- else if(_clientACM > 0)
- {
- interval = _clientACM;
- }
- else if(_serverACM > 0)
- {
- interval = _serverACM;
- }
- interval = _initData.properties.getPropertyAsIntWithDefault("Ice.MonitorConnections", interval);
- if(interval > 0)
- {
- _connectionMonitor = new ConnectionMonitor(this, interval);
- }
+ Ice.Logger logger = pluginManagerImpl.getLogger();
+ if(logger != null)
+ {
+ _initData.logger = logger;
+ }
+
+ //
+ // Get default router and locator proxies. Don't move this
+ // initialization before the plug-in initialization!!! The proxies
+ // might depend on endpoint factories to be installed by plug-ins.
+ //
+ _referenceFactory.setDefaultRouter(Ice.RouterPrxHelper.uncheckedCast(
+ _proxyFactory.propertyToProxy("Ice.Default.Router")));
+
+ _referenceFactory.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(
+ _proxyFactory.propertyToProxy("Ice.Default.Locator")));
+
+ //
+ // Start connection monitor if necessary.
+ //
+ int interval = 0;
+ if(_clientACM > 0 && _serverACM > 0)
+ {
+ if(_clientACM < _serverACM)
+ {
+ interval = _clientACM;
+ }
+ else
+ {
+ interval = _serverACM;
+ }
+ }
+ else if(_clientACM > 0)
+ {
+ interval = _clientACM;
+ }
+ else if(_serverACM > 0)
+ {
+ interval = _serverACM;
+ }
+ interval = _initData.properties.getPropertyAsIntWithDefault("Ice.MonitorConnections", interval);
+ if(interval > 0)
+ {
+ _connectionMonitor = new ConnectionMonitor(this, interval);
+ }
//
// Thread pool initialization is now lazy initialization in
@@ -534,25 +534,25 @@ public final class Instance
public void
destroy()
{
- synchronized(this)
- {
- //
- // If the _state is not StateActive then the instance is
- // either being destroyed, or has already been destroyed.
- //
- if(_state != StateActive)
- {
- return;
- }
-
- //
- // We cannot set state to StateDestroyed otherwise instance
- // methods called during the destroy process (such as
- // outgoingConnectionFactory() from
- // ObjectAdapterI::deactivate() will cause an exception.
- //
- _state = StateDestroyInProgress;
- }
+ synchronized(this)
+ {
+ //
+ // If the _state is not StateActive then the instance is
+ // either being destroyed, or has already been destroyed.
+ //
+ if(_state != StateActive)
+ {
+ return;
+ }
+
+ //
+ // We cannot set state to StateDestroyed otherwise instance
+ // methods called during the destroy process (such as
+ // outgoingConnectionFactory() from
+ // ObjectAdapterI::deactivate() will cause an exception.
+ //
+ _state = StateDestroyInProgress;
+ }
if(_objectAdapterFactory != null)
{
@@ -568,40 +568,40 @@ public final class Instance
{
_objectAdapterFactory.destroy();
}
-
+
if(_outgoingConnectionFactory != null)
{
_outgoingConnectionFactory.waitUntilFinished();
}
-
- ThreadPool serverThreadPool = null;
- ThreadPool clientThreadPool = null;
+
+ ThreadPool serverThreadPool = null;
+ ThreadPool clientThreadPool = null;
- synchronized(this)
- {
- _objectAdapterFactory = null;
+ synchronized(this)
+ {
+ _objectAdapterFactory = null;
- _outgoingConnectionFactory = null;
+ _outgoingConnectionFactory = null;
- if(_connectionMonitor != null)
- {
- _connectionMonitor._destroy();
- _connectionMonitor = null;
- }
+ if(_connectionMonitor != null)
+ {
+ _connectionMonitor._destroy();
+ _connectionMonitor = null;
+ }
- if(_serverThreadPool != null)
- {
- _serverThreadPool.destroy();
- serverThreadPool = _serverThreadPool;
- _serverThreadPool = null;
- }
+ if(_serverThreadPool != null)
+ {
+ _serverThreadPool.destroy();
+ serverThreadPool = _serverThreadPool;
+ _serverThreadPool = null;
+ }
- if(_clientThreadPool != null)
- {
- _clientThreadPool.destroy();
- clientThreadPool = _clientThreadPool;
- _clientThreadPool = null;
- }
+ if(_clientThreadPool != null)
+ {
+ _clientThreadPool.destroy();
+ clientThreadPool = _clientThreadPool;
+ _clientThreadPool = null;
+ }
if(_servantFactoryManager != null)
{
@@ -614,10 +614,10 @@ public final class Instance
_referenceFactory.destroy();
_referenceFactory = null;
}
-
- // No destroy function defined.
- // _proxyFactory.destroy();
- _proxyFactory = null;
+
+ // No destroy function defined.
+ // _proxyFactory.destroy();
+ _proxyFactory = null;
if(_routerManager != null)
{
@@ -642,22 +642,22 @@ public final class Instance
_pluginManager.destroy();
_pluginManager = null;
}
-
- _state = StateDestroyed;
- }
-
- //
- // Join with the thread pool threads outside the
- // synchronization.
- //
- if(clientThreadPool != null)
- {
- clientThreadPool.joinWithAllThreads();
- }
- if(serverThreadPool != null)
- {
- serverThreadPool.joinWithAllThreads();
- }
+
+ _state = StateDestroyed;
+ }
+
+ //
+ // Join with the thread pool threads outside the
+ // synchronization.
+ //
+ if(clientThreadPool != null)
+ {
+ clientThreadPool.joinWithAllThreads();
+ }
+ if(serverThreadPool != null)
+ {
+ serverThreadPool.joinWithAllThreads();
+ }
}
private void
diff --git a/java/src/IceInternal/LocalExceptionWrapper.java b/java/src/IceInternal/LocalExceptionWrapper.java
index 328d8775c42..8c9fbf976c6 100644
--- a/java/src/IceInternal/LocalExceptionWrapper.java
+++ b/java/src/IceInternal/LocalExceptionWrapper.java
@@ -15,14 +15,14 @@ public class LocalExceptionWrapper extends Exception
LocalExceptionWrapper(Ice.LocalException ex, boolean retry)
{
_ex = ex;
- _retry = retry;
+ _retry = retry;
}
public
LocalExceptionWrapper(IceInternal.LocalExceptionWrapper ex)
{
_ex = ex.get();
- _retry = ex._retry;
+ _retry = ex._retry;
}
public Ice.LocalException
diff --git a/java/src/IceInternal/LocatorInfo.java b/java/src/IceInternal/LocatorInfo.java
index 4f84ab70ef9..0d54d87555a 100644
--- a/java/src/IceInternal/LocatorInfo.java
+++ b/java/src/IceInternal/LocatorInfo.java
@@ -13,330 +13,330 @@ public final class LocatorInfo
{
LocatorInfo(Ice.LocatorPrx locator, LocatorTable table)
{
- _locator = locator;
- _table = table;
+ _locator = locator;
+ _table = table;
}
synchronized public void
destroy()
{
- _locatorRegistry = null;
- _table.clear();
+ _locatorRegistry = null;
+ _table.clear();
}
public boolean
equals(java.lang.Object obj)
{
- if(this == obj)
- {
- return true;
- }
+ if(this == obj)
+ {
+ return true;
+ }
- if(obj instanceof LocatorInfo)
- {
- return _locator.equals(((LocatorInfo)obj)._locator);
- }
+ if(obj instanceof LocatorInfo)
+ {
+ return _locator.equals(((LocatorInfo)obj)._locator);
+ }
- return false;
+ return false;
}
public Ice.LocatorPrx
getLocator()
{
- //
- // No synchronization necessary, _locator is immutable.
- //
- return _locator;
+ //
+ // No synchronization necessary, _locator is immutable.
+ //
+ return _locator;
}
public synchronized Ice.LocatorRegistryPrx
getLocatorRegistry()
{
- if(_locatorRegistry == null) // Lazy initialization
- {
- _locatorRegistry = _locator.getRegistry();
+ if(_locatorRegistry == null) // Lazy initialization
+ {
+ _locatorRegistry = _locator.getRegistry();
- //
- // The locator registry can't be located.
- //
- _locatorRegistry = Ice.LocatorRegistryPrxHelper.uncheckedCast(_locatorRegistry.ice_locator(null));
- }
-
- return _locatorRegistry;
+ //
+ // The locator registry can't be located.
+ //
+ _locatorRegistry = Ice.LocatorRegistryPrxHelper.uncheckedCast(_locatorRegistry.ice_locator(null));
+ }
+
+ return _locatorRegistry;
}
public EndpointI[]
getEndpoints(IndirectReference ref, int ttl, Ice.BooleanHolder cached)
{
- EndpointI[] endpoints = null;
- Ice.ObjectPrx object = null;
- cached.value = true;
- String adapterId = ref.getAdapterId();
- Ice.Identity identity = ref.getIdentity();
-
- try
- {
- if(adapterId.length() > 0)
- {
- endpoints = _table.getAdapterEndpoints(adapterId, ttl);
- if(endpoints == null)
- {
- cached.value = false;
-
- if(ref.getInstance().traceLevels().location >= 1)
- {
- StringBuffer s = new StringBuffer();
- s.append("searching for adapter by id\n");
- s.append("adapter = " + adapterId);
- ref.getInstance().initializationData().logger.trace(
- ref.getInstance().traceLevels().locationCat, s.toString());
- }
+ EndpointI[] endpoints = null;
+ Ice.ObjectPrx object = null;
+ cached.value = true;
+ String adapterId = ref.getAdapterId();
+ Ice.Identity identity = ref.getIdentity();
+
+ try
+ {
+ if(adapterId.length() > 0)
+ {
+ endpoints = _table.getAdapterEndpoints(adapterId, ttl);
+ if(endpoints == null)
+ {
+ cached.value = false;
+
+ if(ref.getInstance().traceLevels().location >= 1)
+ {
+ StringBuffer s = new StringBuffer();
+ s.append("searching for adapter by id\n");
+ s.append("adapter = " + adapterId);
+ ref.getInstance().initializationData().logger.trace(
+ ref.getInstance().traceLevels().locationCat, s.toString());
+ }
- //
- // Search the adapter in the location service if we didn't
- // find it in the cache.
- //
- object = _locator.findAdapterById(adapterId);
- if(object != null)
- {
- endpoints = ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints();
-
- if(endpoints.length > 0)
- {
- _table.addAdapterEndpoints(adapterId, endpoints);
- }
- }
- }
- }
- else
- {
- boolean objectCached = true;
- object = _table.getProxy(identity, ttl);
- if(object == null)
- {
- objectCached = false;
+ //
+ // Search the adapter in the location service if we didn't
+ // find it in the cache.
+ //
+ object = _locator.findAdapterById(adapterId);
+ if(object != null)
+ {
+ endpoints = ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints();
+
+ if(endpoints.length > 0)
+ {
+ _table.addAdapterEndpoints(adapterId, endpoints);
+ }
+ }
+ }
+ }
+ else
+ {
+ boolean objectCached = true;
+ object = _table.getProxy(identity, ttl);
+ if(object == null)
+ {
+ objectCached = false;
- if(ref.getInstance().traceLevels().location >= 1)
- {
- StringBuffer s = new StringBuffer();
- s.append("searching for object by id\n");
- s.append("object = " + ref.getInstance().identityToString(identity));
- ref.getInstance().initializationData().logger.trace(
- ref.getInstance().traceLevels().locationCat, s.toString());
- }
+ if(ref.getInstance().traceLevels().location >= 1)
+ {
+ StringBuffer s = new StringBuffer();
+ s.append("searching for object by id\n");
+ s.append("object = " + ref.getInstance().identityToString(identity));
+ ref.getInstance().initializationData().logger.trace(
+ ref.getInstance().traceLevels().locationCat, s.toString());
+ }
- object = _locator.findObjectById(identity);
- }
-
- boolean endpointsCached = true;
- if(object != null)
- {
- Reference r = ((Ice.ObjectPrxHelperBase)object).__reference();
- if(r instanceof DirectReference)
- {
- endpointsCached = false;
- DirectReference odr = (DirectReference)r;
- endpoints = odr.getEndpoints();
- }
- else
- {
- IndirectReference oir = (IndirectReference)r;
- if(oir.getAdapterId().length() > 0)
- {
- Ice.BooleanHolder c = new Ice.BooleanHolder();
- endpoints = getEndpoints(oir, ttl, c);
- endpointsCached = c.value;
- }
- }
- }
-
- if(!objectCached && endpoints != null && endpoints.length > 0)
- {
- _table.addProxy(identity, object);
- }
+ object = _locator.findObjectById(identity);
+ }
+
+ boolean endpointsCached = true;
+ if(object != null)
+ {
+ Reference r = ((Ice.ObjectPrxHelperBase)object).__reference();
+ if(r instanceof DirectReference)
+ {
+ endpointsCached = false;
+ DirectReference odr = (DirectReference)r;
+ endpoints = odr.getEndpoints();
+ }
+ else
+ {
+ IndirectReference oir = (IndirectReference)r;
+ if(oir.getAdapterId().length() > 0)
+ {
+ Ice.BooleanHolder c = new Ice.BooleanHolder();
+ endpoints = getEndpoints(oir, ttl, c);
+ endpointsCached = c.value;
+ }
+ }
+ }
+
+ if(!objectCached && endpoints != null && endpoints.length > 0)
+ {
+ _table.addProxy(identity, object);
+ }
- cached.value = objectCached || endpointsCached;
- }
- }
- catch(Ice.AdapterNotFoundException ex)
- {
- if(ref.getInstance().traceLevels().location >= 1)
- {
- StringBuffer s = new StringBuffer();
- s.append("adapter not found\n");
- s.append("adapter = " + adapterId);
- ref.getInstance().initializationData().logger.trace(
- ref.getInstance().traceLevels().locationCat, s.toString());
- }
+ cached.value = objectCached || endpointsCached;
+ }
+ }
+ catch(Ice.AdapterNotFoundException ex)
+ {
+ if(ref.getInstance().traceLevels().location >= 1)
+ {
+ StringBuffer s = new StringBuffer();
+ s.append("adapter not found\n");
+ s.append("adapter = " + adapterId);
+ ref.getInstance().initializationData().logger.trace(
+ ref.getInstance().traceLevels().locationCat, s.toString());
+ }
- Ice.NotRegisteredException e = new Ice.NotRegisteredException();
- e.kindOfObject = "object adapter";
- e.id = adapterId;
- throw e;
- }
- catch(Ice.ObjectNotFoundException ex)
- {
- if(ref.getInstance().traceLevels().location >= 1)
- {
- StringBuffer s = new StringBuffer();
- s.append("object not found\n");
- s.append("object = " + ref.getInstance().identityToString(identity));
- ref.getInstance().initializationData().logger.trace(
- ref.getInstance().traceLevels().locationCat, s.toString());
- }
+ Ice.NotRegisteredException e = new Ice.NotRegisteredException();
+ e.kindOfObject = "object adapter";
+ e.id = adapterId;
+ throw e;
+ }
+ catch(Ice.ObjectNotFoundException ex)
+ {
+ if(ref.getInstance().traceLevels().location >= 1)
+ {
+ StringBuffer s = new StringBuffer();
+ s.append("object not found\n");
+ s.append("object = " + ref.getInstance().identityToString(identity));
+ ref.getInstance().initializationData().logger.trace(
+ ref.getInstance().traceLevels().locationCat, s.toString());
+ }
- Ice.NotRegisteredException e = new Ice.NotRegisteredException();
- e.kindOfObject = "object";
- e.id = ref.getInstance().identityToString(identity);
- throw e;
- }
- catch(Ice.NotRegisteredException ex)
- {
- throw ex;
- }
- catch(Ice.LocalException ex)
- {
- if(ref.getInstance().traceLevels().location >= 1)
- {
- StringBuffer s = new StringBuffer();
- s.append("couldn't contact the locator to retrieve adapter endpoints\n");
- if(adapterId.length() > 0)
- {
- s.append("adapter = " + adapterId + "\n");
- }
- else
- {
- s.append("object = " + ref.getInstance().identityToString(identity) + "\n");
- }
- s.append("reason = " + ex);
- ref.getInstance().initializationData().logger.trace(
- ref.getInstance().traceLevels().locationCat, s.toString());
- }
- throw ex;
- }
+ Ice.NotRegisteredException e = new Ice.NotRegisteredException();
+ e.kindOfObject = "object";
+ e.id = ref.getInstance().identityToString(identity);
+ throw e;
+ }
+ catch(Ice.NotRegisteredException ex)
+ {
+ throw ex;
+ }
+ catch(Ice.LocalException ex)
+ {
+ if(ref.getInstance().traceLevels().location >= 1)
+ {
+ StringBuffer s = new StringBuffer();
+ s.append("couldn't contact the locator to retrieve adapter endpoints\n");
+ if(adapterId.length() > 0)
+ {
+ s.append("adapter = " + adapterId + "\n");
+ }
+ else
+ {
+ s.append("object = " + ref.getInstance().identityToString(identity) + "\n");
+ }
+ s.append("reason = " + ex);
+ ref.getInstance().initializationData().logger.trace(
+ ref.getInstance().traceLevels().locationCat, s.toString());
+ }
+ throw ex;
+ }
- if(ref.getInstance().traceLevels().location >= 1)
- {
- if(endpoints != null && endpoints.length > 0)
- {
- if(cached.value)
- {
- trace("found endpoints in locator table", ref, endpoints);
- }
- else
- {
- trace("retrieved endpoints from locator, adding to locator table", ref, endpoints);
- }
- }
- else
- {
- StringBuffer s = new StringBuffer();
- s.append("no endpoints configured for ");
- if(adapterId.length() > 0)
- {
- s.append("adapter\n");
- s.append("adapter = " + adapterId + "\n");
- }
- else
- {
- s.append("object\n");
- s.append("object = " + ref.getInstance().identityToString(identity) + "\n");
- }
- }
- }
+ if(ref.getInstance().traceLevels().location >= 1)
+ {
+ if(endpoints != null && endpoints.length > 0)
+ {
+ if(cached.value)
+ {
+ trace("found endpoints in locator table", ref, endpoints);
+ }
+ else
+ {
+ trace("retrieved endpoints from locator, adding to locator table", ref, endpoints);
+ }
+ }
+ else
+ {
+ StringBuffer s = new StringBuffer();
+ s.append("no endpoints configured for ");
+ if(adapterId.length() > 0)
+ {
+ s.append("adapter\n");
+ s.append("adapter = " + adapterId + "\n");
+ }
+ else
+ {
+ s.append("object\n");
+ s.append("object = " + ref.getInstance().identityToString(identity) + "\n");
+ }
+ }
+ }
- return endpoints == null ? new EndpointI[0] : endpoints;
+ return endpoints == null ? new EndpointI[0] : endpoints;
}
public void
clearObjectCache(IndirectReference ref)
{
- if(ref.getAdapterId().length() == 0)
- {
- Ice.ObjectPrx object = _table.removeProxy(ref.getIdentity());
- if(object != null)
- {
- if(((Ice.ObjectPrxHelperBase)object).__reference() instanceof IndirectReference)
- {
- IndirectReference oir = (IndirectReference)((Ice.ObjectPrxHelperBase)object).__reference();
- if(oir.getAdapterId().length() > 0)
- {
- clearCache(oir);
- }
- }
- else
- {
- if(ref.getInstance().traceLevels().location >= 2)
- {
- trace("removed endpoints from locator table",
- ref, ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints());
- }
- }
- }
- }
+ if(ref.getAdapterId().length() == 0)
+ {
+ Ice.ObjectPrx object = _table.removeProxy(ref.getIdentity());
+ if(object != null)
+ {
+ if(((Ice.ObjectPrxHelperBase)object).__reference() instanceof IndirectReference)
+ {
+ IndirectReference oir = (IndirectReference)((Ice.ObjectPrxHelperBase)object).__reference();
+ if(oir.getAdapterId().length() > 0)
+ {
+ clearCache(oir);
+ }
+ }
+ else
+ {
+ if(ref.getInstance().traceLevels().location >= 2)
+ {
+ trace("removed endpoints from locator table",
+ ref, ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints());
+ }
+ }
+ }
+ }
}
public void
clearCache(IndirectReference ref)
{
- if(ref.getAdapterId().length() > 0)
- {
- EndpointI[] endpoints = _table.removeAdapterEndpoints(ref.getAdapterId());
+ if(ref.getAdapterId().length() > 0)
+ {
+ EndpointI[] endpoints = _table.removeAdapterEndpoints(ref.getAdapterId());
- if(endpoints != null && ref.getInstance().traceLevels().location >= 2)
- {
- trace("removed endpoints from locator table\n", ref, endpoints);
- }
- }
- else
- {
- Ice.ObjectPrx object = _table.removeProxy(ref.getIdentity());
- if(object != null)
- {
- if(((Ice.ObjectPrxHelperBase)object).__reference() instanceof IndirectReference)
- {
- IndirectReference oir = (IndirectReference)((Ice.ObjectPrxHelperBase)object).__reference();
- if(oir.getAdapterId().length() > 0)
- {
- clearCache(oir);
- }
- }
- else
- {
- if(ref.getInstance().traceLevels().location >= 2)
- {
- trace("removed endpoints from locator table",
- ref, ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints());
- }
- }
- }
- }
+ if(endpoints != null && ref.getInstance().traceLevels().location >= 2)
+ {
+ trace("removed endpoints from locator table\n", ref, endpoints);
+ }
+ }
+ else
+ {
+ Ice.ObjectPrx object = _table.removeProxy(ref.getIdentity());
+ if(object != null)
+ {
+ if(((Ice.ObjectPrxHelperBase)object).__reference() instanceof IndirectReference)
+ {
+ IndirectReference oir = (IndirectReference)((Ice.ObjectPrxHelperBase)object).__reference();
+ if(oir.getAdapterId().length() > 0)
+ {
+ clearCache(oir);
+ }
+ }
+ else
+ {
+ if(ref.getInstance().traceLevels().location >= 2)
+ {
+ trace("removed endpoints from locator table",
+ ref, ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints());
+ }
+ }
+ }
+ }
}
private void
trace(String msg, IndirectReference ref, EndpointI[] endpoints)
{
- StringBuffer s = new StringBuffer();
- s.append(msg + "\n");
- if(ref.getAdapterId().length() > 0)
- {
- s.append("adapter = " + ref.getAdapterId() + "\n");
- }
- else
- {
- s.append("object = " + ref.getInstance().identityToString(ref.getIdentity()) + "\n");
- }
+ StringBuffer s = new StringBuffer();
+ s.append(msg + "\n");
+ if(ref.getAdapterId().length() > 0)
+ {
+ s.append("adapter = " + ref.getAdapterId() + "\n");
+ }
+ else
+ {
+ s.append("object = " + ref.getInstance().identityToString(ref.getIdentity()) + "\n");
+ }
- s.append("endpoints = ");
- final int sz = endpoints.length;
- for(int i = 0; i < sz; i++)
- {
- s.append(endpoints[i].toString());
- if(i + 1 < sz)
- s.append(":");
- }
+ s.append("endpoints = ");
+ final int sz = endpoints.length;
+ for(int i = 0; i < sz; i++)
+ {
+ s.append(endpoints[i].toString());
+ if(i + 1 < sz)
+ s.append(":");
+ }
- ref.getInstance().initializationData().logger.trace(ref.getInstance().traceLevels().locationCat, s.toString());
+ ref.getInstance().initializationData().logger.trace(ref.getInstance().traceLevels().locationCat, s.toString());
}
private final Ice.LocatorPrx _locator;
diff --git a/java/src/IceInternal/LocatorManager.java b/java/src/IceInternal/LocatorManager.java
index 02bbec8c892..db888a5df7d 100644
--- a/java/src/IceInternal/LocatorManager.java
+++ b/java/src/IceInternal/LocatorManager.java
@@ -18,14 +18,14 @@ public final class LocatorManager
synchronized void
destroy()
{
- java.util.Iterator i = _table.values().iterator();
+ java.util.Iterator i = _table.values().iterator();
while(i.hasNext())
{
LocatorInfo info = (LocatorInfo)i.next();
info.destroy();
}
_table.clear();
- _locatorTables.clear();
+ _locatorTables.clear();
}
//
@@ -40,31 +40,31 @@ public final class LocatorManager
return null;
}
- //
- // The locator can't be located.
- //
- Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(loc.ice_locator(null));
+ //
+ // The locator can't be located.
+ //
+ Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(loc.ice_locator(null));
- //
- // TODO: reap unused locator info objects?
- //
+ //
+ // TODO: reap unused locator info objects?
+ //
synchronized(this)
{
LocatorInfo info = (LocatorInfo)_table.get(locator);
if(info == null)
{
- //
- // Rely on locator identity for the adapter table. We want to
- // have only one table per locator (not one per locator
- // proxy).
- //
- LocatorTable table = (LocatorTable)_locatorTables.get(locator.ice_getIdentity());
- if(table == null)
- {
- table = new LocatorTable();
- _locatorTables.put(locator.ice_getIdentity(), table);
- }
+ //
+ // Rely on locator identity for the adapter table. We want to
+ // have only one table per locator (not one per locator
+ // proxy).
+ //
+ LocatorTable table = (LocatorTable)_locatorTables.get(locator.ice_getIdentity());
+ if(table == null)
+ {
+ table = new LocatorTable();
+ _locatorTables.put(locator.ice_getIdentity(), table);
+ }
info = new LocatorInfo(locator, table);
_table.put(locator, info);
diff --git a/java/src/IceInternal/LocatorTable.java b/java/src/IceInternal/LocatorTable.java
index d3b1a0d34b6..5e3e986890f 100644
--- a/java/src/IceInternal/LocatorTable.java
+++ b/java/src/IceInternal/LocatorTable.java
@@ -18,104 +18,104 @@ final class LocatorTable
synchronized void
clear()
{
- _adapterEndpointsTable.clear();
- _objectTable.clear();
+ _adapterEndpointsTable.clear();
+ _objectTable.clear();
}
synchronized IceInternal.EndpointI[]
getAdapterEndpoints(String adapter, int ttl)
{
- if(ttl == 0) // Locator cache disabled.
- {
- return null;
- }
-
- EndpointTableEntry entry = (EndpointTableEntry)_adapterEndpointsTable.get(adapter);
- if(entry != null && checkTTL(entry.time, ttl))
- {
- return entry.endpoints;
- }
- return null;
+ if(ttl == 0) // Locator cache disabled.
+ {
+ return null;
+ }
+
+ EndpointTableEntry entry = (EndpointTableEntry)_adapterEndpointsTable.get(adapter);
+ if(entry != null && checkTTL(entry.time, ttl))
+ {
+ return entry.endpoints;
+ }
+ return null;
}
synchronized void
addAdapterEndpoints(String adapter, IceInternal.EndpointI[] endpoints)
{
- _adapterEndpointsTable.put(adapter, new EndpointTableEntry(System.currentTimeMillis(), endpoints));
+ _adapterEndpointsTable.put(adapter, new EndpointTableEntry(System.currentTimeMillis(), endpoints));
}
synchronized IceInternal.EndpointI[]
removeAdapterEndpoints(String adapter)
{
- EndpointTableEntry entry = (EndpointTableEntry)_adapterEndpointsTable.remove(adapter);
- return entry != null ? entry.endpoints : null;
+ EndpointTableEntry entry = (EndpointTableEntry)_adapterEndpointsTable.remove(adapter);
+ return entry != null ? entry.endpoints : null;
}
synchronized Ice.ObjectPrx
getProxy(Ice.Identity id, int ttl)
{
- if(ttl == 0) // Locator cache disabled.
- {
- return null;
- }
-
- ProxyTableEntry entry = (ProxyTableEntry)_objectTable.get(id);
- if(entry != null && checkTTL(entry.time, ttl))
- {
- return entry.proxy;
- }
- return null;
+ if(ttl == 0) // Locator cache disabled.
+ {
+ return null;
+ }
+
+ ProxyTableEntry entry = (ProxyTableEntry)_objectTable.get(id);
+ if(entry != null && checkTTL(entry.time, ttl))
+ {
+ return entry.proxy;
+ }
+ return null;
}
synchronized void
addProxy(Ice.Identity id, Ice.ObjectPrx proxy)
{
- _objectTable.put(id, new ProxyTableEntry(System.currentTimeMillis(), proxy));
+ _objectTable.put(id, new ProxyTableEntry(System.currentTimeMillis(), proxy));
}
synchronized Ice.ObjectPrx
removeProxy(Ice.Identity id)
{
- ProxyTableEntry entry = (ProxyTableEntry)_objectTable.remove(id);
- return entry != null ? entry.proxy : null;
+ ProxyTableEntry entry = (ProxyTableEntry)_objectTable.remove(id);
+ return entry != null ? entry.proxy : null;
}
private boolean
checkTTL(long time, int ttl)
{
- assert(ttl != 0);
- if(ttl < 0) // TTL = infinite
- {
- return true;
- }
- else
- {
- return System.currentTimeMillis() - time <= ((long)ttl * 1000);
- }
+ assert(ttl != 0);
+ if(ttl < 0) // TTL = infinite
+ {
+ return true;
+ }
+ else
+ {
+ return System.currentTimeMillis() - time <= ((long)ttl * 1000);
+ }
}
private static final class EndpointTableEntry
{
- public EndpointTableEntry(long time, IceInternal.EndpointI[] endpoints)
+ public EndpointTableEntry(long time, IceInternal.EndpointI[] endpoints)
{
- this.time = time;
- this.endpoints = endpoints;
- }
+ this.time = time;
+ this.endpoints = endpoints;
+ }
- final public long time;
- final public IceInternal.EndpointI[] endpoints;
+ final public long time;
+ final public IceInternal.EndpointI[] endpoints;
};
private static final class ProxyTableEntry
{
- public ProxyTableEntry(long time, Ice.ObjectPrx proxy)
+ public ProxyTableEntry(long time, Ice.ObjectPrx proxy)
{
- this.time = time;
- this.proxy = proxy;
- }
+ this.time = time;
+ this.proxy = proxy;
+ }
- final public long time;
- final public Ice.ObjectPrx proxy;
+ final public long time;
+ final public Ice.ObjectPrx proxy;
};
private java.util.HashMap _adapterEndpointsTable = new java.util.HashMap();
diff --git a/java/src/IceInternal/Network.java b/java/src/IceInternal/Network.java
index 97395479296..51227d0bac3 100644
--- a/java/src/IceInternal/Network.java
+++ b/java/src/IceInternal/Network.java
@@ -31,11 +31,11 @@ public final class Network
"cannot send after transport endpoint shutdown", // ESHUTDOWN (Linux)
"software caused connection abort", // ECONNABORTED
"an existing connection was forcibly closed", // unknown
- "connection closed by remote host", // unknown
- "an established connection was aborted by the software in your host machine", // unknown (Win32)
- "broken pipe", // EPIPE
- "there is no process to read data written to a pipe", // EPIPE? (AIX JDK 1.4.2)
- "socket is closed" // unknown (AIX JDK 1.4.2)
+ "connection closed by remote host", // unknown
+ "an established connection was aborted by the software in your host machine", // unknown (Win32)
+ "broken pipe", // EPIPE
+ "there is no process to read data written to a pipe", // EPIPE? (AIX JDK 1.4.2)
+ "socket is closed" // unknown (AIX JDK 1.4.2)
};
for(int i = 0; i < msgs.length; i++)
@@ -67,7 +67,7 @@ public final class Network
final String[] msgs =
{
"connection refused", // ECONNREFUSED
- "remote host refused an attempted connect operation" // ECONNREFUSED (AIX JDK 1.4.2)
+ "remote host refused an attempted connect operation" // ECONNREFUSED (AIX JDK 1.4.2)
};
for(int i = 0; i < msgs.length; i++)
@@ -85,20 +85,20 @@ public final class Network
public static boolean
notConnected(java.net.SocketException ex)
{
- String msg = ex.getMessage().toLowerCase();
- if(msg.indexOf("transport endpoint is not connected") != -1)
- {
- return true;
- }
- //
- // BUGFIX: We check for EINVAL because shutdown() under Mac OS
- // X returns EINVAL if the server side is gone.
- //
- else if(msg.indexOf("invalid argument") != -1)
- {
- return true;
- }
- return false;
+ String msg = ex.getMessage().toLowerCase();
+ if(msg.indexOf("transport endpoint is not connected") != -1)
+ {
+ return true;
+ }
+ //
+ // BUGFIX: We check for EINVAL because shutdown() under Mac OS
+ // X returns EINVAL if the server side is gone.
+ //
+ else if(msg.indexOf("invalid argument") != -1)
+ {
+ return true;
+ }
+ return false;
}
public static java.nio.channels.SocketChannel
@@ -162,28 +162,28 @@ public final class Network
closeSocketNoThrow(java.nio.channels.SelectableChannel fd)
{
try
- {
- fd.close();
- }
- catch(java.io.IOException ex)
- {
- // Ignore
- }
+ {
+ fd.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ // Ignore
+ }
}
public static void
closeSocket(java.nio.channels.SelectableChannel fd)
{
- try
- {
- fd.close();
- }
- catch(java.io.IOException ex)
- {
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
+ try
+ {
+ fd.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
}
public static void
@@ -195,7 +195,7 @@ public final class Network
}
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -213,7 +213,7 @@ public final class Network
}
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -231,7 +231,7 @@ public final class Network
}
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -245,86 +245,86 @@ public final class Network
{
if(!fd.connect(addr))
{
- java.nio.channels.Selector selector = java.nio.channels.Selector.open();
- try
- {
- while(true)
- {
- try
- {
- java.nio.channels.SelectionKey key =
- fd.register(selector, java.nio.channels.SelectionKey.OP_CONNECT);
- int n;
- if(timeout > 0)
- {
- n = selector.select(timeout);
- }
- else if(timeout == 0)
- {
- n = selector.selectNow();
- }
- else
- {
- n = selector.select();
- }
-
- if(n == 0)
- {
- closeSocketNoThrow(fd);
- throw new Ice.ConnectTimeoutException();
- }
-
- break;
- }
- catch(java.io.IOException ex)
- {
- if(interrupted(ex))
- {
- continue;
- }
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
- }
- }
- finally
- {
- try
- {
- selector.close();
- }
- catch(java.io.IOException ex)
- {
- // Ignore
- }
- }
+ java.nio.channels.Selector selector = java.nio.channels.Selector.open();
+ try
+ {
+ while(true)
+ {
+ try
+ {
+ java.nio.channels.SelectionKey key =
+ fd.register(selector, java.nio.channels.SelectionKey.OP_CONNECT);
+ int n;
+ if(timeout > 0)
+ {
+ n = selector.select(timeout);
+ }
+ else if(timeout == 0)
+ {
+ n = selector.selectNow();
+ }
+ else
+ {
+ n = selector.select();
+ }
+
+ if(n == 0)
+ {
+ closeSocketNoThrow(fd);
+ throw new Ice.ConnectTimeoutException();
+ }
+
+ break;
+ }
+ catch(java.io.IOException ex)
+ {
+ if(interrupted(ex))
+ {
+ continue;
+ }
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
+ }
+ }
+ finally
+ {
+ try
+ {
+ selector.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ // Ignore
+ }
+ }
if(!fd.finishConnect())
{
- throw new Ice.ConnectFailedException();
+ throw new Ice.ConnectFailedException();
}
}
}
catch(java.net.ConnectException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.ConnectFailedException se;
- if(connectionRefused(ex))
- {
- se = new Ice.ConnectionRefusedException();
- }
- else
- {
- se = new Ice.ConnectFailedException();
- }
+ if(connectionRefused(ex))
+ {
+ se = new Ice.ConnectionRefusedException();
+ }
+ else
+ {
+ se = new Ice.ConnectFailedException();
+ }
se.initCause(ex);
throw se;
}
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -340,23 +340,23 @@ public final class Network
}
catch(java.net.ConnectException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.ConnectFailedException se;
- if(connectionRefused(ex))
- {
- se = new Ice.ConnectionRefusedException();
- }
- else
- {
- se = new Ice.ConnectFailedException();
- }
+ if(connectionRefused(ex))
+ {
+ se = new Ice.ConnectionRefusedException();
+ }
+ else
+ {
+ se = new Ice.ConnectFailedException();
+ }
se.initCause(ex);
throw se;
}
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -407,10 +407,10 @@ public final class Network
}
catch(java.io.IOException ex)
{
- if(interrupted(ex))
- {
- continue;
- }
+ if(interrupted(ex))
+ {
+ continue;
+ }
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -432,10 +432,10 @@ public final class Network
}
catch(java.io.IOException ex)
{
- if(interrupted(ex))
- {
- continue;
- }
+ if(interrupted(ex))
+ {
+ continue;
+ }
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -461,14 +461,14 @@ public final class Network
public static void
setSendBufferSize(java.nio.channels.DatagramChannel fd, int size)
{
- try
- {
- java.net.DatagramSocket socket = fd.socket();
- socket.setSendBufferSize(size);
- }
+ try
+ {
+ java.net.DatagramSocket socket = fd.socket();
+ socket.setSendBufferSize(size);
+ }
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -478,33 +478,33 @@ public final class Network
public static int
getSendBufferSize(java.nio.channels.DatagramChannel fd)
{
- int size;
- try
- {
- java.net.DatagramSocket socket = fd.socket();
- size = socket.getSendBufferSize();
- }
+ int size;
+ try
+ {
+ java.net.DatagramSocket socket = fd.socket();
+ size = socket.getSendBufferSize();
+ }
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
}
- return size;
+ return size;
}
public static void
setRecvBufferSize(java.nio.channels.ServerSocketChannel fd, int size)
{
- try
- {
- java.net.ServerSocket socket = fd.socket();
- socket.setReceiveBufferSize(size);
- }
+ try
+ {
+ java.net.ServerSocket socket = fd.socket();
+ socket.setReceiveBufferSize(size);
+ }
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -514,14 +514,14 @@ public final class Network
public static void
setRecvBufferSize(java.nio.channels.DatagramChannel fd, int size)
{
- try
- {
- java.net.DatagramSocket socket = fd.socket();
- socket.setReceiveBufferSize(size);
- }
+ try
+ {
+ java.net.DatagramSocket socket = fd.socket();
+ socket.setReceiveBufferSize(size);
+ }
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
@@ -532,38 +532,38 @@ public final class Network
getRecvBufferSize(java.nio.channels.ServerSocketChannel fd)
{
int size;
- try
- {
- java.net.ServerSocket socket = fd.socket();
- size = socket.getReceiveBufferSize();
- }
+ try
+ {
+ java.net.ServerSocket socket = fd.socket();
+ size = socket.getReceiveBufferSize();
+ }
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
}
- return size;
+ return size;
}
public static int
getRecvBufferSize(java.nio.channels.DatagramChannel fd)
{
int size;
- try
- {
- java.net.DatagramSocket socket = fd.socket();
- size = socket.getReceiveBufferSize();
- }
+ try
+ {
+ java.net.DatagramSocket socket = fd.socket();
+ size = socket.getReceiveBufferSize();
+ }
catch(java.io.IOException ex)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
throw se;
}
- return size;
+ return size;
}
public static java.net.InetSocketAddress
@@ -572,27 +572,27 @@ public final class Network
try
{
java.net.InetAddress[] addrs = java.net.InetAddress.getAllByName(host);
- for(int i = 0; i < addrs.length; ++i)
- {
- if(addrs[i] instanceof java.net.Inet4Address)
- {
- return new java.net.InetSocketAddress(addrs[i], port);
- }
- }
+ for(int i = 0; i < addrs.length; ++i)
+ {
+ if(addrs[i] instanceof java.net.Inet4Address)
+ {
+ return new java.net.InetSocketAddress(addrs[i], port);
+ }
+ }
}
catch(java.net.UnknownHostException ex)
{
- Ice.DNSException e = new Ice.DNSException();
- e.host = host;
- throw e;
+ Ice.DNSException e = new Ice.DNSException();
+ e.host = host;
+ throw e;
}
- //
- // No Inet4Address available.
- //
- Ice.DNSException e = new Ice.DNSException();
- e.host = host;
- throw e;
+ //
+ // No Inet4Address available.
+ //
+ Ice.DNSException e = new Ice.DNSException();
+ e.host = host;
+ throw e;
}
public static java.net.InetAddress
@@ -624,11 +624,11 @@ public final class Network
// address (preferably not the loopback address).
//
java.net.InetAddress loopback = null;
- java.util.ArrayList addrs = getLocalAddresses();
+ java.util.ArrayList addrs = getLocalAddresses();
java.util.Iterator iter = addrs.iterator();
while(addr == null && iter.hasNext())
{
- java.net.InetAddress a = (java.net.InetAddress)iter.next();
+ java.net.InetAddress a = (java.net.InetAddress)iter.next();
if(!a.isLoopbackAddress())
{
addr = a;
@@ -654,12 +654,12 @@ public final class Network
{
java.util.ArrayList hosts = new java.util.ArrayList();
java.util.ArrayList addrs = getLocalAddresses();
- java.util.Iterator iter = addrs.iterator();
- while(iter.hasNext())
- {
- hosts.add(((java.net.InetAddress)iter.next()).getHostAddress());
- }
- return hosts;
+ java.util.Iterator iter = addrs.iterator();
+ while(iter.hasNext())
+ {
+ hosts.add(((java.net.InetAddress)iter.next()).getHostAddress());
+ }
+ return hosts;
}
public static java.util.ArrayList
@@ -667,31 +667,31 @@ public final class Network
{
java.util.ArrayList result = new java.util.ArrayList();
- try
- {
- java.util.Enumeration ifaces = java.net.NetworkInterface.getNetworkInterfaces();
- while(ifaces.hasMoreElements())
- {
+ try
+ {
+ java.util.Enumeration ifaces = java.net.NetworkInterface.getNetworkInterfaces();
+ while(ifaces.hasMoreElements())
+ {
java.net.NetworkInterface iface = (java.net.NetworkInterface)ifaces.nextElement();
java.util.Enumeration addrs = iface.getInetAddresses();
- while(addrs.hasMoreElements())
- {
- java.net.InetAddress addr = (java.net.InetAddress)addrs.nextElement();
- if(!(addr instanceof java.net.Inet6Address))
- {
- result.add(addr);
- }
- }
- }
- }
- catch(java.net.SocketException e)
- {
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(e);
- throw se;
- }
-
- return result;
+ while(addrs.hasMoreElements())
+ {
+ java.net.InetAddress addr = (java.net.InetAddress)addrs.nextElement();
+ if(!(addr instanceof java.net.Inet6Address))
+ {
+ result.add(addr);
+ }
+ }
+ }
+ }
+ catch(java.net.SocketException e)
+ {
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(e);
+ throw se;
+ }
+
+ return result;
}
public static final class SocketPair
@@ -705,132 +705,132 @@ public final class Network
{
SocketPair fds = new SocketPair();
- //
- // BUGFIX: This method should really be very simple.
- // Unfortunately, using a pipe causes a kernel crash under
- // MacOS 10.3.9.
- //
- //try
- //{
- // java.nio.channels.Pipe pipe = java.nio.channels.Pipe.open();
- // fds.sink = pipe.sink();
- // fds.source = pipe.source();
- //}
+ //
+ // BUGFIX: This method should really be very simple.
+ // Unfortunately, using a pipe causes a kernel crash under
+ // MacOS 10.3.9.
+ //
+ //try
+ //{
+ // java.nio.channels.Pipe pipe = java.nio.channels.Pipe.open();
+ // fds.sink = pipe.sink();
+ // fds.source = pipe.source();
+ //}
//catch(java.io.IOException ex)
- //{
- // Ice.SocketException se = new Ice.SocketException();
- // se.initCause(ex);
- // throw se;
- //}
- //
-
+ //{
+ // Ice.SocketException se = new Ice.SocketException();
+ // se.initCause(ex);
+ // throw se;
+ //}
+ //
+
java.nio.channels.ServerSocketChannel fd = createTcpServerSocket();
-
- java.net.InetSocketAddress addr = new java.net.InetSocketAddress("127.0.0.1", 0);
-
- addr = doBind(fd, addr);
-
+
+ java.net.InetSocketAddress addr = new java.net.InetSocketAddress("127.0.0.1", 0);
+
+ addr = doBind(fd, addr);
+
try
- {
+ {
java.nio.channels.SocketChannel sink = createTcpSocket();
- fds.sink = sink;
- doConnect(sink, addr, -1);
+ fds.sink = sink;
+ doConnect(sink, addr, -1);
try
- {
- fds.source = doAccept(fd, -1);
- }
- catch(Ice.LocalException ex)
{
- try
- {
+ fds.source = doAccept(fd, -1);
+ }
+ catch(Ice.LocalException ex)
+ {
+ try
+ {
fds.sink.close();
- }
- catch(java.io.IOException e)
- {
}
- throw ex;
- }
- }
- finally
- {
- closeSocketNoThrow(fd);
- }
-
- return fds;
+ catch(java.io.IOException e)
+ {
+ }
+ throw ex;
+ }
+ }
+ finally
+ {
+ closeSocketNoThrow(fd);
+ }
+
+ return fds;
}
public static String
fdToString(java.nio.channels.SelectableChannel fd)
{
- if(fd == null)
- {
- return "<closed>";
- }
-
- java.net.InetAddress localAddr = null, remoteAddr = null;
- int localPort = -1, remotePort = -1;
-
- if(fd instanceof java.nio.channels.SocketChannel)
- {
- java.net.Socket socket = ((java.nio.channels.SocketChannel)fd).socket();
- localAddr = socket.getLocalAddress();
- localPort = socket.getLocalPort();
- remoteAddr = socket.getInetAddress();
- remotePort = socket.getPort();
- }
- else if(fd instanceof java.nio.channels.DatagramChannel)
- {
- java.net.DatagramSocket socket = ((java.nio.channels.DatagramChannel)fd).socket();
- localAddr = socket.getLocalAddress();
- localPort = socket.getLocalPort();
- remoteAddr = socket.getInetAddress();
- remotePort = socket.getPort();
- }
- else
- {
- assert(false);
- }
-
- return addressesToString(localAddr, localPort, remoteAddr, remotePort);
+ if(fd == null)
+ {
+ return "<closed>";
+ }
+
+ java.net.InetAddress localAddr = null, remoteAddr = null;
+ int localPort = -1, remotePort = -1;
+
+ if(fd instanceof java.nio.channels.SocketChannel)
+ {
+ java.net.Socket socket = ((java.nio.channels.SocketChannel)fd).socket();
+ localAddr = socket.getLocalAddress();
+ localPort = socket.getLocalPort();
+ remoteAddr = socket.getInetAddress();
+ remotePort = socket.getPort();
+ }
+ else if(fd instanceof java.nio.channels.DatagramChannel)
+ {
+ java.net.DatagramSocket socket = ((java.nio.channels.DatagramChannel)fd).socket();
+ localAddr = socket.getLocalAddress();
+ localPort = socket.getLocalPort();
+ remoteAddr = socket.getInetAddress();
+ remotePort = socket.getPort();
+ }
+ else
+ {
+ assert(false);
+ }
+
+ return addressesToString(localAddr, localPort, remoteAddr, remotePort);
}
public static String
fdToString(java.net.Socket fd)
{
- if(fd == null)
- {
- return "<closed>";
- }
+ if(fd == null)
+ {
+ return "<closed>";
+ }
- java.net.InetAddress localAddr = fd.getLocalAddress();
- int localPort = fd.getLocalPort();
- java.net.InetAddress remoteAddr = fd.getInetAddress();
- int remotePort = fd.getPort();
+ java.net.InetAddress localAddr = fd.getLocalAddress();
+ int localPort = fd.getLocalPort();
+ java.net.InetAddress remoteAddr = fd.getInetAddress();
+ int remotePort = fd.getPort();
- return addressesToString(localAddr, localPort, remoteAddr, remotePort);
+ return addressesToString(localAddr, localPort, remoteAddr, remotePort);
}
public static String
addressesToString(java.net.InetAddress localAddr, int localPort, java.net.InetAddress remoteAddr, int remotePort)
{
- StringBuffer s = new StringBuffer();
- s.append("local address = ");
- s.append(localAddr.getHostAddress());
- s.append(':');
- s.append(localPort);
- if(remoteAddr == null)
- {
- s.append("\nremote address = <not connected>");
- }
- else
- {
- s.append("\nremote address = ");
- s.append(remoteAddr.getHostAddress());
- s.append(':');
- s.append(remotePort);
- }
-
- return s.toString();
+ StringBuffer s = new StringBuffer();
+ s.append("local address = ");
+ s.append(localAddr.getHostAddress());
+ s.append(':');
+ s.append(localPort);
+ if(remoteAddr == null)
+ {
+ s.append("\nremote address = <not connected>");
+ }
+ else
+ {
+ s.append("\nremote address = ");
+ s.append(remoteAddr.getHostAddress());
+ s.append(':');
+ s.append(remotePort);
+ }
+
+ return s.toString();
}
public static String
@@ -846,8 +846,8 @@ public final class Network
public static boolean
interrupted(java.io.IOException ex)
{
- return ex instanceof java.io.InterruptedIOException ||
- ex.getMessage().indexOf("Interrupted system call") >= 0 ||
- ex.getMessage().indexOf("A system call received an interrupt") >= 0; // AIX JDK 1.4.2
+ return ex instanceof java.io.InterruptedIOException ||
+ ex.getMessage().indexOf("Interrupted system call") >= 0 ||
+ ex.getMessage().indexOf("A system call received an interrupt") >= 0; // AIX JDK 1.4.2
}
}
diff --git a/java/src/IceInternal/ObjectAdapterFactory.java b/java/src/IceInternal/ObjectAdapterFactory.java
index e4a67e2a297..dcb67beec7f 100644
--- a/java/src/IceInternal/ObjectAdapterFactory.java
+++ b/java/src/IceInternal/ObjectAdapterFactory.java
@@ -16,29 +16,29 @@ public final class ObjectAdapterFactory
{
Ice.ObjectAdapter[] adapters;
- synchronized(this)
- {
- //
- // Ignore shutdown requests if the object adapter factory has
- // already been shut down.
- //
- if(_instance == null)
- {
- return;
- }
+ synchronized(this)
+ {
+ //
+ // Ignore shutdown requests if the object adapter factory has
+ // already been shut down.
+ //
+ if(_instance == null)
+ {
+ return;
+ }
- adapters = (Ice.ObjectAdapter[])_adapters.values().toArray(new Ice.ObjectAdapter[0]);
+ adapters = (Ice.ObjectAdapter[])_adapters.values().toArray(new Ice.ObjectAdapter[0]);
- _instance = null;
- _communicator = null;
-
- notifyAll();
- }
+ _instance = null;
+ _communicator = null;
+
+ notifyAll();
+ }
- //
- // Deactivate outside the thread synchronization, to avoid
- // deadlocks.
- //
+ //
+ // Deactivate outside the thread synchronization, to avoid
+ // deadlocks.
+ //
for(int i = 0; i < adapters.length; ++i)
{
adapters[i].deactivate();
@@ -48,60 +48,60 @@ public final class ObjectAdapterFactory
public void
waitForShutdown()
{
- synchronized(this)
- {
- //
- // First we wait for the shutdown of the factory itself.
- //
- while(_instance != null)
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- //
- // If some other thread is currently shutting down, we wait
- // until this thread is finished.
- //
- while(_waitForShutdown)
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
- _waitForShutdown = true;
- }
-
- //
- // Now we wait for deactivation of each object adapter.
- //
- if(_adapters != null)
- {
- java.util.Iterator i = _adapters.values().iterator();
- while(i.hasNext())
- {
- Ice.ObjectAdapter adapter = (Ice.ObjectAdapter)i.next();
- adapter.waitForDeactivate();
- }
- }
+ synchronized(this)
+ {
+ //
+ // First we wait for the shutdown of the factory itself.
+ //
+ while(_instance != null)
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ //
+ // If some other thread is currently shutting down, we wait
+ // until this thread is finished.
+ //
+ while(_waitForShutdown)
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+ _waitForShutdown = true;
+ }
+
+ //
+ // Now we wait for deactivation of each object adapter.
+ //
+ if(_adapters != null)
+ {
+ java.util.Iterator i = _adapters.values().iterator();
+ while(i.hasNext())
+ {
+ Ice.ObjectAdapter adapter = (Ice.ObjectAdapter)i.next();
+ adapter.waitForDeactivate();
+ }
+ }
- synchronized(this)
- {
- //
- // Signal that waiting is complete.
- //
- _waitForShutdown = false;
- notifyAll();
- }
+ synchronized(this)
+ {
+ //
+ // Signal that waiting is complete.
+ //
+ _waitForShutdown = false;
+ notifyAll();
+ }
}
public synchronized boolean
@@ -114,27 +114,27 @@ public final class ObjectAdapterFactory
destroy()
{
//
- // First wait for shutdown to finish.
- //
- waitForShutdown();
+ // First wait for shutdown to finish.
+ //
+ waitForShutdown();
Ice.ObjectAdapter[] adapters;
- synchronized(this)
- {
- adapters = (Ice.ObjectAdapter[])_adapters.values().toArray(new Ice.ObjectAdapter[0]);
+ synchronized(this)
+ {
+ adapters = (Ice.ObjectAdapter[])_adapters.values().toArray(new Ice.ObjectAdapter[0]);
- //
- // For consistency with C#, we set _adapters to null
- // so that our finalizer does not try to invoke any
- // methods on member objects.
- //
- _adapters = null;
- }
+ //
+ // For consistency with C#, we set _adapters to null
+ // so that our finalizer does not try to invoke any
+ // methods on member objects.
+ //
+ _adapters = null;
+ }
- //
- // Now we destroy each object adapter.
- //
+ //
+ // Now we destroy each object adapter.
+ //
for(int i = 0; i < adapters.length; ++i)
{
adapters[i].destroy();
@@ -144,62 +144,62 @@ public final class ObjectAdapterFactory
public synchronized Ice.ObjectAdapter
createObjectAdapter(String name, String endpoints, Ice.RouterPrx router)
{
- if(_instance == null)
- {
- throw new Ice.ObjectAdapterDeactivatedException();
- }
+ if(_instance == null)
+ {
+ throw new Ice.ObjectAdapterDeactivatedException();
+ }
Ice.ObjectAdapter adapter = (Ice.ObjectAdapter)_adapters.get(name);
if(adapter != null)
{
- throw new Ice.AlreadyRegisteredException("object adapter", name);
+ throw new Ice.AlreadyRegisteredException("object adapter", name);
}
- if(name.length() == 0 && (endpoints.length() != 0 || router != null))
- {
- Ice.InitializationException ex = new Ice.InitializationException();
- ex.reason = "Cannot configure endpoints or router with nameless object adapter";
- throw ex;
- }
+ if(name.length() == 0 && (endpoints.length() != 0 || router != null))
+ {
+ Ice.InitializationException ex = new Ice.InitializationException();
+ ex.reason = "Cannot configure endpoints or router with nameless object adapter";
+ throw ex;
+ }
- if(name.length() == 0)
- {
- String uuid = Ice.Util.generateUUID();
+ if(name.length() == 0)
+ {
+ String uuid = Ice.Util.generateUUID();
adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, uuid, "", null, true);
_adapters.put(uuid, adapter);
- }
- else
- {
+ }
+ else
+ {
adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, name, endpoints, router, false);
_adapters.put(name, adapter);
- }
+ }
return adapter;
}
public synchronized Ice.ObjectAdapter
findObjectAdapter(Ice.ObjectPrx proxy)
{
- if(_instance == null)
- {
- return null;
- }
+ if(_instance == null)
+ {
+ return null;
+ }
java.util.Iterator i = _adapters.values().iterator();
while(i.hasNext())
{
Ice.ObjectAdapterI adapter = (Ice.ObjectAdapterI)i.next();
- try
- {
- if(adapter.isLocal(proxy))
- {
- return adapter;
- }
- }
- catch(Ice.ObjectAdapterDeactivatedException ex)
- {
- // Ignore.
- }
- }
+ try
+ {
+ if(adapter.isLocal(proxy))
+ {
+ return adapter;
+ }
+ }
+ catch(Ice.ObjectAdapterDeactivatedException ex)
+ {
+ // Ignore.
+ }
+ }
return null;
}
@@ -208,9 +208,9 @@ public final class ObjectAdapterFactory
removeObjectAdapter(String name)
{
if(_waitForShutdown || _adapters == null)
- {
- return;
- }
+ {
+ return;
+ }
_adapters.remove(name);
}
@@ -218,20 +218,20 @@ public final class ObjectAdapterFactory
public void
flushBatchRequests()
{
- java.util.LinkedList a = new java.util.LinkedList();
+ java.util.LinkedList a = new java.util.LinkedList();
synchronized(this)
- {
- java.util.Iterator i = _adapters.values().iterator();
- while(i.hasNext())
- {
- a.add(i.next());
- }
- }
- java.util.Iterator p = a.iterator();
- while(p.hasNext())
- {
- ((Ice.ObjectAdapterI)p.next()).flushBatchRequests();
- }
+ {
+ java.util.Iterator i = _adapters.values().iterator();
+ while(i.hasNext())
+ {
+ a.add(i.next());
+ }
+ }
+ java.util.Iterator p = a.iterator();
+ while(p.hasNext())
+ {
+ ((Ice.ObjectAdapterI)p.next()).flushBatchRequests();
+ }
}
//
@@ -240,18 +240,18 @@ public final class ObjectAdapterFactory
ObjectAdapterFactory(Instance instance, Ice.Communicator communicator)
{
_instance = instance;
- _communicator = communicator;
- _waitForShutdown = false;
+ _communicator = communicator;
+ _waitForShutdown = false;
}
protected synchronized void
finalize()
throws Throwable
{
- IceUtil.Assert.FinalizerAssert(_instance == null);
- IceUtil.Assert.FinalizerAssert(_communicator == null);
- IceUtil.Assert.FinalizerAssert(_adapters == null);
- IceUtil.Assert.FinalizerAssert(!_waitForShutdown);
+ IceUtil.Assert.FinalizerAssert(_instance == null);
+ IceUtil.Assert.FinalizerAssert(_communicator == null);
+ IceUtil.Assert.FinalizerAssert(_adapters == null);
+ IceUtil.Assert.FinalizerAssert(!_waitForShutdown);
super.finalize();
}
diff --git a/java/src/IceInternal/ObjectFactoryManager.java b/java/src/IceInternal/ObjectFactoryManager.java
index 400869b4401..0a279433b7b 100644
--- a/java/src/IceInternal/ObjectFactoryManager.java
+++ b/java/src/IceInternal/ObjectFactoryManager.java
@@ -15,35 +15,35 @@ public final class ObjectFactoryManager
add(Ice.ObjectFactory factory, String id)
{
Object o = _factoryMap.get(id);
- if(o != null)
- {
- Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException();
- ex.id = id;
- ex.kindOfObject = "object factory";
- throw ex;
- }
+ if(o != null)
+ {
+ Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException();
+ ex.id = id;
+ ex.kindOfObject = "object factory";
+ throw ex;
+ }
_factoryMap.put(id, factory);
}
public void
remove(String id)
{
- Object o = null;
+ Object o = null;
- synchronized(this)
- {
- o = _factoryMap.get(id);
- if(o == null)
- {
- Ice.NotRegisteredException ex = new Ice.NotRegisteredException();
- ex.id = id;
- ex.kindOfObject = "object factory";
- throw ex;
- }
- _factoryMap.remove(id);
- }
+ synchronized(this)
+ {
+ o = _factoryMap.get(id);
+ if(o == null)
+ {
+ Ice.NotRegisteredException ex = new Ice.NotRegisteredException();
+ ex.id = id;
+ ex.kindOfObject = "object factory";
+ throw ex;
+ }
+ _factoryMap.remove(id);
+ }
- ((Ice.ObjectFactory)o).destroy();
+ ((Ice.ObjectFactory)o).destroy();
}
public synchronized Ice.ObjectFactory
@@ -62,12 +62,12 @@ public final class ObjectFactoryManager
void
destroy()
{
- java.util.Map oldMap = null;
- synchronized(this)
- {
- oldMap = _factoryMap;
- _factoryMap = new java.util.HashMap();
- }
+ java.util.Map oldMap = null;
+ synchronized(this)
+ {
+ oldMap = _factoryMap;
+ _factoryMap = new java.util.HashMap();
+ }
java.util.Iterator i = oldMap.values().iterator();
while(i.hasNext())
diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java
index 14183a8520a..0b684ac7c8f 100644
--- a/java/src/IceInternal/Outgoing.java
+++ b/java/src/IceInternal/Outgoing.java
@@ -13,8 +13,8 @@ public final class Outgoing
{
public
Outgoing(Ice.ConnectionI connection, Reference ref, String operation, Ice.OperationMode mode,
- java.util.Map context, boolean compress)
- throws LocalExceptionWrapper
+ java.util.Map context, boolean compress)
+ throws LocalExceptionWrapper
{
_connection = connection;
_reference = ref;
@@ -23,7 +23,7 @@ public final class Outgoing
_os = new BasicStream(ref.getInstance());
_compress = compress;
- writeHeader(operation, mode, context);
+ writeHeader(operation, mode, context);
}
//
@@ -31,12 +31,12 @@ public final class Outgoing
//
public void
reset(Reference ref, String operation, Ice.OperationMode mode, java.util.Map context, boolean compress)
- throws LocalExceptionWrapper
+ throws LocalExceptionWrapper
{
- _reference = ref;
+ _reference = ref;
_state = StateUnsent;
_exception = null;
- _compress = compress;
+ _compress = compress;
writeHeader(operation, mode, context);
}
@@ -44,8 +44,8 @@ public final class Outgoing
public void
reclaim()
{
- _is.reset();
- _os.reset();
+ _is.reset();
+ _os.reset();
}
// Returns true if ok, false if user exception.
@@ -53,7 +53,7 @@ public final class Outgoing
invoke()
throws LocalExceptionWrapper
{
- assert(_state == StateUnsent);
+ assert(_state == StateUnsent);
_os.endWriteEncaps();
@@ -61,35 +61,35 @@ public final class Outgoing
{
case Reference.ModeTwoway:
{
- //
- // We let all exceptions raised by sending directly
- // propagate to the caller, because they can be
- // retried without violating "at-most-once". In case
- // of such exceptions, the connection object does not
- // call back on this object, so we don't need to lock
- // the mutex, keep track of state, or save exceptions.
- //
- _connection.sendRequest(_os, this, _compress);
-
- //
- // Wait until the request has completed, or until the
- // request times out.
- //
-
- boolean timedOut = false;
+ //
+ // We let all exceptions raised by sending directly
+ // propagate to the caller, because they can be
+ // retried without violating "at-most-once". In case
+ // of such exceptions, the connection object does not
+ // call back on this object, so we don't need to lock
+ // the mutex, keep track of state, or save exceptions.
+ //
+ _connection.sendRequest(_os, this, _compress);
+
+ //
+ // Wait until the request has completed, or until the
+ // request times out.
+ //
+
+ boolean timedOut = false;
synchronized(this)
{
- //
- // It's possible that the request has already
- // completed, due to a regular response, or because of
- // an exception. So we only change the state to "in
- // progress" if it is still "unsent".
- //
- if(_state == StateUnsent)
- {
- _state = StateInProgress;
- }
+ //
+ // It's possible that the request has already
+ // completed, due to a regular response, or because of
+ // an exception. So we only change the state to "in
+ // progress" if it is still "unsent".
+ //
+ if(_state == StateUnsent)
+ {
+ _state = StateInProgress;
+ }
int timeout = _connection.timeout();
while(_state == StateInProgress && !timedOut)
@@ -99,7 +99,7 @@ public final class Outgoing
if(timeout >= 0)
{
wait(timeout);
-
+
if(_state == StateInProgress)
{
timedOut = true;
@@ -115,37 +115,37 @@ public final class Outgoing
}
}
}
-
- if(timedOut)
- {
+
+ if(timedOut)
+ {
//
// Must be called outside the synchronization of
// this object
//
_connection.exception(new Ice.TimeoutException());
- //
- // We must wait until the exception set above has
- // propagated to this Outgoing object.
- //
- synchronized(this)
- {
- while(_state == StateInProgress)
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
- }
+ //
+ // We must wait until the exception set above has
+ // propagated to this Outgoing object.
+ //
+ synchronized(this)
+ {
+ while(_state == StateInProgress)
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+ }
}
if(_exception != null)
{
- _exception.fillInStackTrace();
+ _exception.fillInStackTrace();
//
// A CloseConnectionException indicates graceful
@@ -155,11 +155,11 @@ public final class Outgoing
// guarantees that all outstanding requests can safely
// be repeated.
//
- // An ObjectNotExistException can always be retried as
- // well without violating "at-most-once".
- //
+ // An ObjectNotExistException can always be retried as
+ // well without violating "at-most-once".
+ //
if(_exception instanceof Ice.CloseConnectionException ||
- _exception instanceof Ice.ObjectNotExistException)
+ _exception instanceof Ice.ObjectNotExistException)
{
throw _exception;
}
@@ -176,7 +176,7 @@ public final class Outgoing
{
return false;
}
-
+
assert(_state == StateOK);
break;
}
@@ -184,28 +184,28 @@ public final class Outgoing
case Reference.ModeOneway:
case Reference.ModeDatagram:
{
- //
- // For oneway and datagram requests, the connection object
+ //
+ // For oneway and datagram requests, the connection object
// never calls back on this object. Therefore we don't
// need to lock the mutex or save exceptions. We simply
// let all exceptions from sending propagate to the
// caller, because such exceptions can be retried without
// violating "at-most-once".
- //
- _state = StateInProgress;
- _connection.sendRequest(_os, null, _compress);
+ //
+ _state = StateInProgress;
+ _connection.sendRequest(_os, null, _compress);
break;
}
case Reference.ModeBatchOneway:
case Reference.ModeBatchDatagram:
{
- //
- // For batch oneways and datagrams, the same rules as for
- // regular oneways and datagrams (see comment above)
- // apply.
- //
- _state = StateInProgress;
+ //
+ // For batch oneways and datagrams, the same rules as for
+ // regular oneways and datagrams (see comment above)
+ // apply.
+ //
+ _state = StateInProgress;
_connection.finishBatchRequest(_os, _compress);
break;
}
@@ -218,100 +218,100 @@ public final class Outgoing
abort(Ice.LocalException ex)
throws LocalExceptionWrapper
{
- assert(_state == StateUnsent);
-
- //
- // If we didn't finish a batch oneway or datagram request, we
- // must notify the connection about that we give up ownership
- // of the batch stream.
- //
- int mode = _reference.getMode();
- if(mode == Reference.ModeBatchOneway || mode == Reference.ModeBatchDatagram)
- {
- _connection.abortBatchRequest();
-
- //
- // If we abort a batch requests, we cannot retry, because
- // not only the batch request that caused the problem will
- // be aborted, but all other requests in the batch as
- // well.
- //
- throw new LocalExceptionWrapper(ex, false);
- }
-
- throw ex;
+ assert(_state == StateUnsent);
+
+ //
+ // If we didn't finish a batch oneway or datagram request, we
+ // must notify the connection about that we give up ownership
+ // of the batch stream.
+ //
+ int mode = _reference.getMode();
+ if(mode == Reference.ModeBatchOneway || mode == Reference.ModeBatchDatagram)
+ {
+ _connection.abortBatchRequest();
+
+ //
+ // If we abort a batch requests, we cannot retry, because
+ // not only the batch request that caused the problem will
+ // be aborted, but all other requests in the batch as
+ // well.
+ //
+ throw new LocalExceptionWrapper(ex, false);
+ }
+
+ throw ex;
}
public synchronized void
finished(BasicStream is)
{
- assert(_reference.getMode() == Reference.ModeTwoway); // Can only be called for twoways.
-
- assert(_state <= StateInProgress);
-
- _is.swap(is);
- int status = (int)_is.readByte();
-
- switch(status)
- {
- case DispatchStatus._DispatchOK:
- {
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward
- // oneway requests as blobs.
- //
- _is.startReadEncaps();
- _state = StateOK; // The state must be set last, in case there is an exception.
- break;
- }
-
- case DispatchStatus._DispatchUserException:
- {
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward
- // oneway requests as blobs.
- //
- _is.startReadEncaps();
- _state = StateUserException; // The state must be set last, in case there is an exception.
- break;
- }
-
- case DispatchStatus._DispatchObjectNotExist:
- case DispatchStatus._DispatchFacetNotExist:
- case DispatchStatus._DispatchOperationNotExist:
- {
- Ice.RequestFailedException ex = null;
- switch((int)status)
- {
- case DispatchStatus._DispatchObjectNotExist:
- {
- ex = new Ice.ObjectNotExistException();
- break;
- }
-
- case DispatchStatus._DispatchFacetNotExist:
- {
- ex = new Ice.FacetNotExistException();
- break;
- }
-
- case DispatchStatus._DispatchOperationNotExist:
- {
- ex = new Ice.OperationNotExistException();
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- ex.id = new Ice.Identity();
- ex.id.__read(_is);
+ assert(_reference.getMode() == Reference.ModeTwoway); // Can only be called for twoways.
+
+ assert(_state <= StateInProgress);
+
+ _is.swap(is);
+ int status = (int)_is.readByte();
+
+ switch(status)
+ {
+ case DispatchStatus._DispatchOK:
+ {
+ //
+ // Input and output parameters are always sent in an
+ // encapsulation, which makes it possible to forward
+ // oneway requests as blobs.
+ //
+ _is.startReadEncaps();
+ _state = StateOK; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ case DispatchStatus._DispatchUserException:
+ {
+ //
+ // Input and output parameters are always sent in an
+ // encapsulation, which makes it possible to forward
+ // oneway requests as blobs.
+ //
+ _is.startReadEncaps();
+ _state = StateUserException; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ case DispatchStatus._DispatchObjectNotExist:
+ case DispatchStatus._DispatchFacetNotExist:
+ case DispatchStatus._DispatchOperationNotExist:
+ {
+ Ice.RequestFailedException ex = null;
+ switch((int)status)
+ {
+ case DispatchStatus._DispatchObjectNotExist:
+ {
+ ex = new Ice.ObjectNotExistException();
+ break;
+ }
+
+ case DispatchStatus._DispatchFacetNotExist:
+ {
+ ex = new Ice.FacetNotExistException();
+ break;
+ }
+
+ case DispatchStatus._DispatchOperationNotExist:
+ {
+ ex = new Ice.OperationNotExistException();
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ ex.id = new Ice.Identity();
+ ex.id.__read(_is);
//
// For compatibility with the old FacetPath.
@@ -319,70 +319,70 @@ public final class Outgoing
String[] facetPath = _is.readStringSeq();
if(facetPath.length > 0)
{
- if(facetPath.length > 1)
- {
- throw new Ice.MarshalException();
- }
+ if(facetPath.length > 1)
+ {
+ throw new Ice.MarshalException();
+ }
ex.facet = facetPath[0];
}
- else
- {
- ex.facet = "";
- }
-
- ex.operation = _is.readString();
- _exception = ex;
-
- _state = StateLocalException; // The state must be set last, in case there is an exception.
- break;
- }
-
- case DispatchStatus._DispatchUnknownException:
- case DispatchStatus._DispatchUnknownLocalException:
- case DispatchStatus._DispatchUnknownUserException:
- {
- Ice.UnknownException ex = null;
- switch((int)status)
- {
- case DispatchStatus._DispatchUnknownException:
- {
- ex = new Ice.UnknownException();
- break;
- }
-
- case DispatchStatus._DispatchUnknownLocalException:
- {
- ex = new Ice.UnknownLocalException();
- break;
- }
-
- case DispatchStatus._DispatchUnknownUserException:
- {
- ex = new Ice.UnknownUserException();
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- ex.unknown = _is.readString();
- _exception = ex;
-
- _state = StateLocalException; // The state must be set last, in case there is an exception.
- break;
- }
-
- default:
- {
- _exception = new Ice.UnknownReplyStatusException();
- _state = StateLocalException;
- break;
- }
- }
+ else
+ {
+ ex.facet = "";
+ }
+
+ ex.operation = _is.readString();
+ _exception = ex;
+
+ _state = StateLocalException; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ case DispatchStatus._DispatchUnknownException:
+ case DispatchStatus._DispatchUnknownLocalException:
+ case DispatchStatus._DispatchUnknownUserException:
+ {
+ Ice.UnknownException ex = null;
+ switch((int)status)
+ {
+ case DispatchStatus._DispatchUnknownException:
+ {
+ ex = new Ice.UnknownException();
+ break;
+ }
+
+ case DispatchStatus._DispatchUnknownLocalException:
+ {
+ ex = new Ice.UnknownLocalException();
+ break;
+ }
+
+ case DispatchStatus._DispatchUnknownUserException:
+ {
+ ex = new Ice.UnknownUserException();
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ ex.unknown = _is.readString();
+ _exception = ex;
+
+ _state = StateLocalException; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ default:
+ {
+ _exception = new Ice.UnknownReplyStatusException();
+ _state = StateLocalException;
+ break;
+ }
+ }
notify();
}
@@ -390,13 +390,13 @@ public final class Outgoing
public synchronized void
finished(Ice.LocalException ex)
{
- assert(_reference.getMode() == Reference.ModeTwoway); // Can only be called for twoways.
-
- assert(_state <= StateInProgress);
+ assert(_reference.getMode() == Reference.ModeTwoway); // Can only be called for twoways.
+
+ assert(_state <= StateInProgress);
- _state = StateLocalException;
- _exception = ex;
- notify();
+ _state = StateLocalException;
+ _exception = ex;
+ notify();
}
public BasicStream
@@ -413,7 +413,7 @@ public final class Outgoing
private void
writeHeader(String operation, Ice.OperationMode mode, java.util.Map context)
- throws LocalExceptionWrapper
+ throws LocalExceptionWrapper
{
switch(_reference.getMode())
{
@@ -421,7 +421,7 @@ public final class Outgoing
case Reference.ModeOneway:
case Reference.ModeDatagram:
{
- _os.writeBlob(IceInternal.Protocol.requestHdr);
+ _os.writeBlob(IceInternal.Protocol.requestHdr);
break;
}
@@ -433,66 +433,66 @@ public final class Outgoing
}
}
- try
- {
- _reference.getIdentity().__write(_os);
-
- //
- // For compatibility with the old FacetPath.
- //
- String facet = _reference.getFacet();
- if(facet == null || facet.length() == 0)
- {
- _os.writeStringSeq(null);
- }
- else
- {
- String[] facetPath = { facet };
- _os.writeStringSeq(facetPath);
- }
-
- _os.writeString(operation);
-
- _os.writeByte((byte)mode.value());
-
- if(context != null)
- {
- //
- // Explicit context
- //
- Ice.ContextHelper.write(_os, context);
- }
- else
- {
- //
- // Implicit context
- //
- Ice.ImplicitContextI implicitContext =
- _reference.getInstance().getImplicitContext();
-
- java.util.Map prxContext = _reference.getContext();
-
- if(implicitContext == null)
- {
- Ice.ContextHelper.write(_os, prxContext);
- }
- else
- {
- 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)
- {
- abort(ex);
- }
+ try
+ {
+ _reference.getIdentity().__write(_os);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ String facet = _reference.getFacet();
+ if(facet == null || facet.length() == 0)
+ {
+ _os.writeStringSeq(null);
+ }
+ else
+ {
+ String[] facetPath = { facet };
+ _os.writeStringSeq(facetPath);
+ }
+
+ _os.writeString(operation);
+
+ _os.writeByte((byte)mode.value());
+
+ if(context != null)
+ {
+ //
+ // Explicit context
+ //
+ Ice.ContextHelper.write(_os, context);
+ }
+ else
+ {
+ //
+ // Implicit context
+ //
+ Ice.ImplicitContextI implicitContext =
+ _reference.getInstance().getImplicitContext();
+
+ java.util.Map prxContext = _reference.getContext();
+
+ if(implicitContext == null)
+ {
+ Ice.ContextHelper.write(_os, prxContext);
+ }
+ else
+ {
+ 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)
+ {
+ abort(ex);
+ }
}
private Ice.ConnectionI _connection;
diff --git a/java/src/IceInternal/OutgoingAsync.java b/java/src/IceInternal/OutgoingAsync.java
index 47440535c60..d7a9af5d4d7 100644
--- a/java/src/IceInternal/OutgoingAsync.java
+++ b/java/src/IceInternal/OutgoingAsync.java
@@ -21,31 +21,31 @@ public abstract class OutgoingAsync
public final void
__finished(BasicStream is)
{
- synchronized(_monitor)
- {
- int status;
-
- try
- {
- __is.swap(is);
-
- status = (int)__is.readByte();
-
- switch(status)
- {
- case DispatchStatus._DispatchOK:
- case DispatchStatus._DispatchUserException:
- {
- __is.startReadEncaps();
- break;
- }
-
- case DispatchStatus._DispatchObjectNotExist:
- case DispatchStatus._DispatchFacetNotExist:
- case DispatchStatus._DispatchOperationNotExist:
- {
- Ice.Identity id = new Ice.Identity();
- id.__read(__is);
+ synchronized(_monitor)
+ {
+ int status;
+
+ try
+ {
+ __is.swap(is);
+
+ status = (int)__is.readByte();
+
+ switch(status)
+ {
+ case DispatchStatus._DispatchOK:
+ case DispatchStatus._DispatchUserException:
+ {
+ __is.startReadEncaps();
+ break;
+ }
+
+ case DispatchStatus._DispatchObjectNotExist:
+ case DispatchStatus._DispatchFacetNotExist:
+ case DispatchStatus._DispatchOperationNotExist:
+ {
+ Ice.Identity id = new Ice.Identity();
+ id.__read(__is);
//
// For compatibility with the old FacetPath.
@@ -54,20 +54,20 @@ public abstract class OutgoingAsync
String facet;
if(facetPath.length > 0)
{
- if(facetPath.length > 1)
- {
- throw new Ice.MarshalException();
- }
+ if(facetPath.length > 1)
+ {
+ throw new Ice.MarshalException();
+ }
facet = facetPath[0];
}
- else
- {
- facet = "";
- }
+ else
+ {
+ facet = "";
+ }
- String operation = __is.readString();
+ String operation = __is.readString();
- Ice.RequestFailedException ex = null;
+ Ice.RequestFailedException ex = null;
switch(status)
{
case DispatchStatus._DispatchObjectNotExist:
@@ -95,17 +95,17 @@ public abstract class OutgoingAsync
}
}
- ex.id = id;
- ex.facet = facet;
- ex.operation = operation;
- throw ex;
- }
+ ex.id = id;
+ ex.facet = facet;
+ ex.operation = operation;
+ throw ex;
+ }
- case DispatchStatus._DispatchUnknownException:
- case DispatchStatus._DispatchUnknownLocalException:
- case DispatchStatus._DispatchUnknownUserException:
- {
- String unknown = __is.readString();
+ case DispatchStatus._DispatchUnknownException:
+ case DispatchStatus._DispatchUnknownLocalException:
+ case DispatchStatus._DispatchUnknownUserException:
+ {
+ String unknown = __is.readString();
Ice.UnknownException ex = null;
switch(status)
@@ -135,153 +135,153 @@ public abstract class OutgoingAsync
}
}
- ex.unknown = unknown;
- throw ex;
- }
-
- default:
- {
- throw new Ice.UnknownReplyStatusException();
- }
- }
- }
- catch(Ice.LocalException ex)
- {
- __finished(ex);
- return;
- }
-
- assert(status == DispatchStatus._DispatchOK || status == DispatchStatus._DispatchUserException);
-
- try
- {
- __response(status == DispatchStatus._DispatchOK);
- }
- catch(java.lang.Exception ex)
- {
- warning(ex);
- }
- finally
- {
- cleanup();
- }
- }
+ ex.unknown = unknown;
+ throw ex;
+ }
+
+ default:
+ {
+ throw new Ice.UnknownReplyStatusException();
+ }
+ }
+ }
+ catch(Ice.LocalException ex)
+ {
+ __finished(ex);
+ return;
+ }
+
+ assert(status == DispatchStatus._DispatchOK || status == DispatchStatus._DispatchUserException);
+
+ try
+ {
+ __response(status == DispatchStatus._DispatchOK);
+ }
+ catch(java.lang.Exception ex)
+ {
+ warning(ex);
+ }
+ finally
+ {
+ cleanup();
+ }
+ }
}
public final void
__finished(Ice.LocalException exc)
{
- synchronized(_monitor)
- {
- if(__os != null) // Don't retry if cleanup() was already called.
- {
- //
- // A CloseConnectionException indicates graceful
- // server shutdown, and is therefore always repeatable
- // without violating "at-most-once". That's because by
- // sending a close connection message, the server
- // guarantees that all outstanding requests can safely
- // be repeated. Otherwise, we can also retry if the
- // operation mode is Nonmutating or Idempotent.
- //
- // An ObjectNotExistException can always be retried as
- // well without violating "at-most-once".
- //
- if(_mode == Ice.OperationMode.Nonmutating || _mode == Ice.OperationMode.Idempotent ||
- exc instanceof Ice.CloseConnectionException || exc instanceof Ice.ObjectNotExistException)
- {
- try
- {
- _cnt = ((Ice.ObjectPrxHelperBase)_proxy).__handleException(_delegate, exc, _cnt);
- __send();
- return;
- }
- catch(Ice.LocalException ex)
- {
- }
- }
- }
-
- try
- {
- ice_exception(exc);
- }
- catch(java.lang.Exception ex)
- {
- warning(ex);
- }
- finally
- {
- cleanup();
- }
- }
+ synchronized(_monitor)
+ {
+ if(__os != null) // Don't retry if cleanup() was already called.
+ {
+ //
+ // A CloseConnectionException indicates graceful
+ // server shutdown, and is therefore always repeatable
+ // without violating "at-most-once". That's because by
+ // sending a close connection message, the server
+ // guarantees that all outstanding requests can safely
+ // be repeated. Otherwise, we can also retry if the
+ // operation mode is Nonmutating or Idempotent.
+ //
+ // An ObjectNotExistException can always be retried as
+ // well without violating "at-most-once".
+ //
+ if(_mode == Ice.OperationMode.Nonmutating || _mode == Ice.OperationMode.Idempotent ||
+ exc instanceof Ice.CloseConnectionException || exc instanceof Ice.ObjectNotExistException)
+ {
+ try
+ {
+ _cnt = ((Ice.ObjectPrxHelperBase)_proxy).__handleException(_delegate, exc, _cnt);
+ __send();
+ return;
+ }
+ catch(Ice.LocalException ex)
+ {
+ }
+ }
+ }
+
+ try
+ {
+ ice_exception(exc);
+ }
+ catch(java.lang.Exception ex)
+ {
+ warning(ex);
+ }
+ finally
+ {
+ cleanup();
+ }
+ }
}
public final boolean
__timedOut()
{
- //
- // No synchronization necessary, because
- // _absoluteTimeoutMillis is declared volatile. We cannot
- // synchronize here because otherwise there might be deadlocks
- // when Ice.ConnectionI calls back on this object with this
- // function.
- //
- if(_absoluteTimeoutMillis > 0)
- {
- return System.currentTimeMillis() >= _absoluteTimeoutMillis;
- }
- else
- {
- return false;
- }
+ //
+ // No synchronization necessary, because
+ // _absoluteTimeoutMillis is declared volatile. We cannot
+ // synchronize here because otherwise there might be deadlocks
+ // when Ice.ConnectionI calls back on this object with this
+ // function.
+ //
+ if(_absoluteTimeoutMillis > 0)
+ {
+ return System.currentTimeMillis() >= _absoluteTimeoutMillis;
+ }
+ else
+ {
+ return false;
+ }
}
protected final void
__prepare(Ice.ObjectPrx prx, String operation, Ice.OperationMode mode, java.util.Map context)
{
- synchronized(_monitor)
- {
- try
- {
- //
- // We must first wait for other requests to finish.
- //
- while(__os != null)
- {
- try
- {
- _monitor.wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- //
- // Can't call async via a oneway proxy.
- //
- ((Ice.ObjectPrxHelperBase)prx).__checkTwowayOnly(operation);
-
- _proxy = prx;
+ synchronized(_monitor)
+ {
+ try
+ {
+ //
+ // We must first wait for other requests to finish.
+ //
+ while(__os != null)
+ {
+ try
+ {
+ _monitor.wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ //
+ // Can't call async via a oneway proxy.
+ //
+ ((Ice.ObjectPrxHelperBase)prx).__checkTwowayOnly(operation);
+
+ _proxy = prx;
_delegate = null;
- _cnt = 0;
- _mode = mode;
+ _cnt = 0;
+ _mode = mode;
- Reference ref = ((Ice.ObjectPrxHelperBase)_proxy).__reference();
- assert(__is == null);
- __is = new BasicStream(ref.getInstance());
- assert(__os == null);
- __os = new BasicStream(ref.getInstance());
+ Reference ref = ((Ice.ObjectPrxHelperBase)_proxy).__reference();
+ assert(__is == null);
+ __is = new BasicStream(ref.getInstance());
+ assert(__os == null);
+ __os = new BasicStream(ref.getInstance());
- __os.writeBlob(IceInternal.Protocol.requestHdr);
-
- ref.getIdentity().__write(__os);
+ __os.writeBlob(IceInternal.Protocol.requestHdr);
+
+ ref.getIdentity().__write(__os);
//
// For compatibility with the old FacetPath.
//
- String facet = ref.getFacet();
+ String facet = ref.getFacet();
if(facet == null || facet.length() == 0)
{
__os.writeStringSeq(null);
@@ -292,96 +292,96 @@ public abstract class OutgoingAsync
__os.writeStringSeq(facetPath);
}
- __os.writeString(operation);
-
- __os.writeByte((byte)mode.value());
-
- if(context != null)
- {
- //
- // Explicit context
- //
- Ice.ContextHelper.write(__os, context);
- }
- else
- {
- //
- // Implicit context
- //
- Ice.ImplicitContextI implicitContext =
- ref.getInstance().getImplicitContext();
-
- java.util.Map prxContext = ref.getContext();
-
- if(implicitContext == null)
- {
- Ice.ContextHelper.write(__os, prxContext);
- }
- else
- {
- implicitContext.write(prxContext, __os);
- }
- }
-
- __os.startWriteEncaps();
- }
- catch(Ice.LocalException ex)
- {
- cleanup();
- throw ex;
- }
- }
+ __os.writeString(operation);
+
+ __os.writeByte((byte)mode.value());
+
+ if(context != null)
+ {
+ //
+ // Explicit context
+ //
+ Ice.ContextHelper.write(__os, context);
+ }
+ else
+ {
+ //
+ // Implicit context
+ //
+ Ice.ImplicitContextI implicitContext =
+ ref.getInstance().getImplicitContext();
+
+ java.util.Map prxContext = ref.getContext();
+
+ if(implicitContext == null)
+ {
+ Ice.ContextHelper.write(__os, prxContext);
+ }
+ else
+ {
+ implicitContext.write(prxContext, __os);
+ }
+ }
+
+ __os.startWriteEncaps();
+ }
+ catch(Ice.LocalException ex)
+ {
+ cleanup();
+ throw ex;
+ }
+ }
}
protected final void
__send()
{
- synchronized(_monitor)
- {
- try
- {
- while(true)
- {
- Ice.BooleanHolder comp = new Ice.BooleanHolder();
+ synchronized(_monitor)
+ {
+ try
+ {
+ while(true)
+ {
+ Ice.BooleanHolder comp = new Ice.BooleanHolder();
_delegate = ((Ice.ObjectPrxHelperBase)_proxy).__getDelegate();
- Ice.ConnectionI con = _delegate.__getConnection(comp);
- if(con.timeout() >= 0)
- {
- _absoluteTimeoutMillis = System.currentTimeMillis() + con.timeout();
- }
- else
- {
- _absoluteTimeoutMillis = 0;
- }
-
- try
- {
- con.sendAsyncRequest(__os, this, comp.value);
-
- //
- // Don't do anything after sendAsyncRequest() returned
- // without an exception. I such case, there will be
- // callbacks, i.e., calls to the __finished()
- // functions. Since there is no mutex protection, we
- // cannot modify state here and in such callbacks.
- //
- return;
- }
- catch(LocalExceptionWrapper ex)
- {
- ((Ice.ObjectPrxHelperBase)_proxy).__handleExceptionWrapper(_delegate, ex);
- }
- catch(Ice.LocalException ex)
- {
- _cnt = ((Ice.ObjectPrxHelperBase)_proxy).__handleException(_delegate, ex, _cnt);
- }
- }
- }
- catch(Ice.LocalException ex)
- {
- __finished(ex);
- }
- }
+ Ice.ConnectionI con = _delegate.__getConnection(comp);
+ if(con.timeout() >= 0)
+ {
+ _absoluteTimeoutMillis = System.currentTimeMillis() + con.timeout();
+ }
+ else
+ {
+ _absoluteTimeoutMillis = 0;
+ }
+
+ try
+ {
+ con.sendAsyncRequest(__os, this, comp.value);
+
+ //
+ // Don't do anything after sendAsyncRequest() returned
+ // without an exception. I such case, there will be
+ // callbacks, i.e., calls to the __finished()
+ // functions. Since there is no mutex protection, we
+ // cannot modify state here and in such callbacks.
+ //
+ return;
+ }
+ catch(LocalExceptionWrapper ex)
+ {
+ ((Ice.ObjectPrxHelperBase)_proxy).__handleExceptionWrapper(_delegate, ex);
+ }
+ catch(Ice.LocalException ex)
+ {
+ _cnt = ((Ice.ObjectPrxHelperBase)_proxy).__handleException(_delegate, ex, _cnt);
+ }
+ }
+ }
+ catch(Ice.LocalException ex)
+ {
+ __finished(ex);
+ }
+ }
}
protected abstract void __response(boolean ok);
@@ -389,31 +389,31 @@ public abstract class OutgoingAsync
private final void
warning(java.lang.Exception ex)
{
- if(__os != null) // Don't print anything if cleanup() was already called.
- {
- Reference ref = ((Ice.ObjectPrxHelperBase)_proxy).__reference();
- if(ref.getInstance().initializationData().properties.getPropertyAsIntWithDefault(
- "Ice.Warn.AMICallback", 1) > 0)
- {
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- IceUtil.OutputBase out = new IceUtil.OutputBase(pw);
- out.setUseTab(false);
- out.print("exception raised by AMI callback:\n");
- ex.printStackTrace(pw);
- pw.flush();
- ref.getInstance().initializationData().logger.warning(sw.toString());
- }
- }
+ if(__os != null) // Don't print anything if cleanup() was already called.
+ {
+ Reference ref = ((Ice.ObjectPrxHelperBase)_proxy).__reference();
+ if(ref.getInstance().initializationData().properties.getPropertyAsIntWithDefault(
+ "Ice.Warn.AMICallback", 1) > 0)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ IceUtil.OutputBase out = new IceUtil.OutputBase(pw);
+ out.setUseTab(false);
+ out.print("exception raised by AMI callback:\n");
+ ex.printStackTrace(pw);
+ pw.flush();
+ ref.getInstance().initializationData().logger.warning(sw.toString());
+ }
+ }
}
private final void
cleanup()
{
- __is = null;
- __os = null;
+ __is = null;
+ __os = null;
- _monitor.notify();
+ _monitor.notify();
}
protected BasicStream __is;
diff --git a/java/src/IceInternal/OutgoingConnectionFactory.java b/java/src/IceInternal/OutgoingConnectionFactory.java
index bad0c4edba8..d44b99cdabe 100644
--- a/java/src/IceInternal/OutgoingConnectionFactory.java
+++ b/java/src/IceInternal/OutgoingConnectionFactory.java
@@ -22,15 +22,15 @@ public final class OutgoingConnectionFactory
java.util.Iterator p = _connections.values().iterator();
while(p.hasNext())
{
- java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
-
- java.util.Iterator q = connectionList.iterator();
- while(q.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
- connection.destroy(Ice.ConnectionI.CommunicatorDestroyed);
- }
- }
+ java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
+
+ java.util.Iterator q = connectionList.iterator();
+ while(q.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
+ connection.destroy(Ice.ConnectionI.CommunicatorDestroyed);
+ }
+ }
_destroyed = true;
notifyAll();
@@ -39,72 +39,72 @@ public final class OutgoingConnectionFactory
public void
waitUntilFinished()
{
- java.util.HashMap connections;
-
- synchronized(this)
- {
- //
- // First we wait until the factory is destroyed. We also
- // wait until there are no pending connections
- // anymore. Only then we can be sure the _connections
- // contains all connections.
- //
- while(!_destroyed || !_pending.isEmpty())
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- //
- // We want to wait until all connections are finished outside the
- // thread synchronization.
- //
- // For consistency with C#, we set _connections to null rather than to a
- // new empty list so that our finalizer does not try to invoke any
- // methods on member objects.
- //
- connections = _connections;
- _connections = null;
- }
-
- //
- // Now we wait for until the destruction of each connection is
- // finished.
- //
+ java.util.HashMap connections;
+
+ synchronized(this)
+ {
+ //
+ // First we wait until the factory is destroyed. We also
+ // wait until there are no pending connections
+ // anymore. Only then we can be sure the _connections
+ // contains all connections.
+ //
+ while(!_destroyed || !_pending.isEmpty())
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ //
+ // We want to wait until all connections are finished outside the
+ // thread synchronization.
+ //
+ // For consistency with C#, we set _connections to null rather than to a
+ // new empty list so that our finalizer does not try to invoke any
+ // methods on member objects.
+ //
+ connections = _connections;
+ _connections = null;
+ }
+
+ //
+ // Now we wait for until the destruction of each connection is
+ // finished.
+ //
java.util.Iterator p = connections.values().iterator();
while(p.hasNext())
{
- java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
-
- java.util.Iterator q = connectionList.iterator();
- while(q.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
- connection.waitUntilFinished();
- }
+ java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
+
+ java.util.Iterator q = connectionList.iterator();
+ while(q.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
+ connection.waitUntilFinished();
+ }
}
}
public Ice.ConnectionI
create(EndpointI[] endpts, boolean hasMore, boolean threadPerConnection, Ice.BooleanHolder compress)
{
- assert(endpts.length > 0);
- EndpointI[] endpoints = new EndpointI[endpts.length];
- System.arraycopy(endpts, 0, endpoints, 0, endpts.length);
+ assert(endpts.length > 0);
+ EndpointI[] endpoints = new EndpointI[endpts.length];
+ System.arraycopy(endpts, 0, endpoints, 0, endpts.length);
DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
- synchronized(this)
- {
- if(_destroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
+ synchronized(this)
+ {
+ if(_destroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
//
// TODO: Remove when we no longer support SSL for JDK 1.4.
@@ -119,296 +119,296 @@ public final class OutgoingConnectionFactory
}
}
- //
- // Reap connections for which destruction has completed.
- //
- java.util.Iterator p = _connections.values().iterator();
- while(p.hasNext())
- {
- java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
-
- java.util.Iterator q = connectionList.iterator();
- while(q.hasNext())
- {
- Ice.ConnectionI con = (Ice.ConnectionI)q.next();
- if(con.isFinished())
- {
- q.remove();
- }
- }
-
- if(connectionList.isEmpty())
- {
- p.remove();
- }
- }
-
- //
- // Modify endpoints with overrides.
- //
- for(int i = 0; i < endpoints.length; i++)
- {
- if(defaultsAndOverrides.overrideTimeout)
- {
- endpoints[i] = endpoints[i].timeout(defaultsAndOverrides.overrideTimeoutValue);
- }
-
- //
- // The Connection object does not take the compression flag of
- // endpoints into account, but instead gets the information
- // about whether messages should be compressed or not from
- // other sources. In order to allow connection sharing for
- // endpoints that differ in the value of the compression flag
- // only, we always set the compression flag to false here in
- // this connection factory.
- //
- endpoints[i] = endpoints[i].compress(false);
- }
-
- //
- // Search for existing connections.
- //
- for(int i = 0; i < endpoints.length; i++)
- {
- java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]);
- if(connectionList != null)
- {
- java.util.Iterator q = connectionList.iterator();
-
- while(q.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
-
- //
- // Don't return connections for which destruction has
- // been initiated. The connection must also match the
+ //
+ // Reap connections for which destruction has completed.
+ //
+ java.util.Iterator p = _connections.values().iterator();
+ while(p.hasNext())
+ {
+ java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
+
+ java.util.Iterator q = connectionList.iterator();
+ while(q.hasNext())
+ {
+ Ice.ConnectionI con = (Ice.ConnectionI)q.next();
+ if(con.isFinished())
+ {
+ q.remove();
+ }
+ }
+
+ if(connectionList.isEmpty())
+ {
+ p.remove();
+ }
+ }
+
+ //
+ // Modify endpoints with overrides.
+ //
+ for(int i = 0; i < endpoints.length; i++)
+ {
+ if(defaultsAndOverrides.overrideTimeout)
+ {
+ endpoints[i] = endpoints[i].timeout(defaultsAndOverrides.overrideTimeoutValue);
+ }
+
+ //
+ // The Connection object does not take the compression flag of
+ // endpoints into account, but instead gets the information
+ // about whether messages should be compressed or not from
+ // other sources. In order to allow connection sharing for
+ // endpoints that differ in the value of the compression flag
+ // only, we always set the compression flag to false here in
+ // this connection factory.
+ //
+ endpoints[i] = endpoints[i].compress(false);
+ }
+
+ //
+ // Search for existing connections.
+ //
+ for(int i = 0; i < endpoints.length; i++)
+ {
+ java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]);
+ if(connectionList != null)
+ {
+ java.util.Iterator q = connectionList.iterator();
+
+ while(q.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
+
+ //
+ // Don't return connections for which destruction has
+ // been initiated. The connection must also match the
// requested thread-per-connection setting.
- //
- if(!connection.isDestroyed() && connection.threadPerConnection() == threadPerConnection)
- {
- if(defaultsAndOverrides.overrideCompress)
- {
- compress.value = defaultsAndOverrides.overrideCompressValue;
- }
- else
- {
- compress.value = endpts[i].compress();
- }
-
- return connection;
- }
- }
- }
- }
-
- //
- // If some other thread is currently trying to establish a
- // connection to any of our endpoints, we wait until this
- // thread is finished.
- //
- boolean searchAgain = false;
- while(!_destroyed)
- {
- int i;
- for(i = 0; i < endpoints.length; i++)
- {
- if(_pending.contains(endpoints[i]))
- {
- break;
- }
- }
-
- if(i == endpoints.length)
- {
- break;
- }
-
- searchAgain = true;
-
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- if(_destroyed)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
-
- //
- // Search for existing connections again if we waited
- // above, as new connections might have been added in the
- // meantime.
- //
- if(searchAgain)
- {
- for(int i = 0; i < endpoints.length; i++)
- {
- java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]);
- if(connectionList != null)
- {
- java.util.Iterator q = connectionList.iterator();
-
- while(q.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
-
- //
- // Don't return connections for which destruction has
+ //
+ if(!connection.isDestroyed() && connection.threadPerConnection() == threadPerConnection)
+ {
+ if(defaultsAndOverrides.overrideCompress)
+ {
+ compress.value = defaultsAndOverrides.overrideCompressValue;
+ }
+ else
+ {
+ compress.value = endpts[i].compress();
+ }
+
+ return connection;
+ }
+ }
+ }
+ }
+
+ //
+ // If some other thread is currently trying to establish a
+ // connection to any of our endpoints, we wait until this
+ // thread is finished.
+ //
+ boolean searchAgain = false;
+ while(!_destroyed)
+ {
+ int i;
+ for(i = 0; i < endpoints.length; i++)
+ {
+ if(_pending.contains(endpoints[i]))
+ {
+ break;
+ }
+ }
+
+ if(i == endpoints.length)
+ {
+ break;
+ }
+
+ searchAgain = true;
+
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ if(_destroyed)
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
+
+ //
+ // Search for existing connections again if we waited
+ // above, as new connections might have been added in the
+ // meantime.
+ //
+ if(searchAgain)
+ {
+ for(int i = 0; i < endpoints.length; i++)
+ {
+ java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]);
+ if(connectionList != null)
+ {
+ java.util.Iterator q = connectionList.iterator();
+
+ while(q.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
+
+ //
+ // Don't return connections for which destruction has
// been initiated. The connection must also match the
// requested thread-per-connection setting.
- //
+ //
if(!connection.isDestroyed() && connection.threadPerConnection() == threadPerConnection)
- {
- if(defaultsAndOverrides.overrideCompress)
- {
- compress.value = defaultsAndOverrides.overrideCompressValue;
- }
- else
- {
- compress.value = endpts[i].compress();
- }
-
- return connection;
- }
- }
- }
- }
- }
-
- //
- // No connection to any of our endpoints exists yet, so we
- // will try to create one. To avoid that other threads try
- // to create connections to the same endpoints, we add our
- // endpoints to _pending.
- //
- for(int i = 0; i < endpoints.length; i++)
- {
- _pending.add(endpoints[i]);
- }
- }
-
- Ice.ConnectionI connection = null;
- Ice.LocalException exception = null;
-
- for(int i = 0; i < endpoints.length; i++)
- {
- EndpointI endpoint = endpoints[i];
-
- try
- {
- Transceiver transceiver = endpoint.clientTransceiver();
- if(transceiver == null)
- {
- Connector connector = endpoint.connector();
- assert(connector != null);
-
- int timeout;
- if(defaultsAndOverrides.overrideConnectTimeout)
- {
- timeout = defaultsAndOverrides.overrideConnectTimeoutValue;
- }
- // It is not necessary to check for overrideTimeout,
- // the endpoint has already been modified with this
- // override, if set.
- else
- {
- timeout = endpoint.timeout();
- }
-
- transceiver = connector.connect(timeout);
- assert(transceiver != null);
- }
- connection = new Ice.ConnectionI(_instance, transceiver, endpoint, null, threadPerConnection);
- connection.validate();
-
- if(defaultsAndOverrides.overrideCompress)
- {
- compress.value = defaultsAndOverrides.overrideCompressValue;
- }
- else
- {
- compress.value = endpts[i].compress();
- }
- break;
- }
- catch(Ice.LocalException ex)
- {
- exception = ex;
-
- //
- // If a connection object was constructed, then validate()
- // must have raised the exception.
- //
- if(connection != null)
- {
- connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
- connection = null;
- }
- }
-
- TraceLevels traceLevels = _instance.traceLevels();
- if(traceLevels.retry >= 2)
- {
- StringBuffer s = new StringBuffer();
- s.append("connection to endpoint failed");
- if(hasMore || i < endpoints.length - 1)
- {
- s.append(", trying next endpoint\n");
- }
- else
- {
- s.append(" and no more endpoints to try\n");
- }
- s.append(exception.toString());
- _instance.initializationData().logger.trace(traceLevels.retryCat, s.toString());
- }
- }
-
- synchronized(this)
- {
- //
- // Signal other threads that we are done with trying to
- // establish connections to our endpoints.
- //
- for(int i = 0; i < endpoints.length; i++)
- {
- _pending.remove(endpoints[i]);
- }
- notifyAll();
-
- if(connection == null)
- {
- assert(exception != null);
- throw exception;
- }
- else
- {
- java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(connection.endpoint());
- if(connectionList == null)
- {
- connectionList = new java.util.LinkedList();
- _connections.put(connection.endpoint(), connectionList);
- }
- connectionList.add(connection);
-
- if(_destroyed)
- {
- connection.destroy(Ice.ConnectionI.CommunicatorDestroyed);
- throw new Ice.CommunicatorDestroyedException();
- }
- else
- {
- connection.activate();
- }
- }
- }
-
- assert(connection != null);
+ {
+ if(defaultsAndOverrides.overrideCompress)
+ {
+ compress.value = defaultsAndOverrides.overrideCompressValue;
+ }
+ else
+ {
+ compress.value = endpts[i].compress();
+ }
+
+ return connection;
+ }
+ }
+ }
+ }
+ }
+
+ //
+ // No connection to any of our endpoints exists yet, so we
+ // will try to create one. To avoid that other threads try
+ // to create connections to the same endpoints, we add our
+ // endpoints to _pending.
+ //
+ for(int i = 0; i < endpoints.length; i++)
+ {
+ _pending.add(endpoints[i]);
+ }
+ }
+
+ Ice.ConnectionI connection = null;
+ Ice.LocalException exception = null;
+
+ for(int i = 0; i < endpoints.length; i++)
+ {
+ EndpointI endpoint = endpoints[i];
+
+ try
+ {
+ Transceiver transceiver = endpoint.clientTransceiver();
+ if(transceiver == null)
+ {
+ Connector connector = endpoint.connector();
+ assert(connector != null);
+
+ int timeout;
+ if(defaultsAndOverrides.overrideConnectTimeout)
+ {
+ timeout = defaultsAndOverrides.overrideConnectTimeoutValue;
+ }
+ // It is not necessary to check for overrideTimeout,
+ // the endpoint has already been modified with this
+ // override, if set.
+ else
+ {
+ timeout = endpoint.timeout();
+ }
+
+ transceiver = connector.connect(timeout);
+ assert(transceiver != null);
+ }
+ connection = new Ice.ConnectionI(_instance, transceiver, endpoint, null, threadPerConnection);
+ connection.validate();
+
+ if(defaultsAndOverrides.overrideCompress)
+ {
+ compress.value = defaultsAndOverrides.overrideCompressValue;
+ }
+ else
+ {
+ compress.value = endpts[i].compress();
+ }
+ break;
+ }
+ catch(Ice.LocalException ex)
+ {
+ exception = ex;
+
+ //
+ // If a connection object was constructed, then validate()
+ // must have raised the exception.
+ //
+ if(connection != null)
+ {
+ connection.waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
+ connection = null;
+ }
+ }
+
+ TraceLevels traceLevels = _instance.traceLevels();
+ if(traceLevels.retry >= 2)
+ {
+ StringBuffer s = new StringBuffer();
+ s.append("connection to endpoint failed");
+ if(hasMore || i < endpoints.length - 1)
+ {
+ s.append(", trying next endpoint\n");
+ }
+ else
+ {
+ s.append(" and no more endpoints to try\n");
+ }
+ s.append(exception.toString());
+ _instance.initializationData().logger.trace(traceLevels.retryCat, s.toString());
+ }
+ }
+
+ synchronized(this)
+ {
+ //
+ // Signal other threads that we are done with trying to
+ // establish connections to our endpoints.
+ //
+ for(int i = 0; i < endpoints.length; i++)
+ {
+ _pending.remove(endpoints[i]);
+ }
+ notifyAll();
+
+ if(connection == null)
+ {
+ assert(exception != null);
+ throw exception;
+ }
+ else
+ {
+ java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(connection.endpoint());
+ if(connectionList == null)
+ {
+ connectionList = new java.util.LinkedList();
+ _connections.put(connection.endpoint(), connectionList);
+ }
+ connectionList.add(connection);
+
+ if(_destroyed)
+ {
+ connection.destroy(Ice.ConnectionI.CommunicatorDestroyed);
+ throw new Ice.CommunicatorDestroyedException();
+ }
+ else
+ {
+ connection.activate();
+ }
+ }
+ }
+
+ assert(connection != null);
return connection;
}
@@ -422,59 +422,59 @@ public final class OutgoingConnectionFactory
assert(routerInfo != null);
- //
- // Search for connections to the router's client proxy
- // endpoints, and update the object adapter for such
- // connections, so that callbacks from the router can be
- // received over such connections.
- //
- Ice.ObjectAdapter adapter = routerInfo.getAdapter();
- DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
- EndpointI[] endpoints = routerInfo.getClientEndpoints();
- for(int i = 0; i < endpoints.length; i++)
- {
- EndpointI endpoint = endpoints[i];
-
- //
- // Modify endpoints with overrides.
- //
- if(defaultsAndOverrides.overrideTimeout)
- {
- endpoint = endpoint.timeout(defaultsAndOverrides.overrideTimeoutValue);
- }
-
- //
- // The Connection object does not take the compression flag of
- // endpoints into account, but instead gets the information
- // about whether messages should be compressed or not from
- // other sources. In order to allow connection sharing for
- // endpoints that differ in the value of the compression flag
- // only, we always set the compression flag to false here in
- // this connection factory.
- //
- endpoint = endpoint.compress(false);
-
- java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]);
- if(connectionList != null)
- {
- java.util.Iterator p = connectionList.iterator();
-
- while(p.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
- try
- {
- connection.setAdapter(adapter);
- }
- catch(Ice.LocalException ex)
- {
- //
- // Ignore, the connection is being closed or closed.
- //
- }
- }
- }
- }
+ //
+ // Search for connections to the router's client proxy
+ // endpoints, and update the object adapter for such
+ // connections, so that callbacks from the router can be
+ // received over such connections.
+ //
+ Ice.ObjectAdapter adapter = routerInfo.getAdapter();
+ DefaultsAndOverrides defaultsAndOverrides = _instance.defaultsAndOverrides();
+ EndpointI[] endpoints = routerInfo.getClientEndpoints();
+ for(int i = 0; i < endpoints.length; i++)
+ {
+ EndpointI endpoint = endpoints[i];
+
+ //
+ // Modify endpoints with overrides.
+ //
+ if(defaultsAndOverrides.overrideTimeout)
+ {
+ endpoint = endpoint.timeout(defaultsAndOverrides.overrideTimeoutValue);
+ }
+
+ //
+ // The Connection object does not take the compression flag of
+ // endpoints into account, but instead gets the information
+ // about whether messages should be compressed or not from
+ // other sources. In order to allow connection sharing for
+ // endpoints that differ in the value of the compression flag
+ // only, we always set the compression flag to false here in
+ // this connection factory.
+ //
+ endpoint = endpoint.compress(false);
+
+ java.util.LinkedList connectionList = (java.util.LinkedList)_connections.get(endpoints[i]);
+ if(connectionList != null)
+ {
+ java.util.Iterator p = connectionList.iterator();
+
+ while(p.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)p.next();
+ try
+ {
+ connection.setAdapter(adapter);
+ }
+ catch(Ice.LocalException ex)
+ {
+ //
+ // Ignore, the connection is being closed or closed.
+ //
+ }
+ }
+ }
+ }
}
public synchronized void
@@ -488,61 +488,61 @@ public final class OutgoingConnectionFactory
java.util.Iterator p = _connections.values().iterator();
while(p.hasNext())
{
- java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
-
- java.util.Iterator q = connectionList.iterator();
- while(q.hasNext())
- {
- Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
- if(connection.getAdapter() == adapter)
- {
- try
- {
- connection.setAdapter(null);
- }
- catch(Ice.LocalException ex)
- {
- //
- // Ignore, the connection is being closed or closed.
- //
- }
- }
- }
- }
+ java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
+
+ java.util.Iterator q = connectionList.iterator();
+ while(q.hasNext())
+ {
+ Ice.ConnectionI connection = (Ice.ConnectionI)q.next();
+ if(connection.getAdapter() == adapter)
+ {
+ try
+ {
+ connection.setAdapter(null);
+ }
+ catch(Ice.LocalException ex)
+ {
+ //
+ // Ignore, the connection is being closed or closed.
+ //
+ }
+ }
+ }
+ }
}
public void
flushBatchRequests()
{
- java.util.LinkedList c = new java.util.LinkedList();
+ java.util.LinkedList c = new java.util.LinkedList();
synchronized(this)
- {
- java.util.Iterator p = _connections.values().iterator();
- while(p.hasNext())
- {
- java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
- java.util.Iterator q = connectionList.iterator();
- while(q.hasNext())
- {
- c.add(q.next());
- }
- }
- }
-
- java.util.Iterator p = c.iterator();
- while(p.hasNext())
- {
- Ice.ConnectionI conn = (Ice.ConnectionI)p.next();
- try
- {
- conn.flushBatchRequests();
- }
- catch(Ice.LocalException ex)
- {
- // Ignore.
- }
- }
+ {
+ java.util.Iterator p = _connections.values().iterator();
+ while(p.hasNext())
+ {
+ java.util.LinkedList connectionList = (java.util.LinkedList)p.next();
+ java.util.Iterator q = connectionList.iterator();
+ while(q.hasNext())
+ {
+ c.add(q.next());
+ }
+ }
+ }
+
+ java.util.Iterator p = c.iterator();
+ while(p.hasNext())
+ {
+ Ice.ConnectionI conn = (Ice.ConnectionI)p.next();
+ try
+ {
+ conn.flushBatchRequests();
+ }
+ catch(Ice.LocalException ex)
+ {
+ // Ignore.
+ }
+ }
}
//
@@ -551,15 +551,15 @@ public final class OutgoingConnectionFactory
OutgoingConnectionFactory(Instance instance)
{
_instance = instance;
- _destroyed = false;
+ _destroyed = false;
}
protected synchronized void
finalize()
throws Throwable
{
- IceUtil.Assert.FinalizerAssert(_destroyed);
- IceUtil.Assert.FinalizerAssert(_connections == null);
+ IceUtil.Assert.FinalizerAssert(_destroyed);
+ IceUtil.Assert.FinalizerAssert(_connections == null);
super.finalize();
}
diff --git a/java/src/IceInternal/Protocol.java b/java/src/IceInternal/Protocol.java
index 3968cc5c091..a1952ff8d30 100644
--- a/java/src/IceInternal/Protocol.java
+++ b/java/src/IceInternal/Protocol.java
@@ -28,7 +28,7 @@ final public class Protocol
//
// The magic number at the front of each message
//
- public final static byte magic[] = { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P'
+ public final static byte magic[] = { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P'
//
// The current Ice protocol and encoding version
@@ -49,10 +49,10 @@ final public class Protocol
public final static byte[] requestHdr =
{
- IceInternal.Protocol.magic[0],
- IceInternal.Protocol.magic[1],
- IceInternal.Protocol.magic[2],
- IceInternal.Protocol.magic[3],
+ IceInternal.Protocol.magic[0],
+ IceInternal.Protocol.magic[1],
+ IceInternal.Protocol.magic[2],
+ IceInternal.Protocol.magic[3],
IceInternal.Protocol.protocolMajor,
IceInternal.Protocol.protocolMinor,
IceInternal.Protocol.encodingMajor,
@@ -65,10 +65,10 @@ final public class Protocol
public final static byte[] requestBatchHdr =
{
- IceInternal.Protocol.magic[0],
- IceInternal.Protocol.magic[1],
- IceInternal.Protocol.magic[2],
- IceInternal.Protocol.magic[3],
+ IceInternal.Protocol.magic[0],
+ IceInternal.Protocol.magic[1],
+ IceInternal.Protocol.magic[2],
+ IceInternal.Protocol.magic[3],
IceInternal.Protocol.protocolMajor,
IceInternal.Protocol.protocolMinor,
IceInternal.Protocol.encodingMajor,
@@ -81,10 +81,10 @@ final public class Protocol
public final static byte[] replyHdr =
{
- IceInternal.Protocol.magic[0],
- IceInternal.Protocol.magic[1],
- IceInternal.Protocol.magic[2],
- IceInternal.Protocol.magic[3],
+ IceInternal.Protocol.magic[0],
+ IceInternal.Protocol.magic[1],
+ IceInternal.Protocol.magic[2],
+ IceInternal.Protocol.magic[3],
IceInternal.Protocol.protocolMajor,
IceInternal.Protocol.protocolMinor,
IceInternal.Protocol.encodingMajor,
diff --git a/java/src/IceInternal/ProtocolPluginFacadeI.java b/java/src/IceInternal/ProtocolPluginFacadeI.java
index b4198940756..53ae82a59d1 100644
--- a/java/src/IceInternal/ProtocolPluginFacadeI.java
+++ b/java/src/IceInternal/ProtocolPluginFacadeI.java
@@ -14,8 +14,8 @@ public class ProtocolPluginFacadeI implements ProtocolPluginFacade
public
ProtocolPluginFacadeI(Ice.Communicator communicator)
{
- _communicator = communicator;
- _instance = Ice.Util.getInstance(communicator);
+ _communicator = communicator;
+ _instance = Ice.Util.getInstance(communicator);
}
//
@@ -25,7 +25,7 @@ public class ProtocolPluginFacadeI implements ProtocolPluginFacade
public Ice.Communicator
getCommunicator()
{
- return _communicator;
+ return _communicator;
}
//
@@ -34,7 +34,7 @@ public class ProtocolPluginFacadeI implements ProtocolPluginFacade
public String
getDefaultHost()
{
- return _instance.defaultsAndOverrides().defaultHost;
+ return _instance.defaultsAndOverrides().defaultHost;
}
//
@@ -43,13 +43,13 @@ public class ProtocolPluginFacadeI implements ProtocolPluginFacade
public int
getNetworkTraceLevel()
{
- return _instance.traceLevels().network;
+ return _instance.traceLevels().network;
}
public String
getNetworkTraceCategory()
{
- return _instance.traceLevels().networkCat;
+ return _instance.traceLevels().networkCat;
}
//
@@ -58,7 +58,7 @@ public class ProtocolPluginFacadeI implements ProtocolPluginFacade
public void
addEndpointFactory(EndpointFactory factory)
{
- _instance.endpointFactoryManager().add(factory);
+ _instance.endpointFactoryManager().add(factory);
}
private Instance _instance;
diff --git a/java/src/IceInternal/ProxyFactory.java b/java/src/IceInternal/ProxyFactory.java
index 92931ebdd0b..4e06ae80e44 100644
--- a/java/src/IceInternal/ProxyFactory.java
+++ b/java/src/IceInternal/ProxyFactory.java
@@ -89,51 +89,51 @@ public final class ProxyFactory
TraceLevels traceLevels = _instance.traceLevels();
Ice.Logger logger = _instance.initializationData().logger;
- if(ex instanceof Ice.ObjectNotExistException)
- {
- Ice.ObjectNotExistException one = (Ice.ObjectNotExistException)ex;
+ if(ex instanceof Ice.ObjectNotExistException)
+ {
+ Ice.ObjectNotExistException one = (Ice.ObjectNotExistException)ex;
- LocatorInfo li = ref.getLocatorInfo();
- if(li != null)
- {
- //
- // We retry ObjectNotExistException if the reference is
- // indirect.
- //
- li.clearObjectCache((IceInternal.IndirectReference)ref);
- }
- else if(ref.getRouterInfo() != null && one.operation.equals("ice_add_proxy"))
- {
- //
- // If we have a router, an ObjectNotExistException with an
- // operation name "ice_add_proxy" indicates to the client
- // that the router isn't aware of the proxy (for example,
- // because it was evicted by the router). In this case, we
- // must *always* retry, so that the missing proxy is added
- // to the router.
- //
- if(traceLevels.retry >= 1)
- {
+ LocatorInfo li = ref.getLocatorInfo();
+ if(li != null)
+ {
+ //
+ // We retry ObjectNotExistException if the reference is
+ // indirect.
+ //
+ li.clearObjectCache((IceInternal.IndirectReference)ref);
+ }
+ else if(ref.getRouterInfo() != null && one.operation.equals("ice_add_proxy"))
+ {
+ //
+ // If we have a router, an ObjectNotExistException with an
+ // operation name "ice_add_proxy" indicates to the client
+ // that the router isn't aware of the proxy (for example,
+ // because it was evicted by the router). In this case, we
+ // must *always* retry, so that the missing proxy is added
+ // to the router.
+ //
+ if(traceLevels.retry >= 1)
+ {
String s = "retrying operation call to add proxy to router\n" + ex.toString();
logger.trace(traceLevels.retryCat, s);
- }
- return cnt; // We must always retry, so we don't look at the retry count.
- }
- else
- {
- //
- // For all other cases, we don't retry ObjectNotExistException.
- //
- throw ex;
- }
- }
- else if(ex instanceof Ice.RequestFailedException)
- {
+ }
+ return cnt; // We must always retry, so we don't look at the retry count.
+ }
+ else
+ {
+ //
+ // For all other cases, we don't retry ObjectNotExistException.
+ //
+ throw ex;
+ }
+ }
+ else if(ex instanceof Ice.RequestFailedException)
+ {
//
// For all other cases, we don't retry ObjectNotExistException
//
- throw ex;
- }
+ throw ex;
+ }
//
// There is no point in retrying an operation that resulted in a
@@ -212,44 +212,44 @@ public final class ProxyFactory
{
_instance = instance;
- String str = _instance.initializationData().properties.getPropertyWithDefault("Ice.RetryIntervals", "0");
+ String str = _instance.initializationData().properties.getPropertyWithDefault("Ice.RetryIntervals", "0");
String[] arr = str.trim().split("[ \t\n\r]+");
- if(arr.length > 0)
- {
- _retryIntervals = new int[arr.length];
+ if(arr.length > 0)
+ {
+ _retryIntervals = new int[arr.length];
- for(int i = 0; i < arr.length; i++)
- {
- int v;
+ for(int i = 0; i < arr.length; i++)
+ {
+ int v;
- try
- {
- v = Integer.parseInt(arr[i]);
- }
- catch(NumberFormatException ex)
- {
- v = 0;
- }
+ try
+ {
+ v = Integer.parseInt(arr[i]);
+ }
+ catch(NumberFormatException ex)
+ {
+ v = 0;
+ }
- //
- // If -1 is the first value, no retry and wait intervals.
- //
- if(i == 0 && v == -1)
- {
- _retryIntervals = new int[0];
- break;
- }
+ //
+ // If -1 is the first value, no retry and wait intervals.
+ //
+ if(i == 0 && v == -1)
+ {
+ _retryIntervals = new int[0];
+ break;
+ }
- _retryIntervals[i] = v > 0 ? v : 0;
- }
- }
- else
- {
- _retryIntervals = new int[1];
- _retryIntervals[0] = 0;
- }
+ _retryIntervals[i] = v > 0 ? v : 0;
+ }
+ }
+ else
+ {
+ _retryIntervals = new int[1];
+ _retryIntervals[0] = 0;
+ }
}
private Instance _instance;
diff --git a/java/src/IceInternal/Reference.java b/java/src/IceInternal/Reference.java
index e586a8715fb..59ccbee7bec 100644
--- a/java/src/IceInternal/Reference.java
+++ b/java/src/IceInternal/Reference.java
@@ -45,15 +45,15 @@ public abstract class Reference implements Cloneable
public final java.util.Map
getContext()
{
- return _context;
+ return _context;
}
public final Reference
defaultContext()
{
- Reference r = _instance.referenceFactory().copy(this);
- r._context = _instance.getDefaultContext();
- return r;
+ Reference r = _instance.referenceFactory().copy(this);
+ r._context = _instance.getDefaultContext();
+ return r;
}
@@ -92,56 +92,56 @@ public abstract class Reference implements Cloneable
public final Reference
changeContext(java.util.Map newContext)
{
- if(newContext == null)
- {
- newContext = _emptyContext;
- }
- Reference r = _instance.referenceFactory().copy(this);
- if(newContext.isEmpty())
- {
- r._context = _emptyContext;
- }
- else
- {
- r._context = new java.util.HashMap(newContext);
- }
- return r;
+ if(newContext == null)
+ {
+ newContext = _emptyContext;
+ }
+ Reference r = _instance.referenceFactory().copy(this);
+ if(newContext.isEmpty())
+ {
+ r._context = _emptyContext;
+ }
+ else
+ {
+ r._context = new java.util.HashMap(newContext);
+ }
+ return r;
}
public final Reference
changeMode(int newMode)
{
if(newMode == _mode)
- {
- return this;
- }
- Reference r = _instance.referenceFactory().copy(this);
- r._mode = newMode;
- return r;
+ {
+ return this;
+ }
+ Reference r = _instance.referenceFactory().copy(this);
+ r._mode = newMode;
+ return r;
}
public final Reference
changeIdentity(Ice.Identity newIdentity)
{
if(newIdentity.equals(_identity))
- {
- return this;
- }
- Reference r = _instance.referenceFactory().copy(this);
- r._identity = (Ice.Identity)newIdentity.clone();
- return r;
+ {
+ return this;
+ }
+ Reference r = _instance.referenceFactory().copy(this);
+ r._identity = (Ice.Identity)newIdentity.clone();
+ return r;
}
public final Reference
changeFacet(String newFacet)
{
if(newFacet.equals(_facet))
- {
- return this;
- }
- Reference r = _instance.referenceFactory().copy(this);
- r._facet = newFacet;
- return r;
+ {
+ return this;
+ }
+ Reference r = _instance.referenceFactory().copy(this);
+ r._facet = newFacet;
+ return r;
}
public abstract Reference changeSecure(boolean newSecure);
@@ -162,10 +162,10 @@ public abstract class Reference implements Cloneable
public synchronized int
hashCode()
{
- if(_hashInitialized)
- {
- return _hashValue;
- }
+ if(_hashInitialized)
+ {
+ return _hashValue;
+ }
int h = _mode;
@@ -181,7 +181,7 @@ public abstract class Reference implements Cloneable
h = 5 * h + (int)_identity.category.charAt(i);
}
- h = 5 * h + _context.entrySet().hashCode();
+ h = 5 * h + _context.entrySet().hashCode();
sz = _facet.length();
for(int i = 0; i < sz; i++)
@@ -191,8 +191,8 @@ public abstract class Reference implements Cloneable
h = 5 * h + (getSecure() ? 1 : 0);
- _hashValue = h;
- _hashInitialized = true;
+ _hashValue = h;
+ _hashInitialized = true;
return h;
}
@@ -225,7 +225,7 @@ public abstract class Reference implements Cloneable
s.writeBool(getSecure());
- // Derived class writes the remainder of the reference.
+ // Derived class writes the remainder of the reference.
}
//
@@ -234,13 +234,13 @@ public abstract class Reference implements Cloneable
public String
toString()
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
+ //
+ // WARNING: Certain features, such as proxy validation in Glacier2,
+ // depend on the format of proxy strings. Changes to toString() and
+ // methods called to generate parts of the reference string could break
+ // these features. Please review for all features that depend on the
+ // format of proxyToString() before changing this and related code.
+ //
StringBuffer s = new StringBuffer();
//
@@ -321,7 +321,7 @@ public abstract class Reference implements Cloneable
return s.toString();
- // Derived class writes the remainder of the string.
+ // Derived class writes the remainder of the string.
}
public abstract Ice.ConnectionI getConnection(Ice.BooleanHolder comp);
@@ -329,9 +329,9 @@ public abstract class Reference implements Cloneable
public boolean
equals(java.lang.Object obj)
{
- //
- // Note: if(this == obj) and type test are performed by each non-abstract derived class.
- //
+ //
+ // Note: if(this == obj) and type test are performed by each non-abstract derived class.
+ //
Reference r = (Reference)obj; // Guaranteed to succeed.
@@ -345,10 +345,10 @@ public abstract class Reference implements Cloneable
return false;
}
- if(!_context.equals(r._context))
- {
- return false;
- }
+ if(!_context.equals(r._context))
+ {
+ return false;
+ }
if(!_facet.equals(r._facet))
{
@@ -360,18 +360,18 @@ public abstract class Reference implements Cloneable
public Object clone()
{
- //
- // A member-wise copy is safe because the members are immutable.
- //
- Object o = null;
- try
- {
- o = super.clone();
- }
- catch(CloneNotSupportedException ex)
- {
- }
- return o;
+ //
+ // A member-wise copy is safe because the members are immutable.
+ //
+ Object o = null;
+ try
+ {
+ o = super.clone();
+ }
+ catch(CloneNotSupportedException ex)
+ {
+ }
+ return o;
}
private Instance _instance;
@@ -388,9 +388,9 @@ public abstract class Reference implements Cloneable
protected
Reference(Instance inst,
- Ice.Communicator communicator,
+ Ice.Communicator communicator,
Ice.Identity ident,
- java.util.Map ctx,
+ java.util.Map ctx,
String fac,
int md)
{
@@ -405,8 +405,8 @@ public abstract class Reference implements Cloneable
_communicator = communicator;
_mode = md;
_identity = ident;
- _context = ctx == null ? _emptyContext : ctx;
+ _context = ctx == null ? _emptyContext : ctx;
_facet = fac;
- _hashInitialized = false;
+ _hashInitialized = false;
}
}
diff --git a/java/src/IceInternal/ReferenceFactory.java b/java/src/IceInternal/ReferenceFactory.java
index 56125ba4335..a2f1433cce3 100644
--- a/java/src/IceInternal/ReferenceFactory.java
+++ b/java/src/IceInternal/ReferenceFactory.java
@@ -20,7 +20,7 @@ public final class ReferenceFactory
boolean preferSecure,
EndpointI[] endpoints,
RouterInfo routerInfo,
- boolean collocationOptimization,
+ boolean collocationOptimization,
boolean cacheConnection,
Ice.EndpointSelectionType endpointSelection,
boolean threadPerConnection)
@@ -39,9 +39,9 @@ public final class ReferenceFactory
// Create new reference
//
DirectReference ref = new DirectReference(_instance, _communicator, ident, context, facet, mode, secure,
- preferSecure, endpoints, routerInfo, collocationOptimization,
+ preferSecure, endpoints, routerInfo, collocationOptimization,
cacheConnection, endpointSelection, threadPerConnection);
- return updateCache(ref);
+ return updateCache(ref);
}
public synchronized Reference
@@ -53,12 +53,12 @@ public final class ReferenceFactory
boolean preferSecure,
String adapterId,
RouterInfo routerInfo,
- LocatorInfo locatorInfo,
- boolean collocationOptimization,
+ LocatorInfo locatorInfo,
+ boolean collocationOptimization,
boolean cacheConnection,
Ice.EndpointSelectionType endpointSelection,
boolean threadPerConnection,
- int locatorCacheTimeout)
+ int locatorCacheTimeout)
{
if(_instance == null)
{
@@ -74,10 +74,10 @@ public final class ReferenceFactory
// Create new reference
//
IndirectReference ref = new IndirectReference(_instance, _communicator, ident, context, facet, mode, secure,
- preferSecure, adapterId, routerInfo, locatorInfo,
- collocationOptimization, cacheConnection, endpointSelection,
+ preferSecure, adapterId, routerInfo, locatorInfo,
+ collocationOptimization, cacheConnection, endpointSelection,
threadPerConnection, locatorCacheTimeout);
- return updateCache(ref);
+ return updateCache(ref);
}
public synchronized Reference
@@ -85,7 +85,7 @@ public final class ReferenceFactory
java.util.Map context,
String facet,
int mode,
- Ice.ConnectionI[] fixedConnections)
+ Ice.ConnectionI[] fixedConnections)
{
if(_instance == null)
{
@@ -101,24 +101,24 @@ public final class ReferenceFactory
// Create new reference
//
FixedReference ref = new FixedReference(_instance, _communicator, ident, context, facet, mode,
- fixedConnections);
- return updateCache(ref);
+ fixedConnections);
+ return updateCache(ref);
}
public synchronized Reference
copy(Reference r)
{
if(_instance == null)
- {
- throw new Ice.CommunicatorDestroyedException();
- }
-
- Ice.Identity ident = r.getIdentity();
- if(ident.name.length() == 0 && ident.category.length() == 0)
- {
- return null;
- }
- return (Reference)r.clone();
+ {
+ throw new Ice.CommunicatorDestroyedException();
+ }
+
+ Ice.Identity ident = r.getIdentity();
+ if(ident.name.length() == 0 && ident.category.length() == 0)
+ {
+ return null;
+ }
+ return (Reference)r.clone();
}
public Reference
@@ -138,8 +138,8 @@ public final class ReferenceFactory
if(beg == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
//
@@ -151,8 +151,8 @@ public final class ReferenceFactory
if(end == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
else if(end == 0)
{
@@ -173,8 +173,8 @@ public final class ReferenceFactory
if(beg == end)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
//
@@ -215,7 +215,7 @@ public final class ReferenceFactory
String facet = "";
int mode = Reference.ModeTwoway;
boolean secure = false;
- String adapter = "";
+ String adapter = "";
while(true)
{
@@ -245,8 +245,8 @@ public final class ReferenceFactory
if(option.length() != 2 || option.charAt(0) != '-')
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
//
@@ -266,8 +266,8 @@ public final class ReferenceFactory
if(end == -1)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
else if(end == 0)
{
@@ -298,16 +298,16 @@ public final class ReferenceFactory
if(argument == null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
Ice.StringHolder facetH = new Ice.StringHolder();
if(!IceUtil.StringUtil.unescapeString(argument, 0, argument.length(), facetH))
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
facet = facetH.value;
@@ -319,8 +319,8 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
mode = Reference.ModeTwoway;
break;
@@ -331,8 +331,8 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
mode = Reference.ModeOneway;
break;
@@ -343,8 +343,8 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
mode = Reference.ModeBatchOneway;
break;
@@ -355,8 +355,8 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
mode = Reference.ModeDatagram;
break;
@@ -367,8 +367,8 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
mode = Reference.ModeBatchDatagram;
break;
@@ -379,8 +379,8 @@ public final class ReferenceFactory
if(argument != null)
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
secure = true;
break;
@@ -389,126 +389,126 @@ public final class ReferenceFactory
default:
{
Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
+ e.str = s;
+ throw e;
}
}
}
- RouterInfo routerInfo = _instance.routerManager().get(getDefaultRouter());
- LocatorInfo locatorInfo = _instance.locatorManager().get(getDefaultLocator());
+ RouterInfo routerInfo = _instance.routerManager().get(getDefaultRouter());
+ LocatorInfo locatorInfo = _instance.locatorManager().get(getDefaultLocator());
- if(beg == -1)
- {
- return create(ident, _instance.getDefaultContext(), facet, mode, secure,
- _instance.defaultsAndOverrides().defaultPreferSecure, "", routerInfo,
- locatorInfo, _instance.defaultsAndOverrides().defaultCollocationOptimization, true,
+ if(beg == -1)
+ {
+ return create(ident, _instance.getDefaultContext(), facet, mode, secure,
+ _instance.defaultsAndOverrides().defaultPreferSecure, "", routerInfo,
+ locatorInfo, _instance.defaultsAndOverrides().defaultCollocationOptimization, true,
_instance.defaultsAndOverrides().defaultEndpointSelection, _instance.threadPerConnection(),
- _instance.defaultsAndOverrides().defaultLocatorCacheTimeout);
- }
+ _instance.defaultsAndOverrides().defaultLocatorCacheTimeout);
+ }
java.util.ArrayList endpoints = new java.util.ArrayList();
- if(s.charAt(beg) == ':')
- {
- java.util.ArrayList unknownEndpoints = new java.util.ArrayList();
- end = beg;
-
- while(end < s.length() && s.charAt(end) == ':')
- {
- beg = end + 1;
-
- end = s.indexOf(':', beg);
- if(end == -1)
- {
- end = s.length();
- }
-
- String es = s.substring(beg, end);
- EndpointI endp = _instance.endpointFactoryManager().create(es);
- if(endp != null)
- {
- java.util.ArrayList endps = endp.expand(false);
- endpoints.addAll(endps);
- }
- else
- {
- unknownEndpoints.add(es);
- }
- }
- if(endpoints.size() == 0)
- {
- Ice.EndpointParseException e = new Ice.EndpointParseException();
- e.str = (String)unknownEndpoints.get(0);
- throw e;
- }
- else if(unknownEndpoints.size() != 0 &&
- _instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0)
- {
- String msg = "Proxy contains unknown endpoints:";
- java.util.Iterator iter = unknownEndpoints.iterator();
- while(iter.hasNext())
- {
- msg += " `" + (String)iter.next() + "'";
- }
- _instance.initializationData().logger.warning(msg);
- }
-
- EndpointI[] endp = new EndpointI[endpoints.size()];
- endpoints.toArray(endp);
- return create(ident, _instance.getDefaultContext(), facet, mode, secure,
- _instance.defaultsAndOverrides().defaultPreferSecure, endp, routerInfo,
- _instance.defaultsAndOverrides().defaultCollocationOptimization, true,
+ if(s.charAt(beg) == ':')
+ {
+ java.util.ArrayList unknownEndpoints = new java.util.ArrayList();
+ end = beg;
+
+ while(end < s.length() && s.charAt(end) == ':')
+ {
+ beg = end + 1;
+
+ end = s.indexOf(':', beg);
+ if(end == -1)
+ {
+ end = s.length();
+ }
+
+ String es = s.substring(beg, end);
+ EndpointI endp = _instance.endpointFactoryManager().create(es);
+ if(endp != null)
+ {
+ java.util.ArrayList endps = endp.expand(false);
+ endpoints.addAll(endps);
+ }
+ else
+ {
+ unknownEndpoints.add(es);
+ }
+ }
+ if(endpoints.size() == 0)
+ {
+ Ice.EndpointParseException e = new Ice.EndpointParseException();
+ e.str = (String)unknownEndpoints.get(0);
+ throw e;
+ }
+ else if(unknownEndpoints.size() != 0 &&
+ _instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0)
+ {
+ String msg = "Proxy contains unknown endpoints:";
+ java.util.Iterator iter = unknownEndpoints.iterator();
+ while(iter.hasNext())
+ {
+ msg += " `" + (String)iter.next() + "'";
+ }
+ _instance.initializationData().logger.warning(msg);
+ }
+
+ EndpointI[] endp = new EndpointI[endpoints.size()];
+ endpoints.toArray(endp);
+ return create(ident, _instance.getDefaultContext(), facet, mode, secure,
+ _instance.defaultsAndOverrides().defaultPreferSecure, endp, routerInfo,
+ _instance.defaultsAndOverrides().defaultCollocationOptimization, true,
_instance.defaultsAndOverrides().defaultEndpointSelection, _instance.threadPerConnection());
- }
- else if(s.charAt(beg) == '@')
- {
- beg = IceUtil.StringUtil.findFirstNotOf(s, delim, beg + 1);
- if(beg == -1)
- {
- Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
- }
-
- end = IceUtil.StringUtil.checkQuote(s, beg);
- if(end == -1)
- {
- Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
- }
- else if(end == 0)
- {
- end = IceUtil.StringUtil.findFirstOf(s, delim, beg);
- if(end == -1)
- {
- end = s.length();
- }
- }
- else
- {
- beg++; // Skip leading quote
- }
-
- Ice.StringHolder token = new Ice.StringHolder();
- if(!IceUtil.StringUtil.unescapeString(s, beg, end, token) || token.value.length() == 0)
- {
- Ice.ProxyParseException e = new Ice.ProxyParseException();
- e.str = s;
- throw e;
- }
- adapter = token.value;
- return create(ident, _instance.getDefaultContext(), facet, mode, secure,
- _instance.defaultsAndOverrides().defaultPreferSecure, adapter,
- routerInfo, locatorInfo, _instance.defaultsAndOverrides().defaultCollocationOptimization,
+ }
+ else if(s.charAt(beg) == '@')
+ {
+ beg = IceUtil.StringUtil.findFirstNotOf(s, delim, beg + 1);
+ if(beg == -1)
+ {
+ Ice.ProxyParseException e = new Ice.ProxyParseException();
+ e.str = s;
+ throw e;
+ }
+
+ end = IceUtil.StringUtil.checkQuote(s, beg);
+ if(end == -1)
+ {
+ Ice.ProxyParseException e = new Ice.ProxyParseException();
+ e.str = s;
+ throw e;
+ }
+ else if(end == 0)
+ {
+ end = IceUtil.StringUtil.findFirstOf(s, delim, beg);
+ if(end == -1)
+ {
+ end = s.length();
+ }
+ }
+ else
+ {
+ beg++; // Skip leading quote
+ }
+
+ Ice.StringHolder token = new Ice.StringHolder();
+ if(!IceUtil.StringUtil.unescapeString(s, beg, end, token) || token.value.length() == 0)
+ {
+ Ice.ProxyParseException e = new Ice.ProxyParseException();
+ e.str = s;
+ throw e;
+ }
+ adapter = token.value;
+ return create(ident, _instance.getDefaultContext(), facet, mode, secure,
+ _instance.defaultsAndOverrides().defaultPreferSecure, adapter,
+ routerInfo, locatorInfo, _instance.defaultsAndOverrides().defaultCollocationOptimization,
true, _instance.defaultsAndOverrides().defaultEndpointSelection,
_instance.threadPerConnection(), _instance.defaultsAndOverrides().defaultLocatorCacheTimeout);
- }
+ }
- Ice.ProxyParseException ex = new Ice.ProxyParseException();
- ex.str = s;
- throw ex;
+ Ice.ProxyParseException ex = new Ice.ProxyParseException();
+ ex.str = s;
+ throw ex;
}
public Reference
@@ -516,67 +516,67 @@ public final class ReferenceFactory
{
Ice.Properties properties = _instance.initializationData().properties;
- Reference ref = create(properties.getProperty(propertyPrefix));
- if(ref == null)
- {
- return null;
- }
-
- String property = propertyPrefix + ".Locator";
- if(properties.getProperty(property).length() != 0)
- {
- ref = ref.changeLocator(Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)));
- }
-
- property = propertyPrefix + ".LocatorCacheTimeout";
- if(properties.getProperty(property).length() != 0)
- {
- ref = ref.changeLocatorCacheTimeout(properties.getPropertyAsInt(property));
- }
-
- property = propertyPrefix + ".Router";
- if(properties.getProperty(property).length() != 0)
- {
- ref = ref.changeRouter(Ice.RouterPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)));
- }
-
- property = propertyPrefix + ".PreferSecure";
- if(properties.getProperty(property).length() != 0)
- {
- ref = ref.changePreferSecure(properties.getPropertyAsInt(property) > 0);
- }
-
- property = propertyPrefix + ".ConnectionCached";
- if(properties.getProperty(property).length() != 0)
- {
- ref = ref.changeCacheConnection(properties.getPropertyAsInt(property) > 0);
- }
-
- property = propertyPrefix + ".EndpointSelection";
- if(properties.getProperty(property).length() != 0)
- {
- String type = properties.getProperty(property);
- if(type.equals("Random"))
- {
- ref = ref.changeEndpointSelection(Ice.EndpointSelectionType.Random);
- }
- else if(type.equals("Ordered"))
- {
- ref = ref.changeEndpointSelection(Ice.EndpointSelectionType.Ordered);
- }
- else
- {
- Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException();
- ex.str = type;
- throw ex;
- }
- }
-
- property = propertyPrefix + ".CollocationOptimization";
- if(properties.getProperty(property).length() != 0)
- {
- ref = ref.changeCollocationOptimization(properties.getPropertyAsInt(property) > 0);
- }
+ Reference ref = create(properties.getProperty(propertyPrefix));
+ if(ref == null)
+ {
+ return null;
+ }
+
+ String property = propertyPrefix + ".Locator";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeLocator(Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)));
+ }
+
+ property = propertyPrefix + ".LocatorCacheTimeout";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeLocatorCacheTimeout(properties.getPropertyAsInt(property));
+ }
+
+ property = propertyPrefix + ".Router";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeRouter(Ice.RouterPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)));
+ }
+
+ property = propertyPrefix + ".PreferSecure";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changePreferSecure(properties.getPropertyAsInt(property) > 0);
+ }
+
+ property = propertyPrefix + ".ConnectionCached";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeCacheConnection(properties.getPropertyAsInt(property) > 0);
+ }
+
+ property = propertyPrefix + ".EndpointSelection";
+ if(properties.getProperty(property).length() != 0)
+ {
+ String type = properties.getProperty(property);
+ if(type.equals("Random"))
+ {
+ ref = ref.changeEndpointSelection(Ice.EndpointSelectionType.Random);
+ }
+ else if(type.equals("Ordered"))
+ {
+ ref = ref.changeEndpointSelection(Ice.EndpointSelectionType.Ordered);
+ }
+ else
+ {
+ Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException();
+ ex.str = type;
+ throw ex;
+ }
+ }
+
+ property = propertyPrefix + ".CollocationOptimization";
+ if(properties.getProperty(property).length() != 0)
+ {
+ ref = ref.changeCollocationOptimization(properties.getPropertyAsInt(property) > 0);
+ }
property = propertyPrefix + ".ThreadPerConnection";
if(properties.getProperty(property).length() != 0)
@@ -584,7 +584,7 @@ public final class ReferenceFactory
ref = ref.changeThreadPerConnection(properties.getPropertyAsInt(property) > 0);
}
- return ref;
+ return ref;
}
public Reference
@@ -607,16 +607,16 @@ public final class ReferenceFactory
String facet;
if(facetPath.length > 0)
{
- if(facetPath.length > 1)
- {
- throw new Ice.ProxyUnmarshalException();
- }
+ if(facetPath.length > 1)
+ {
+ throw new Ice.ProxyUnmarshalException();
+ }
facet = facetPath[0];
}
- else
+ else
{
- facet = "";
- }
+ facet = "";
+ }
int mode = (int)s.readByte();
if(mode < 0 || mode > Reference.ModeLast)
@@ -627,34 +627,34 @@ public final class ReferenceFactory
boolean secure = s.readBool();
EndpointI[] endpoints;
- String adapterId = "";
+ String adapterId = "";
RouterInfo routerInfo = _instance.routerManager().get(getDefaultRouter());
LocatorInfo locatorInfo = _instance.locatorManager().get(getDefaultLocator());
int sz = s.readSize();
- if(sz > 0)
- {
- endpoints = new EndpointI[sz];
- for(int i = 0; i < sz; i++)
- {
- endpoints[i] = _instance.endpointFactoryManager().read(s);
- }
- return create(ident, _instance.getDefaultContext(), facet, mode, secure,
- _instance.defaultsAndOverrides().defaultPreferSecure, endpoints,
- routerInfo, _instance.defaultsAndOverrides().defaultCollocationOptimization, true,
+ if(sz > 0)
+ {
+ endpoints = new EndpointI[sz];
+ for(int i = 0; i < sz; i++)
+ {
+ endpoints[i] = _instance.endpointFactoryManager().read(s);
+ }
+ return create(ident, _instance.getDefaultContext(), facet, mode, secure,
+ _instance.defaultsAndOverrides().defaultPreferSecure, endpoints,
+ routerInfo, _instance.defaultsAndOverrides().defaultCollocationOptimization, true,
_instance.defaultsAndOverrides().defaultEndpointSelection, _instance.threadPerConnection());
- }
- else
- {
- endpoints = new EndpointI[0];
- adapterId = s.readString();
- return create(ident, _instance.getDefaultContext(), facet, mode, secure,
- _instance.defaultsAndOverrides().defaultPreferSecure, adapterId, routerInfo, locatorInfo,
- _instance.defaultsAndOverrides().defaultCollocationOptimization, true,
+ }
+ else
+ {
+ endpoints = new EndpointI[0];
+ adapterId = s.readString();
+ return create(ident, _instance.getDefaultContext(), facet, mode, secure,
+ _instance.defaultsAndOverrides().defaultPreferSecure, adapterId, routerInfo, locatorInfo,
+ _instance.defaultsAndOverrides().defaultCollocationOptimization, true,
_instance.defaultsAndOverrides().defaultEndpointSelection, _instance.threadPerConnection(),
- _instance.defaultsAndOverrides().defaultLocatorCacheTimeout);
- }
+ _instance.defaultsAndOverrides().defaultLocatorCacheTimeout);
+ }
}
public synchronized void
diff --git a/java/src/IceInternal/RoutableReference.java b/java/src/IceInternal/RoutableReference.java
index 3bb2620d487..4c3a4b5bc7f 100644
--- a/java/src/IceInternal/RoutableReference.java
+++ b/java/src/IceInternal/RoutableReference.java
@@ -21,26 +21,26 @@ public abstract class RoutableReference extends Reference
getRoutedEndpoints()
{
if(_routerInfo != null)
- {
- //
- // If we route, we send everything to the router's client
- // proxy endpoints.
- //
- return _routerInfo.getClientEndpoints();
- }
- return new EndpointI[0];
+ {
+ //
+ // If we route, we send everything to the router's client
+ // proxy endpoints.
+ //
+ return _routerInfo.getClientEndpoints();
+ }
+ return new EndpointI[0];
}
public final boolean
getSecure()
{
- return _secure;
+ return _secure;
}
public final boolean
getPreferSecure()
{
- return _preferSecure;
+ return _preferSecure;
}
public final boolean
@@ -52,13 +52,13 @@ public abstract class RoutableReference extends Reference
public final boolean
getCacheConnection()
{
- return _cacheConnection;
+ return _cacheConnection;
}
public final Ice.EndpointSelectionType
getEndpointSelection()
{
- return _endpointSelection;
+ return _endpointSelection;
}
public final boolean
@@ -70,112 +70,112 @@ public abstract class RoutableReference extends Reference
public Reference
changeSecure(boolean newSecure)
{
- if(newSecure == _secure)
- {
- return this;
- }
- RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
- r._secure = newSecure;
- return r;
+ if(newSecure == _secure)
+ {
+ return this;
+ }
+ RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
+ r._secure = newSecure;
+ return r;
}
public Reference
changePreferSecure(boolean newPreferSecure)
{
- if(newPreferSecure == _preferSecure)
- {
- return this;
- }
- RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
- r._preferSecure = newPreferSecure;
- return r;
+ if(newPreferSecure == _preferSecure)
+ {
+ return this;
+ }
+ RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
+ r._preferSecure = newPreferSecure;
+ return r;
}
public Reference
changeRouter(Ice.RouterPrx newRouter)
{
RouterInfo newRouterInfo = getInstance().routerManager().get(newRouter);
- if(newRouterInfo != null && _routerInfo != null && newRouterInfo.equals(_routerInfo))
- {
- return this;
- }
- RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
- r._routerInfo = newRouterInfo;
- return r;
+ if(newRouterInfo != null && _routerInfo != null && newRouterInfo.equals(_routerInfo))
+ {
+ return this;
+ }
+ RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
+ r._routerInfo = newRouterInfo;
+ return r;
}
public Reference
changeCollocationOptimization(boolean newCollocationOptimization)
{
if(newCollocationOptimization == _collocationOptimization)
- {
- return this;
- }
- RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
- r._collocationOptimization = newCollocationOptimization;
- return r;
+ {
+ return this;
+ }
+ RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
+ r._collocationOptimization = newCollocationOptimization;
+ return r;
}
public Reference
changeCompress(boolean newCompress)
{
- if(_overrideCompress && _compress == newCompress)
- {
- return this;
- }
+ if(_overrideCompress && _compress == newCompress)
+ {
+ return this;
+ }
RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
- r._compress = newCompress;
- r._overrideCompress = true;
- return r;
+ r._compress = newCompress;
+ r._overrideCompress = true;
+ return r;
}
public Reference
changeTimeout(int newTimeout)
{
- if(_overrideTimeout && _timeout == newTimeout)
- {
- return this;
- }
+ if(_overrideTimeout && _timeout == newTimeout)
+ {
+ return this;
+ }
RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
- r._timeout = newTimeout;
- r._overrideTimeout = true;
- return r;
+ r._timeout = newTimeout;
+ r._overrideTimeout = true;
+ return r;
}
public Reference
changeConnectionId(String id)
{
- if(_connectionId.equals(id))
- {
- return this;
- }
+ if(_connectionId.equals(id))
+ {
+ return this;
+ }
RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
- r._connectionId = id;
- return r;
+ r._connectionId = id;
+ return r;
}
public final Reference
changeCacheConnection(boolean newCache)
{
if(newCache == _cacheConnection)
- {
- return this;
- }
- RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
- r._cacheConnection = newCache;
- return r;
+ {
+ return this;
+ }
+ RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
+ r._cacheConnection = newCache;
+ return r;
}
public final Reference
changeEndpointSelection(Ice.EndpointSelectionType newType)
{
if(newType == _endpointSelection)
- {
- return this;
- }
- RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
- r._endpointSelection = newType;
- return r;
+ {
+ return this;
+ }
+ RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
+ r._endpointSelection = newType;
+ return r;
}
public Reference
@@ -187,7 +187,7 @@ public abstract class RoutableReference extends Reference
}
RoutableReference r = (RoutableReference)getInstance().referenceFactory().copy(this);
r._threadPerConnection = newTpc;
- return r;
+ return r;
}
public synchronized int
@@ -199,109 +199,109 @@ public abstract class RoutableReference extends Reference
public boolean
equals(java.lang.Object obj)
{
- //
- // Note: if(this == obj) and type test are performed by each non-abstract derived class.
- //
+ //
+ // Note: if(this == obj) and type test are performed by each non-abstract derived class.
+ //
if(!super.equals(obj))
{
return false;
}
RoutableReference rhs = (RoutableReference)obj; // Guaranteed to succeed.
- if(_secure != rhs._secure)
- {
- return false;
- }
- if(_preferSecure != rhs._preferSecure)
- {
- return false;
- }
- if(_collocationOptimization != rhs._collocationOptimization)
- {
- return false;
- }
- if(_cacheConnection != rhs._cacheConnection)
- {
- return false;
- }
- if(_endpointSelection != rhs._endpointSelection)
- {
- return false;
- }
- if(!_connectionId.equals(rhs._connectionId))
- {
- return false;
- }
- if(_overrideCompress != rhs._overrideCompress)
- {
- return false;
- }
- if(_overrideCompress && _compress != rhs._compress)
- {
- return false;
- }
- if(_overrideTimeout != rhs._overrideTimeout)
- {
- return false;
- }
- if(_overrideTimeout && _timeout != rhs._timeout)
- {
- return false;
- }
- if(_threadPerConnection != rhs._threadPerConnection)
- {
- return false;
- }
- return _routerInfo == null ? rhs._routerInfo == null : _routerInfo.equals(rhs._routerInfo);
+ if(_secure != rhs._secure)
+ {
+ return false;
+ }
+ if(_preferSecure != rhs._preferSecure)
+ {
+ return false;
+ }
+ if(_collocationOptimization != rhs._collocationOptimization)
+ {
+ return false;
+ }
+ if(_cacheConnection != rhs._cacheConnection)
+ {
+ return false;
+ }
+ if(_endpointSelection != rhs._endpointSelection)
+ {
+ return false;
+ }
+ if(!_connectionId.equals(rhs._connectionId))
+ {
+ return false;
+ }
+ if(_overrideCompress != rhs._overrideCompress)
+ {
+ return false;
+ }
+ if(_overrideCompress && _compress != rhs._compress)
+ {
+ return false;
+ }
+ if(_overrideTimeout != rhs._overrideTimeout)
+ {
+ return false;
+ }
+ if(_overrideTimeout && _timeout != rhs._timeout)
+ {
+ return false;
+ }
+ if(_threadPerConnection != rhs._threadPerConnection)
+ {
+ return false;
+ }
+ return _routerInfo == null ? rhs._routerInfo == null : _routerInfo.equals(rhs._routerInfo);
}
protected
RoutableReference(Instance inst,
- Ice.Communicator com,
- Ice.Identity ident,
- java.util.Map ctx,
- String fac,
- int md,
- boolean sec,
- boolean prefSec,
- RouterInfo rtrInfo,
- boolean collocationOpt,
+ Ice.Communicator com,
+ Ice.Identity ident,
+ java.util.Map ctx,
+ String fac,
+ int md,
+ boolean sec,
+ boolean prefSec,
+ RouterInfo rtrInfo,
+ boolean collocationOpt,
boolean cacheConnection,
Ice.EndpointSelectionType endpointSelection,
boolean threadPerConnection)
{
super(inst, com, ident, ctx, fac, md);
- _secure = sec;
- _preferSecure = prefSec;
- _routerInfo = rtrInfo;
- _collocationOptimization = collocationOpt;
- _cacheConnection = cacheConnection;
- _endpointSelection = endpointSelection;
- _overrideCompress = false;
- _compress = false;
- _overrideTimeout = false;
- _timeout = -1;
+ _secure = sec;
+ _preferSecure = prefSec;
+ _routerInfo = rtrInfo;
+ _collocationOptimization = collocationOpt;
+ _cacheConnection = cacheConnection;
+ _endpointSelection = endpointSelection;
+ _overrideCompress = false;
+ _compress = false;
+ _overrideTimeout = false;
+ _timeout = -1;
_threadPerConnection = threadPerConnection;
}
protected void
applyOverrides(EndpointI[] endpts)
{
- //
- // Apply the endpoint overrides to each endpoint.
- //
- for(int i = 0; i < endpts.length; ++i)
- {
- endpts[i] = endpts[i].connectionId(_connectionId);
- if(_overrideCompress)
- {
- endpts[i] = endpts[i].compress(_compress);
- }
- if(_overrideTimeout)
- {
- endpts[i] = endpts[i].timeout(_timeout);
- }
- }
+ //
+ // Apply the endpoint overrides to each endpoint.
+ //
+ for(int i = 0; i < endpts.length; ++i)
+ {
+ endpts[i] = endpts[i].connectionId(_connectionId);
+ if(_overrideCompress)
+ {
+ endpts[i] = endpts[i].compress(_compress);
+ }
+ if(_overrideTimeout)
+ {
+ endpts[i] = endpts[i].timeout(_timeout);
+ }
+ }
}
protected Ice.ConnectionI
@@ -319,10 +319,10 @@ public abstract class RoutableReference extends Reference
endpoints.add(allEndpoints[i]);
}
}
-
- //
- // Filter out endpoints according to the mode of the reference.
- //
+
+ //
+ // Filter out endpoints according to the mode of the reference.
+ //
switch(getMode())
{
case Reference.ModeTwoway:
@@ -363,36 +363,36 @@ public abstract class RoutableReference extends Reference
}
}
- //
- // Sort the endpoints according to the endpoint selection type.
- //
- switch(getEndpointSelection().value())
- {
- case Ice.EndpointSelectionType._Random:
- {
- java.util.Collections.shuffle(endpoints);
- break;
- }
- case Ice.EndpointSelectionType._Ordered:
- {
- // Nothing to do.
- break;
- }
- default:
- {
- assert(false);
- break;
- }
- }
+ //
+ // Sort the endpoints according to the endpoint selection type.
+ //
+ switch(getEndpointSelection().value())
+ {
+ case Ice.EndpointSelectionType._Random:
+ {
+ java.util.Collections.shuffle(endpoints);
+ break;
+ }
+ case Ice.EndpointSelectionType._Ordered:
+ {
+ // Nothing to do.
+ break;
+ }
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
//
// If a secure connection is requested or secure overrides is
// set, remove all non-secure endpoints. Otherwise if preferSecure is set
- // make secure endpoints prefered. By default make non-secure
- // endpoints preferred over secure endpoints.
+ // make secure endpoints prefered. By default make non-secure
+ // endpoints preferred over secure endpoints.
//
- DefaultsAndOverrides overrides = getInstance().defaultsAndOverrides();
- if(overrides.overrideSecure ? overrides.overrideSecureValue : getSecure())
+ DefaultsAndOverrides overrides = getInstance().defaultsAndOverrides();
+ if(overrides.overrideSecure ? overrides.overrideSecureValue : getSecure())
{
java.util.Iterator i = endpoints.iterator();
while(i.hasNext())
@@ -404,110 +404,110 @@ public abstract class RoutableReference extends Reference
}
}
}
- else if(getPreferSecure())
- {
+ else if(getPreferSecure())
+ {
java.util.Collections.sort(endpoints, _preferSecureEndpointComparator);
- }
+ }
else
{
java.util.Collections.sort(endpoints, _preferNonSecureEndpointComparator);
}
- if(endpoints.size() == 0)
- {
- Ice.NoEndpointException ex = new Ice.NoEndpointException();
- ex.proxy = toString();
- throw ex;
- }
-
- //
- // Finally, create the connection.
- //
- OutgoingConnectionFactory factory = getInstance().outgoingConnectionFactory();
- if(getCacheConnection() || endpoints.size() == 1)
- {
- //
- // Get an existing connection or create one if there's no
- // existing connection to one of the given endpoints.
- //
- return factory.create((EndpointI[])endpoints.toArray(
+ if(endpoints.size() == 0)
+ {
+ Ice.NoEndpointException ex = new Ice.NoEndpointException();
+ ex.proxy = toString();
+ throw ex;
+ }
+
+ //
+ // Finally, create the connection.
+ //
+ OutgoingConnectionFactory factory = getInstance().outgoingConnectionFactory();
+ if(getCacheConnection() || endpoints.size() == 1)
+ {
+ //
+ // Get an existing connection or create one if there's no
+ // existing connection to one of the given endpoints.
+ //
+ return factory.create((EndpointI[])endpoints.toArray(
new EndpointI[endpoints.size()]), false, _threadPerConnection, compress);
- }
- else
- {
- //
- // Go through the list of endpoints and try to create the
- // connection until it succeeds. This is different from just
- // calling create() with the given endpoints since this might
- // create a new connection even if there's an existing
- // connection for one of the endpoints.
- //
-
- Ice.LocalException exception = null;
- EndpointI[] endpoint = new EndpointI[1];
-
+ }
+ else
+ {
+ //
+ // Go through the list of endpoints and try to create the
+ // connection until it succeeds. This is different from just
+ // calling create() with the given endpoints since this might
+ // create a new connection even if there's an existing
+ // connection for one of the endpoints.
+ //
+
+ Ice.LocalException exception = null;
+ EndpointI[] endpoint = new EndpointI[1];
+
java.util.Iterator i = endpoints.iterator();
while(i.hasNext())
{
- try
- {
- endpoint[0] = (EndpointI)i.next();
- return factory.create(endpoint, i.hasNext(), _threadPerConnection, compress);
- }
- catch(Ice.LocalException ex)
- {
- exception = ex;
- }
- }
-
- assert(exception != null);
- throw exception;
- }
+ try
+ {
+ endpoint[0] = (EndpointI)i.next();
+ return factory.create(endpoint, i.hasNext(), _threadPerConnection, compress);
+ }
+ catch(Ice.LocalException ex)
+ {
+ exception = ex;
+ }
+ }
+
+ assert(exception != null);
+ throw exception;
+ }
}
static class EndpointComparator implements java.util.Comparator
{
EndpointComparator(boolean preferSecure)
- {
- _preferSecure = preferSecure;
- }
+ {
+ _preferSecure = preferSecure;
+ }
- public int
- compare(java.lang.Object l, java.lang.Object r)
- {
- IceInternal.EndpointI le = (IceInternal.EndpointI)l;
- IceInternal.EndpointI re = (IceInternal.EndpointI)r;
- boolean ls = le.secure();
- boolean rs = re.secure();
- if((ls && rs) || (!ls && !rs))
- {
- return 0;
- }
- else if(!ls && rs)
- {
- if(_preferSecure)
- {
- return 1;
- }
- else
- {
- return -1;
- }
- }
- else
- {
- if(_preferSecure)
- {
- return -1;
- }
- else
- {
- return 1;
- }
- }
- }
-
- private boolean _preferSecure;
+ public int
+ compare(java.lang.Object l, java.lang.Object r)
+ {
+ IceInternal.EndpointI le = (IceInternal.EndpointI)l;
+ IceInternal.EndpointI re = (IceInternal.EndpointI)r;
+ boolean ls = le.secure();
+ boolean rs = re.secure();
+ if((ls && rs) || (!ls && !rs))
+ {
+ return 0;
+ }
+ else if(!ls && rs)
+ {
+ if(_preferSecure)
+ {
+ return 1;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ if(_preferSecure)
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ }
+
+ private boolean _preferSecure;
}
private static EndpointComparator _preferNonSecureEndpointComparator = new EndpointComparator(false);
diff --git a/java/src/IceInternal/RouterInfo.java b/java/src/IceInternal/RouterInfo.java
index c1ebbf8526d..d9e6c6f6839 100644
--- a/java/src/IceInternal/RouterInfo.java
+++ b/java/src/IceInternal/RouterInfo.java
@@ -21,26 +21,26 @@ public final class RouterInfo
synchronized public void
destroy()
{
- _clientEndpoints = new EndpointI[0];
- _serverEndpoints = new EndpointI[0];
- _adapter = null;
- _identities.clear();
+ _clientEndpoints = new EndpointI[0];
+ _serverEndpoints = new EndpointI[0];
+ _adapter = null;
+ _identities.clear();
}
public boolean
equals(java.lang.Object obj)
{
- if(this == obj)
- {
- return true;
- }
+ if(this == obj)
+ {
+ return true;
+ }
- if(obj instanceof RouterInfo)
- {
- return _router.equals(((RouterInfo)obj)._router);
- }
+ if(obj instanceof RouterInfo)
+ {
+ return _router.equals(((RouterInfo)obj)._router);
+ }
- return false;
+ return false;
}
public Ice.RouterPrx
@@ -60,31 +60,31 @@ public final class RouterInfo
Ice.ObjectPrx clientProxy = _router.getClientProxy();
if(clientProxy == null)
{
- //
- // If getClientProxy() return nil, use router endpoints.
- //
- _clientEndpoints = ((Ice.ObjectPrxHelperBase)_router).__reference().getEndpoints();
+ //
+ // If getClientProxy() return nil, use router endpoints.
+ //
+ _clientEndpoints = ((Ice.ObjectPrxHelperBase)_router).__reference().getEndpoints();
+ }
+ else
+ {
+ clientProxy = clientProxy.ice_router(null); // The client proxy cannot be routed.
+
+ //
+ // In order to avoid creating a new connection to the
+ // router, we must use the same timeout as the already
+ // existing connection.
+ //
+ try
+ {
+ clientProxy = clientProxy.ice_timeout(_router.ice_getConnection().timeout());
+ }
+ catch(Ice.CollocationOptimizationException ex)
+ {
+ // Ignore - collocated router.
+ }
+
+ _clientEndpoints = ((Ice.ObjectPrxHelperBase)clientProxy).__reference().getEndpoints();
}
- else
- {
- clientProxy = clientProxy.ice_router(null); // The client proxy cannot be routed.
-
- //
- // In order to avoid creating a new connection to the
- // router, we must use the same timeout as the already
- // existing connection.
- //
- try
- {
- clientProxy = clientProxy.ice_timeout(_router.ice_getConnection().timeout());
- }
- catch(Ice.CollocationOptimizationException ex)
- {
- // Ignore - collocated router.
- }
-
- _clientEndpoints = ((Ice.ObjectPrxHelperBase)clientProxy).__reference().getEndpoints();
- }
}
return _clientEndpoints;
@@ -102,7 +102,7 @@ public final class RouterInfo
}
serverProxy = serverProxy.ice_router(null); // The server proxy cannot be routed.
- _serverEndpoints = ((Ice.ObjectPrxHelperBase)serverProxy).__reference().getEndpoints();
+ _serverEndpoints = ((Ice.ObjectPrxHelperBase)serverProxy).__reference().getEndpoints();
}
return _serverEndpoints;
@@ -113,28 +113,28 @@ public final class RouterInfo
{
assert(proxy != null);
- if(!_identities.contains(proxy.ice_getIdentity()))
- {
- //
- // Only add the proxy to the router if it's not already in our local map.
- //
- Ice.ObjectPrx[] proxies = new Ice.ObjectPrx[1];
- proxies[0] = proxy;
- Ice.ObjectPrx[] evictedProxies = _router.addProxies(proxies);
-
- //
- // If we successfully added the proxy to the router, we add it to our local map.
- //
- _identities.add(proxy.ice_getIdentity());
-
- //
- // We also must remove whatever proxies the router evicted.
- //
- for(int i = 0; i < evictedProxies.length; ++i)
- {
- _identities.remove(evictedProxies[i].ice_getIdentity());
- }
- }
+ if(!_identities.contains(proxy.ice_getIdentity()))
+ {
+ //
+ // Only add the proxy to the router if it's not already in our local map.
+ //
+ Ice.ObjectPrx[] proxies = new Ice.ObjectPrx[1];
+ proxies[0] = proxy;
+ Ice.ObjectPrx[] evictedProxies = _router.addProxies(proxies);
+
+ //
+ // If we successfully added the proxy to the router, we add it to our local map.
+ //
+ _identities.add(proxy.ice_getIdentity());
+
+ //
+ // We also must remove whatever proxies the router evicted.
+ //
+ for(int i = 0; i < evictedProxies.length; ++i)
+ {
+ _identities.remove(evictedProxies[i].ice_getIdentity());
+ }
+ }
}
public synchronized void
diff --git a/java/src/IceInternal/RouterManager.java b/java/src/IceInternal/RouterManager.java
index a644b762913..a34091fd479 100644
--- a/java/src/IceInternal/RouterManager.java
+++ b/java/src/IceInternal/RouterManager.java
@@ -18,7 +18,7 @@ public final class RouterManager
synchronized void
destroy()
{
- java.util.Iterator i = _table.values().iterator();
+ java.util.Iterator i = _table.values().iterator();
while(i.hasNext())
{
RouterInfo info = (RouterInfo)i.next();
@@ -57,18 +57,18 @@ public final class RouterManager
public RouterInfo
erase(Ice.RouterPrx rtr)
{
- RouterInfo info = null;
- if(rtr != null)
- {
- // The router cannot be routed.
- Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(rtr.ice_router(null));
+ RouterInfo info = null;
+ if(rtr != null)
+ {
+ // The router cannot be routed.
+ Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(rtr.ice_router(null));
- synchronized(this)
- {
- info = (RouterInfo)_table.remove(router);
- }
- }
- return info;
+ synchronized(this)
+ {
+ info = (RouterInfo)_table.remove(router);
+ }
+ }
+ return info;
}
private java.util.HashMap _table = new java.util.HashMap();
diff --git a/java/src/IceInternal/ServantManager.java b/java/src/IceInternal/ServantManager.java
index 200a150f482..caf5f6ba933 100644
--- a/java/src/IceInternal/ServantManager.java
+++ b/java/src/IceInternal/ServantManager.java
@@ -14,7 +14,7 @@ public final class ServantManager
public synchronized void
addServant(Ice.Object servant, Ice.Identity ident, String facet)
{
- assert(_instance != null); // Must not be called after destruction.
+ assert(_instance != null); // Must not be called after destruction.
if(facet == null)
{
@@ -48,7 +48,7 @@ public final class ServantManager
public synchronized Ice.Object
removeServant(Ice.Identity ident, String facet)
{
- assert(_instance != null); // Must not be called after destruction.
+ assert(_instance != null); // Must not be called after destruction.
if(facet == null)
{
@@ -58,39 +58,39 @@ public final class ServantManager
java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident);
Ice.Object obj = null;
if(m == null || (obj = (Ice.Object)m.remove(facet)) == null)
- {
- Ice.NotRegisteredException ex = new Ice.NotRegisteredException();
- ex.id = _instance.identityToString(ident);
- ex.kindOfObject = "servant";
+ {
+ Ice.NotRegisteredException ex = new Ice.NotRegisteredException();
+ ex.id = _instance.identityToString(ident);
+ ex.kindOfObject = "servant";
if(facet.length() > 0)
{
ex.id += " -f " + IceUtil.StringUtil.escapeString(facet, "");
}
- throw ex;
- }
+ throw ex;
+ }
if(m.isEmpty())
{
_servantMapMap.remove(ident);
}
- return obj;
+ return obj;
}
public synchronized java.util.Map
removeAllFacets(Ice.Identity ident)
{
- assert(_instance != null); // Must not be called after destruction.
+ assert(_instance != null); // Must not be called after destruction.
java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident);
if(m == null)
- {
- Ice.NotRegisteredException ex = new Ice.NotRegisteredException();
- ex.id = _instance.identityToString(ident);
- ex.kindOfObject = "servant";
- throw ex;
- }
+ {
+ Ice.NotRegisteredException ex = new Ice.NotRegisteredException();
+ ex.id = _instance.identityToString(ident);
+ ex.kindOfObject = "servant";
+ throw ex;
+ }
- _servantMapMap.remove(ident);
+ _servantMapMap.remove(ident);
return m;
}
@@ -98,13 +98,13 @@ public final class ServantManager
public synchronized Ice.Object
findServant(Ice.Identity ident, String facet)
{
- //
- // This assert is not valid if the adapter dispatch incoming
- // requests from bidir connections. This method might be called if
- // requests are received over the bidir connection after the
- // adapter was deactivated.
- //
- //assert(_instance != null); // Must not be called after destruction.
+ //
+ // This assert is not valid if the adapter dispatch incoming
+ // requests from bidir connections. This method might be called if
+ // requests are received over the bidir connection after the
+ // adapter was deactivated.
+ //
+ //assert(_instance != null); // Must not be called after destruction.
if(facet == null)
{
@@ -124,7 +124,7 @@ public final class ServantManager
public synchronized java.util.Map
findAllFacets(Ice.Identity ident)
{
- assert(_instance != null); // Must not be called after destruction.
+ assert(_instance != null); // Must not be called after destruction.
java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident);
if(m != null)
@@ -138,13 +138,13 @@ public final class ServantManager
public synchronized boolean
hasServant(Ice.Identity ident)
{
- //
- // This assert is not valid if the adapter dispatch incoming
- // requests from bidir connections. This method might be called if
- // requests are received over the bidir connection after the
- // adapter was deactivated.
- //
- //assert(_instance != null); // Must not be called after destruction.
+ //
+ // This assert is not valid if the adapter dispatch incoming
+ // requests from bidir connections. This method might be called if
+ // requests are received over the bidir connection after the
+ // adapter was deactivated.
+ //
+ //assert(_instance != null); // Must not be called after destruction.
java.util.HashMap m = (java.util.HashMap)_servantMapMap.get(ident);
if(m == null)
@@ -161,16 +161,16 @@ public final class ServantManager
public synchronized void
addServantLocator(Ice.ServantLocator locator, String category)
{
- assert(_instance != null); // Must not be called after destruction.
+ assert(_instance != null); // Must not be called after destruction.
- Ice.ServantLocator l = (Ice.ServantLocator)_locatorMap.get(category);
- if(l != null)
- {
- Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException();
- ex.id = IceUtil.StringUtil.escapeString(category, "");
- ex.kindOfObject = "servant locator";
- throw ex;
- }
+ Ice.ServantLocator l = (Ice.ServantLocator)_locatorMap.get(category);
+ if(l != null)
+ {
+ Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException();
+ ex.id = IceUtil.StringUtil.escapeString(category, "");
+ ex.kindOfObject = "servant locator";
+ throw ex;
+ }
_locatorMap.put(category, locator);
}
@@ -178,13 +178,13 @@ public final class ServantManager
public synchronized Ice.ServantLocator
findServantLocator(String category)
{
- //
- // This assert is not valid if the adapter dispatch incoming
- // requests from bidir connections. This method might be called if
- // requests are received over the bidir connection after the
- // adapter was deactivated.
- //
- //assert(_instance != null); // Must not be called after destruction.
+ //
+ // This assert is not valid if the adapter dispatch incoming
+ // requests from bidir connections. This method might be called if
+ // requests are received over the bidir connection after the
+ // adapter was deactivated.
+ //
+ //assert(_instance != null); // Must not be called after destruction.
return (Ice.ServantLocator)_locatorMap.get(category);
}
@@ -195,21 +195,21 @@ public final class ServantManager
public
ServantManager(Instance instance, String adapterName)
{
- _instance = instance;
- _adapterName = adapterName;
+ _instance = instance;
+ _adapterName = adapterName;
}
protected void
finalize()
throws Throwable
{
- //
- // Don't check whether destroy() has been called. It might have
- // not been called if the associated object adapter was not
- // properly deactivated.
- //
- //IceUtil.Assert.FinalizerAssert(_instance == null);
-
+ //
+ // Don't check whether destroy() has been called. It might have
+ // not been called if the associated object adapter was not
+ // properly deactivated.
+ //
+ //IceUtil.Assert.FinalizerAssert(_instance == null);
+
super.finalize();
}
@@ -219,34 +219,34 @@ public final class ServantManager
public synchronized void
destroy()
{
- assert(_instance != null); // Must not be called after destruction.
-
- _servantMapMap.clear();
-
- java.util.Iterator p = _locatorMap.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry e = (java.util.Map.Entry)p.next();
- Ice.ServantLocator locator = (Ice.ServantLocator)e.getValue();
- try
- {
- locator.deactivate((String)e.getKey());
- }
- catch(java.lang.Exception ex)
- {
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "exception during locator deactivation:\n" + "object adapter: `" + _adapterName + "'\n" +
- "locator category: `" + e.getKey() + "'\n" + sw.toString();
- _instance.initializationData().logger.error(s);
- }
- }
-
- _locatorMap.clear();
-
- _instance = null;
+ assert(_instance != null); // Must not be called after destruction.
+
+ _servantMapMap.clear();
+
+ java.util.Iterator p = _locatorMap.entrySet().iterator();
+ while(p.hasNext())
+ {
+ java.util.Map.Entry e = (java.util.Map.Entry)p.next();
+ Ice.ServantLocator locator = (Ice.ServantLocator)e.getValue();
+ try
+ {
+ locator.deactivate((String)e.getKey());
+ }
+ catch(java.lang.Exception ex)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "exception during locator deactivation:\n" + "object adapter: `" + _adapterName + "'\n" +
+ "locator category: `" + e.getKey() + "'\n" + sw.toString();
+ _instance.initializationData().logger.error(s);
+ }
+ }
+
+ _locatorMap.clear();
+
+ _instance = null;
}
private Instance _instance;
diff --git a/java/src/IceInternal/TcpAcceptor.java b/java/src/IceInternal/TcpAcceptor.java
index b34f11e7505..2e94912e525 100644
--- a/java/src/IceInternal/TcpAcceptor.java
+++ b/java/src/IceInternal/TcpAcceptor.java
@@ -28,13 +28,13 @@ class TcpAcceptor implements Acceptor
java.nio.channels.ServerSocketChannel fd;
java.nio.channels.Selector selector;
- synchronized(this)
- {
- fd = _fd;
- selector = _selector;
- _fd = null;
- _selector = null;
- }
+ synchronized(this)
+ {
+ fd = _fd;
+ selector = _selector;
+ _fd = null;
+ _selector = null;
+ }
if(fd != null)
{
try
@@ -46,17 +46,17 @@ class TcpAcceptor implements Acceptor
// Ignore.
}
}
- if(selector != null)
- {
- try
- {
- selector.close();
- }
- catch(java.io.IOException ex)
- {
- // Ignore.
- }
- }
+ if(selector != null)
+ {
+ try
+ {
+ selector.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ // Ignore.
+ }
+ }
}
public void
@@ -74,84 +74,84 @@ class TcpAcceptor implements Acceptor
public Transceiver
accept(int timeout)
{
- java.nio.channels.SocketChannel fd = null;
- while(fd == null)
- {
- try
- {
- fd = _fd.accept();
- if(fd == null)
- {
- if(_selector == null)
- {
- _selector = java.nio.channels.Selector.open();
- }
-
- while(true)
- {
- try
- {
- java.nio.channels.SelectionKey key =
- _fd.register(_selector, java.nio.channels.SelectionKey.OP_ACCEPT);
- if(timeout > 0)
- {
- if(_selector.select(timeout) == 0)
- {
- throw new Ice.TimeoutException();
- }
- }
- else if(timeout == 0)
- {
- if(_selector.selectNow() == 0)
- {
- throw new Ice.TimeoutException();
- }
- }
- else
- {
- _selector.select();
- }
-
- break;
- }
- catch(java.io.IOException ex)
- {
- if(Network.interrupted(ex))
- {
- continue;
- }
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
- }
- }
- }
- catch(java.io.IOException ex)
- {
- if(Network.interrupted(ex))
- {
- continue;
- }
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
- }
-
- Network.setBlock(fd, false);
- try
- {
- java.net.Socket socket = fd.socket();
- socket.setTcpNoDelay(true);
- socket.setKeepAlive(true);
- }
- catch(java.io.IOException ex)
- {
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
+ java.nio.channels.SocketChannel fd = null;
+ while(fd == null)
+ {
+ try
+ {
+ fd = _fd.accept();
+ if(fd == null)
+ {
+ if(_selector == null)
+ {
+ _selector = java.nio.channels.Selector.open();
+ }
+
+ while(true)
+ {
+ try
+ {
+ java.nio.channels.SelectionKey key =
+ _fd.register(_selector, java.nio.channels.SelectionKey.OP_ACCEPT);
+ if(timeout > 0)
+ {
+ if(_selector.select(timeout) == 0)
+ {
+ throw new Ice.TimeoutException();
+ }
+ }
+ else if(timeout == 0)
+ {
+ if(_selector.selectNow() == 0)
+ {
+ throw new Ice.TimeoutException();
+ }
+ }
+ else
+ {
+ _selector.select();
+ }
+
+ break;
+ }
+ catch(java.io.IOException ex)
+ {
+ if(Network.interrupted(ex))
+ {
+ continue;
+ }
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
+ }
+ }
+ }
+ catch(java.io.IOException ex)
+ {
+ if(Network.interrupted(ex))
+ {
+ continue;
+ }
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
+ }
+
+ Network.setBlock(fd, false);
+ try
+ {
+ java.net.Socket socket = fd.socket();
+ socket.setTcpNoDelay(true);
+ socket.setKeepAlive(true);
+ }
+ catch(java.io.IOException ex)
+ {
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
if(_traceLevels.network >= 1)
{
@@ -165,10 +165,10 @@ class TcpAcceptor implements Acceptor
public void
connectToSelf()
{
- java.nio.channels.SocketChannel fd = Network.createTcpSocket();
- Network.setBlock(fd, false);
- Network.doConnect(fd, _addr, -1);
- Network.closeSocket(fd);
+ java.nio.channels.SocketChannel fd = Network.createTcpSocket();
+ Network.setBlock(fd, false);
+ Network.doConnect(fd, _addr, -1);
+ Network.closeSocket(fd);
}
public String
@@ -207,11 +207,11 @@ class TcpAcceptor implements Acceptor
_fd = Network.createTcpServerSocket();
Network.setBlock(_fd, false);
_addr = new java.net.InetSocketAddress(host, port);
- if(_traceLevels.network >= 2)
- {
- String s = "attempting to bind to tcp socket " + toString();
- _logger.trace(_traceLevels.networkCat, s);
- }
+ if(_traceLevels.network >= 2)
+ {
+ String s = "attempting to bind to tcp socket " + toString();
+ _logger.trace(_traceLevels.networkCat, s);
+ }
_addr = Network.doBind(_fd, _addr);
}
catch(RuntimeException ex)
diff --git a/java/src/IceInternal/TcpConnector.java b/java/src/IceInternal/TcpConnector.java
index 426c459dd0a..6d3dad03a5f 100644
--- a/java/src/IceInternal/TcpConnector.java
+++ b/java/src/IceInternal/TcpConnector.java
@@ -21,7 +21,7 @@ final class TcpConnector implements Connector
}
java.nio.channels.SocketChannel fd = Network.createTcpSocket();
- Network.setBlock(fd, false);
+ Network.setBlock(fd, false);
Network.doConnect(fd, _addr, timeout);
if(_traceLevels.network >= 1)
diff --git a/java/src/IceInternal/TcpEndpointI.java b/java/src/IceInternal/TcpEndpointI.java
index 1dd7b360932..21eb90d067c 100644
--- a/java/src/IceInternal/TcpEndpointI.java
+++ b/java/src/IceInternal/TcpEndpointI.java
@@ -21,8 +21,8 @@ final class TcpEndpointI extends EndpointI
_port = po;
_timeout = ti;
_connectionId = conId;
- _compress = co;
- _publish = pub;
+ _compress = co;
+ _publish = pub;
calcHashValue();
}
@@ -33,8 +33,8 @@ final class TcpEndpointI extends EndpointI
_host = null;
_port = 0;
_timeout = -1;
- _compress = false;
- _publish = true;
+ _compress = false;
+ _publish = true;
String[] arr = str.split("[ \t\n\r]+");
@@ -50,7 +50,7 @@ final class TcpEndpointI extends EndpointI
String option = arr[i++];
if(option.length() != 2 || option.charAt(0) != '-')
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("tcp " + str);
}
String argument = null;
@@ -65,7 +65,7 @@ final class TcpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("tcp " + str);
}
_host = argument;
@@ -76,7 +76,7 @@ final class TcpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("tcp " + str);
}
try
@@ -85,13 +85,13 @@ final class TcpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("tcp " + str);
}
- if(_port < 0 || _port > 65535)
- {
- throw new Ice.EndpointParseException("tcp " + str);
- }
+ if(_port < 0 || _port > 65535)
+ {
+ throw new Ice.EndpointParseException("tcp " + str);
+ }
break;
}
@@ -100,7 +100,7 @@ final class TcpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("tcp " + str);
}
try
@@ -109,7 +109,7 @@ final class TcpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("tcp " + str);
}
break;
@@ -119,7 +119,7 @@ final class TcpEndpointI extends EndpointI
{
if(argument != null)
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("tcp " + str);
}
_compress = true;
@@ -128,7 +128,7 @@ final class TcpEndpointI extends EndpointI
default:
{
- throw new Ice.EndpointParseException("tcp " + str);
+ throw new Ice.EndpointParseException("tcp " + str);
}
}
}
@@ -142,9 +142,9 @@ final class TcpEndpointI extends EndpointI
_host = s.readString();
_port = s.readInt();
_timeout = s.readInt();
- _compress = s.readBool();
+ _compress = s.readBool();
s.endReadEncaps();
- _publish = true;
+ _publish = true;
calcHashValue();
}
@@ -159,7 +159,7 @@ final class TcpEndpointI extends EndpointI
s.writeString(_host);
s.writeInt(_port);
s.writeInt(_timeout);
- s.writeBool(_compress);
+ s.writeBool(_compress);
s.endWriteEncaps();
}
@@ -169,22 +169,22 @@ final class TcpEndpointI extends EndpointI
public String
_toString()
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
+ //
+ // WARNING: Certain features, such as proxy validation in Glacier2,
+ // depend on the format of proxy strings. Changes to toString() and
+ // methods called to generate parts of the reference string could break
+ // these features. Please review for all features that depend on the
+ // format of proxyToString() before changing this and related code.
+ //
String s = "tcp -h " + _host + " -p " + _port;
if(_timeout != -1)
{
s += " -t " + _timeout;
}
- if(_compress)
- {
- s += " -z";
- }
+ if(_compress)
+ {
+ s += " -z";
+ }
return s;
}
@@ -342,7 +342,7 @@ final class TcpEndpointI extends EndpointI
{
TcpAcceptor p = new TcpAcceptor(_instance, _host, _port);
endpoint.value = new TcpEndpointI(_instance, _host, p.effectivePort(), _timeout, _connectionId,
- _compress, _publish);
+ _compress, _publish);
return p;
}
@@ -357,41 +357,41 @@ final class TcpEndpointI extends EndpointI
if(_host == null)
{
_host = _instance.defaultsAndOverrides().defaultHost;
- if(_host == null)
- {
- if(server)
- {
- _host = "0.0.0.0";
- }
- else
- {
- _host = "127.0.0.1";
- }
- }
+ if(_host == null)
+ {
+ if(server)
+ {
+ _host = "0.0.0.0";
+ }
+ else
+ {
+ _host = "127.0.0.1";
+ }
+ }
+ }
+ else if(_host.equals("*"))
+ {
+ _host = "0.0.0.0";
}
- else if(_host.equals("*"))
- {
- _host = "0.0.0.0";
- }
java.util.ArrayList endps = new java.util.ArrayList();
- if(_host.equals("0.0.0.0"))
- {
- java.util.ArrayList hosts = Network.getLocalHosts();
- java.util.Iterator iter = hosts.iterator();
- while(iter.hasNext())
- {
- String host = (String)iter.next();
- endps.add(new TcpEndpointI(_instance, host, _port, _timeout, _connectionId, _compress,
- hosts.size() == 1 || !host.equals("127.0.0.1")));
- }
- }
- else
- {
+ if(_host.equals("0.0.0.0"))
+ {
+ java.util.ArrayList hosts = Network.getLocalHosts();
+ java.util.Iterator iter = hosts.iterator();
+ while(iter.hasNext())
+ {
+ String host = (String)iter.next();
+ endps.add(new TcpEndpointI(_instance, host, _port, _timeout, _connectionId, _compress,
+ hosts.size() == 1 || !host.equals("127.0.0.1")));
+ }
+ }
+ else
+ {
calcHashValue();
- endps.add(this);
- }
- return endps;
+ endps.add(this);
+ }
+ return endps;
}
//
@@ -481,10 +481,10 @@ final class TcpEndpointI extends EndpointI
return 1;
}
- if(!_connectionId.equals(p._connectionId))
- {
- return _connectionId.compareTo(p._connectionId);
- }
+ if(!_connectionId.equals(p._connectionId))
+ {
+ return _connectionId.compareTo(p._connectionId);
+ }
if(!_compress && p._compress)
{
@@ -501,48 +501,48 @@ final class TcpEndpointI extends EndpointI
// We do the most time-consuming part of the comparison last.
//
java.net.InetSocketAddress laddr = null;
- try
- {
- laddr = Network.getAddress(_host, _port);
- }
- catch(Ice.DNSException ex)
- {
- }
+ try
+ {
+ laddr = Network.getAddress(_host, _port);
+ }
+ catch(Ice.DNSException ex)
+ {
+ }
java.net.InetSocketAddress raddr = null;
- try
- {
- raddr = Network.getAddress(p._host, p._port);
- }
- catch(Ice.DNSException ex)
- {
- }
-
- if(laddr == null && raddr != null)
- {
- return -1;
- }
- else if(raddr == null && laddr != null)
- {
- return 1;
- }
- else if(laddr != null && raddr != null)
- {
- byte[] larr = laddr.getAddress().getAddress();
- byte[] rarr = raddr.getAddress().getAddress();
- assert(larr.length == rarr.length);
- for(int i = 0; i < larr.length; i++)
- {
- if(larr[i] < rarr[i])
- {
- return -1;
- }
- else if(rarr[i] < larr[i])
- {
- return 1;
- }
- }
- }
+ try
+ {
+ raddr = Network.getAddress(p._host, p._port);
+ }
+ catch(Ice.DNSException ex)
+ {
+ }
+
+ if(laddr == null && raddr != null)
+ {
+ return -1;
+ }
+ else if(raddr == null && laddr != null)
+ {
+ return 1;
+ }
+ else if(laddr != null && raddr != null)
+ {
+ byte[] larr = laddr.getAddress().getAddress();
+ byte[] rarr = raddr.getAddress().getAddress();
+ assert(larr.length == rarr.length);
+ for(int i = 0; i < larr.length; i++)
+ {
+ if(larr[i] < rarr[i])
+ {
+ return -1;
+ }
+ else if(rarr[i] < larr[i])
+ {
+ return 1;
+ }
+ }
+ }
}
return 0;
diff --git a/java/src/IceInternal/TcpTransceiver.java b/java/src/IceInternal/TcpTransceiver.java
index b5537689b71..b0f8fc3ba6c 100644
--- a/java/src/IceInternal/TcpTransceiver.java
+++ b/java/src/IceInternal/TcpTransceiver.java
@@ -27,48 +27,48 @@ final class TcpTransceiver implements Transceiver
_logger.trace(_traceLevels.networkCat, s);
}
- synchronized(this)
- {
- assert(_fd != null);
- if(_readSelector != null)
- {
- try
- {
- _readSelector.close();
- }
- catch(java.io.IOException ex)
- {
- // Ignore.
- }
- _readSelector = null;
- }
- if(_writeSelector != null)
- {
- try
- {
- _writeSelector.close();
- }
- catch(java.io.IOException ex)
- {
- // Ignore.
- }
- _writeSelector = null;
- }
- try
- {
- _fd.close();
- }
- catch(java.io.IOException ex)
- {
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
- finally
- {
- _fd = null;
- }
- }
+ synchronized(this)
+ {
+ assert(_fd != null);
+ if(_readSelector != null)
+ {
+ try
+ {
+ _readSelector.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ // Ignore.
+ }
+ _readSelector = null;
+ }
+ if(_writeSelector != null)
+ {
+ try
+ {
+ _writeSelector.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ // Ignore.
+ }
+ _writeSelector = null;
+ }
+ try
+ {
+ _fd.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
+ finally
+ {
+ _fd = null;
+ }
+ }
}
public void
@@ -88,23 +88,23 @@ final class TcpTransceiver implements Transceiver
}
catch(java.net.SocketException ex)
{
- //
- // Ignore errors indicating that we are shutdown already.
- //
- if(Network.notConnected(ex))
- {
- return;
- }
+ //
+ // Ignore errors indicating that we are shutdown already.
+ //
+ if(Network.notConnected(ex))
+ {
+ return;
+ }
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
}
catch(java.io.IOException ex)
{
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
}
}
@@ -121,99 +121,99 @@ final class TcpTransceiver implements Transceiver
java.net.Socket socket = _fd.socket();
try
{
- socket.shutdownInput(); // Shutdown socket for reading
- socket.shutdownOutput(); // Shutdown socket for writing
+ socket.shutdownInput(); // Shutdown socket for reading
+ socket.shutdownOutput(); // Shutdown socket for writing
}
catch(java.net.SocketException ex)
{
- // Ignore.
+ // Ignore.
}
catch(java.io.IOException ex)
{
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
}
}
public void
write(BasicStream stream, int timeout)
- throws LocalExceptionWrapper
+ throws LocalExceptionWrapper
{
java.nio.ByteBuffer buf = stream.prepareWrite();
- while(buf.hasRemaining())
- {
- try
- {
- assert(_fd != null);
- int ret = _fd.write(buf);
-
- if(ret == -1)
- {
- throw new Ice.ConnectionLostException();
- }
-
- if(ret == 0)
- {
- if(timeout == 0)
- {
- throw new Ice.TimeoutException();
- }
-
- if(_writeSelector == null)
- {
- _writeSelector = java.nio.channels.Selector.open();
- _fd.register(_writeSelector, java.nio.channels.SelectionKey.OP_WRITE, null);
- }
-
- try
- {
- if(timeout > 0)
- {
- long start = System.currentTimeMillis();
- int n = _writeSelector.select(timeout);
- if(n == 0 && System.currentTimeMillis() >= start + timeout)
- {
- throw new Ice.TimeoutException();
- }
- }
- else
- {
- _writeSelector.select();
- }
- }
- catch(java.io.InterruptedIOException ex)
- {
- // Ignore.
- }
+ while(buf.hasRemaining())
+ {
+ try
+ {
+ assert(_fd != null);
+ int ret = _fd.write(buf);
+
+ if(ret == -1)
+ {
+ throw new Ice.ConnectionLostException();
+ }
+
+ if(ret == 0)
+ {
+ if(timeout == 0)
+ {
+ throw new Ice.TimeoutException();
+ }
+
+ if(_writeSelector == null)
+ {
+ _writeSelector = java.nio.channels.Selector.open();
+ _fd.register(_writeSelector, java.nio.channels.SelectionKey.OP_WRITE, null);
+ }
+
+ try
+ {
+ if(timeout > 0)
+ {
+ long start = System.currentTimeMillis();
+ int n = _writeSelector.select(timeout);
+ if(n == 0 && System.currentTimeMillis() >= start + timeout)
+ {
+ throw new Ice.TimeoutException();
+ }
+ }
+ else
+ {
+ _writeSelector.select();
+ }
+ }
+ catch(java.io.InterruptedIOException ex)
+ {
+ // Ignore.
+ }
- continue;
- }
+ continue;
+ }
-
- if(_traceLevels.network >= 3)
- {
- String s = "sent " + ret + " of " + buf.limit() + " bytes via tcp\n" + toString();
- _logger.trace(_traceLevels.networkCat, s);
- }
+
+ if(_traceLevels.network >= 3)
+ {
+ String s = "sent " + ret + " of " + buf.limit() + " bytes via tcp\n" + toString();
+ _logger.trace(_traceLevels.networkCat, s);
+ }
- if(_stats != null)
- {
- _stats.bytesSent(type(), ret);
- }
- }
- catch(java.io.InterruptedIOException ex)
- {
- continue;
- }
- catch(java.io.IOException ex)
- {
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
- }
+ if(_stats != null)
+ {
+ _stats.bytesSent(type(), ret);
+ }
+ }
+ catch(java.io.InterruptedIOException ex)
+ {
+ continue;
+ }
+ catch(java.io.IOException ex)
+ {
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
+ }
}
public boolean
@@ -227,89 +227,89 @@ final class TcpTransceiver implements Transceiver
remaining = buf.remaining();
}
- while(buf.hasRemaining())
- {
- try
- {
- assert(_fd != null);
- int ret = _fd.read(buf);
-
- if(ret == -1)
- {
- throw new Ice.ConnectionLostException();
- }
-
- if(ret == 0)
- {
- if(timeout == 0)
- {
- throw new Ice.TimeoutException();
- }
+ while(buf.hasRemaining())
+ {
+ try
+ {
+ assert(_fd != null);
+ int ret = _fd.read(buf);
+
+ if(ret == -1)
+ {
+ throw new Ice.ConnectionLostException();
+ }
+
+ if(ret == 0)
+ {
+ if(timeout == 0)
+ {
+ throw new Ice.TimeoutException();
+ }
- if(_readSelector == null)
- {
- _readSelector = java.nio.channels.Selector.open();
- _fd.register(_readSelector, java.nio.channels.SelectionKey.OP_READ, null);
- }
-
- try
- {
- if(timeout > 0)
- {
- long start = System.currentTimeMillis();
- int n = _readSelector.select(timeout);
- if(n == 0 && System.currentTimeMillis() >= start + timeout)
- {
- throw new Ice.TimeoutException();
- }
- }
- else
- {
- _readSelector.select();
- }
- }
- catch(java.io.InterruptedIOException ex)
- {
- // Ignore.
- }
+ if(_readSelector == null)
+ {
+ _readSelector = java.nio.channels.Selector.open();
+ _fd.register(_readSelector, java.nio.channels.SelectionKey.OP_READ, null);
+ }
+
+ try
+ {
+ if(timeout > 0)
+ {
+ long start = System.currentTimeMillis();
+ int n = _readSelector.select(timeout);
+ if(n == 0 && System.currentTimeMillis() >= start + timeout)
+ {
+ throw new Ice.TimeoutException();
+ }
+ }
+ else
+ {
+ _readSelector.select();
+ }
+ }
+ catch(java.io.InterruptedIOException ex)
+ {
+ // Ignore.
+ }
- continue;
- }
-
- if(ret > 0)
- {
- if(_traceLevels.network >= 3)
- {
- String s = "received " + ret + " of " + remaining + " bytes via tcp\n" + toString();
- _logger.trace(_traceLevels.networkCat, s);
- }
+ continue;
+ }
+
+ if(ret > 0)
+ {
+ if(_traceLevels.network >= 3)
+ {
+ String s = "received " + ret + " of " + remaining + " bytes via tcp\n" + toString();
+ _logger.trace(_traceLevels.networkCat, s);
+ }
- if(_stats != null)
- {
- _stats.bytesReceived(type(), ret);
- }
- }
- }
- catch(java.io.InterruptedIOException ex)
- {
- continue;
- }
- catch(java.io.IOException ex)
- {
- if(Network.connectionLost(ex))
- {
- Ice.ConnectionLostException se = new Ice.ConnectionLostException();
- se.initCause(ex);
- throw se;
- }
-
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
- }
+ if(_stats != null)
+ {
+ _stats.bytesReceived(type(), ret);
+ }
+ }
+ }
+ catch(java.io.InterruptedIOException ex)
+ {
+ continue;
+ }
+ catch(java.io.IOException ex)
+ {
+ if(Network.connectionLost(ex))
+ {
+ Ice.ConnectionLostException se = new Ice.ConnectionLostException();
+ se.initCause(ex);
+ throw se;
+ }
+
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
+ }
- return false;
+ return false;
}
public String
@@ -327,10 +327,10 @@ final class TcpTransceiver implements Transceiver
public void
checkSendSize(BasicStream stream, int messageSizeMax)
{
- if(stream.size() > messageSizeMax)
- {
- throw new Ice.MemoryLimitException();
- }
+ if(stream.size() > messageSizeMax)
+ {
+ throw new Ice.MemoryLimitException();
+ }
}
//
diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java
index 948c56d4418..30ed86a3082 100644
--- a/java/src/IceInternal/ThreadPool.java
+++ b/java/src/IceInternal/ThreadPool.java
@@ -26,24 +26,24 @@ public final class ThreadPool
_destroyed = false;
_prefix = prefix;
_timeout = timeout;
- _threadIndex = 0;
- _running = 0;
- _inUse = 0;
- _load = 1.0;
- _promote = true;
- _warnUdp = _instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
-
- String programName = _instance.initializationData().properties.getProperty("Ice.ProgramName");
+ _threadIndex = 0;
+ _running = 0;
+ _inUse = 0;
+ _load = 1.0;
+ _promote = true;
+ _warnUdp = _instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
+
+ String programName = _instance.initializationData().properties.getProperty("Ice.ProgramName");
if(programName.length() > 0)
{
_programNamePrefix = programName + "-";
}
- else
- {
- _programNamePrefix = "";
- }
+ else
+ {
+ _programNamePrefix = "";
+ }
- Network.SocketPair pair = Network.createPipe();
+ Network.SocketPair pair = Network.createPipe();
_fdIntrRead = (java.nio.channels.ReadableByteChannel)pair.source;
_fdIntrWrite = pair.sink;
@@ -66,64 +66,64 @@ public final class ThreadPool
//
_keys = _selector.selectedKeys();
- //
- // We use just one thread as the default. This is the fastest
- // possible setting, still allows one level of nesting, and
- // doesn't require to make the servants thread safe.
- //
- int size = _instance.initializationData().properties.getPropertyAsIntWithDefault(_prefix + ".Size", 1);
- if(size < 1)
- {
- String s = _prefix + ".Size < 1; Size adjusted to 1";
- _instance.initializationData().logger.warning(s);
- size = 1;
- }
-
- int sizeMax =
- _instance.initializationData().properties.getPropertyAsIntWithDefault(_prefix + ".SizeMax", size);
- if(sizeMax < size)
- {
- String s = _prefix + ".SizeMax < " + _prefix + ".Size; SizeMax adjusted to Size (" + size + ")";
- _instance.initializationData().logger.warning(s);
- sizeMax = size;
- }
-
- int sizeWarn = _instance.initializationData().properties.getPropertyAsIntWithDefault(
- _prefix + ".SizeWarn", sizeMax * 80 / 100);
- if(sizeWarn > sizeMax)
- {
- String s = _prefix + ".SizeWarn > " + _prefix + ".SizeMax; adjusted SizeWarn to SizeMax (" + sizeMax + ")";
- _instance.initializationData().logger.warning(s);
- sizeWarn = sizeMax;
- }
-
- _size = size;
- _sizeMax = sizeMax;
- _sizeWarn = sizeWarn;
-
- try
+ //
+ // We use just one thread as the default. This is the fastest
+ // possible setting, still allows one level of nesting, and
+ // doesn't require to make the servants thread safe.
+ //
+ int size = _instance.initializationData().properties.getPropertyAsIntWithDefault(_prefix + ".Size", 1);
+ if(size < 1)
+ {
+ String s = _prefix + ".Size < 1; Size adjusted to 1";
+ _instance.initializationData().logger.warning(s);
+ size = 1;
+ }
+
+ int sizeMax =
+ _instance.initializationData().properties.getPropertyAsIntWithDefault(_prefix + ".SizeMax", size);
+ if(sizeMax < size)
+ {
+ String s = _prefix + ".SizeMax < " + _prefix + ".Size; SizeMax adjusted to Size (" + size + ")";
+ _instance.initializationData().logger.warning(s);
+ sizeMax = size;
+ }
+
+ int sizeWarn = _instance.initializationData().properties.getPropertyAsIntWithDefault(
+ _prefix + ".SizeWarn", sizeMax * 80 / 100);
+ if(sizeWarn > sizeMax)
+ {
+ String s = _prefix + ".SizeWarn > " + _prefix + ".SizeMax; adjusted SizeWarn to SizeMax (" + sizeMax + ")";
+ _instance.initializationData().logger.warning(s);
+ sizeWarn = sizeMax;
+ }
+
+ _size = size;
+ _sizeMax = sizeMax;
+ _sizeWarn = sizeWarn;
+
+ try
{
_threads = new java.util.ArrayList();
for(int i = 0; i < _size; i++)
{
- EventHandlerThread thread = new EventHandlerThread(_programNamePrefix + _prefix + "-" +
- _threadIndex++);
+ EventHandlerThread thread = new EventHandlerThread(_programNamePrefix + _prefix + "-" +
+ _threadIndex++);
_threads.add(thread);
- thread.start();
- ++_running;
+ thread.start();
+ ++_running;
}
}
catch(RuntimeException ex)
{
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "cannot create thread for `" + _prefix + "':\n" + sw.toString();
- _instance.initializationData().logger.error(s);
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "cannot create thread for `" + _prefix + "':\n" + sw.toString();
+ _instance.initializationData().logger.error(s);
destroy();
- joinWithAllThreads();
+ joinWithAllThreads();
throw ex;
}
}
@@ -144,8 +144,8 @@ public final class ThreadPool
}
assert(!_destroyed);
- assert(_handlerMap.isEmpty());
- assert(_changes.isEmpty());
+ assert(_handlerMap.isEmpty());
+ assert(_changes.isEmpty());
_destroyed = true;
setInterrupt();
}
@@ -157,7 +157,7 @@ public final class ThreadPool
{
trace("adding handler of type " + handler.getClass().getName() + " for channel " + fd);
}
- assert(!_destroyed);
+ assert(!_destroyed);
_changes.add(new FdHandlerPair(fd, handler));
setInterrupt();
}
@@ -188,7 +188,7 @@ public final class ThreadPool
}
}
- assert(!_destroyed);
+ assert(!_destroyed);
_changes.add(new FdHandlerPair(fd, null));
setInterrupt();
}
@@ -198,64 +198,64 @@ public final class ThreadPool
{
if(_sizeMax > 1)
{
- synchronized(this)
- {
- assert(!_promote);
- _promote = true;
- notify();
-
- if(!_destroyed)
- {
- assert(_inUse >= 0);
- ++_inUse;
-
- if(_inUse == _sizeWarn)
- {
- String s = "thread pool `" + _prefix + "' is running low on threads\n"
- + "Size=" + _size + ", " + "SizeMax=" + _sizeMax + ", " + "SizeWarn=" + _sizeWarn;
- _instance.initializationData().logger.warning(s);
- }
-
- assert(_inUse <= _running);
- if(_inUse < _sizeMax && _inUse == _running)
- {
- try
- {
- EventHandlerThread thread = new EventHandlerThread(_programNamePrefix + _prefix + "-" +
- _threadIndex++);
- _threads.add(thread);
- thread.start();
- ++_running;
- }
- catch(RuntimeException ex)
- {
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "cannot create thread for `" + _prefix + "':\n" + sw.toString();
- _instance.initializationData().logger.error(s);
- }
- }
- }
- }
+ synchronized(this)
+ {
+ assert(!_promote);
+ _promote = true;
+ notify();
+
+ if(!_destroyed)
+ {
+ assert(_inUse >= 0);
+ ++_inUse;
+
+ if(_inUse == _sizeWarn)
+ {
+ String s = "thread pool `" + _prefix + "' is running low on threads\n"
+ + "Size=" + _size + ", " + "SizeMax=" + _sizeMax + ", " + "SizeWarn=" + _sizeWarn;
+ _instance.initializationData().logger.warning(s);
+ }
+
+ assert(_inUse <= _running);
+ if(_inUse < _sizeMax && _inUse == _running)
+ {
+ try
+ {
+ EventHandlerThread thread = new EventHandlerThread(_programNamePrefix + _prefix + "-" +
+ _threadIndex++);
+ _threads.add(thread);
+ thread.start();
+ ++_running;
+ }
+ catch(RuntimeException ex)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "cannot create thread for `" + _prefix + "':\n" + sw.toString();
+ _instance.initializationData().logger.error(s);
+ }
+ }
+ }
+ }
}
}
public void
joinWithAllThreads()
{
- //
- // _threads is immutable after destroy() has been called,
- // therefore no synchronization is needed. (Synchronization
- // wouldn't be possible here anyway, because otherwise the
- // other threads would never terminate.)
- //
- java.util.Iterator i = _threads.iterator();
- while(i.hasNext())
- {
- EventHandlerThread thread = (EventHandlerThread)i.next();
-
+ //
+ // _threads is immutable after destroy() has been called,
+ // therefore no synchronization is needed. (Synchronization
+ // wouldn't be possible here anyway, because otherwise the
+ // other threads would never terminate.)
+ //
+ java.util.Iterator i = _threads.iterator();
+ while(i.hasNext())
+ {
+ EventHandlerThread thread = (EventHandlerThread)i.next();
+
while(true)
{
try
@@ -269,72 +269,72 @@ public final class ThreadPool
}
}
- //
- // Cleanup the selector, and the socket pair.
- //
- try
- {
- if(_selector != null)
- {
- try
- {
- _selector.close();
- }
- catch(java.io.IOException ex)
- {
- //
- // BUGFIX:
- //
- // Ignore this exception. This shouldn't happen
- // but for some reasons the close() call raises
- // "java.io.IOException: Bad file descriptor" on
- // Mac OS X 10.3.x (it works fine on OS X 10.4.x)
- //
- }
- _selector = null;
- }
-
- if(_fdIntrWrite != null)
- {
- try
- {
- _fdIntrWrite.close();
- }
- catch(java.io.IOException ex)
- {
- //
- // BUGFIX:
- //
- // Ignore this exception. This shouldn't happen
- // but for some reasons the close() call raises
- // "java.io.IOException: No such file or
- // directory" under Linux with JDK 1.4.2.
- //
- }
- _fdIntrWrite = null;
- }
-
- if(_fdIntrRead != null)
- {
- _fdIntrRead.close();
- _fdIntrRead = null;
- }
- }
- catch(java.io.IOException ex)
- {
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "exception in `" + _prefix + "' while calling close():\n" + sw.toString();
- _instance.initializationData().logger.error(s);
- }
+ //
+ // Cleanup the selector, and the socket pair.
+ //
+ try
+ {
+ if(_selector != null)
+ {
+ try
+ {
+ _selector.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ //
+ // BUGFIX:
+ //
+ // Ignore this exception. This shouldn't happen
+ // but for some reasons the close() call raises
+ // "java.io.IOException: Bad file descriptor" on
+ // Mac OS X 10.3.x (it works fine on OS X 10.4.x)
+ //
+ }
+ _selector = null;
+ }
+
+ if(_fdIntrWrite != null)
+ {
+ try
+ {
+ _fdIntrWrite.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ //
+ // BUGFIX:
+ //
+ // Ignore this exception. This shouldn't happen
+ // but for some reasons the close() call raises
+ // "java.io.IOException: No such file or
+ // directory" under Linux with JDK 1.4.2.
+ //
+ }
+ _fdIntrWrite = null;
+ }
+
+ if(_fdIntrRead != null)
+ {
+ _fdIntrRead.close();
+ _fdIntrRead = null;
+ }
+ }
+ catch(java.io.IOException ex)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "exception in `" + _prefix + "' while calling close():\n" + sw.toString();
+ _instance.initializationData().logger.error(s);
+ }
}
public String
prefix()
{
- return _prefix;
+ return _prefix;
}
private void
@@ -429,492 +429,492 @@ public final class ThreadPool
private boolean
run(BasicStream stream)
{
- if(_sizeMax > 1)
- {
- synchronized(this)
- {
- while(!_promote)
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- _promote = false;
- }
-
- if(TRACE_THREAD)
- {
- trace("thread " + Thread.currentThread() + " has the lock");
- }
- }
-
- while(true)
+ if(_sizeMax > 1)
{
- if(TRACE_REGISTRATION)
- {
- java.util.Set keys = _selector.keys();
- trace("selecting on " + keys.size() + " channels:");
- java.util.Iterator i = keys.iterator();
- while(i.hasNext())
- {
- java.nio.channels.SelectionKey key = (java.nio.channels.SelectionKey)i.next();
- trace(" " + key.channel());
- }
- }
-
- EventHandler handler = null;
-
- //
- // Only call select() if there are no pending handlers with additional data
- // for us to read.
- //
- if(!_pendingHandlers.isEmpty())
- {
- handler = (EventHandler)_pendingHandlers.removeFirst();
- }
- else
- {
- select();
- }
-
- boolean finished = false;
- boolean shutdown = false;
-
- if(handler == null)
- {
- synchronized(this)
- {
- if(_keys.size() == 0) // We initiate a shutdown if there is a thread pool timeout.
- {
- if(TRACE_SELECT)
- {
- trace("timeout");
- }
-
- assert(_timeout > 0);
- _timeout = 0;
- shutdown = true;
- }
- else
- {
- if(_keys.contains(_fdIntrReadKey) && _fdIntrReadKey.isReadable())
- {
- if(TRACE_SELECT || TRACE_INTERRUPT)
- {
- trace("detected interrupt");
- }
-
- //
- // There are two possiblities for an interrupt:
- //
- // 1. The thread pool has been destroyed.
- //
- // 2. An event handler was registered or unregistered.
- //
-
- //
- // Thread pool destroyed?
- //
- if(_destroyed)
- {
- if(TRACE_SHUTDOWN)
- {
- trace("destroyed, thread id = " + Thread.currentThread());
- }
-
- //
- // Don't clear the interrupt fd if
- // destroyed, so that the other threads
- // exit as well.
- //
- return true;
- }
-
- //
- // Remove the interrupt channel from the
- // selected key set.
- //
- _keys.remove(_fdIntrReadKey);
-
- clearInterrupt();
-
- //
- // An event handler must have been registered
- // or unregistered.
- //
- assert(!_changes.isEmpty());
- FdHandlerPair change = (FdHandlerPair)_changes.removeFirst();
-
- if(change.handler != null) // Addition if handler is set.
- {
- int op;
- if((change.fd.validOps() & java.nio.channels.SelectionKey.OP_READ) > 0)
- {
- op = java.nio.channels.SelectionKey.OP_READ;
- }
- else
- {
- op = java.nio.channels.SelectionKey.OP_ACCEPT;
- }
-
- java.nio.channels.SelectionKey key = null;
- try
- {
- key = change.fd.register(_selector, op, change.handler);
- }
- catch(java.nio.channels.ClosedChannelException ex)
- {
- assert(false);
- }
- _handlerMap.put(change.fd, new HandlerKeyPair(change.handler, key));
-
- if(TRACE_REGISTRATION)
- {
- trace("added handler (" + change.handler.getClass().getName() + ") for fd " +
- change.fd);
- }
-
- continue;
- }
- else // Removal if handler is not set.
- {
- HandlerKeyPair pair = (HandlerKeyPair)_handlerMap.remove(change.fd);
- assert(pair != null);
- handler = pair.handler;
- finished = true;
- pair.key.cancel();
-
- if(TRACE_REGISTRATION)
- {
- trace("removed handler (" + handler.getClass().getName() + ") for fd " +
- change.fd);
- }
-
- // Don't continue; we have to call
- // finished() on the event handler below,
- // outside the thread synchronization.
- }
- }
- else
- {
- java.nio.channels.SelectionKey key = null;
- java.util.Iterator iter = _keys.iterator();
- while(iter.hasNext())
- {
- //
- // Ignore selection keys that have been cancelled
- //
- java.nio.channels.SelectionKey k = (java.nio.channels.SelectionKey)iter.next();
- iter.remove();
- if(k.isValid() && k != _fdIntrReadKey)
- {
- if(TRACE_SELECT)
- {
- trace("found a key: " + keyToString(k));
- }
-
- key = k;
- break;
- }
- }
-
- if(key == null)
- {
- if(TRACE_SELECT)
- {
- trace("didn't find a valid key");
- }
-
- continue;
- }
-
- handler = (EventHandler)key.attachment();
- }
- }
- }
- }
-
- //
- // Now we are outside the thread synchronization.
- //
-
- if(shutdown)
- {
- if(TRACE_SHUTDOWN)
- {
- trace("shutdown detected");
- }
-
- //
- // Initiate server shutdown.
- //
- ObjectAdapterFactory factory;
- try
- {
- factory = _instance.objectAdapterFactory();
- }
- catch(Ice.CommunicatorDestroyedException e)
- {
- continue;
- }
-
- promoteFollower();
- factory.shutdown();
-
- //
- // No "continue", because we want shutdown to be done in
- // its own thread from this pool. Therefore we called
- // promoteFollower().
- //
- }
- else
- {
- assert(handler != null);
-
- if(finished)
- {
- //
- // Notify a handler about its removal from
- // the thread pool.
- //
- try
- {
- handler.finished(this);
- }
- catch(Ice.LocalException ex)
- {
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "exception in `" + _prefix + "' while calling finished():\n" +
- sw.toString() + "\n" + handler.toString();
- _instance.initializationData().logger.error(s);
- }
-
- //
- // No "continue", because we want finished() to be
- // called in its own thread from this pool. Note
- // that this means that finished() must call
- // promoteFollower().
- //
- }
- else
- {
- //
- // If the handler is "readable", try to read a
- // message.
- //
- try
- {
- if(handler.readable())
- {
- try
- {
- //
- // If read returns true, the handler has more data for the thread pool
- // to process.
- //
- if(read(handler))
- {
- _pendingHandlers.add(handler);
- }
- }
- catch(Ice.TimeoutException ex) // Expected.
- {
- continue;
- }
- catch(Ice.DatagramLimitException ex) // Expected.
- {
- continue;
- }
- catch(Ice.SocketException ex)
- {
- if(TRACE_EXCEPTION)
- {
- trace("informing handler (" + handler.getClass().getName() +
- ") about exception " + ex);
- ex.printStackTrace();
- }
-
- handler.exception(ex);
- continue;
- }
- catch(Ice.LocalException ex)
- {
- if(handler.datagram())
- {
- if(_instance.initializationData().properties.getPropertyAsInt(
- "Ice.Warn.Connections") > 0)
- {
- _instance.initializationData().logger.warning(
- "datagram connection exception:\n" + ex + "\n" + handler.toString());
- }
- }
- else
- {
- if(TRACE_EXCEPTION)
- {
- trace("informing handler (" + handler.getClass().getName() +
- ") about exception " + ex);
- ex.printStackTrace();
- }
-
- handler.exception(ex);
- }
- continue;
- }
-
- stream.swap(handler._stream);
- assert(stream.pos() == stream.size());
- }
-
- //
- // Provide a new message to the handler.
- //
- try
- {
- handler.message(stream, this);
- }
- catch(Ice.LocalException ex)
- {
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- ex.printStackTrace(pw);
- pw.flush();
- String s = "exception in `" + _prefix + "' while calling message():\n" +
- sw.toString() + "\n" + handler.toString();
- _instance.initializationData().logger.error(s);
- }
-
- //
- // No "continue", because we want message() to
- // be called in its own thread from this
- // pool. Note that this means that message()
- // must call promoteFollower().
- //
- }
- finally
- {
- stream.reset();
- }
- }
- }
-
- if(_sizeMax > 1)
- {
- synchronized(this)
- {
- if(!_destroyed)
- {
- //
- // First we reap threads that have been
- // destroyed before.
- //
- int sz = _threads.size();
- assert(_running <= sz);
- if(_running < sz)
- {
- java.util.Iterator i = _threads.iterator();
- while(i.hasNext())
- {
- EventHandlerThread thread = (EventHandlerThread)i.next();
-
- if(!thread.isAlive())
- {
- try
- {
- thread.join();
- i.remove();
- }
- catch(InterruptedException ex)
- {
- }
- }
- }
- }
-
- //
- // Now we check if this thread can be destroyed, based
- // on a load factor.
- //
-
- //
- // The load factor jumps immediately to the number of
- // threads that are currently in use, but decays
- // exponentially if the number of threads in use is
- // smaller than the load factor. This reflects that we
- // create threads immediately when they are needed,
- // but want the number of threads to slowly decline to
- // the configured minimum.
- //
- double inUse = (double)_inUse;
- if(_load < inUse)
- {
- _load = inUse;
- }
- else
- {
- final double loadFactor = 0.05; // TODO: Configurable?
- final double oneMinusLoadFactor = 1 - loadFactor;
- _load = _load * oneMinusLoadFactor + _inUse * loadFactor;
- }
-
- if(_running > _size)
- {
- int load = (int)(_load + 0.5);
-
- //
- // We add one to the load factor because one
- // additional thread is needed for select().
- //
- if(load + 1 < _running)
- {
- assert(_inUse > 0);
- --_inUse;
-
- assert(_running > 0);
- --_running;
-
- return false;
- }
- }
-
- assert(_inUse > 0);
- --_inUse;
- }
-
- while(!_promote)
- {
- try
- {
- wait();
- }
- catch(InterruptedException ex)
- {
- }
- }
-
- _promote = false;
- }
-
- if(TRACE_THREAD)
- {
- trace("thread " + Thread.currentThread() + " has the lock");
- }
- }
+ synchronized(this)
+ {
+ while(!_promote)
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ _promote = false;
+ }
+
+ if(TRACE_THREAD)
+ {
+ trace("thread " + Thread.currentThread() + " has the lock");
+ }
+ }
+
+ while(true)
+ {
+ if(TRACE_REGISTRATION)
+ {
+ java.util.Set keys = _selector.keys();
+ trace("selecting on " + keys.size() + " channels:");
+ java.util.Iterator i = keys.iterator();
+ while(i.hasNext())
+ {
+ java.nio.channels.SelectionKey key = (java.nio.channels.SelectionKey)i.next();
+ trace(" " + key.channel());
+ }
+ }
+
+ EventHandler handler = null;
+
+ //
+ // Only call select() if there are no pending handlers with additional data
+ // for us to read.
+ //
+ if(!_pendingHandlers.isEmpty())
+ {
+ handler = (EventHandler)_pendingHandlers.removeFirst();
+ }
+ else
+ {
+ select();
+ }
+
+ boolean finished = false;
+ boolean shutdown = false;
+
+ if(handler == null)
+ {
+ synchronized(this)
+ {
+ if(_keys.size() == 0) // We initiate a shutdown if there is a thread pool timeout.
+ {
+ if(TRACE_SELECT)
+ {
+ trace("timeout");
+ }
+
+ assert(_timeout > 0);
+ _timeout = 0;
+ shutdown = true;
+ }
+ else
+ {
+ if(_keys.contains(_fdIntrReadKey) && _fdIntrReadKey.isReadable())
+ {
+ if(TRACE_SELECT || TRACE_INTERRUPT)
+ {
+ trace("detected interrupt");
+ }
+
+ //
+ // There are two possiblities for an interrupt:
+ //
+ // 1. The thread pool has been destroyed.
+ //
+ // 2. An event handler was registered or unregistered.
+ //
+
+ //
+ // Thread pool destroyed?
+ //
+ if(_destroyed)
+ {
+ if(TRACE_SHUTDOWN)
+ {
+ trace("destroyed, thread id = " + Thread.currentThread());
+ }
+
+ //
+ // Don't clear the interrupt fd if
+ // destroyed, so that the other threads
+ // exit as well.
+ //
+ return true;
+ }
+
+ //
+ // Remove the interrupt channel from the
+ // selected key set.
+ //
+ _keys.remove(_fdIntrReadKey);
+
+ clearInterrupt();
+
+ //
+ // An event handler must have been registered
+ // or unregistered.
+ //
+ assert(!_changes.isEmpty());
+ FdHandlerPair change = (FdHandlerPair)_changes.removeFirst();
+
+ if(change.handler != null) // Addition if handler is set.
+ {
+ int op;
+ if((change.fd.validOps() & java.nio.channels.SelectionKey.OP_READ) > 0)
+ {
+ op = java.nio.channels.SelectionKey.OP_READ;
+ }
+ else
+ {
+ op = java.nio.channels.SelectionKey.OP_ACCEPT;
+ }
+
+ java.nio.channels.SelectionKey key = null;
+ try
+ {
+ key = change.fd.register(_selector, op, change.handler);
+ }
+ catch(java.nio.channels.ClosedChannelException ex)
+ {
+ assert(false);
+ }
+ _handlerMap.put(change.fd, new HandlerKeyPair(change.handler, key));
+
+ if(TRACE_REGISTRATION)
+ {
+ trace("added handler (" + change.handler.getClass().getName() + ") for fd " +
+ change.fd);
+ }
+
+ continue;
+ }
+ else // Removal if handler is not set.
+ {
+ HandlerKeyPair pair = (HandlerKeyPair)_handlerMap.remove(change.fd);
+ assert(pair != null);
+ handler = pair.handler;
+ finished = true;
+ pair.key.cancel();
+
+ if(TRACE_REGISTRATION)
+ {
+ trace("removed handler (" + handler.getClass().getName() + ") for fd " +
+ change.fd);
+ }
+
+ // Don't continue; we have to call
+ // finished() on the event handler below,
+ // outside the thread synchronization.
+ }
+ }
+ else
+ {
+ java.nio.channels.SelectionKey key = null;
+ java.util.Iterator iter = _keys.iterator();
+ while(iter.hasNext())
+ {
+ //
+ // Ignore selection keys that have been cancelled
+ //
+ java.nio.channels.SelectionKey k = (java.nio.channels.SelectionKey)iter.next();
+ iter.remove();
+ if(k.isValid() && k != _fdIntrReadKey)
+ {
+ if(TRACE_SELECT)
+ {
+ trace("found a key: " + keyToString(k));
+ }
+
+ key = k;
+ break;
+ }
+ }
+
+ if(key == null)
+ {
+ if(TRACE_SELECT)
+ {
+ trace("didn't find a valid key");
+ }
+
+ continue;
+ }
+
+ handler = (EventHandler)key.attachment();
+ }
+ }
+ }
+ }
+
+ //
+ // Now we are outside the thread synchronization.
+ //
+
+ if(shutdown)
+ {
+ if(TRACE_SHUTDOWN)
+ {
+ trace("shutdown detected");
+ }
+
+ //
+ // Initiate server shutdown.
+ //
+ ObjectAdapterFactory factory;
+ try
+ {
+ factory = _instance.objectAdapterFactory();
+ }
+ catch(Ice.CommunicatorDestroyedException e)
+ {
+ continue;
+ }
+
+ promoteFollower();
+ factory.shutdown();
+
+ //
+ // No "continue", because we want shutdown to be done in
+ // its own thread from this pool. Therefore we called
+ // promoteFollower().
+ //
+ }
+ else
+ {
+ assert(handler != null);
+
+ if(finished)
+ {
+ //
+ // Notify a handler about its removal from
+ // the thread pool.
+ //
+ try
+ {
+ handler.finished(this);
+ }
+ catch(Ice.LocalException ex)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "exception in `" + _prefix + "' while calling finished():\n" +
+ sw.toString() + "\n" + handler.toString();
+ _instance.initializationData().logger.error(s);
+ }
+
+ //
+ // No "continue", because we want finished() to be
+ // called in its own thread from this pool. Note
+ // that this means that finished() must call
+ // promoteFollower().
+ //
+ }
+ else
+ {
+ //
+ // If the handler is "readable", try to read a
+ // message.
+ //
+ try
+ {
+ if(handler.readable())
+ {
+ try
+ {
+ //
+ // If read returns true, the handler has more data for the thread pool
+ // to process.
+ //
+ if(read(handler))
+ {
+ _pendingHandlers.add(handler);
+ }
+ }
+ catch(Ice.TimeoutException ex) // Expected.
+ {
+ continue;
+ }
+ catch(Ice.DatagramLimitException ex) // Expected.
+ {
+ continue;
+ }
+ catch(Ice.SocketException ex)
+ {
+ if(TRACE_EXCEPTION)
+ {
+ trace("informing handler (" + handler.getClass().getName() +
+ ") about exception " + ex);
+ ex.printStackTrace();
+ }
+
+ handler.exception(ex);
+ continue;
+ }
+ catch(Ice.LocalException ex)
+ {
+ if(handler.datagram())
+ {
+ if(_instance.initializationData().properties.getPropertyAsInt(
+ "Ice.Warn.Connections") > 0)
+ {
+ _instance.initializationData().logger.warning(
+ "datagram connection exception:\n" + ex + "\n" + handler.toString());
+ }
+ }
+ else
+ {
+ if(TRACE_EXCEPTION)
+ {
+ trace("informing handler (" + handler.getClass().getName() +
+ ") about exception " + ex);
+ ex.printStackTrace();
+ }
+
+ handler.exception(ex);
+ }
+ continue;
+ }
+
+ stream.swap(handler._stream);
+ assert(stream.pos() == stream.size());
+ }
+
+ //
+ // Provide a new message to the handler.
+ //
+ try
+ {
+ handler.message(stream, this);
+ }
+ catch(Ice.LocalException ex)
+ {
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ ex.printStackTrace(pw);
+ pw.flush();
+ String s = "exception in `" + _prefix + "' while calling message():\n" +
+ sw.toString() + "\n" + handler.toString();
+ _instance.initializationData().logger.error(s);
+ }
+
+ //
+ // No "continue", because we want message() to
+ // be called in its own thread from this
+ // pool. Note that this means that message()
+ // must call promoteFollower().
+ //
+ }
+ finally
+ {
+ stream.reset();
+ }
+ }
+ }
+
+ if(_sizeMax > 1)
+ {
+ synchronized(this)
+ {
+ if(!_destroyed)
+ {
+ //
+ // First we reap threads that have been
+ // destroyed before.
+ //
+ int sz = _threads.size();
+ assert(_running <= sz);
+ if(_running < sz)
+ {
+ java.util.Iterator i = _threads.iterator();
+ while(i.hasNext())
+ {
+ EventHandlerThread thread = (EventHandlerThread)i.next();
+
+ if(!thread.isAlive())
+ {
+ try
+ {
+ thread.join();
+ i.remove();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+ }
+ }
+
+ //
+ // Now we check if this thread can be destroyed, based
+ // on a load factor.
+ //
+
+ //
+ // The load factor jumps immediately to the number of
+ // threads that are currently in use, but decays
+ // exponentially if the number of threads in use is
+ // smaller than the load factor. This reflects that we
+ // create threads immediately when they are needed,
+ // but want the number of threads to slowly decline to
+ // the configured minimum.
+ //
+ double inUse = (double)_inUse;
+ if(_load < inUse)
+ {
+ _load = inUse;
+ }
+ else
+ {
+ final double loadFactor = 0.05; // TODO: Configurable?
+ final double oneMinusLoadFactor = 1 - loadFactor;
+ _load = _load * oneMinusLoadFactor + _inUse * loadFactor;
+ }
+
+ if(_running > _size)
+ {
+ int load = (int)(_load + 0.5);
+
+ //
+ // We add one to the load factor because one
+ // additional thread is needed for select().
+ //
+ if(load + 1 < _running)
+ {
+ assert(_inUse > 0);
+ --_inUse;
+
+ assert(_running > 0);
+ --_running;
+
+ return false;
+ }
+ }
+
+ assert(_inUse > 0);
+ --_inUse;
+ }
+
+ while(!_promote)
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ _promote = false;
+ }
+
+ if(TRACE_THREAD)
+ {
+ trace("thread " + Thread.currentThread() + " has the lock");
+ }
+ }
}
}
private boolean
read(EventHandler handler)
{
- boolean moreData = false;
+ boolean moreData = false;
BasicStream stream = handler._stream;
@@ -931,50 +931,50 @@ public final class ThreadPool
}
int pos = stream.pos();
- if(pos < Protocol.headerSize)
- {
- //
- // This situation is possible for small UDP packets.
- //
- throw new Ice.IllegalMessageSizeException();
- }
+ if(pos < Protocol.headerSize)
+ {
+ //
+ // This situation is possible for small UDP packets.
+ //
+ throw new Ice.IllegalMessageSizeException();
+ }
stream.pos(0);
- byte[] m = new byte[4];
- m[0] = stream.readByte();
- m[1] = stream.readByte();
- m[2] = stream.readByte();
- m[3] = stream.readByte();
- if(m[0] != Protocol.magic[0] || m[1] != Protocol.magic[1]
- || m[2] != Protocol.magic[2] || m[3] != Protocol.magic[3])
- {
- Ice.BadMagicException ex = new Ice.BadMagicException();
- ex.badMagic = m;
- throw ex;
- }
-
- byte pMajor = stream.readByte();
- byte pMinor = stream.readByte();
- if(pMajor != Protocol.protocolMajor || pMinor > Protocol.protocolMinor)
- {
- Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
- e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor;
- e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor;
- e.major = Protocol.protocolMajor;
- e.minor = Protocol.protocolMinor;
- throw e;
- }
-
- byte eMajor = stream.readByte();
- byte eMinor = stream.readByte();
- if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor)
- {
- Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
- e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor;
- e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor;
- e.major = Protocol.encodingMajor;
- e.minor = Protocol.encodingMinor;
- throw e;
- }
+ byte[] m = new byte[4];
+ m[0] = stream.readByte();
+ m[1] = stream.readByte();
+ m[2] = stream.readByte();
+ m[3] = stream.readByte();
+ if(m[0] != Protocol.magic[0] || m[1] != Protocol.magic[1]
+ || m[2] != Protocol.magic[2] || m[3] != Protocol.magic[3])
+ {
+ Ice.BadMagicException ex = new Ice.BadMagicException();
+ ex.badMagic = m;
+ throw ex;
+ }
+
+ byte pMajor = stream.readByte();
+ byte pMinor = stream.readByte();
+ if(pMajor != Protocol.protocolMajor || pMinor > Protocol.protocolMinor)
+ {
+ Ice.UnsupportedProtocolException e = new Ice.UnsupportedProtocolException();
+ e.badMajor = pMajor < 0 ? pMajor + 255 : pMajor;
+ e.badMinor = pMinor < 0 ? pMinor + 255 : pMinor;
+ e.major = Protocol.protocolMajor;
+ e.minor = Protocol.protocolMinor;
+ throw e;
+ }
+
+ byte eMajor = stream.readByte();
+ byte eMinor = stream.readByte();
+ if(eMajor != Protocol.encodingMajor || eMinor > Protocol.encodingMinor)
+ {
+ Ice.UnsupportedEncodingException e = new Ice.UnsupportedEncodingException();
+ e.badMajor = eMajor < 0 ? eMajor + 255 : eMajor;
+ e.badMinor = eMinor < 0 ? eMinor + 255 : eMinor;
+ e.major = Protocol.encodingMajor;
+ e.minor = Protocol.encodingMinor;
+ throw e;
+ }
byte messageType = stream.readByte();
byte compress = stream.readByte();
@@ -994,26 +994,26 @@ public final class ThreadPool
stream.pos(pos);
if(stream.pos() != stream.size())
- {
- if(handler.datagram())
- {
- if(_warnUdp)
- {
- _instance.initializationData().logger.warning("DatagramLimitException: maximum size of "
- + stream.pos() + " exceeded");
- }
- stream.pos(0);
- stream.resize(0, true);
- throw new Ice.DatagramLimitException();
- }
- else
- {
- moreData = handler.read(stream);
- assert(stream.pos() == stream.size());
- }
+ {
+ if(handler.datagram())
+ {
+ if(_warnUdp)
+ {
+ _instance.initializationData().logger.warning("DatagramLimitException: maximum size of "
+ + stream.pos() + " exceeded");
+ }
+ stream.pos(0);
+ stream.resize(0, true);
+ throw new Ice.DatagramLimitException();
+ }
+ else
+ {
+ moreData = handler.read(stream);
+ assert(stream.pos() == stream.size());
+ }
}
- return moreData;
+ return moreData;
}
/*
@@ -1070,13 +1070,13 @@ public final class ThreadPool
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
//throw se;
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- se.printStackTrace(pw);
- pw.flush();
- String s = "exception in `" + _prefix + "':\n" + sw.toString();
- _instance.initializationData().logger.error(s);
- continue;
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ se.printStackTrace(pw);
+ pw.flush();
+ String s = "exception in `" + _prefix + "':\n" + sw.toString();
+ _instance.initializationData().logger.error(s);
+ continue;
}
}
}
@@ -1096,14 +1096,14 @@ public final class ThreadPool
trace("select on " + _selector.keys().size() + " keys, thread id = " + Thread.currentThread());
}
- if(_timeout > 0)
- {
- ret = _selector.select(_timeout * 1000);
- }
- else
- {
- ret = _selector.select();
- }
+ if(_timeout > 0)
+ {
+ ret = _selector.select(_timeout * 1000);
+ }
+ else
+ {
+ ret = _selector.select();
+ }
}
catch(java.io.IOException ex)
{
@@ -1121,13 +1121,13 @@ public final class ThreadPool
Ice.SocketException se = new Ice.SocketException();
se.initCause(ex);
//throw se;
- java.io.StringWriter sw = new java.io.StringWriter();
- java.io.PrintWriter pw = new java.io.PrintWriter(sw);
- se.printStackTrace(pw);
- pw.flush();
- String s = "exception in `" + _prefix + "':\n" + sw.toString();
- _instance.initializationData().logger.error(s);
- continue;
+ java.io.StringWriter sw = new java.io.StringWriter();
+ java.io.PrintWriter pw = new java.io.PrintWriter(sw);
+ se.printStackTrace(pw);
+ pw.flush();
+ String s = "exception in `" + _prefix + "':\n" + sw.toString();
+ _instance.initializationData().logger.error(s);
+ continue;
}
if(TRACE_SELECT)
@@ -1228,18 +1228,18 @@ public final class ThreadPool
public void
run()
{
- if(_instance.initializationData().threadHook != null)
- {
- _instance.initializationData().threadHook.start();
- }
+ if(_instance.initializationData().threadHook != null)
+ {
+ _instance.initializationData().threadHook.start();
+ }
BasicStream stream = new BasicStream(_instance);
- boolean promote;
+ boolean promote;
try
{
- promote = ThreadPool.this.run(stream);
+ promote = ThreadPool.this.run(stream);
}
catch(Ice.LocalException ex)
{
@@ -1249,7 +1249,7 @@ public final class ThreadPool
pw.flush();
String s = "exception in `" + _prefix + "' thread " + getName() + ":\n" + sw.toString();
_instance.initializationData().logger.error(s);
- promote = true;
+ promote = true;
}
catch(java.lang.Exception ex)
{
@@ -1259,32 +1259,32 @@ public final class ThreadPool
pw.flush();
String s = "unknown exception in `" + _prefix + "' thread " + getName() + ":\n" + sw.toString();
_instance.initializationData().logger.error(s);
- promote = true;
+ promote = true;
}
- if(promote && _sizeMax > 1)
- {
- //
- // Promote a follower, but w/o modifying _inUse or
- // creating new threads.
- //
- synchronized(ThreadPool.this)
- {
- assert(!_promote);
- _promote = true;
- ThreadPool.this.notify();
- }
- }
+ if(promote && _sizeMax > 1)
+ {
+ //
+ // Promote a follower, but w/o modifying _inUse or
+ // creating new threads.
+ //
+ synchronized(ThreadPool.this)
+ {
+ assert(!_promote);
+ _promote = true;
+ ThreadPool.this.notify();
+ }
+ }
if(TRACE_THREAD)
{
trace("run() terminated");
}
- if(_instance.initializationData().threadHook != null)
- {
- _instance.initializationData().threadHook.stop();
- }
+ if(_instance.initializationData().threadHook != null)
+ {
+ _instance.initializationData().threadHook.stop();
+ }
}
}
diff --git a/java/src/IceInternal/TraceLevels.java b/java/src/IceInternal/TraceLevels.java
index 7458ac971c3..35c92d59def 100644
--- a/java/src/IceInternal/TraceLevels.java
+++ b/java/src/IceInternal/TraceLevels.java
@@ -16,16 +16,16 @@ public final class TraceLevels
networkCat = "Network";
protocolCat = "Protocol";
retryCat = "Retry";
- locationCat = "Location";
- slicingCat = "Slicing";
+ locationCat = "Location";
+ slicingCat = "Slicing";
final String keyBase = "Ice.Trace.";
network = properties.getPropertyAsInt(keyBase + networkCat);
- protocol = properties.getPropertyAsInt(keyBase + protocolCat);
+ protocol = properties.getPropertyAsInt(keyBase + protocolCat);
retry = properties.getPropertyAsInt(keyBase + retryCat);
- location = properties.getPropertyAsInt(keyBase + locationCat);
- slicing = properties.getPropertyAsInt(keyBase + slicingCat);
+ location = properties.getPropertyAsInt(keyBase + locationCat);
+ slicing = properties.getPropertyAsInt(keyBase + slicingCat);
}
final public int network;
diff --git a/java/src/IceInternal/TraceUtil.java b/java/src/IceInternal/TraceUtil.java
index 470be7744ef..6b57b96c540 100644
--- a/java/src/IceInternal/TraceUtil.java
+++ b/java/src/IceInternal/TraceUtil.java
@@ -67,9 +67,9 @@ public final class TraceUtil
printHeader(s, str);
int batchRequestNum = str.readInt();
- s.write("\nnumber of requests = " + batchRequestNum);
-
- for(int i = 0; i < batchRequestNum; ++i)
+ s.write("\nnumber of requests = " + batchRequestNum);
+
+ for(int i = 0; i < batchRequestNum; ++i)
{
s.write("\nrequest #" + i + ':');
printRequestHeader(s, str);
@@ -117,72 +117,72 @@ public final class TraceUtil
case DispatchStatus._DispatchFacetNotExist:
case DispatchStatus._DispatchOperationNotExist:
{
- switch(status)
- {
- case DispatchStatus._DispatchObjectNotExist:
- {
- s.write("(object not exist)");
- break;
- }
-
- case DispatchStatus._DispatchFacetNotExist:
- {
- s.write("(facet not exist)");
- break;
- }
-
- case DispatchStatus._DispatchOperationNotExist:
- {
- s.write("(operation not exist)");
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- printIdentityFacetOperation(s, str);
- break;
+ switch(status)
+ {
+ case DispatchStatus._DispatchObjectNotExist:
+ {
+ s.write("(object not exist)");
+ break;
+ }
+
+ case DispatchStatus._DispatchFacetNotExist:
+ {
+ s.write("(facet not exist)");
+ break;
+ }
+
+ case DispatchStatus._DispatchOperationNotExist:
+ {
+ s.write("(operation not exist)");
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ printIdentityFacetOperation(s, str);
+ break;
}
- case DispatchStatus._DispatchUnknownException:
- case DispatchStatus._DispatchUnknownLocalException:
- case DispatchStatus._DispatchUnknownUserException:
- {
- switch(status)
- {
- case DispatchStatus._DispatchUnknownException:
- {
- s.write("(unknown exception)");
- break;
- }
-
- case DispatchStatus._DispatchUnknownLocalException:
- {
- s.write("(unknown local exception)");
- break;
- }
-
- case DispatchStatus._DispatchUnknownUserException:
- {
- s.write("(unknown user exception)");
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- String unknown = str.readString();
- s.write("\nunknown = " + unknown);
- break;
- }
+ case DispatchStatus._DispatchUnknownException:
+ case DispatchStatus._DispatchUnknownLocalException:
+ case DispatchStatus._DispatchUnknownUserException:
+ {
+ switch(status)
+ {
+ case DispatchStatus._DispatchUnknownException:
+ {
+ s.write("(unknown exception)");
+ break;
+ }
+
+ case DispatchStatus._DispatchUnknownLocalException:
+ {
+ s.write("(unknown local exception)");
+ break;
+ }
+
+ case DispatchStatus._DispatchUnknownUserException:
+ {
+ s.write("(unknown user exception)");
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ String unknown = str.readString();
+ s.write("\nunknown = " + unknown);
+ break;
+ }
default:
{
@@ -201,12 +201,12 @@ public final class TraceUtil
synchronized static void
traceSlicing(String kind, String typeId, String slicingCat, Ice.Logger logger)
{
- if(slicingIds.add(typeId))
- {
- java.io.StringWriter s = new java.io.StringWriter();
- s.write("unknown " + kind + " type `" + typeId + "'");
- logger.trace(slicingCat, s.toString());
- }
+ if(slicingIds.add(typeId))
+ {
+ java.io.StringWriter s = new java.io.StringWriter();
+ s.write("unknown " + kind + " type `" + typeId + "'");
+ logger.trace(slicingCat, s.toString());
+ }
}
public static void
@@ -291,7 +291,7 @@ public final class TraceUtil
out.write("\nfacet = ");
if(facet.length > 0)
{
- out.write(IceUtil.StringUtil.escapeString(facet[0], ""));
+ out.write(IceUtil.StringUtil.escapeString(facet[0], ""));
}
String operation = stream.readString();
@@ -306,38 +306,38 @@ public final class TraceUtil
private static void
printRequestHeader(java.io.Writer out, BasicStream stream)
{
- printIdentityFacetOperation(out, stream);
+ printIdentityFacetOperation(out, stream);
try
{
byte mode = stream.readByte();
out.write("\nmode = " + (int)mode + ' ');
- switch(mode)
- {
- case Ice.OperationMode._Normal:
- {
- out.write("(normal)");
- break;
- }
-
- case Ice.OperationMode._Nonmutating:
- {
- out.write("(nonmutating)");
- break;
- }
-
- case Ice.OperationMode._Idempotent:
- {
- out.write("(idempotent)");
- break;
- }
-
- default:
- {
- out.write("(unknown)");
- break;
- }
- }
+ switch(mode)
+ {
+ case Ice.OperationMode._Normal:
+ {
+ out.write("(normal)");
+ break;
+ }
+
+ case Ice.OperationMode._Nonmutating:
+ {
+ out.write("(nonmutating)");
+ break;
+ }
+
+ case Ice.OperationMode._Idempotent:
+ {
+ out.write("(idempotent)");
+ break;
+ }
+
+ default:
+ {
+ out.write("(unknown)");
+ break;
+ }
+ }
int sz = stream.readSize();
out.write("\ncontext = ");
@@ -363,18 +363,18 @@ public final class TraceUtil
{
try
{
- byte magic;
- magic = stream.readByte(); // Don't bother printing the magic number
- magic = stream.readByte();
- magic = stream.readByte();
- magic = stream.readByte();
-
- byte pMajor = stream.readByte();
- byte pMinor = stream.readByte();
+ byte magic;
+ magic = stream.readByte(); // Don't bother printing the magic number
+ magic = stream.readByte();
+ magic = stream.readByte();
+ magic = stream.readByte();
+
+ byte pMajor = stream.readByte();
+ byte pMinor = stream.readByte();
// out.write("\nprotocol version = " + (int)pMajor + "." + (int)pMinor);
- byte eMajor = stream.readByte();
- byte eMinor = stream.readByte();
+ byte eMajor = stream.readByte();
+ byte eMinor = stream.readByte();
// out.write("\nencoding version = " + (int)eMajor + "." + (int)eMinor);
byte type = stream.readByte();
@@ -402,7 +402,7 @@ public final class TraceUtil
case Protocol.closeConnectionMsg:
{
out.write("(close connection)");
- break;
+ break;
}
case Protocol.validateConnectionMsg:
diff --git a/java/src/IceInternal/Transceiver.java b/java/src/IceInternal/Transceiver.java
index e04eac5689b..260d59bde77 100644
--- a/java/src/IceInternal/Transceiver.java
+++ b/java/src/IceInternal/Transceiver.java
@@ -19,10 +19,10 @@ public interface Transceiver
// NOTE: In Java, write() can raise LocalExceptionWrapper to indicate that
// retrying may not be safe, which is necessary to address an issue
// in the IceSSL implementation for JDK 1.4. We can remove this if
- // we ever drop support for JDK 1.4 (also see Ice.ConnectionI).
+ // we ever drop support for JDK 1.4 (also see Ice.ConnectionI).
//
void write(BasicStream stream, int timeout)
- throws LocalExceptionWrapper;
+ throws LocalExceptionWrapper;
//
// NOTE: In Java, read() returns a boolean to indicate whether the transceiver
// has read more data than requested.
diff --git a/java/src/IceInternal/UdpEndpointI.java b/java/src/IceInternal/UdpEndpointI.java
index b78daccd0ec..6207a0499b8 100644
--- a/java/src/IceInternal/UdpEndpointI.java
+++ b/java/src/IceInternal/UdpEndpointI.java
@@ -19,14 +19,14 @@ final class UdpEndpointI extends EndpointI
_instance = instance;
_host = ho;
_port = po;
- _protocolMajor = Protocol.protocolMajor;
- _protocolMinor = Protocol.protocolMinor;
- _encodingMajor = Protocol.encodingMajor;
- _encodingMinor = Protocol.encodingMinor;
+ _protocolMajor = Protocol.protocolMajor;
+ _protocolMinor = Protocol.protocolMinor;
+ _encodingMajor = Protocol.encodingMajor;
+ _encodingMinor = Protocol.encodingMinor;
_connect = conn;
- _connectionId = conId;
- _compress = co;
- _publish = pub;
+ _connectionId = conId;
+ _compress = co;
+ _publish = pub;
calcHashValue();
}
@@ -36,13 +36,13 @@ final class UdpEndpointI extends EndpointI
_instance = instance;
_host = null;
_port = 0;
- _protocolMajor = Protocol.protocolMajor;
- _protocolMinor = Protocol.protocolMinor;
- _encodingMajor = Protocol.encodingMajor;
- _encodingMinor = Protocol.encodingMinor;
+ _protocolMajor = Protocol.protocolMajor;
+ _protocolMinor = Protocol.protocolMinor;
+ _encodingMajor = Protocol.encodingMajor;
+ _encodingMinor = Protocol.encodingMinor;
_connect = false;
- _compress = false;
- _publish = true;
+ _compress = false;
+ _publish = true;
String[] arr = str.split("[ \t\n\r]+");
@@ -58,7 +58,7 @@ final class UdpEndpointI extends EndpointI
String option = arr[i++];
if(option.length() != 2 || option.charAt(0) != '-')
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
String argument = null;
@@ -73,46 +73,46 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
- int pos = argument.indexOf('.');
+ int pos = argument.indexOf('.');
if(pos == -1)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("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);
- }
+ 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("udp " + str);
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- throw new Ice.EndpointParseException("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;
+ {
+ throw new Ice.EndpointParseException("udp " + str);
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ throw new Ice.EndpointParseException("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;
break;
}
@@ -121,46 +121,46 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
- int pos = argument.indexOf('.');
+ int pos = argument.indexOf('.');
if(pos == -1)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("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);
- }
+ 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("udp " + str);
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- throw new Ice.EndpointParseException("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;
+ {
+ throw new Ice.EndpointParseException("udp " + str);
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ throw new Ice.EndpointParseException("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;
break;
}
@@ -169,7 +169,7 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
_host = argument;
@@ -180,7 +180,7 @@ final class UdpEndpointI extends EndpointI
{
if(argument == null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
try
@@ -189,13 +189,13 @@ final class UdpEndpointI extends EndpointI
}
catch(NumberFormatException ex)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
- if(_port < 0 || _port > 65535)
- {
- throw new Ice.EndpointParseException("udp " + str);
- }
+ if(_port < 0 || _port > 65535)
+ {
+ throw new Ice.EndpointParseException("udp " + str);
+ }
break;
}
@@ -204,7 +204,7 @@ final class UdpEndpointI extends EndpointI
{
if(argument != null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
_connect = true;
@@ -215,7 +215,7 @@ final class UdpEndpointI extends EndpointI
{
if(argument != null)
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
_compress = true;
@@ -224,7 +224,7 @@ final class UdpEndpointI extends EndpointI
default:
{
- throw new Ice.EndpointParseException("udp " + str);
+ throw new Ice.EndpointParseException("udp " + str);
}
}
}
@@ -237,34 +237,34 @@ 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;
- }
+ _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;
+ }
// Not transmitted.
//_connect = s.readBool();
_connect = false;
- _compress = s.readBool();
+ _compress = s.readBool();
s.endReadEncaps();
- _publish = true;
+ _publish = true;
calcHashValue();
}
@@ -278,13 +278,13 @@ 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);
+ s.writeByte(_protocolMajor);
+ s.writeByte(_protocolMinor);
+ s.writeByte(_encodingMajor);
+ s.writeByte(_encodingMinor);
// Not transmitted.
//s.writeBool(_connect);
- s.writeBool(_compress);
+ s.writeBool(_compress);
s.endWriteEncaps();
}
@@ -294,38 +294,38 @@ final class UdpEndpointI extends EndpointI
public String
_toString()
{
- //
- // WARNING: Certain features, such as proxy validation in Glacier2,
- // depend on the format of proxy strings. Changes to toString() and
- // methods called to generate parts of the reference string could break
- // these features. Please review for all features that depend on the
- // format of proxyToString() before changing this and related code.
- //
+ //
+ // WARNING: Certain features, such as proxy validation in Glacier2,
+ // depend on the format of proxy strings. Changes to toString() and
+ // methods called to generate parts of the reference string could break
+ // these features. Please review for all features that depend on the
+ // format of proxyToString() before changing this and related code.
+ //
String s = "udp";
- if((int)_protocolMajor != 1 || (int)_protocolMinor != 0)
- {
- s += " -v " + (_protocolMajor < 0 ? (int)_protocolMajor + 255 : _protocolMajor)
- + "." + (_protocolMinor < 0 ? (int)_protocolMinor + 255 : _protocolMinor);
- }
+ if((int)_protocolMajor != 1 || (int)_protocolMinor != 0)
+ {
+ s += " -v " + (_protocolMajor < 0 ? (int)_protocolMajor + 255 : _protocolMajor)
+ + "." + (_protocolMinor < 0 ? (int)_protocolMinor + 255 : _protocolMinor);
+ }
- if((int)_encodingMajor != 1 || (int)_encodingMinor != 0)
- {
- s += " -e " + (_encodingMajor < 0 ? (int)_encodingMajor + 255 : _encodingMajor)
- + "." + (_encodingMinor < 0 ? (int)_encodingMinor + 255 : _encodingMinor);
- }
+ if((int)_encodingMajor != 1 || (int)_encodingMinor != 0)
+ {
+ s += " -e " + (_encodingMajor < 0 ? (int)_encodingMajor + 255 : _encodingMajor)
+ + "." + (_encodingMinor < 0 ? (int)_encodingMinor + 255 : _encodingMinor);
+ }
- s += " -h " + _host + " -p " + _port;
+ s += " -h " + _host + " -p " + _port;
if(_connect)
{
s += " -c";
}
- if(_compress)
- {
- s += " -z";
- }
+ if(_compress)
+ {
+ s += " -z";
+ }
return s;
}
@@ -453,7 +453,7 @@ final class UdpEndpointI extends EndpointI
{
UdpTransceiver p = new UdpTransceiver(_instance, _host, _port, _connect);
endpoint.value = new UdpEndpointI(_instance, _host, p.effectivePort(), _connect, _connectionId, _compress,
- _publish);
+ _publish);
return p;
}
@@ -494,20 +494,20 @@ final class UdpEndpointI extends EndpointI
_host = _instance.defaultsAndOverrides().defaultHost;
if(_host == null)
{
- if(server)
- {
- _host = "0.0.0.0";
- }
- else
- {
- _host = "127.0.0.1";
- }
+ if(server)
+ {
+ _host = "0.0.0.0";
+ }
+ else
+ {
+ _host = "127.0.0.1";
+ }
}
}
- else if(_host.equals("*"))
- {
- _host = "0.0.0.0";
- }
+ else if(_host.equals("*"))
+ {
+ _host = "0.0.0.0";
+ }
java.util.ArrayList endps = new java.util.ArrayList();
if(_host.equals("0.0.0.0"))
@@ -518,12 +518,12 @@ final class UdpEndpointI extends EndpointI
{
String host = (String)iter.next();
endps.add(new UdpEndpointI(_instance, host, _port, _connect, _connectionId, _compress,
- hosts.size() == 1 || !host.equals("127.0.0.1")));
+ hosts.size() == 1 || !host.equals("127.0.0.1")));
}
}
else
{
- calcHashValue();
+ calcHashValue();
endps.add(this);
}
return endps;
@@ -616,10 +616,10 @@ final class UdpEndpointI extends EndpointI
return 1;
}
- if(!_connectionId.equals(p._connectionId))
- {
- return _connectionId.compareTo(p._connectionId);
- }
+ if(!_connectionId.equals(p._connectionId))
+ {
+ return _connectionId.compareTo(p._connectionId);
+ }
if(!_compress && p._compress)
{
@@ -630,41 +630,41 @@ 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(_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(!_host.equals(p._host))
{
@@ -672,48 +672,48 @@ final class UdpEndpointI extends EndpointI
// We do the most time-consuming part of the comparison last.
//
java.net.InetSocketAddress laddr = null;
- try
- {
- laddr = Network.getAddress(_host, _port);
- }
- catch(Ice.DNSException ex)
- {
- }
+ try
+ {
+ laddr = Network.getAddress(_host, _port);
+ }
+ catch(Ice.DNSException ex)
+ {
+ }
java.net.InetSocketAddress raddr = null;
- try
- {
- raddr = Network.getAddress(p._host, p._port);
- }
- catch(Ice.DNSException ex)
- {
- }
-
- if(laddr == null && raddr != null)
- {
- return -1;
- }
- else if(raddr == null && laddr != null)
- {
- return 1;
- }
- else if(laddr != null && raddr != null)
- {
- byte[] larr = laddr.getAddress().getAddress();
- byte[] rarr = raddr.getAddress().getAddress();
- assert(larr.length == rarr.length);
- for(int i = 0; i < larr.length; i++)
- {
- if(larr[i] < rarr[i])
- {
- return -1;
- }
- else if(rarr[i] < larr[i])
- {
- return 1;
- }
- }
- }
+ try
+ {
+ raddr = Network.getAddress(p._host, p._port);
+ }
+ catch(Ice.DNSException ex)
+ {
+ }
+
+ if(laddr == null && raddr != null)
+ {
+ return -1;
+ }
+ else if(raddr == null && laddr != null)
+ {
+ return 1;
+ }
+ else if(laddr != null && raddr != null)
+ {
+ byte[] larr = laddr.getAddress().getAddress();
+ byte[] rarr = raddr.getAddress().getAddress();
+ assert(larr.length == rarr.length);
+ for(int i = 0; i < larr.length; i++)
+ {
+ if(larr[i] < rarr[i])
+ {
+ return -1;
+ }
+ else if(rarr[i] < larr[i])
+ {
+ return 1;
+ }
+ }
+ }
}
return 0;
diff --git a/java/src/IceInternal/UdpTransceiver.java b/java/src/IceInternal/UdpTransceiver.java
index 5c68802d5ea..92ad59db9e3 100644
--- a/java/src/IceInternal/UdpTransceiver.java
+++ b/java/src/IceInternal/UdpTransceiver.java
@@ -21,66 +21,66 @@ final class UdpTransceiver implements Transceiver
public synchronized void
close()
{
- //
- // NOTE: closeSocket() may have already been invoked by shutdownReadWrite().
- //
- closeSocket();
-
- if(_readSelector != null)
- {
- try
- {
- _readSelector.close();
- }
- catch(java.io.IOException ex)
- {
- // Ignore.
- }
- _readSelector = null;
- }
+ //
+ // NOTE: closeSocket() may have already been invoked by shutdownReadWrite().
+ //
+ closeSocket();
+
+ if(_readSelector != null)
+ {
+ try
+ {
+ _readSelector.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ // Ignore.
+ }
+ _readSelector = null;
+ }
}
public void
shutdownWrite()
{
- //
- // NOTE: DatagramSocket does not support shutdownOutput.
- //
+ //
+ // NOTE: DatagramSocket does not support shutdownOutput.
+ //
}
public synchronized void
shutdownReadWrite()
{
- //
- // NOTE: DatagramSocket does not support shutdownInput, and we
- // cannot use the C++ technique of sending a "wakeup" packet to
- // this socket because the Java implementation deadlocks when we
- // call disconnect() while receive() is in progress. Therefore
- // we close the socket here and wake up the selector.
- //
- closeSocket();
-
- if(_readSelector != null)
- {
- _readSelector.wakeup();
- }
+ //
+ // NOTE: DatagramSocket does not support shutdownInput, and we
+ // cannot use the C++ technique of sending a "wakeup" packet to
+ // this socket because the Java implementation deadlocks when we
+ // call disconnect() while receive() is in progress. Therefore
+ // we close the socket here and wake up the selector.
+ //
+ closeSocket();
+
+ if(_readSelector != null)
+ {
+ _readSelector.wakeup();
+ }
}
public void
write(BasicStream stream, int timeout) // NOTE: timeout is not used
- throws LocalExceptionWrapper
+ throws LocalExceptionWrapper
{
java.nio.ByteBuffer buf = stream.prepareWrite();
assert(buf.position() == 0);
final int packetSize = java.lang.Math.min(_maxPacketSize, _sndSize - _udpOverhead);
if(packetSize < buf.limit())
- {
- //
- // We don't log a warning here because the client gets an exception anyway.
- //
- throw new Ice.DatagramLimitException();
- }
+ {
+ //
+ // We don't log a warning here because the client gets an exception anyway.
+ //
+ throw new Ice.DatagramLimitException();
+ }
while(buf.hasRemaining())
{
@@ -103,12 +103,12 @@ final class UdpTransceiver implements Transceiver
assert(ret == buf.limit());
break;
}
- catch(java.nio.channels.AsynchronousCloseException ex)
- {
+ catch(java.nio.channels.AsynchronousCloseException ex)
+ {
Ice.ConnectionLostException se = new Ice.ConnectionLostException();
se.initCause(ex);
throw se;
- }
+ }
catch(java.net.PortUnreachableException ex)
{
Ice.ConnectionLostException se = new Ice.ConnectionLostException();
@@ -131,128 +131,128 @@ final class UdpTransceiver implements Transceiver
public boolean
read(BasicStream stream, int timeout) // NOTE: timeout is not used
{
- assert(stream.pos() == 0);
-
- final int packetSize = java.lang.Math.min(_maxPacketSize, _rcvSize - _udpOverhead);
- if(packetSize < stream.size())
- {
- //
- // We log a warning here because this is the server side -- without the
- // the warning, there would only be silence.
- //
- if(_warn)
- {
- _logger.warning("DatagramLimitException: maximum size of " + packetSize + " exceeded");
- }
- throw new Ice.DatagramLimitException();
- }
+ assert(stream.pos() == 0);
+
+ final int packetSize = java.lang.Math.min(_maxPacketSize, _rcvSize - _udpOverhead);
+ if(packetSize < stream.size())
+ {
+ //
+ // We log a warning here because this is the server side -- without the
+ // the warning, there would only be silence.
+ //
+ if(_warn)
+ {
+ _logger.warning("DatagramLimitException: maximum size of " + packetSize + " exceeded");
+ }
+ throw new Ice.DatagramLimitException();
+ }
stream.resize(packetSize, true);
java.nio.ByteBuffer buf = stream.prepareRead();
buf.position(0);
- synchronized(this)
- {
- assert(_fd != null);
- if(_readSelector == null)
- {
- try
- {
- _readSelector = java.nio.channels.Selector.open();
- _fd.register(_readSelector, java.nio.channels.SelectionKey.OP_READ, null);
- }
- catch(java.io.IOException ex)
- {
- if(Network.connectionLost(ex))
- {
- Ice.ConnectionLostException se = new Ice.ConnectionLostException();
- se.initCause(ex);
- throw se;
- }
-
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
- }
- }
+ synchronized(this)
+ {
+ assert(_fd != null);
+ if(_readSelector == null)
+ {
+ try
+ {
+ _readSelector = java.nio.channels.Selector.open();
+ _fd.register(_readSelector, java.nio.channels.SelectionKey.OP_READ, null);
+ }
+ catch(java.io.IOException ex)
+ {
+ if(Network.connectionLost(ex))
+ {
+ Ice.ConnectionLostException se = new Ice.ConnectionLostException();
+ se.initCause(ex);
+ throw se;
+ }
+
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
+ }
+ }
int ret = 0;
while(true)
{
- //
- // Check for shutdown.
- //
- java.nio.channels.DatagramChannel fd = null;
- synchronized(this)
- {
- if(_fd == null)
- {
- throw new Ice.ConnectionLostException();
- }
- fd = _fd;
- }
-
- try
- {
- java.net.InetSocketAddress sender = (java.net.InetSocketAddress)fd.receive(buf);
- if(sender == null || buf.position() == 0)
- {
- //
- // Wait until packet arrives or socket is closed.
- //
- _readSelector.select();
- continue;
- }
-
- ret = buf.position();
-
- if(_connect)
- {
- //
- // If we must connect, then we connect to the first peer that
- // sends us a packet.
- //
- Network.doConnect(fd, sender, -1);
- _connect = false; // We're connected now
-
- if(_traceLevels.network >= 1)
- {
- String s = "connected udp socket\n" + toString();
- _logger.trace(_traceLevels.networkCat, s);
- }
- }
-
- break;
- }
- catch(java.nio.channels.AsynchronousCloseException ex)
- {
+ //
+ // Check for shutdown.
+ //
+ java.nio.channels.DatagramChannel fd = null;
+ synchronized(this)
+ {
+ if(_fd == null)
+ {
+ throw new Ice.ConnectionLostException();
+ }
+ fd = _fd;
+ }
+
+ try
+ {
+ java.net.InetSocketAddress sender = (java.net.InetSocketAddress)fd.receive(buf);
+ if(sender == null || buf.position() == 0)
+ {
+ //
+ // Wait until packet arrives or socket is closed.
+ //
+ _readSelector.select();
+ continue;
+ }
+
+ ret = buf.position();
+
+ if(_connect)
+ {
+ //
+ // If we must connect, then we connect to the first peer that
+ // sends us a packet.
+ //
+ Network.doConnect(fd, sender, -1);
+ _connect = false; // We're connected now
+
+ if(_traceLevels.network >= 1)
+ {
+ String s = "connected udp socket\n" + toString();
+ _logger.trace(_traceLevels.networkCat, s);
+ }
+ }
+
+ break;
+ }
+ catch(java.nio.channels.AsynchronousCloseException ex)
+ {
Ice.ConnectionLostException se = new Ice.ConnectionLostException();
se.initCause(ex);
throw se;
- }
+ }
catch(java.net.PortUnreachableException ex)
{
Ice.ConnectionLostException se = new Ice.ConnectionLostException();
se.initCause(ex);
throw se;
}
- catch(java.io.InterruptedIOException ex)
- {
- continue;
- }
- catch(java.io.IOException ex)
- {
- if(Network.connectionLost(ex))
- {
- Ice.ConnectionLostException se = new Ice.ConnectionLostException();
- se.initCause(ex);
- throw se;
- }
-
- Ice.SocketException se = new Ice.SocketException();
- se.initCause(ex);
- throw se;
- }
+ catch(java.io.InterruptedIOException ex)
+ {
+ continue;
+ }
+ catch(java.io.IOException ex)
+ {
+ if(Network.connectionLost(ex))
+ {
+ Ice.ConnectionLostException se = new Ice.ConnectionLostException();
+ se.initCause(ex);
+ throw se;
+ }
+
+ Ice.SocketException se = new Ice.SocketException();
+ se.initCause(ex);
+ throw se;
+ }
}
if(_traceLevels.network >= 3)
@@ -269,7 +269,7 @@ final class UdpTransceiver implements Transceiver
stream.resize(ret, true);
stream.pos(ret);
- return false;
+ return false;
}
public String
@@ -287,15 +287,15 @@ final class UdpTransceiver implements Transceiver
public void
checkSendSize(BasicStream stream, int messageSizeMax)
{
- if(stream.size() > messageSizeMax)
- {
- throw new Ice.MemoryLimitException();
- }
+ if(stream.size() > messageSizeMax)
+ {
+ throw new Ice.MemoryLimitException();
+ }
final int packetSize = java.lang.Math.min(_maxPacketSize, _sndSize - _udpOverhead);
- if(packetSize < stream.size())
- {
- throw new Ice.DatagramLimitException();
- }
+ if(packetSize < stream.size())
+ {
+ throw new Ice.DatagramLimitException();
+ }
}
public final boolean
@@ -321,13 +321,13 @@ final class UdpTransceiver implements Transceiver
_stats = instance.initializationData().stats;
_incoming = false;
_connect = true;
- _warn = instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
+ _warn = instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
try
{
_fd = Network.createUdpSocket();
- setBufSize(instance);
- Network.setBlock(_fd, false);
+ setBufSize(instance);
+ Network.setBlock(_fd, false);
_addr = Network.getAddress(host, port);
Network.doConnect(_fd, _addr, -1);
_connect = false; // We're connected now
@@ -355,19 +355,19 @@ final class UdpTransceiver implements Transceiver
_stats = instance.initializationData().stats;
_incoming = true;
_connect = connect;
- _warn = instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
+ _warn = instance.initializationData().properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
try
{
_fd = Network.createUdpSocket();
- setBufSize(instance);
- Network.setBlock(_fd, false);
+ setBufSize(instance);
+ Network.setBlock(_fd, false);
_addr = new java.net.InetSocketAddress(host, port);
- if(_traceLevels.network >= 2)
- {
- String s = "attempting to bind to udp socket " + Network.addrToString(_addr);
- _logger.trace(_traceLevels.networkCat, s);
- }
+ if(_traceLevels.network >= 2)
+ {
+ String s = "attempting to bind to udp socket " + Network.addrToString(_addr);
+ _logger.trace(_traceLevels.networkCat, s);
+ }
_addr = Network.doBind(_fd, _addr);
if(_traceLevels.network >= 1)
@@ -388,89 +388,89 @@ final class UdpTransceiver implements Transceiver
{
assert(_fd != null);
- for(int i = 0; i < 2; ++i)
- {
- String direction;
- String prop;
- int dfltSize;
- if(i == 0)
- {
- direction = "receive";
- prop = "Ice.UDP.RcvSize";
- dfltSize = Network.getRecvBufferSize(_fd);
- _rcvSize = dfltSize;
- }
- else
- {
- direction = "send";
- prop = "Ice.UDP.SndSize";
- dfltSize = Network.getSendBufferSize(_fd);
- _sndSize = dfltSize;
- }
-
- //
- // Get property for buffer size and check for sanity.
- //
- int sizeRequested = instance.initializationData().properties.getPropertyAsIntWithDefault(prop, dfltSize);
- if(sizeRequested < _udpOverhead)
- {
- _logger.warning("Invalid " + prop + " value of " + sizeRequested + " adjusted to " + dfltSize);
- sizeRequested = dfltSize;
- }
-
- if(sizeRequested != dfltSize)
- {
- //
- // Try to set the buffer size. The kernel will silently adjust
- // the size to an acceptable value. Then read the size back to
- // get the size that was actually set.
- //
- int sizeSet;
- if(i == 0)
- {
- Network.setRecvBufferSize(_fd, sizeRequested);
- _rcvSize = Network.getRecvBufferSize(_fd);
- sizeSet = _rcvSize;
- }
- else
- {
- Network.setSendBufferSize(_fd, sizeRequested);
- _sndSize = Network.getSendBufferSize(_fd);
- sizeSet = _sndSize;
- }
-
- //
- // Warn if the size that was set is less than the requested size.
- //
- if(sizeSet < sizeRequested)
- {
- _logger.warning("UDP " + direction + " buffer size: requested size of "
- + sizeRequested + " adjusted to " + sizeSet);
- }
- }
- }
+ for(int i = 0; i < 2; ++i)
+ {
+ String direction;
+ String prop;
+ int dfltSize;
+ if(i == 0)
+ {
+ direction = "receive";
+ prop = "Ice.UDP.RcvSize";
+ dfltSize = Network.getRecvBufferSize(_fd);
+ _rcvSize = dfltSize;
+ }
+ else
+ {
+ direction = "send";
+ prop = "Ice.UDP.SndSize";
+ dfltSize = Network.getSendBufferSize(_fd);
+ _sndSize = dfltSize;
+ }
+
+ //
+ // Get property for buffer size and check for sanity.
+ //
+ int sizeRequested = instance.initializationData().properties.getPropertyAsIntWithDefault(prop, dfltSize);
+ if(sizeRequested < _udpOverhead)
+ {
+ _logger.warning("Invalid " + prop + " value of " + sizeRequested + " adjusted to " + dfltSize);
+ sizeRequested = dfltSize;
+ }
+
+ if(sizeRequested != dfltSize)
+ {
+ //
+ // Try to set the buffer size. The kernel will silently adjust
+ // the size to an acceptable value. Then read the size back to
+ // get the size that was actually set.
+ //
+ int sizeSet;
+ if(i == 0)
+ {
+ Network.setRecvBufferSize(_fd, sizeRequested);
+ _rcvSize = Network.getRecvBufferSize(_fd);
+ sizeSet = _rcvSize;
+ }
+ else
+ {
+ Network.setSendBufferSize(_fd, sizeRequested);
+ _sndSize = Network.getSendBufferSize(_fd);
+ sizeSet = _sndSize;
+ }
+
+ //
+ // Warn if the size that was set is less than the requested size.
+ //
+ if(sizeSet < sizeRequested)
+ {
+ _logger.warning("UDP " + direction + " buffer size: requested size of "
+ + sizeRequested + " adjusted to " + sizeSet);
+ }
+ }
+ }
}
private void
closeSocket()
{
if(_fd != null)
- {
- if(_traceLevels.network >= 1)
- {
- String s = "closing udp connection\n" + toString();
- _logger.trace(_traceLevels.networkCat, s);
- }
-
- try
- {
- _fd.close();
- }
- catch(java.io.IOException ex)
- {
- }
- _fd = null;
- }
+ {
+ if(_traceLevels.network >= 1)
+ {
+ String s = "closing udp connection\n" + toString();
+ _logger.trace(_traceLevels.networkCat, s);
+ }
+
+ try
+ {
+ _fd.close();
+ }
+ catch(java.io.IOException ex)
+ {
+ }
+ _fd = null;
+ }
}
protected synchronized void
diff --git a/java/src/IceInternal/UnknownEndpointI.java b/java/src/IceInternal/UnknownEndpointI.java
index 699a6e4011f..0b9b4271715 100644
--- a/java/src/IceInternal/UnknownEndpointI.java
+++ b/java/src/IceInternal/UnknownEndpointI.java
@@ -101,7 +101,7 @@ final class UnknownEndpointI extends EndpointI
public EndpointI
compress(boolean compress)
{
- return this;
+ return this;
}
//
@@ -188,7 +188,7 @@ final class UnknownEndpointI extends EndpointI
expand(boolean server)
{
assert(false);
- return null;
+ return null;
}
//
diff --git a/java/src/IceInternal/ValueWriter.java b/java/src/IceInternal/ValueWriter.java
index 0c8c9004624..25fbd47a74d 100644
--- a/java/src/IceInternal/ValueWriter.java
+++ b/java/src/IceInternal/ValueWriter.java
@@ -36,26 +36,26 @@ public final class ValueWriter
}
else if(c.equals(String.class))
{
- //
- // Indent the lines of a string value.
- //
+ //
+ // Indent the lines of a string value.
+ //
writeName(name, out);
out.print("\"");
- out.useCurrentPosAsIndent();
+ out.useCurrentPosAsIndent();
String str = value.toString();
- int start = 0, pos;
- while(start < str.length() && (pos = str.indexOf('\n', start)) != -1)
- {
- out.print(str.substring(start, pos));
- out.nl();
- start = pos + 1;
- }
- if(start < str.length())
- {
- out.print(str.substring(start));
- }
+ int start = 0, pos;
+ while(start < str.length() && (pos = str.indexOf('\n', start)) != -1)
+ {
+ out.print(str.substring(start, pos));
+ out.nl();
+ start = pos + 1;
+ }
+ if(start < str.length())
+ {
+ out.print(str.substring(start));
+ }
out.print("\"");
- out.restoreIndent();
+ out.restoreIndent();
}
else if(c.isArray())
{