Code cleanup.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
5f118a0941
commit
8197c12325
|
@ -181,12 +181,17 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
{
|
||||
_server = server;
|
||||
_executor = executor != null ? executor : _server.getThreadPool();
|
||||
addBean(_executor);
|
||||
if (executor == null)
|
||||
unmanage(_executor); // inherited from server
|
||||
if (scheduler == null)
|
||||
scheduler = _server.getBean(Scheduler.class);
|
||||
_scheduler = scheduler != null ? scheduler : new ScheduledExecutorScheduler(String.format("Connector-Scheduler-%x", hashCode()), false);
|
||||
addBean(_scheduler);
|
||||
if (pool == null)
|
||||
pool = _server.getBean(ByteBufferPool.class);
|
||||
_byteBufferPool = pool != null ? pool : new ArrayByteBufferPool();
|
||||
addBean(_byteBufferPool);
|
||||
|
||||
addEventListener(new Container.Listener()
|
||||
{
|
||||
|
@ -205,13 +210,6 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
}
|
||||
});
|
||||
|
||||
addBean(_server, false);
|
||||
addBean(_executor);
|
||||
if (executor == null)
|
||||
unmanage(_executor); // inherited from server
|
||||
addBean(_scheduler);
|
||||
addBean(_byteBufferPool);
|
||||
|
||||
for (ConnectionFactory factory : factories)
|
||||
{
|
||||
addConnectionFactory(factory);
|
||||
|
@ -380,7 +378,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
|
||||
// Reduce the idle timeout of existing connections
|
||||
for (EndPoint ep : _endpoints)
|
||||
ep.setIdleTimeout(_shutdownIdleTimeout);
|
||||
ep.setIdleTimeout(getShutdownIdleTimeout());
|
||||
|
||||
// Return Future that waits for no acceptors and no connections.
|
||||
return done;
|
||||
|
@ -519,35 +517,23 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
throw new IllegalStateException(getState());
|
||||
|
||||
List<ConnectionFactory> existings = new ArrayList<>(_factories.values());
|
||||
_factories.clear();
|
||||
clearConnectionFactories();
|
||||
addConnectionFactory(factory);
|
||||
for (ConnectionFactory existing : existings)
|
||||
{
|
||||
addConnectionFactory(existing);
|
||||
}
|
||||
_defaultProtocol = factory.getProtocol();
|
||||
}
|
||||
|
||||
// Used from XML, do not remove.
|
||||
public void addIfAbsentConnectionFactory(ConnectionFactory factory)
|
||||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
String key = StringUtil.asciiToLowerCase(factory.getProtocol());
|
||||
if (_factories.containsKey(key))
|
||||
{
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} addIfAbsent ignored {}", this, factory);
|
||||
}
|
||||
else
|
||||
{
|
||||
_factories.put(key, factory);
|
||||
addBean(factory);
|
||||
if (_defaultProtocol == null)
|
||||
_defaultProtocol = factory.getProtocol();
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} addIfAbsent added {}", this, factory);
|
||||
}
|
||||
if (!_factories.containsKey(key))
|
||||
addConnectionFactory(factory);
|
||||
}
|
||||
|
||||
public ConnectionFactory removeConnectionFactory(String protocol)
|
||||
|
@ -556,6 +542,8 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
throw new IllegalStateException(getState());
|
||||
|
||||
ConnectionFactory factory = _factories.remove(StringUtil.asciiToLowerCase(protocol));
|
||||
if (_factories.isEmpty())
|
||||
_defaultProtocol = null;
|
||||
removeBean(factory);
|
||||
return factory;
|
||||
}
|
||||
|
@ -583,6 +571,15 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
}
|
||||
}
|
||||
|
||||
public void clearConnectionFactories()
|
||||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
_factories.clear();
|
||||
_defaultProtocol = null;
|
||||
}
|
||||
|
||||
@ManagedAttribute("The priority delta to apply to acceptor threads")
|
||||
public int getAcceptorPriorityDelta()
|
||||
{
|
||||
|
@ -618,14 +615,6 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
return new ArrayList<>(_factories.keySet());
|
||||
}
|
||||
|
||||
public void clearConnectionFactories()
|
||||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
_factories.clear();
|
||||
}
|
||||
|
||||
@ManagedAttribute("This connector's default protocol")
|
||||
public String getDefaultProtocol()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue