org.jboss.xnio
Class Xnio
java.lang.Object
org.jboss.xnio.Xnio
- All Implemented Interfaces:
- Closeable
- Direct Known Subclasses:
- NioXnio
public abstract class Xnio
- extends Object
- implements Closeable
The XNIO entry point class.
Method Summary |
void |
awaken(Thread targetThread)
Wake up any blocking I/O operation being carried out on a given thread. |
abstract void |
close()
Close this XNIO provider. |
static Xnio |
create()
Create an instance of the default XNIO provider. |
ConfigurableFactory<CloseableConnector<String,DatagramChannel<String>>> |
createLocalDatagramConnector()
Create a configurable local datagram connector. |
ConfigurableFactory<CloseableConnector<String,DatagramChannel<String>>> |
createLocalDatagramConnector(Executor executor)
Create a configurable local datagram connector. |
ConfigurableFactory<BoundServer<String,BoundChannel<String>>> |
createLocalDatagramServer(Executor executor,
IoHandlerFactory<? super DatagramChannel<String>> handlerFactory)
Create a local datagram server. |
ConfigurableFactory<BoundServer<String,BoundChannel<String>>> |
createLocalDatagramServer(IoHandlerFactory<? super DatagramChannel<String>> handlerFactory)
Create a local datagram server. |
ConfigurableFactory<CloseableConnector<String,ConnectedStreamChannel<String>>> |
createLocalStreamConnector()
Create a configurable local stream connector. |
ConfigurableFactory<CloseableConnector<String,ConnectedStreamChannel<String>>> |
createLocalStreamConnector(Executor executor)
Create a configurable local stream connector. |
ConfigurableFactory<BoundServer<String,BoundChannel<String>>> |
createLocalStreamServer(Executor executor,
IoHandlerFactory<? super ConnectedStreamChannel<String>> handlerFactory)
Create a local stream server. |
ConfigurableFactory<BoundServer<String,BoundChannel<String>>> |
createLocalStreamServer(IoHandlerFactory<? super StreamChannel> handlerFactory)
Create a local stream server. |
IoFuture<Closeable> |
createOneWayPipeConnection(Executor executor,
IoHandler<? super StreamSourceChannel> sourceHandler,
IoHandler<? super StreamSinkChannel> sinkHandler)
Create a single one-way pipe connection. |
IoFuture<Closeable> |
createOneWayPipeConnection(IoHandler<? super StreamSourceChannel> sourceHandler,
IoHandler<? super StreamSinkChannel> sinkHandler)
Create a single one-way pipe connection. |
IoFuture<Closeable> |
createPipeConnection(Executor executor,
IoHandler<? super StreamChannel> leftHandler,
IoHandler<? super StreamChannel> rightHandler)
Create a single pipe connection. |
IoFuture<Closeable> |
createPipeConnection(IoHandler<? super StreamChannel> leftHandler,
IoHandler<? super StreamChannel> rightHandler)
Create a single pipe connection. |
ChannelSource<StreamChannel> |
createPipeServer(Executor executor,
IoHandlerFactory<? super StreamChannel> handlerFactory)
Create a pipe "server". |
ChannelSource<StreamChannel> |
createPipeServer(IoHandlerFactory<? super StreamChannel> handlerFactory)
Create a pipe "server". |
ChannelSource<StreamSinkChannel> |
createPipeSinkServer(Executor executor,
IoHandlerFactory<? super StreamSourceChannel> handlerFactory)
Create a one-way pipe "server". |
ChannelSource<StreamSinkChannel> |
createPipeSinkServer(IoHandlerFactory<? super StreamSourceChannel> handlerFactory)
Create a one-way pipe "server". |
ChannelSource<StreamSourceChannel> |
createPipeSourceServer(Executor executor,
IoHandlerFactory<? super StreamSinkChannel> handlerFactory)
Create a one-way pipe "server". |
ChannelSource<StreamSourceChannel> |
createPipeSourceServer(IoHandlerFactory<? super StreamSinkChannel> handlerFactory)
Create a one-way pipe "server". |
ConfigurableFactory<CloseableTcpAcceptor> |
createTcpAcceptor()
Create a TCP acceptor. |
ConfigurableFactory<CloseableTcpAcceptor> |
createTcpAcceptor(Executor executor)
Create a TCP acceptor. |
ConfigurableFactory<CloseableTcpConnector> |
createTcpConnector()
Create a configurable TCP connector. |
ConfigurableFactory<CloseableTcpConnector> |
createTcpConnector(Executor executor)
Create a configurable TCP connector. |
ConfigurableFactory<BoundServer<SocketAddress,BoundChannel<SocketAddress>>> |
createTcpServer(Executor executor,
IoHandlerFactory<? super TcpChannel> handlerFactory,
SocketAddress... bindAddresses)
Create a TCP server. |
ConfigurableFactory<BoundServer<SocketAddress,BoundChannel<SocketAddress>>> |
createTcpServer(IoHandlerFactory<? super TcpChannel> handlerFactory,
SocketAddress... bindAddresses)
Create a TCP server. |
ConfigurableFactory<BoundServer<SocketAddress,UdpChannel>> |
createUdpServer(boolean multicast,
IoHandlerFactory<? super UdpChannel> handlerFactory,
SocketAddress... bindAddresses)
Create a UDP server. |
ConfigurableFactory<BoundServer<SocketAddress,UdpChannel>> |
createUdpServer(Executor executor,
boolean multicast,
IoHandlerFactory<? super UdpChannel> handlerFactory,
SocketAddress... bindAddresses)
Create a UDP server. |
String |
getName()
Get the name of this XNIO instance. |
protected String |
getProperty(String name)
Get an XNIO property. |
protected String |
getProperty(String name,
String defaultValue)
Get an XNIO property. |
protected Closeable |
registerMBean(OneWayPipeConnectionMBean mBean)
Register a one-way pipe connection MBean. |
protected Closeable |
registerMBean(PipeConnectionMBean mBean)
Register a pipe connection MBean. |
protected Closeable |
registerMBean(PipeServerMBean mBean)
Register a pipe server MBean. |
protected Closeable |
registerMBean(PipeSinkServerMBean mBean)
Register a pipe sink server MBean. |
protected Closeable |
registerMBean(PipeSourceServerMBean mBean)
Register a pipe source server MBean. |
protected Closeable |
registerMBean(TcpConnectionMBean mBean)
Register a TCP connection MBean. |
protected Closeable |
registerMBean(TcpServerMBean mBean)
Register a TCP server MBean. |
protected Closeable |
registerMBean(UdpServerMBean mBean)
Register a UDP server MBean. |
String |
toString()
Get a string representation of this XNIO instance. |
Xnio
protected Xnio(XnioConfiguration configuration)
- Construct an XNIO provider instance.
create
public static Xnio create()
throws IOException
- Create an instance of the default XNIO provider. The class name of this provider can be specified through the
xnio.provider
system property. Any failure to create the XNIO provider will cause an java.io.IOException
to be thrown.
- Returns:
- an XNIO instance
- Throws:
IOException
- the the XNIO provider could not be created
createTcpServer
public ConfigurableFactory<BoundServer<SocketAddress,BoundChannel<SocketAddress>>> createTcpServer(Executor executor,
IoHandlerFactory<? super TcpChannel> handlerFactory,
SocketAddress... bindAddresses)
- Create a TCP server. The server will bind to the given addresses. The
provider's executor will be used to execute handler methods.
- Parameters:
executor
- the executor to use to execute the handlershandlerFactory
- the factory which will produce handlers for inbound connectionsbindAddresses
- the addresses to bind to
- Returns:
- a factory that can be used to configure the new TCP server
createTcpServer
public ConfigurableFactory<BoundServer<SocketAddress,BoundChannel<SocketAddress>>> createTcpServer(IoHandlerFactory<? super TcpChannel> handlerFactory,
SocketAddress... bindAddresses)
- Create a TCP server. The server will bind to the given addresses. The
provider's default executor will be used to execute handler methods.
- Parameters:
handlerFactory
- the factory which will produce handlers for inbound connectionsbindAddresses
- the addresses to bind to
- Returns:
- a factory that can be used to configure the new TCP server
createTcpConnector
public ConfigurableFactory<CloseableTcpConnector> createTcpConnector(Executor executor)
- Create a configurable TCP connector. The connector can be configured before it is actually created.
- Parameters:
executor
- the executor to use to execute the handlers
- Returns:
- a factory that can be used to configure the new TCP connector
createTcpConnector
public ConfigurableFactory<CloseableTcpConnector> createTcpConnector()
- Create a configurable TCP connector. The connector can be configured before it is actually created. The
provider's default executor will be used to execute handler methods.
- Returns:
- a factory that can be used to configure the new TCP connector
createUdpServer
public ConfigurableFactory<BoundServer<SocketAddress,UdpChannel>> createUdpServer(Executor executor,
boolean multicast,
IoHandlerFactory<? super UdpChannel> handlerFactory,
SocketAddress... bindAddresses)
- Create a UDP server. The server will bind to the given addresses. The UDP server can be configured to be
multicast-capable; this should only be done if multicast is needed, since some providers have a performance
penalty associated with multicast.
- Parameters:
executor
- the executor to use to execute the handlersmulticast
- true
if the UDP server should be multicast-capablehandlerFactory
- the factory which will produce handlers for each channelbindAddresses
- the addresses to bind
- Returns:
- a factory that can be used to configure the new UDP server
createUdpServer
public ConfigurableFactory<BoundServer<SocketAddress,UdpChannel>> createUdpServer(boolean multicast,
IoHandlerFactory<? super UdpChannel> handlerFactory,
SocketAddress... bindAddresses)
- Create a UDP server. The server will bind to the given addresses. The provider's default executor will be used to
execute handler methods.
- Parameters:
multicast
- true
if the UDP server should be multicast-capablehandlerFactory
- the factory which will produce handlers for each channelbindAddresses
- the addresses to bind
- Returns:
- a factory that can be used to configure the new UDP server
createPipeServer
public ChannelSource<StreamChannel> createPipeServer(Executor executor,
IoHandlerFactory<? super StreamChannel> handlerFactory)
- Create a pipe "server". The provided handler factory is used to supply handlers for the server "end" of the
pipe. The returned channel source is used to establish connections to the server.
- Parameters:
executor
- the executor to use to execute the handlershandlerFactory
- the server handler factory
- Returns:
- the client channel source
- Since:
- 1.2
createPipeServer
public ChannelSource<StreamChannel> createPipeServer(IoHandlerFactory<? super StreamChannel> handlerFactory)
- Create a pipe "server". The provided handler factory is used to supply handlers for the server "end" of the
pipe. The returned channel source is used to establish connections to the server. The provider's default executor will be used to
execute handler methods.
- Parameters:
handlerFactory
- the server handler factory
- Returns:
- the client channel source
- Since:
- 1.1
createPipeSourceServer
public ChannelSource<StreamSourceChannel> createPipeSourceServer(Executor executor,
IoHandlerFactory<? super StreamSinkChannel> handlerFactory)
- Create a one-way pipe "server". The provided handler factory is used to supply handlers for the server "end" of
the pipe. The returned channel source is used to establish connections to the server. The data flows from the
server to the client.
- Parameters:
executor
- the executor to use to execute the handlershandlerFactory
- the server handler factory
- Returns:
- the client channel source
- Since:
- 1.2
createPipeSourceServer
public ChannelSource<StreamSourceChannel> createPipeSourceServer(IoHandlerFactory<? super StreamSinkChannel> handlerFactory)
- Create a one-way pipe "server". The provided handler factory is used to supply handlers for the server "end" of
the pipe. The returned channel source is used to establish connections to the server. The data flows from the
server to the client. The provider's default executor will be used to
execute handler methods.
- Parameters:
handlerFactory
- the server handler factory
- Returns:
- the client channel source
- Since:
- 1.1
createPipeSinkServer
public ChannelSource<StreamSinkChannel> createPipeSinkServer(Executor executor,
IoHandlerFactory<? super StreamSourceChannel> handlerFactory)
- Create a one-way pipe "server". The provided handler factory is used to supply handlers for the server "end" of
the pipe. The returned channel source is used to establish connections to the server. The data flows from the
client to the server.
- Parameters:
executor
- the executor to use to execute the handlershandlerFactory
- the server handler factory
- Returns:
- the client channel source
- Since:
- 1.2
createPipeSinkServer
public ChannelSource<StreamSinkChannel> createPipeSinkServer(IoHandlerFactory<? super StreamSourceChannel> handlerFactory)
- Create a one-way pipe "server". The provided handler factory is used to supply handlers for the server "end" of
the pipe. The returned channel source is used to establish connections to the server. The data flows from the
client to the server. The provider's default executor will be used to
execute handler methods.
- Parameters:
handlerFactory
- the server handler factory
- Returns:
- the client channel source
- Since:
- 1.1
createPipeConnection
public IoFuture<Closeable> createPipeConnection(Executor executor,
IoHandler<? super StreamChannel> leftHandler,
IoHandler<? super StreamChannel> rightHandler)
- Create a single pipe connection.
- Parameters:
executor
- the executor to use to execute the handlersleftHandler
- the handler for the "left" side of the piperightHandler
- the handler for the "right" side of the pipe
- Returns:
- the future connection
- Since:
- 1.2
createPipeConnection
public IoFuture<Closeable> createPipeConnection(IoHandler<? super StreamChannel> leftHandler,
IoHandler<? super StreamChannel> rightHandler)
- Create a single pipe connection. The provider's default executor will be used to
execute handler methods.
- Parameters:
leftHandler
- the handler for the "left" side of the piperightHandler
- the handler for the "right" side of the pipe
- Returns:
- the future connection
- Since:
- 1.1
createOneWayPipeConnection
public IoFuture<Closeable> createOneWayPipeConnection(Executor executor,
IoHandler<? super StreamSourceChannel> sourceHandler,
IoHandler<? super StreamSinkChannel> sinkHandler)
- Create a single one-way pipe connection.
- Parameters:
executor
- the executor to use to execute the handlerssourceHandler
- the handler for the "source" side of the pipesinkHandler
- the handler for the "sink" side of the pipe
- Returns:
- the future connection
- Since:
- 1.2
createOneWayPipeConnection
public IoFuture<Closeable> createOneWayPipeConnection(IoHandler<? super StreamSourceChannel> sourceHandler,
IoHandler<? super StreamSinkChannel> sinkHandler)
- Create a single one-way pipe connection. The provider's default executor will be used to
execute handler methods.
- Parameters:
sourceHandler
- the handler for the "source" side of the pipesinkHandler
- the handler for the "sink" side of the pipe
- Returns:
- the future connection
- Since:
- 1.1
createTcpAcceptor
public ConfigurableFactory<CloseableTcpAcceptor> createTcpAcceptor(Executor executor)
- Create a TCP acceptor.
- Parameters:
executor
- the executor to use to execute the handlers
- Returns:
- a factory that can be used to configure a TCP acceptor
- Since:
- 1.2
createTcpAcceptor
public ConfigurableFactory<CloseableTcpAcceptor> createTcpAcceptor()
- Create a TCP acceptor. The provider's default executor will be used to
execute handler methods.
- Returns:
- a factory that can be used to configure a TCP acceptor
- Since:
- 1.2
createLocalStreamServer
public ConfigurableFactory<BoundServer<String,BoundChannel<String>>> createLocalStreamServer(Executor executor,
IoHandlerFactory<? super ConnectedStreamChannel<String>> handlerFactory)
- Create a local stream server. The stream server is bound to one or more files in the filesystem. If no bind
addresses are specified, one is created.
- Parameters:
executor
- the executor to use to execute the handlershandlerFactory
- the factory which will produce handlers for inbound connections
- Returns:
- a factory that can be used to configure the new stream server
- Since:
- 1.2
createLocalStreamServer
public ConfigurableFactory<BoundServer<String,BoundChannel<String>>> createLocalStreamServer(IoHandlerFactory<? super StreamChannel> handlerFactory)
- Create a local stream server. The stream server is bound to one or more files in the filesystem. If no bind
addresses are specified, one is created. The provider's default executor will be used to
execute handler methods.
- Parameters:
handlerFactory
- the factory which will produce handlers for inbound connections
- Returns:
- a factory that can be used to configure the new stream server
- Since:
- 1.2
createLocalStreamConnector
public ConfigurableFactory<CloseableConnector<String,ConnectedStreamChannel<String>>> createLocalStreamConnector(Executor executor)
- Create a configurable local stream connector. The connector can be configured before it is actually created.
- Parameters:
executor
- the executor to use to execute the handlers
- Returns:
- a factory that can be used to configure the new local stream connector
- Since:
- 1.2
createLocalStreamConnector
public ConfigurableFactory<CloseableConnector<String,ConnectedStreamChannel<String>>> createLocalStreamConnector()
- Create a configurable local stream connector. The connector can be configured before it is actually created.
The provider's default executor will be used to execute handler methods.
- Returns:
- a factory that can be used to configure the new local stream connector
- Since:
- 1.2
createLocalDatagramServer
public ConfigurableFactory<BoundServer<String,BoundChannel<String>>> createLocalDatagramServer(Executor executor,
IoHandlerFactory<? super DatagramChannel<String>> handlerFactory)
- Create a local datagram server. The datagram server is bound to one or more files in the filesystem. If no
bind addresses are specified, one is created.
- Parameters:
executor
- the executor to use to execute the handlershandlerFactory
- the factory which will produce handlers for inbound connections
- Returns:
- a factory that can be used to configure the new datagram server
- Since:
- 1.2
createLocalDatagramServer
public ConfigurableFactory<BoundServer<String,BoundChannel<String>>> createLocalDatagramServer(IoHandlerFactory<? super DatagramChannel<String>> handlerFactory)
- Create a local datagram server. The datagram server is bound to one or more files in the filesystem. If no
bind addresses are specified, one is created. The provider's default executor will be used to
execute handler methods.
- Parameters:
handlerFactory
- the factory which will produce handlers for inbound connections
- Returns:
- a factory that can be used to configure the new datagram server
- Since:
- 1.2
createLocalDatagramConnector
public ConfigurableFactory<CloseableConnector<String,DatagramChannel<String>>> createLocalDatagramConnector(Executor executor)
- Create a configurable local datagram connector. The connector can be configured before it is actually created.
- Parameters:
executor
- the executor to use to execute the handlers
- Returns:
- a factory that can be used to configure the new local datagram connector
- Since:
- 1.2
createLocalDatagramConnector
public ConfigurableFactory<CloseableConnector<String,DatagramChannel<String>>> createLocalDatagramConnector()
- Create a configurable local datagram connector. The connector can be configured before it is actually created.
The provider's default executor will be used to execute handler methods.
- Returns:
- a factory that can be used to configure the new local datagram connector
- Since:
- 1.2
awaken
public void awaken(Thread targetThread)
- Wake up any blocking I/O operation being carried out on a given thread. Custom implementors of
Thread
may call this method from their implementation of Thread.interrupt()
after the default implementation
to ensure that any thread waiting in a blocking operation is woken up in a timely manner. Some implementations
may not implement this method, relying instead on the interruption mechanism built in to the JVM; as such this
method should not be relied upon as a guaranteed way to awaken a blocking thread independently of thread
interruption.
- Parameters:
targetThread
- the thread to awaken- Since:
- 1.2
getName
public String getName()
- Get the name of this XNIO instance.
- Returns:
- the name
toString
public String toString()
- Get a string representation of this XNIO instance.
- Overrides:
toString
in class Object
- Returns:
- the string representation
close
public abstract void close()
throws IOException
- Close this XNIO provider. Calling this method more than one time has no additional effect.
- Specified by:
close
in interface Closeable
- Throws:
IOException
getProperty
protected String getProperty(String name)
- Get an XNIO property. The property name must start with
"xnio."
.
- Parameters:
name
- the property name
- Returns:
- the property value, or
null
if it wasn't found - Since:
- 1.2
getProperty
protected String getProperty(String name,
String defaultValue)
- Get an XNIO property. The property name must start with
"xnio."
.
- Parameters:
name
- the property namedefaultValue
- the default value
- Returns:
- the property value, or
defaultValue
if it wasn't found - Since:
- 1.2
registerMBean
protected Closeable registerMBean(TcpServerMBean mBean)
- Register a TCP server MBean.
- Parameters:
mBean
- the MBean
- Returns:
- a handle which may be used to unregister the MBean
- Since:
- 1.2
registerMBean
protected Closeable registerMBean(TcpConnectionMBean mBean)
- Register a TCP connection MBean.
- Parameters:
mBean
- the MBean
- Returns:
- a handle which may be used to unregister the MBean
- Since:
- 1.2
registerMBean
protected Closeable registerMBean(UdpServerMBean mBean)
- Register a UDP server MBean.
- Parameters:
mBean
- the MBean
- Returns:
- a handle which may be used to unregister the MBean
- Since:
- 1.2
registerMBean
protected Closeable registerMBean(OneWayPipeConnectionMBean mBean)
- Register a one-way pipe connection MBean.
- Parameters:
mBean
- the MBean
- Returns:
- a handle which may be used to unregister the MBean
- Since:
- 1.2
registerMBean
protected Closeable registerMBean(PipeConnectionMBean mBean)
- Register a pipe connection MBean.
- Parameters:
mBean
- the MBean
- Returns:
- a handle which may be used to unregister the MBean
- Since:
- 1.2
registerMBean
protected Closeable registerMBean(PipeServerMBean mBean)
- Register a pipe server MBean.
- Parameters:
mBean
- the MBean
- Returns:
- a handle which may be used to unregister the MBean
- Since:
- 1.2
registerMBean
protected Closeable registerMBean(PipeSourceServerMBean mBean)
- Register a pipe source server MBean.
- Parameters:
mBean
- the MBean
- Returns:
- a handle which may be used to unregister the MBean
- Since:
- 1.2
registerMBean
protected Closeable registerMBean(PipeSinkServerMBean mBean)
- Register a pipe sink server MBean.
- Parameters:
mBean
- the MBean
- Returns:
- a handle which may be used to unregister the MBean
- Since:
- 1.2
Copyright © 2008 JBoss, a division of Red Hat, Inc.