- Alle implementierten Schnittstellen:
Closeable
,AutoCloseable
Handles a connection to DBus.
This is a Singleton class, only 1 connection to the SYSTEM or SESSION busses can be made. Repeated calls to getConnection will return the same reference.
Signal Handlers and method calls from remote objects are run in their own threads, you MUST handle the concurrency issues.
-
Verschachtelte Klassen - Übersicht
-
Feldübersicht
Von Klasse geerbte Felder org.freedesktop.dbus.connections.AbstractConnection
DOLLAR_PATTERN, FLOAT_SUPPORT, MAX_ARRAY_LENGTH, MAX_NAME_LENGTH
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungaddGenericSigHandler
(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) Adds aDBusMatchRule
to with a generic signal handler.<T extends DBusSignal>
AutoCloseableaddSigHandler
(Class<T> _type, String _source, DBusInterface _object, DBusSigHandler<T> _handler) Add a Signal Handler.<T extends DBusSignal>
AutoCloseableaddSigHandler
(Class<T> _type, String _source, DBusSigHandler<T> _handler) Add a Signal Handler.<T extends DBusSignal>
AutoCloseableaddSigHandler
(DBusMatchRule _rule, DBusSigHandler<T> _handler) Add a signal handler with the givenDBusMatchRule
to DBus.void
close()
Same as disconnect.void
Disconnect from the Bus.<T extends DBusInterface>
TdynamicProxy
(String _source, String _path, Class<T> _type) Tries to resolve a proxy to a remote object.getExportedObject
(String _source, String _path) Retrieves an remote object using source and path.<T extends DBusInterface>
TgetExportedObject
(String _source, String _path, Class<T> _type) Retrieves an remote object using source and path.The generated UUID of this machine.String[]
getNames()
Returns all the names owned by this connection.getPeerRemoteObject
(String _busname, String _objectpath) Return a reference to a remote object.<I extends DBusInterface>
IgetPeerRemoteObject
(String _busname, String _objectpath, Class<I> _type) <I extends DBusInterface>
IgetPeerRemoteObject
(String _busname, String _objectpath, Class<I> _type, boolean _autostart) Return a reference to a remote object.getRemoteObject
(String _busname, String _objectpath) Return a reference to a remote object.<I extends DBusInterface>
IgetRemoteObject
(String _busname, String _objectpath, Class<I> _type) Return a reference to a remote object.<I extends DBusInterface>
IgetRemoteObject
(String _busname, String _objectpath, Class<I> _type, boolean _autostart) Return a reference to a remote object.Returns the unique name of this connection.void
register()
Register this connection on the bus using 'Hello' message.
Will do nothing if session was already registered.void
releaseBusName
(String _busname) Release a bus name.void
removeGenericSigHandler
(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) Remove a generic signal handler with the givenDBusMatchRule
.<T extends DBusSignal>
voidremoveSigHandler
(Class<T> _type, String _source, DBusInterface _object, DBusSigHandler<T> _handler) Remove a Signal Handler.<T extends DBusSignal>
voidremoveSigHandler
(Class<T> _type, String _source, DBusSigHandler<T> _handler) Remove a Signal Handler.protected <T extends DBusSignal>
voidremoveSigHandler
(DBusMatchRule _rule, DBusSigHandler<T> _handler) Remove a match rule with the givenDBusSigHandler
.void
requestBusName
(String _busname) Request a bus name.Von Klasse geerbte Methoden org.freedesktop.dbus.connections.AbstractConnection
addFallback, addSigHandler, addSigHandler, addSigHandlerWithoutMatch, callMethodAsync, callWithCallback, createReaderThread, exportObject, exportObject, findMatchingTypes, isFileDescriptorSupported, queueCallback, removeFallback, removeSigHandler, removeSigHandler, setWeakReferences
Von Klasse geerbte Methoden org.freedesktop.dbus.connections.base.ConnectionMessageHandler
handleException, handleMessage, handleMessage
Von Klasse geerbte Methoden org.freedesktop.dbus.connections.base.DBusBoundPropertyHandler
handleDBusBoundProperties, handleGet, handleGetAll, handleSet
Von Klasse geerbte Methoden org.freedesktop.dbus.connections.base.ConnectionMethodInvocation
invokedMethodReply, invokeMethod, invokeMethodAndReply, queueInvokeMethod, setupAndInvoke
Von Klasse geerbte Methoden org.freedesktop.dbus.connections.base.AbstractConnectionBase
connect, disconnect, getAddress, getBusAddress, getCallbackManager, getCallInfo, getDisconnectCallback, getError, getExportedObject, getExportedObjects, getFallbackContainer, getGenericHandledSignals, getHandledSignals, getImportedObjects, getInfoMap, getLogger, getMessageFactory, getObjectTree, getPendingCalls, getPendingErrorQueue, getReceivingService, getTransport, getTransportConfig, internalDisconnect, isConnected, listen, rejectUnknownProperty, sendMessage, setDisconnectCallback, toString, unExportObject
-
Methodendetails
-
register
Register this connection on the bus using 'Hello' message.
Will do nothing if session was already registered.- Löst aus:
DBusException
- when sending message fails- Seit:
- 5.0.0 - 2023-10-11
-
dynamicProxy
public <T extends DBusInterface> T dynamicProxy(String _source, String _path, Class<T> _type) throws DBusException Tries to resolve a proxy to a remote object. If a type class is given, it tries to convert the object using that class. If null is given as type, it tries to find a proper interface for this object.- Typparameter:
T
- object type (DBusInterface compatible)- Parameter:
_source
- source_path
- path_type
- class of object type- Gibt zurück:
- DBusInterface compatible object
- Löst aus:
DBusException
- when something goes wrong
-
getExportedObject
public <T extends DBusInterface> T getExportedObject(String _source, String _path, Class<T> _type) throws DBusException Beschreibung aus Klasse kopiert:AbstractConnectionBase
Retrieves an remote object using source and path. Will use the given type as object class.- Angegeben von:
getExportedObject
in KlasseAbstractConnectionBase
- Parameter:
_source
- source_path
- path_type
- class of remote object- Gibt zurück:
DBusInterface
compatible object- Löst aus:
DBusException
-
getExportedObject
Beschreibung aus Klasse kopiert:AbstractConnectionBase
Retrieves an remote object using source and path. Will try to find suitable exported DBusInterface automatically.- Angegeben von:
getExportedObject
in KlasseAbstractConnectionBase
- Parameter:
_source
- source_path
- path- Gibt zurück:
DBusInterface
compatible object- Löst aus:
DBusException
-
releaseBusName
Release a bus name. Releases the name so that other people can use it- Parameter:
_busname
- The name to release. MUST be in dot-notation like "org.freedesktop.local"- Löst aus:
DBusException
- If the busname is incorrectly formatted.
-
requestBusName
Request a bus name. Request the well known name that this should respond to on the Bus.- Parameter:
_busname
- The name to respond to. MUST be in dot-notation like "org.freedesktop.local"- Löst aus:
DBusException
- If the register name failed, or our name already exists on the bus. or if busname is incorrectly formatted.
-
getUniqueName
Returns the unique name of this connection.- Gibt zurück:
- unique name
-
getNames
Returns all the names owned by this connection.- Gibt zurück:
- connection names
-
getPeerRemoteObject
public <I extends DBusInterface> I getPeerRemoteObject(String _busname, String _objectpath, Class<I> _type) throws DBusException - Löst aus:
DBusException
-
getPeerRemoteObject
public DBusInterface getPeerRemoteObject(String _busname, String _objectpath) throws InvalidBusNameException, DBusException Return a reference to a remote object. This method will resolve the well known name (if given) to a unique bus name when you call it. This means that if a well known name is released by one process and acquired by another calls to objects gained from this method will continue to operate on the original process. This method will use bus introspection to determine the interfaces on a remote object and so may block and may fail. The resulting proxy object will, however, be castable to any interface it implements. It will also autostart the process if applicable. Also note that the resulting proxy may fail to execute the correct method with overloaded methods and that complex types may fail in interesting ways. Basically, if something odd happens, try specifying the interface explicitly.- Parameter:
_busname
- The bus name to connect to. Usually a well known bus name in dot-notation (such as "org.freedesktop.local") or may be a DBus address such as ":1-16"._objectpath
- The path on which the process is exporting the object.$- Gibt zurück:
- A reference to a remote object.
- Löst aus:
ClassCastException
- If type is not a sub-type of DBusInterfaceInvalidBusNameException
- If busname or objectpath are incorrectly formatted.DBusException
- If retrieving remote object fails
-
getRemoteObject
public DBusInterface getRemoteObject(String _busname, String _objectpath) throws DBusException, InvalidBusNameException, InvalidObjectPathException Return a reference to a remote object. This method will always refer to the well known name (if given) rather than resolving it to a unique bus name. In particular this means that if a process providing the well known name disappears and is taken over by another process proxy objects gained by this method will make calls on the new proccess. This method will use bus introspection to determine the interfaces on a remote object and so may block and may fail. The resulting proxy object will, however, be castable to any interface it implements. It will also autostart the process if applicable. Also note that the resulting proxy may fail to execute the correct method with overloaded methods and that complex types may fail in interesting ways. Basically, if something odd happens, try specifying the interface explicitly.- Parameter:
_busname
- The bus name to connect to. Usually a well known bus name name in dot-notation (such as "org.freedesktop.local") or may be a DBus address such as ":1-16"._objectpath
- The path on which the process is exporting the object.- Gibt zurück:
- A reference to a remote object.
- Löst aus:
ClassCastException
- If type is not a sub-type of DBusInterfaceDBusException
- If remote object cannot be retrievedInvalidBusNameException
- If busname is incorrectly formattedInvalidObjectPathException
- If objectpath is incorrectly formatted
-
getPeerRemoteObject
public <I extends DBusInterface> I getPeerRemoteObject(String _busname, String _objectpath, Class<I> _type, boolean _autostart) throws DBusException, InvalidBusNameException Return a reference to a remote object. This method will resolve the well known name (if given) to a unique bus name when you call it. This means that if a well known name is released by one process and acquired by another calls to objects gained from this method will continue to operate on the original process.- Typparameter:
I
- class extendingDBusInterface
- Parameter:
_busname
- The bus name to connect to. Usually a well known bus name in dot-notation (such as "org.freedesktop.local") or may be a DBus address such as ":1-16"._objectpath
- The path on which the process is exporting the object.$_type
- The interface they are exporting it on. This type must have the same full class name and exposed method signatures as the interface the remote object is exporting._autostart
- Disable/Enable auto-starting of services in response to calls on this object. Default is enabled; when calling a method with auto-start enabled, if the destination is a well-known name and is not owned the bus will attempt to start a process to take the name. When disabled an error is returned immediately.- Gibt zurück:
- A reference to a remote object.
- Löst aus:
ClassCastException
- If type is not a sub-type of DBusInterfaceDBusException
- If busname or objectpath are incorrectly formatted or type is not in a package.InvalidBusNameException
- If busname is incorrectly formatted
-
getRemoteObject
public <I extends DBusInterface> I getRemoteObject(String _busname, String _objectpath, Class<I> _type) throws DBusException Return a reference to a remote object. This method will always refer to the well known name (if given) rather than resolving it to a unique bus name. In particular this means that if a process providing the well known name disappears and is taken over by another process proxy objects gained by this method will make calls on the new proccess.- Typparameter:
I
- class extendingDBusInterface
- Parameter:
_busname
- The bus name to connect to. Usually a well known bus name name in dot-notation (such as "org.freedesktop.local") or may be a DBus address such as ":1-16"._objectpath
- The path on which the process is exporting the object._type
- The interface they are exporting it on. This type must have the same full class name and exposed method signatures as the interface the remote object is exporting.- Gibt zurück:
- A reference to a remote object.
- Löst aus:
ClassCastException
- If type is not a sub-type of DBusInterfaceDBusException
- If busname or objectpath are incorrectly formatted or type is not in a package.
-
getRemoteObject
public <I extends DBusInterface> I getRemoteObject(String _busname, String _objectpath, Class<I> _type, boolean _autostart) throws DBusException Return a reference to a remote object. This method will always refer to the well known name (if given) rather than resolving it to a unique bus name. In particular this means that if a process providing the well known name disappears and is taken over by another process proxy objects gained by this method will make calls on the new proccess.- Typparameter:
I
- class extendingDBusInterface
- Parameter:
_busname
- The bus name to connect to. Usually a well known bus name name in dot-notation (such as "org.freedesktop.local") or may be a DBus address such as ":1-16"._objectpath
- The path on which the process is exporting the object._type
- The interface they are exporting it on. This type must have the same full class name and exposed method signatures as the interface the remote object is exporting._autostart
- Disable/Enable auto-starting of services in response to calls on this object. Default is enabled; when calling a method with auto-start enabled, if the destination is a well-known name and is not owned the bus will attempt to start a process to take the name. When disabled an error is returned immediately.- Gibt zurück:
- A reference to a remote object.
- Löst aus:
ClassCastException
- If type is not a sub-type of DBusInterfaceDBusException
- If busname or objectpath are incorrectly formatted or type is not in a package.
-
removeSigHandler
public <T extends DBusSignal> void removeSigHandler(Class<T> _type, String _source, DBusSigHandler<T> _handler) throws DBusException Remove a Signal Handler. Stops listening for this signal.- Typparameter:
T
- class extendingDBusSignal
- Parameter:
_type
- The signal to watch for._source
- The source of the signal._handler
- the handler- Löst aus:
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, String _source, DBusInterface _object, DBusSigHandler<T> _handler) throws DBusException Remove a Signal Handler. Stops listening for this signal.- Typparameter:
T
- class extendingDBusSignal
- Parameter:
_type
- The signal to watch for._source
- The source of the signal._object
- The object emitting the signal._handler
- the handler- Löst aus:
DBusException
- If listening for the signal on the bus failed.ClassCastException
- If type is not a sub-type of DBusSignal.
-
removeSigHandler
protected <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.- Angegeben von:
removeSigHandler
in KlasseAbstractConnection
- Typparameter:
T
- signal type- Parameter:
_rule
- rule to remove_handler
- handler to remove- Löst aus:
DBusException
- on error
-
addSigHandler
public <T extends DBusSignal> AutoCloseable addSigHandler(Class<T> _type, String _source, 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 source.- Typparameter:
T
- class extendingDBusSignal
- Parameter:
_type
- The signal to watch for._source
- The process which will send the signal. This MUST be a unique bus name and not a well known name._handler
- The handler to call when a signal is received.- Gibt zurück:
- closeable that removes signal handler
- Löst aus:
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, String _source, 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, source and object.- Typparameter:
T
- class extendingDBusSignal
- Parameter:
_type
- The signal to watch for._source
- The process which will send the signal. This MUST be a unique bus name and not a well known name._object
- The object from which the signal will be emitted_handler
- The handler to call when a signal is received.- Gibt zurück:
- closeable that removes signal handler
- Löst aus:
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(DBusMatchRule _rule, DBusSigHandler<T> _handler) throws DBusException Add a signal handler with the givenDBusMatchRule
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.- Angegeben von:
addSigHandler
in KlasseAbstractConnection
- Typparameter:
T
- signal type- Parameter:
_rule
- rule to add_handler
- handler to use- Gibt zurück:
- closeable that removes signal handler
- Löst aus:
DBusException
- on error
-
disconnect
public void disconnect()Disconnect from the Bus. If this is a shared connection, it only disconnects when the last reference to the bus has called disconnect. If this is not a shared connection, disconnect will close the connection instantly.- Setzt außer Kraft:
disconnect
in KlasseAbstractConnectionBase
-
close
Same as disconnect.- Angegeben von:
close
in SchnittstelleAutoCloseable
- Angegeben von:
close
in SchnittstelleCloseable
- Setzt außer Kraft:
close
in KlasseAbstractConnectionBase
- Löst aus:
IOException
-
getMachineId
Beschreibung aus Klasse kopiert:AbstractConnectionBase
The generated UUID of this machine.- Angegeben von:
getMachineId
in KlasseAbstractConnectionBase
- Gibt zurück:
- String
-
removeGenericSigHandler
public void removeGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException Beschreibung aus Klasse kopiert:AbstractConnection
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.- Angegeben von:
removeGenericSigHandler
in KlasseAbstractConnection
- Parameter:
_rule
- rule to remove_handler
- handler to remove- Löst aus:
DBusException
- on error
-
addGenericSigHandler
public AutoCloseable addGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException Beschreibung aus Klasse kopiert:AbstractConnection
Adds aDBusMatchRule
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.- Angegeben von:
addGenericSigHandler
in KlasseAbstractConnection
- Parameter:
_rule
- rule to add_handler
- handler to use- Gibt zurück:
- closeable that removes signal handler
- Löst aus:
DBusException
- on error
-