Top Description Fields Constructors Methods
org.freedesktop.dbus.connections

public abstract non-sealed Class AbstractConnection

extends ConnectionMessageHandler
Class Inheritance
Known Direct Subclasses
org.freedesktop.dbus.connections.impl.DBusConnection, org.freedesktop.dbus.connections.impl.DirectConnection
Imports
org.freedesktop.dbus.DBusAsyncReply, .DBusMatchRule, .RemoteInvocationHandler, .RemoteObject, org.freedesktop.dbus.connections.base.ConnectionMessageHandler, .IncomingMessageThread, org.freedesktop.dbus.connections.config.ReceivingServiceConfig, .TransportConfig, org.freedesktop.dbus.connections.impl.ConnectionConfig, org.freedesktop.dbus.exceptions.DBusException, .DBusExecutionException, .InvalidSignalException, org.freedesktop.dbus.interfaces.CallbackHandler, .DBusInterface, .DBusSigHandler, org.freedesktop.dbus.messages.DBusSignal, .ExportedObject, .MethodCall, org.freedesktop.dbus.utils.DBusObjects, java.lang.reflect.Method, java.util.*, java.util.concurrent.ConcurrentLinkedQueue, java.util.regex.Pattern

Handles a connection to DBus.

Field Summary

Modifier and TypeField and Description
public static final Pattern
public static final boolean
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
addFallback(String
The path below which the fallback handles calls. MUST be in slash-notation, like "/org/freedesktop/Local",
_objectPrefix
,
DBusInterface
The object to export.
_object
)

Export an object as a fallback object.

protected abstract AutoCloseable

Returns:

closeable that removes signal handler
addGenericSigHandler
(DBusMatchRule
rule to add
_rule
,
DBusSigHandler<DBusSignal>
handler to use
_handler
)

Adds a DBusMatchRule to with a generic signal handler.

protected abstract <
signal type
T extends DBusSignal
>
AutoCloseable

Returns:

closeable that removes signal handler
addSigHandler
(DBusMatchRule
rule to add
_rule
,
DBusSigHandler<T>
handler to use
_handler
)

Add a signal handler with the given DBusMatchRule to DBus.

public <
class extending DBusSignal
T extends DBusSignal
>
AutoCloseable

Returns:

closeable that removes signal handler
addSigHandler
(Class<T>
The signal to watch for.
_type
,
DBusSigHandler<T>
The handler to call when a signal is received.
_handler
)

Add a Signal Handler.

public <
class extending DBusSignal
T extends DBusSignal
>
AutoCloseable

Returns:

closeable that removes signal handler
addSigHandler
(Class<T>
The signal to watch for.
_type
,
DBusInterface
The object from which the signal will be emitted
_object
,
DBusSigHandler<T>
The handler to call when a signal is received.
_handler
)

Add a Signal Handler.

protected <T extends DBusSignal> void
addSigHandlerWithoutMatch(Class<? extends DBusSignal> _signal, DBusSigHandler<T> _handler)

private <T extends DBusSignal> void
assertSignal(Class<T> _type)

public DBusAsyncReply<?>

Returns:

A handle to the call.
callMethodAsync
(DBusInterface
The remote object on which to call the method.
_object
,
String
The name of the method on the interface to call.
_method
,
Object...
The parameters to call the method with.
_parameters
)

Call a method asynchronously and get a handle with which to get the reply.

public <
whatever
A
>
void
callWithCallback(DBusInterface
The remote object on which to call the method.
_object
,
String
The name of the method on the interface to call.
_m
,
CallbackHandler<A>
The callback handler.
_callback
,
Object...
The parameters to call the method with.
_parameters
)

Call a method asynchronously and set a callback.

protected IncomingMessageThread
createReaderThread(BusAddress
current bus address
_busAddress
)

Implements abstract org.freedesktop.dbus.connections.base.AbstractConnectionBase.createReaderThread.

Create the read thread for reading incoming messages.

private static Class<?>[]
createTypesArray(Object... _parameters)

public void
exportObject(String
The path to the object we are exposing. MUST be in slash-notation, like "/org/freedesktop/Local", and SHOULD end with a capitalised term. Only one object may be exposed on each path at any one time, but an object may be exposed on several paths at once.
_objectPath
,
DBusInterface
The object to export.
_object
)

Export an object so that its methods can be called on DBus.

public void
exportObject(DBusInterface
The object to export.
_object
)

Export an object so that its methods can be called on DBus.

protected <
any DBusInterface compatible object
T extends DBusInterface
>
List<Class<?>>

Returns:

List
findMatchingTypes
(Class<T>
type or null
_type
,
List<String>
interfaces to examining when type is null
_ifaces
)

If given type is null, will try to find suitable types by examining the given ifaces.

public boolean
public void
queueCallback(MethodCall _call, Method _method, CallbackHandler<?> _callback)

public void
removeFallback(String
The prefix to remove the fallback for.
_objectprefix
)

Remove a fallback

protected abstract void
removeGenericSigHandler(DBusMatchRule
rule to remove
_rule
,
DBusSigHandler<DBusSignal>
handler to remove
_handler
)

Remove a generic signal handler with the given DBusMatchRule.

protected abstract <
signal type
T extends DBusSignal
>
void
removeSigHandler(DBusMatchRule
rule to remove
_rule
,
DBusSigHandler<T>
handler to remove
_handler
)

Remove a match rule with the given DBusSigHandler.

public <
class extending DBusSignal
T extends DBusSignal
>
void
removeSigHandler(Class<T>
The signal to watch for.
_type
,
DBusSigHandler<T>
the handler
_handler
)

Remove a Signal Handler.

public <
class extending DBusSignal
T extends DBusSignal
>
void
removeSigHandler(Class<T>
The signal to watch for.
_type
,
DBusInterface
The object emitting the signal.
_object
,
DBusSigHandler<T>
the handler
_handler
)

Remove a Signal Handler.

public void
setWeakReferences(boolean
reference
_weakreferences
)
Deprecated for removal since 5.1.0 - 2024-07-12. should be set during construction time (using the builder), will be removed in future

If set to true the bus will not hold a strong reference to exported objects.

Inherited from org.freedesktop.dbus.connections.base.ConnectionMessageHandler:
handleExceptionhandleMessagehandleMessage

Field Detail

DOLLAR_PATTERNback to summary
public static final Pattern DOLLAR_PATTERN
FLOAT_SUPPORTback to summary
public static final boolean FLOAT_SUPPORT
MAX_ARRAY_LENGTHback to summary
public static final int MAX_ARRAY_LENGTH
MAX_NAME_LENGTHback to summary
public static final int MAX_NAME_LENGTH

Constructor Detail

AbstractConnectionback to summary
protected AbstractConnection(ConnectionConfig _conCfg, TransportConfig _transportConfig, ReceivingServiceConfig _rsCfg) throws DBusException

Method Detail

addFallbackback to summary
public void addFallback(String _objectPrefix, DBusInterface _object) throws DBusException

Export an object as a fallback object. This object will have it's methods invoked for all paths starting with this object path.

Parameters
_objectPrefix:String

The path below which the fallback handles calls. MUST be in slash-notation, like "/org/freedesktop/Local",

_object:DBusInterface

The object to export.

Exceptions
DBusException:
If the objectpath is incorrectly formatted,
addGenericSigHandlerback to summary
protected abstract AutoCloseable addGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException

Adds a DBusMatchRule to with a generic signal handler. Generic signal handlers allow receiving different signals with the same handler. If the rule was already added, the signal handler is added to the internal map receiving the same signal as the first (and additional) handlers for this rule.

Parameters
_rule:DBusMatchRule

rule to add

_handler:DBusSigHandler<DBusSignal>

handler to use

Returns:AutoCloseable

closeable that removes signal handler

Exceptions
DBusException:
on error
addSigHandlerback to summary
protected abstract <T extends DBusSignal> AutoCloseable addSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) throws DBusException

Add a signal handler with the given DBusMatchRule to DBus. The rule will be added to DBus if it was not added before. If the rule was already added, the signal handler is added to the internal map receiving the same signal as the first (and additional) handlers for this rule.

Parameters
<T>
signal type
_rule:DBusMatchRule

rule to add

_handler:DBusSigHandler<T>

handler to use

Returns:AutoCloseable

closeable that removes signal handler

Exceptions
DBusException:
on error
addSigHandlerback to summary
public <T extends DBusSignal> AutoCloseable addSigHandler(Class<T> _type, DBusSigHandler<T> _handler) throws DBusException

Add a Signal Handler. Adds a signal handler to call when a signal is received which matches the specified type and name.

Parameters
<T>
class extending DBusSignal
_type:Class<T>

The signal to watch for.

_handler:DBusSigHandler<T>

The handler to call when a signal is received.

Returns:AutoCloseable

closeable that removes signal handler

Exceptions
DBusException:
If listening for the signal on the bus failed.
ClassCastException:
If type is not a sub-type of DBusSignal.
addSigHandlerback to summary
public <T extends DBusSignal> AutoCloseable addSigHandler(Class<T> _type, DBusInterface _object, DBusSigHandler<T> _handler) throws DBusException

Add a Signal Handler. Adds a signal handler to call when a signal is received which matches the specified type, name and object.

Parameters
<T>
class extending DBusSignal
_type:Class<T>

The signal to watch for.

_object:DBusInterface

The object from which the signal will be emitted

_handler:DBusSigHandler<T>

The handler to call when a signal is received.

Returns:AutoCloseable

closeable that removes signal handler

Exceptions
DBusException:
If listening for the signal on the bus failed.
ClassCastException:
If type is not a sub-type of DBusSignal.
addSigHandlerWithoutMatchback to summary
protected <T extends DBusSignal> void addSigHandlerWithoutMatch(Class<? extends DBusSignal> _signal, DBusSigHandler<T> _handler) throws DBusException
assertSignalback to summary
private <T extends DBusSignal> void assertSignal(Class<T> _type) throws InvalidSignalException
callMethodAsyncback to summary
public DBusAsyncReply<?> callMethodAsync(DBusInterface _object, String _method, Object... _parameters)

Call a method asynchronously and get a handle with which to get the reply.

Parameters
_object:DBusInterface

The remote object on which to call the method.

_method:String

The name of the method on the interface to call.

_parameters:Object[]

The parameters to call the method with.

Returns:DBusAsyncReply<?>

A handle to the call.

callWithCallbackback to summary
public <A> void callWithCallback(DBusInterface _object, String _m, CallbackHandler<A> _callback, Object... _parameters)

Call a method asynchronously and set a callback. This handler will be called in a separate thread.

Parameters
<A>
whatever
_object:DBusInterface

The remote object on which to call the method.

_m:String

The name of the method on the interface to call.

_callback:CallbackHandler<A>

The callback handler.

_parameters:Object[]

The parameters to call the method with.

createReaderThreadback to summary
protected IncomingMessageThread createReaderThread(BusAddress _busAddress)

Implements abstract org.freedesktop.dbus.connections.base.AbstractConnectionBase.createReaderThread.

Doc from org.freedesktop.dbus.connections.base.AbstractConnectionBase.createReaderThread.

Create the read thread for reading incoming messages.

Parameters
_busAddress:BusAddress

current bus address

Returns:IncomingMessageThread

IncomingMessageThread, never null

Annotations
@Override
createTypesArrayback to summary
private static Class<?>[] createTypesArray(Object... _parameters)
exportObjectback to summary
public void exportObject(String _objectPath, DBusInterface _object) throws DBusException

Export an object so that its methods can be called on DBus.

Parameters
_objectPath:String

The path to the object we are exposing. MUST be in slash-notation, like "/org/freedesktop/Local", and SHOULD end with a capitalised term. Only one object may be exposed on each path at any one time, but an object may be exposed on several paths at once.

_object:DBusInterface

The object to export.

Exceptions
DBusException:
If the objectpath is already exporting an object. or if objectpath is incorrectly formatted,
exportObjectback to summary
public void exportObject(DBusInterface _object) throws DBusException

Export an object so that its methods can be called on DBus. The path to the object will be taken from the DBusInterface#getObjectPath() method, make sure it is implemented and returns immutable value. If you want export object with multiple paths, please use AbstractConnection#exportObject(String, DBusInterface).

Parameters
_object:DBusInterface

The object to export.

Exceptions
DBusException:
If the object path is already exporting an object or if object path is incorrectly formatted.
findMatchingTypesback to summary
protected <T extends DBusInterface> List<Class<?>> findMatchingTypes(Class<T> _type, List<String> _ifaces)

If given type is null, will try to find suitable types by examining the given ifaces. If a non-null type is given, returns the given type.

Parameters
<T>
any DBusInterface compatible object
_type:Class<T>

type or null

_ifaces:List<String>

interfaces to examining when type is null

Returns:List<Class<?>>

List

isFileDescriptorSupportedback to summary
public boolean isFileDescriptorSupported()
queueCallbackback to summary
public void queueCallback(MethodCall _call, Method _method, CallbackHandler<?> _callback)
removeFallbackback to summary
public void removeFallback(String _objectprefix)

Remove a fallback

Parameters
_objectprefix:String

The prefix to remove the fallback for.

removeGenericSigHandlerback to summary
protected abstract void removeGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException

Remove a generic signal handler with the given DBusMatchRule. The rule will only be removed from DBus if no other additional handlers are registered to the same rule.

Parameters
_rule:DBusMatchRule

rule to remove

_handler:DBusSigHandler<DBusSignal>

handler to remove

Exceptions
DBusException:
on error
removeSigHandlerback to summary
protected abstract <T extends DBusSignal> void removeSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) throws DBusException

Remove a match rule with the given DBusSigHandler. The rule will only be removed from DBus if no other additional handlers are registered to the same rule.

Parameters
<T>
signal type
_rule:DBusMatchRule

rule to remove

_handler:DBusSigHandler<T>

handler to remove

Exceptions
DBusException:
on error
removeSigHandlerback to summary
public <T extends DBusSignal> void removeSigHandler(Class<T> _type, DBusSigHandler<T> _handler) throws DBusException

Remove a Signal Handler. Stops listening for this signal.

Parameters
<T>
class extending DBusSignal
_type:Class<T>

The signal to watch for.

_handler:DBusSigHandler<T>

the handler

Exceptions
DBusException:
If listening for the signal on the bus failed.
ClassCastException:
If type is not a sub-type of DBusSignal.
removeSigHandlerback to summary
public <T extends DBusSignal> void removeSigHandler(Class<T> _type, DBusInterface _object, DBusSigHandler<T> _handler) throws DBusException

Remove a Signal Handler. Stops listening for this signal.

Parameters
<T>
class extending DBusSignal
_type:Class<T>

The signal to watch for.

_object:DBusInterface

The object emitting the signal.

_handler:DBusSigHandler<T>

the handler

Exceptions
DBusException:
If listening for the signal on the bus failed.
ClassCastException:
If type is not a sub-type of DBusSignal.
setWeakReferencesback to summary
public void setWeakReferences(boolean _weakreferences)

Deprecated

for removal since 5.1.0 - 2024-07-12.

should be set during construction time (using the builder), will be removed in future

If set to true the bus will not hold a strong reference to exported objects. If they go out of scope they will automatically be unexported from the bus. The default is to hold a strong reference, which means objects must be explicitly unexported before they will be garbage collected.

Parameters
_weakreferences:boolean

reference

Annotations
@Deprecated
since:5.1.0 - 2024-07-12
forRemoval:true