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.
| Modifier and Type | Class and Description |
|---|---|
| public static enum | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| pack-priv final AtomicInteger | concurrentConnections
Count how many 'connections' we manage internally. |
| pack-priv static final ConcurrentMap | |
| private DBus | |
| private final Logger | |
| private final String | |
| private boolean | registered
Whether the connection was registered using 'Hello' message. |
| private final boolean | shared
Whether this connection is used in shared mode. |
| Access | Constructor and Description |
|---|---|
| pack-priv | DBusConnection(boolean _shared, String _machineId, ConnectionConfig _conCfg, TransportConfig _tranportCfg, ReceivingServiceConfig _rsCfg)
|
| Modifier and Type | Method and Description |
|---|---|
| public AutoCloseable | addGenericSigHandler(DBusMatchRule
rule to add _rule, DBusSigHandler<DBusSignal> handler to use _handler)Implements abstract org. Adds a |
| public < class extending T extends DBusSignal> AutoCloseableDBusSignal | Returns: closeable that removes signal handlerThe signal to watch for. _type, String The process which will send the signal. This MUST be a unique bus name and not a well known
name. _source, DBusSigHandler<T> The handler to call when a signal is received. _handler)Add a Signal Handler. |
| public < class extending T extends DBusSignal> AutoCloseableDBusSignal | Returns: closeable that removes signal handlerThe signal to watch for. _type, String The process which will send the signal. This MUST be a unique bus name and not a well known
name. _source, 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. |
| public <T extends DBusSignal> AutoCloseable | addSigHandler(DBusMatchRule
rule to add _rule, DBusSigHandler<T> handler to use _handler)Implements abstract org. Add a signal handler with the given |
| public void | close()
Overrides org. Implements java. Same as disconnect. |
| pack-priv void | |
| public synchronized void | disconnect()
Overrides org. Disconnect from the Bus. |
| private void | doWithBusNames(Consumer<List<String>>
action to execute _action)Do some action with the currently registered names in a synchronized manor. |
| private <T> T | Returns: whatever the action returnsaction to execute _action)Do some action with the currently registered names in a synchronized manor. |
| public < object type (DBusInterface compatible) T extends DBusInterface> T | Returns: DBusInterface compatible objectsource _source, String path _path, Class<T> class of object type _type)Tries to resolve a proxy to a remote object. |
| private AtomicInteger | |
| public String | getDBusOwnerName(String
bus name _busName)Implements org. Returns name of the current owning dbus session. |
| public <T extends DBusInterface> T | getExportedObject(String
source _source, String path _path, Class<T> class of remote object _type)Implements abstract org. Retrieves an remote object using source and path. |
| public DBusInterface | getExportedObject(String
source _source, String path _path)Implements abstract org. Retrieves an remote object using source and path. |
| public String | getMachineId()
Implements abstract org. The generated UUID of this machine. |
| public String[] | |
| public DBusInterface | getPeerRemoteObject(String
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". _busname, String The path on which the process is exporting the object.$ _objectpath)Implements org. Return a reference to a remote object. |
| public DBusInterface | getRemoteObject(String
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". _busname, String The path on which the process is exporting the object. _objectpath)Implements org. Return a reference to a remote object. |
| public <I extends DBusInterface> I | getRemoteObject(String
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". _busname, String The path on which the process is exporting the object. _objectpath, Class<I> 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. _type, boolean 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. _autostart)Implements org. Return a reference to a remote object. |
| public String | |
| public void | |
| public void | releaseBusName(String
The name to release. MUST be in dot-notation like "org.freedesktop.local" _busname)Release a bus name. |
| public void | removeGenericSigHandler(DBusMatchRule
rule to remove _rule, DBusSigHandler<DBusSignal> handler to remove _handler)Implements abstract org. Remove a generic signal handler with the given |
| public < class extending T extends DBusSignal> voidDBusSignal | removeSigHandler(Class<T>
The signal to watch for. _type, String The source of the signal. _source, DBusSigHandler<T> the handler _handler)Remove a Signal Handler. |
| public < class extending T extends DBusSignal> voidDBusSignal | removeSigHandler(Class<T>
The signal to watch for. _type, String The source of the signal. _source, DBusInterface The object emitting the signal. _object, DBusSigHandler<T> the handler _handler)Remove a Signal Handler. |
| protected <T extends DBusSignal> void | removeSigHandler(DBusMatchRule
rule to remove _rule, DBusSigHandler<T> handler to remove _handler)Implements abstract org. Remove a match rule with the given |
| public void | requestBusName(String
The name to respond to. MUST be in dot-notation like "org.freedesktop.local" _busname)Request a bus name. |
| private < type of class T extends DBusSignal> void | validateSignal(Class<T>
class _type, String _source)Checks if given type is a DBusSignal and matches the required rules. |
| busnames | back to summary |
|---|---|
| private final List<String> busnames | |
| concurrentConnections | back to summary |
|---|---|
| pack-priv final AtomicInteger concurrentConnections Count how many 'connections' we manage internally.
This is required because a | |
| CONNECTIONS | back to summary |
|---|---|
| pack-priv static final ConcurrentMap<String, DBusConnection> CONNECTIONS | |
| dbus | back to summary |
|---|---|
| private DBus dbus | |
| logger | back to summary |
|---|---|
| private final Logger logger Hides org. | |
| machineId | back to summary |
|---|---|
| private final String machineId | |
| registered | back to summary |
|---|---|
| private boolean registered Whether the connection was registered using 'Hello' message. | |
| shared | back to summary |
|---|---|
| private final boolean shared Whether this connection is used in shared mode. | |
| DBusConnection | back to summary |
|---|---|
| pack-priv DBusConnection(boolean _shared, String _machineId, ConnectionConfig _conCfg, TransportConfig _tranportCfg, ReceivingServiceConfig _rsCfg) throws DBusException | |
| addGenericSigHandler | back to summary |
|---|---|
| public AutoCloseable addGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException Implements abstract org. Doc from org. Adds a
| |
| addSigHandler | back to summary |
|---|---|
| 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.
| |
| addSigHandler | back to summary |
|---|---|
| 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.
| |
| addSigHandler | back to summary |
|---|---|
| public <T extends DBusSignal> AutoCloseable addSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) throws DBusException Implements abstract org. Doc from org. Add a signal handler with the given
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides org. Implements java. Same as disconnect.
| |
| connectImpl | back to summary |
|---|---|
| pack-priv void connectImpl() throws DBusException Connect to bus and register if asked. Should only be called by Builder.
| |
| disconnect | back to summary |
|---|---|
| public synchronized void disconnect() Overrides org. 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.
| |
| doWithBusNames | back to summary |
|---|---|
| private void doWithBusNames(Consumer<List<String>> _action) Do some action with the currently registered names in a synchronized manor. | |
| doWithBusNamesAndReturn | back to summary |
|---|---|
| private <T> T doWithBusNamesAndReturn(Function<List<String>, T> _action) Do some action with the currently registered names in a synchronized manor. | |
| dynamicProxy | back to summary |
|---|---|
| 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. API Note This method is only intended for internal use. Visibility may change in future release
| |
| getConcurrentConnections | back to summary |
|---|---|
| private AtomicInteger getConcurrentConnections() | |
| getDBusOwnerName | back to summary |
|---|---|
| public String getDBusOwnerName(String _busName) Implements org. Doc from org. Returns name of the current owning dbus session. | |
| getExportedObject | back to summary |
|---|---|
| public <T extends DBusInterface> T getExportedObject(String _source, String _path, Class<T> _type) throws DBusException Implements abstract org. Doc from org. Retrieves an remote object using source and path. Will use the given type as object class.
| |
| getExportedObject | back to summary |
|---|---|
| public DBusInterface getExportedObject(String _source, String _path) throws DBusException Implements abstract org. Doc from org. Retrieves an remote object using source and path. Will try to find suitable exported DBusInterface automatically.
| |
| getMachineId | back to summary |
|---|---|
| public String getMachineId() Implements abstract org. Doc from org. The generated UUID of this machine. | |
| getNames | back to summary |
|---|---|
| public String[] getNames() Returns all the names owned by this connection.
| |
| getPeerRemoteObject | back to summary |
|---|---|
| public DBusInterface getPeerRemoteObject(String _busname, String _objectpath) throws InvalidBusNameException, DBusException Implements org. Doc from org. 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.
| |
| getRemoteObject | back to summary |
|---|---|
| public DBusInterface getRemoteObject(String _busname, String _objectpath) throws DBusException, InvalidBusNameException, InvalidObjectPathException Implements org. Doc from org. 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.
| |
| getRemoteObject | back to summary |
|---|---|
| public <I extends DBusInterface> I getRemoteObject(String _busname, String _objectpath, Class<I> _type, boolean _autostart) throws DBusException Implements org. Doc from org. 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 process.
| |
| getUniqueName | back to summary |
|---|---|
| public String getUniqueName() Returns the unique name of this connection.
| |
| register | back to summary |
|---|---|
| public void register() throws DBusException Register this connection on the bus using 'Hello' message.
| |
| releaseBusName | back to summary |
|---|---|
| public void releaseBusName(String _busname) throws DBusException Release a bus name. Releases the name so that other people can use it
| |
| removeGenericSigHandler | back to summary |
|---|---|
| public void removeGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException Implements abstract org. Doc from org. Remove a generic signal handler with the given
| |
| removeSigHandler | back to summary |
|---|---|
| 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.
| |
| removeSigHandler | back to summary |
|---|---|
| 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.
| |
| removeSigHandler | back to summary |
|---|---|
| protected <T extends DBusSignal> void removeSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) throws DBusException Implements abstract org. Doc from org. Remove a match rule with the given
| |
| requestBusName | back to summary |
|---|---|
| public void requestBusName(String _busname) throws DBusException Request a bus name. Request the well known name that this should respond to on the Bus.
| |
| validateSignal | back to summary |
|---|---|
| private <T extends DBusSignal> void validateSignal(Class<T> _type, String _source) throws DBusException Checks if given type is a DBusSignal and matches the required rules.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final DBusConnection. | SESSION
Session Bus |
| public static final DBusConnection. | SYSTEM
System Bus |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static DBusConnection. | |
| public static DBusConnection. |
| SESSION | back to summary |
|---|---|
| public static final DBusConnection. Session Bus | |
| SYSTEM | back to summary |
|---|---|
| public static final DBusConnection. System Bus | |
| DBusBusType | back to summary |
|---|---|
| private DBusBusType() | |
| valueOf | back to summary |
|---|---|
| public static DBusConnection. | |
| values | back to summary |
|---|---|
| public static DBusConnection. | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | handle(DBusSignal
The signal to handle. If such a class exists, the signal will be an instance of the class with the
correct type signature. Otherwise it will be an instance of DBusSignal _signal)Implements org. Handle a signal. |
| SigHandler | back to summary |
|---|---|
| private SigHandler() | |
| handle | back to summary |
|---|---|
| public void handle(DBusSignal _signal) Implements org. Doc from org. Handle a signal.
| |