Class AbstractConnection
java.lang.Object
org.freedesktop.dbus.connections.base.AbstractConnectionBase
org.freedesktop.dbus.connections.base.ConnectionMethodInvocation
org.freedesktop.dbus.connections.base.DBusBoundPropertyHandler
org.freedesktop.dbus.connections.base.ConnectionMessageHandler
org.freedesktop.dbus.connections.AbstractConnection
- All Implemented Interfaces:
Closeable, AutoCloseable
- Direct Known Subclasses:
DBusConnection, DirectConnection
Handles a connection to DBus.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Patternstatic final booleanstatic final intstatic final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractConnection(ConnectionConfig _conCfg, TransportConfig _transportConfig, ReceivingServiceConfig _rsCfg) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFallback(String _objectPrefix, DBusInterface _object) Export an object as a fallback object.protected abstract AutoCloseableaddGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) Adds aDBusMatchRuleto with a generic signal handler.<T extends DBusSignal>
AutoCloseableaddSigHandler(Class<T> _type, DBusInterface _object, DBusSigHandler<T> _handler) Add a Signal Handler.<T extends DBusSignal>
AutoCloseableaddSigHandler(Class<T> _type, DBusSigHandler<T> _handler) Add a Signal Handler.abstract <T extends DBusSignal>
AutoCloseableaddSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) Add a signal handler with the givenDBusMatchRuleto DBus.protected <T extends DBusSignal>
voidaddSigHandlerWithoutMatch(Class<? extends DBusSignal> _signal, DBusSigHandler<T> _handler) callMethodAsync(DBusInterface _object, String _method, Object... _parameters) Call a method asynchronously and get a handle with which to get the reply.<A> voidcallWithCallback(DBusInterface _object, String _m, CallbackHandler<A> _callback, Object... _parameters) Call a method asynchronously and set a callback.protected IncomingMessageThreadcreateReaderThread(BusAddress _busAddress) Create the read thread for reading incoming messages.voidexportObject(String _objectPath, DBusInterface _object) Export an object so that its methods can be called on DBus.voidexportObject(DBusInterface _object) Export an object so that its methods can be called on DBus.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.booleanvoidqueueCallback(MethodCall _call, Method _method, CallbackHandler<?> _callback) voidremoveFallback(String _objectprefix) Remove a fallbackprotected abstract voidremoveGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) Remove a generic signal handler with the givenDBusMatchRule.<T extends DBusSignal>
voidremoveSigHandler(Class<T> _type, DBusInterface _object, DBusSigHandler<T> _handler) Remove a Signal Handler.<T extends DBusSignal>
voidremoveSigHandler(Class<T> _type, DBusSigHandler<T> _handler) Remove a Signal Handler.abstract <T extends DBusSignal>
voidremoveSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) Remove a match rule with the givenDBusSigHandler.voidsetWeakReferences(boolean _weakreferences) Deprecated, for removal: This API element is subject to removal in a future version.should be set during construction time (using the builder), will be removed in futureMethods inherited from class ConnectionMessageHandler
handleException, handleMessage, handleMessageMethods inherited from class DBusBoundPropertyHandler
handleDBusBoundProperties, handleGet, handleGetAll, handleSetMethods inherited from class ConnectionMethodInvocation
invokedMethodReply, invokeMethod, invokeMethodAndReply, queueInvokeMethod, setupAndInvokeMethods inherited from class AbstractConnectionBase
close, connect, disconnect, disconnect, doWithExportedObjects, doWithExportedObjectsAndReturn, getAddress, getBusAddress, getCallbackManager, getCallInfo, getConnectionConfig, getDisconnectCallback, getError, getExportedObject, getExportedObject, getExportedObject, getFallbackContainer, getGenericHandledSignals, getHandledSignals, getImportedObjects, getInfoMap, getLogger, getMachineId, getMessageFactory, getObjectTree, getPendingCalls, getPendingErrorQueue, getReceivingService, getTransport, getTransportConfig, internalDisconnect, isConnected, listen, rejectUnknownProperty, sendMessage, setDisconnectCallback, toString, unExportObject
-
Field Details
-
FLOAT_SUPPORT
public static final boolean FLOAT_SUPPORT -
DOLLAR_PATTERN
-
MAX_ARRAY_LENGTH
public static final int MAX_ARRAY_LENGTH- See Also:
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTH- See Also:
-
-
Constructor Details
-
AbstractConnection
protected AbstractConnection(ConnectionConfig _conCfg, TransportConfig _transportConfig, ReceivingServiceConfig _rsCfg) throws DBusException - Throws:
DBusException
-
-
Method Details
-
createReaderThread
Description copied from class:AbstractConnectionBaseCreate the read thread for reading incoming messages.- Specified by:
createReaderThreadin classAbstractConnectionBase- Parameters:
_busAddress- current bus address- Returns:
- IncomingMessageThread, never
null
-
removeSigHandler
public abstract <T extends DBusSignal> void removeSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) throws DBusException Remove a match rule with the givenDBusSigHandler. The rule will only be removed from DBus if no other additional handlers are registered to the same rule.- Type Parameters:
T- signal type- Parameters:
_rule- rule to remove_handler- handler to remove- Throws:
DBusException- on error- API Note:
- public since 5.2.0 - 2025-05-03
-
addSigHandler
public abstract <T extends DBusSignal> AutoCloseable addSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) throws DBusException Add a signal handler with the givenDBusMatchRuleto 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.- Type Parameters:
T- signal type- Parameters:
_rule- rule to add_handler- handler to use- Returns:
- closeable that removes signal handler
- Throws:
DBusException- on error- API Note:
- public since 5.2.0 - 2025-05-03
-
removeGenericSigHandler
protected abstract void removeGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException Remove a generic signal handler with the givenDBusMatchRule. The rule will only be removed from DBus if no other additional handlers are registered to the same rule.- Parameters:
_rule- rule to remove_handler- handler to remove- Throws:
DBusException- on error
-
addGenericSigHandler
protected abstract AutoCloseable addGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException Adds aDBusMatchRuleto 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- rule to add_handler- handler to use- Returns:
- closeable that removes signal handler
- Throws:
DBusException- on error
-
findMatchingTypes
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.- Type Parameters:
T- any DBusInterface compatible object- Parameters:
_type- type or null_ifaces- interfaces to examining when type is null- Returns:
- List
-
setWeakReferences
@Deprecated(since="5.1.0 - 2024-07-12", forRemoval=true) public void setWeakReferences(boolean _weakreferences) Deprecated, for removal: This API element is subject to removal in a future version.should be set during construction time (using the builder), will be removed in futureIf 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- reference
-
exportObject
Export an object so that its methods can be called on DBus.- Parameters:
_objectPath- 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- The object to export.- Throws:
DBusException- If the objectpath is already exporting an object. or if objectpath is incorrectly formatted,
-
exportObject
Export an object so that its methods can be called on DBus. The path to the object will be taken from theDBusInterface.getObjectPath()method, make sure it is implemented and returns immutable value. If you want export object with multiple paths, please useexportObject(String, DBusInterface).- Parameters:
_object- The object to export.- Throws:
DBusException- If the object path is already exporting an object or if object path is incorrectly formatted.
-
addFallback
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- The path below which the fallback handles calls. MUST be in slash-notation, like "/org/freedesktop/Local",_object- The object to export.- Throws:
DBusException- If the objectpath is incorrectly formatted,
-
removeFallback
Remove a fallback- Parameters:
_objectprefix- The prefix to remove the fallback for.
-
removeSigHandler
public <T extends DBusSignal> void removeSigHandler(Class<T> _type, DBusSigHandler<T> _handler) throws DBusException Remove a Signal Handler. Stops listening for this signal.- Type Parameters:
T- class extendingDBusSignal- Parameters:
_type- The signal to watch for._handler- the handler- Throws:
DBusException- If listening for the signal on the bus failed.ClassCastException- If type is not a sub-type of DBusSignal.
-
removeSigHandler
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.- Type Parameters:
T- class extendingDBusSignal- Parameters:
_type- The signal to watch for._object- The object emitting the signal._handler- the handler- Throws:
DBusException- If listening for the signal on the bus failed.ClassCastException- If type is not a sub-type of DBusSignal.
-
addSigHandler
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.- Type Parameters:
T- class extendingDBusSignal- Parameters:
_type- The signal to watch for._handler- The handler to call when a signal is received.- Returns:
- closeable that removes signal handler
- Throws:
DBusException- If listening for the signal on the bus failed.ClassCastException- If type is not a sub-type of DBusSignal.
-
addSigHandler
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.- Type Parameters:
T- class extendingDBusSignal- Parameters:
_type- The signal to watch for._object- The object from which the signal will be emitted_handler- The handler to call when a signal is received.- Returns:
- closeable that removes signal handler
- Throws:
DBusException- If listening for the signal on the bus failed.ClassCastException- If type is not a sub-type of DBusSignal.
-
addSigHandlerWithoutMatch
protected <T extends DBusSignal> void addSigHandlerWithoutMatch(Class<? extends DBusSignal> _signal, DBusSigHandler<T> _handler) throws DBusException - Throws:
DBusException
-
callWithCallback
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.- Type Parameters:
A- whatever- Parameters:
_object- The remote object on which to call the method._m- The name of the method on the interface to call._callback- The callback handler._parameters- The parameters to call the method with.
-
callMethodAsync
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- The remote object on which to call the method._method- The name of the method on the interface to call._parameters- The parameters to call the method with.- Returns:
- A handle to the call.
-
queueCallback
-
isFileDescriptorSupported
public boolean isFileDescriptorSupported()
-