summaryrefslogtreecommitdiff
path: root/java/src/IceInternal/IncomingConnectionFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/IceInternal/IncomingConnectionFactory.java')
-rw-r--r--java/src/IceInternal/IncomingConnectionFactory.java150
1 files changed, 86 insertions, 64 deletions
diff --git a/java/src/IceInternal/IncomingConnectionFactory.java b/java/src/IceInternal/IncomingConnectionFactory.java
index e0d19f65356..eb261376ebf 100644
--- a/java/src/IceInternal/IncomingConnectionFactory.java
+++ b/java/src/IceInternal/IncomingConnectionFactory.java
@@ -12,69 +12,6 @@ package IceInternal;
public class IncomingConnectionFactory extends EventHandler
{
- public
- IncomingConnectionFactory(Instance instance, Endpoint endpoint,
- Ice.ObjectAdapter adapter)
- {
- super(instance);
- _endpoint = endpoint;
- _adapter = adapter;
- _state = StateHolding;
-
- try
- {
- String val =
- _instance.properties().getProperty("Ice.ConnectionWarnings");
- _warn = Integer.parseInt(val) > 0 ? true : false;
- }
- catch (NumberFormatException ex)
- {
- _warn = false;
- }
-
- try
- {
- EndpointHolder h = new EndpointHolder();
- h.value = _endpoint;
- _transceiver = _endpoint.serverTransceiver(h);
- if (_transceiver != null)
- {
- _endpoint = h.value;
- Connection connection = new Connection(_instance, _transceiver,
- _endpoint, _adapter);
- _connections.add(connection);
- }
- else
- {
- h.value = _endpoint;
- _acceptor = _endpoint.acceptor(h);
- _endpoint = h.value;
- assert(_acceptor != null);
- _acceptor.listen();
- _threadPool = _instance.threadPool();
- }
- }
- catch (RuntimeException ex)
- {
- setState(StateClosed);
- throw ex;
- }
- }
-
- protected void
- finalize()
- throws Throwable
- {
- assert(_state == StateClosed);
- super.finalize();
- }
-
- public synchronized void
- destroy()
- {
- setState(StateClosed);
- }
-
public synchronized void
hold()
{
@@ -90,6 +27,7 @@ public class IncomingConnectionFactory extends EventHandler
public Endpoint
endpoint()
{
+ // No mutex protection necessary, _endpoint is immutable.
return _endpoint;
}
@@ -105,6 +43,27 @@ public class IncomingConnectionFactory extends EventHandler
return endp.equivalent(_acceptor);
}
+ public synchronized Connection[]
+ connections()
+ {
+ //
+ // Reap destroyed connections
+ //
+ java.util.ListIterator iter = _connections.listIterator();
+ while (iter.hasNext())
+ {
+ Connection connection = (Connection)iter.next();
+ if (connection.destroyed())
+ {
+ iter.remove();
+ }
+ }
+
+ Connection[] arr = new Connection[_connections.size()];
+ _connections.toArray(arr);
+ return arr;
+ }
+
//
// Operations from EventHandler
//
@@ -137,7 +96,7 @@ public class IncomingConnectionFactory extends EventHandler
}
//
- // First reap destroyed connections
+ // Reap destroyed connections
//
java.util.ListIterator iter = _connections.listIterator();
while (iter.hasNext())
@@ -212,6 +171,69 @@ public class IncomingConnectionFactory extends EventHandler
}
*/
+ public
+ IncomingConnectionFactory(Instance instance, Endpoint endpoint,
+ Ice.ObjectAdapter adapter)
+ {
+ super(instance);
+ _endpoint = endpoint;
+ _adapter = adapter;
+ _state = StateHolding;
+
+ try
+ {
+ String val =
+ _instance.properties().getProperty("Ice.ConnectionWarnings");
+ _warn = Integer.parseInt(val) > 0 ? true : false;
+ }
+ catch (NumberFormatException ex)
+ {
+ _warn = false;
+ }
+
+ try
+ {
+ EndpointHolder h = new EndpointHolder();
+ h.value = _endpoint;
+ _transceiver = _endpoint.serverTransceiver(h);
+ if (_transceiver != null)
+ {
+ _endpoint = h.value;
+ Connection connection = new Connection(_instance, _transceiver,
+ _endpoint, _adapter);
+ _connections.add(connection);
+ }
+ else
+ {
+ h.value = _endpoint;
+ _acceptor = _endpoint.acceptor(h);
+ _endpoint = h.value;
+ assert(_acceptor != null);
+ _acceptor.listen();
+ _threadPool = _instance.threadPool();
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ setState(StateClosed);
+ throw ex;
+ }
+ }
+
+ protected void
+ finalize()
+ throws Throwable
+ {
+ assert(_state == StateClosed);
+ super.finalize();
+ }
+
+ public synchronized void
+ destroy()
+ {
+ setState(StateClosed);
+ }
+
private static final int StateActive = 0;
private static final int StateHolding = 1;
private static final int StateClosed = 2;