Modul org.freedesktop.dbus
Klasse AbstractTransport
java.lang.Object
org.freedesktop.dbus.connections.transports.AbstractTransport
- Alle implementierten Schnittstellen:
Closeable
,AutoCloseable
- Bekannte direkte Unterklassen:
AbstractUnixTransport
Base class for all transport types.
- Seit:
- v3.2.0 - 2019-02-08
- Autor:
- hypfvieh
-
Konstruktorübersicht
ModifiziererKonstruktorBeschreibungprotected
AbstractTransport
(BusAddress _address, TransportConfig _config) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected abstract SocketChannel
Method to accept new incoming listening connections.
This is the place whereaccept()
is called on the server socket created bybindImpl()
.
Therefore this method will block until a client is connected.protected abstract void
bindImpl()
Method called to prepare listening for connections.
This is usually the place where theServerSocketChannel
is created andbind()
is called.final void
close()
protected abstract void
Method which is called to close a transport.
Should be used to close all sockets and/or serversockets.final SocketChannel
connect()
Establish connection on created transport.protected abstract SocketChannel
Abstract method implemented by concrete sub classes to establish a connection.protected BusAddress
Returns theBusAddress
used for this transport.protected org.slf4j.Logger
Get the logger in subclasses.Currently configured message factory.protected SaslConfig
Returns the current configuration used for SASL authentication.Returns the current transport connection.protected abstract boolean
Method to indicate if passing of file descriptors is allowed.protected abstract boolean
isBound()
Status of the server socket if this transport is configured to be a server connection.
Must be false ifbindImpl()
was not called.boolean
Returns true if inputReader and outputWriter are not yet closed.boolean
final boolean
True if this transport connection is a listening (server) connection.final TransportConnection
listen()
Start listening on created transport.Read a message from the underlying socket.void
Set a callback which will be called right before the connection will be established to the transport.toString()
void
writeMessage
(Message _msg) Write a message to the underlying socket.
-
Konstruktordetails
-
AbstractTransport
-
-
Methodendetails
-
writeMessage
Write a message to the underlying socket.- Parameter:
_msg
- message to write- Löst aus:
IOException
- on write error or if output was already closed or null
-
readMessage
Read a message from the underlying socket.- Gibt zurück:
- read message, maybe null
- Löst aus:
IOException
- when input already close or nullDBusException
- when message could not be converted to a DBus message
-
isConnected
public boolean isConnected()Returns true if inputReader and outputWriter are not yet closed.- Gibt zurück:
- boolean
-
hasFileDescriptorSupport
protected abstract boolean hasFileDescriptorSupport()Method to indicate if passing of file descriptors is allowed.- Gibt zurück:
- true to allow FD passing, false otherwise
-
connectImpl
Abstract method implemented by concrete sub classes to establish a connection.- Gibt zurück:
- socket channel connected to DBus server
- Löst aus:
IOException
- when connection fails
-
acceptImpl
Method to accept new incoming listening connections.
This is the place whereaccept()
is called on the server socket created bybindImpl()
.
Therefore this method will block until a client is connected.- Gibt zurück:
- newly connected client socket
- Löst aus:
IOException
- when connection fails- Seit:
- 5.0.0 - 2023-10-20
-
bindImpl
Method called to prepare listening for connections.
This is usually the place where theServerSocketChannel
is created andbind()
is called.- Löst aus:
IOException
- when connection fails- Seit:
- 5.0.0 - 2023-10-20
-
closeTransport
Method which is called to close a transport.
Should be used to close all sockets and/or serversockets.- Löst aus:
IOException
- when something fails while closing transport- Seit:
- 5.0.0 - 2023-10-20
-
isBound
protected abstract boolean isBound()Status of the server socket if this transport is configured to be a server connection.
Must be false ifbindImpl()
was not called.- Gibt zurück:
- boolean
- Seit:
- 5.0.0 - 2023-10-20
-
connect
Establish connection on created transport.
This method can only be used for non-listening connections.
Trying to use this with listening addresses will throw anInvalidBusAddressException
.- Gibt zurück:
SocketChannel
of the created connection- Löst aus:
IOException
- if connection fails
-
isListening
public final boolean isListening()True if this transport connection is a listening (server) connection.- Gibt zurück:
- boolean
-
listen
Start listening on created transport.
This method can only be used for listening connections.
Trying to use this with non-listening addresses will throw anInvalidBusAddressException
.Will return the
TransportConnection
as soon as a client connects.
Therefore this method should be called in a loop to accept multiple clients- Gibt zurück:
TransportConnection
containing createdSocketChannel
andIMessageReader
/IMessageWriter
- Löst aus:
IOException
- if connection fails
-
setPreConnectCallback
Set a callback which will be called right before the connection will be established to the transport.- Parameter:
_run
- runnable to execute, null if no callback should be executed- Seit:
- 4.2.0 - 2022-07-20
-
getAddress
Returns theBusAddress
used for this transport.- Gibt zurück:
- BusAddress, never null
-
getLogger
protected org.slf4j.Logger getLogger()Get the logger in subclasses.- Gibt zurück:
- Logger, never null
-
getSaslConfig
Returns the current configuration used for SASL authentication.- Gibt zurück:
- SaslConfig, never null
-
getTransportConnection
Returns the current transport connection.- Gibt zurück:
- TransportConnection, null if not connected yet
-
getMessageFactory
Currently configured message factory.- Gibt zurück:
- factory
-
getTransportConfig
-
isFileDescriptorSupported
public boolean isFileDescriptorSupported() -
toString
-
close
- Angegeben von:
close
in SchnittstelleAutoCloseable
- Angegeben von:
close
in SchnittstelleCloseable
- Löst aus:
IOException
-