Package org.eclipse.jetty.server
Class AbstractNetworkConnector
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.server.AbstractConnector
-
- org.eclipse.jetty.server.AbstractNetworkConnector
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Connector
,NetworkConnector
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,Graceful
,LifeCycle
- Direct Known Subclasses:
ServerConnector
@ManagedObject("AbstractNetworkConnector") public abstract class AbstractNetworkConnector extends AbstractConnector implements NetworkConnector
An abstract Network Connector.Extends the
AbstractConnector
support for theNetworkConnector
interface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Graceful
Graceful.Shutdown
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
-
Constructor Summary
Constructors Constructor Description AbstractNetworkConnector(Server server, java.util.concurrent.Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Performs the activities needed to close the network communication (for example, to stop accepting network connections).protected void
doStart()
Starts the managed lifecycle beans in the order they were added.protected void
doStop()
Stops the managed lifecycle beans in the reverse order they were added.java.lang.String
getHost()
int
getLocalPort()
int
getPort()
protected boolean
handleAcceptFailure(java.lang.Throwable ex)
void
open()
Performs the activities needed to open the network communication (for example, to start accepting incoming network connections).void
setHost(java.lang.String host)
void
setPort(int port)
java.util.concurrent.Future<java.lang.Void>
shutdown()
java.lang.String
toString()
-
Methods inherited from class org.eclipse.jetty.server.AbstractConnector
accept, addConnectionFactory, addFirstConnectionFactory, addIfAbsentConnectionFactory, clearConnectionFactories, getAcceptorPriorityDelta, getAcceptors, getByteBufferPool, getConnectedEndPoints, getConnectionFactories, getConnectionFactory, getConnectionFactory, getDefaultConnectionFactory, getDefaultProtocol, getExecutor, getHttpChannelListeners, getIdleTimeout, getName, getProtocols, getScheduler, getServer, interruptAcceptors, isAccepting, isShutdown, join, join, onEndPointClosed, onEndPointOpened, removeConnectionFactory, setAccepting, setAcceptorPriorityDelta, setConnectionFactories, setDefaultProtocol, setIdleTimeout, setName
-
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.server.Connector
getByteBufferPool, getConnectedEndPoints, getConnectionFactories, getConnectionFactory, getConnectionFactory, getDefaultConnectionFactory, getExecutor, getIdleTimeout, getName, getProtocols, getScheduler, getServer, getTransport
-
Methods inherited from interface org.eclipse.jetty.util.component.Container
addBean, addBean, addEventListener, getBean, getBeans, getBeans, getContainedBeans, isManaged, manage, removeBean, removeEventListener, unmanage
-
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Methods inherited from interface org.eclipse.jetty.util.component.Graceful
isShutdown
-
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
-
Methods inherited from interface org.eclipse.jetty.server.NetworkConnector
isOpen
-
-
-
-
Constructor Detail
-
AbstractNetworkConnector
public AbstractNetworkConnector(Server server, java.util.concurrent.Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories)
-
-
Method Detail
-
setHost
public void setHost(java.lang.String host)
-
getHost
@ManagedAttribute("The network interface this connector binds to as an IP address or a hostname. If null or 0.0.0.0, then bind to all interfaces.") public java.lang.String getHost()
- Specified by:
getHost
in interfaceNetworkConnector
- Returns:
- The hostname representing the interface to which this connector will bind, or null for all interfaces.
-
setPort
public void setPort(int port)
-
getPort
@ManagedAttribute("Port this connector listens on. If set the 0 a random port is assigned which may be obtained with getLocalPort()") public int getPort()
- Specified by:
getPort
in interfaceNetworkConnector
- Returns:
- The configured port for the connector or 0 if any available port may be used.
-
getLocalPort
public int getLocalPort()
- Specified by:
getLocalPort
in interfaceNetworkConnector
- Returns:
- The actual port the connector is listening on, or -1 if it has not been opened, or -2 if it has been closed.
-
doStart
protected void doStart() throws java.lang.Exception
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classAbstractConnector
- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.Exception
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classAbstractConnector
- Throws:
java.lang.Exception
-
open
public void open() throws java.io.IOException
Description copied from interface:NetworkConnector
Performs the activities needed to open the network communication (for example, to start accepting incoming network connections).
- Specified by:
open
in interfaceNetworkConnector
- Throws:
java.io.IOException
- if this connector cannot be opened- See Also:
NetworkConnector.close()
-
close
public void close()
Description copied from interface:NetworkConnector
Performs the activities needed to close the network communication (for example, to stop accepting network connections).
Once a connector has been closed, it cannot be opened again without first callingLifeCycle.stop()
and it will not be active again until a subsequent call toLifeCycle.start()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceNetworkConnector
-
shutdown
public java.util.concurrent.Future<java.lang.Void> shutdown()
- Specified by:
shutdown
in interfaceGraceful
- Overrides:
shutdown
in classAbstractConnector
-
handleAcceptFailure
protected boolean handleAcceptFailure(java.lang.Throwable ex)
- Overrides:
handleAcceptFailure
in classAbstractConnector
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractConnector
-
-