java.lang.Object
org.freedesktop.dbus.connections.AbstractConnection
- Alle implementierten Schnittstellen:
Closeable,AutoCloseable
- Bekannte direkte Unterklassen:
DBusConnection,DirectConnection
Handles a connection to DBus.
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final Patternstatic final Patternstatic final Patternstatic final booleanstatic final intstatic final intstatic final Patternstatic final StringVeraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.is no longer in usestatic final intVeraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.no longer used -
Konstruktorübersicht
KonstruktorenModifiziererKonstruktorBeschreibungprotectedAbstractConnection(TransportConfig _transportConfig, ReceivingServiceConfig _rsCfg) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidaddFallback(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.protected 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.voidchangeThreadCount(byte _newPoolSize) Veraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.does nothing as threading has been changed significantlyvoidclose()Disconnect this session (for use in try-with-resources).booleanconnect()Connects the underlying transport if it is not already connected.voidDisconnect from the Bus.protected voiddisconnect(IDisconnectAction _before, IDisconnectAction _after) Special disconnect method which may be used whenever some cleanup before or after disconnection to DBus is required.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.Returns the address this connection is connected to.static DBusCallInfoReturns a structure with information on the current method call.Returns the currently configured disconnect callback.static byteGet current endianness to use.getError()Return any DBus error which has been received.abstract DBusInterfacegetExportedObject(String _source, String _path) Retrieves an remote object using source and path.abstract <T extends DBusInterface>
TgetExportedObject(String _source, String _path, Class<T> _type) Retrieves an remote object using source and path.getExportedObject(DBusInterface _interface) protected Map<String, ExportedObject> protected Map<DBusMatchRule, Queue<DBusSigHandler<DBusSignal>>> protected Map<DBusMatchRule, Queue<DBusSigHandler<? extends DBusSignal>>> protected Map<DBusInterface, RemoteObject> abstract StringThe generated UUID of this machine.protected ObjectTreeprotected Map<Long, MethodCall> static byteVeraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.useBaseConnectionBuilder.getSystemEndianness()insteadprotected TransportConfigReturns the transport's configuration.
Please note: changing any value will not change the transport settings!protected voidhandleException(Message _methodOrSignal, DBusExecutionException _exception) protected final voidinternalDisconnect(IOException _connectionError) Disconnects the DBus session.booleanprotected voidlisten()Start reading and sending messages.voidqueueCallback(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.protected abstract <T extends DBusSignal>
voidremoveSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) Remove a match rule with the givenDBusSigHandler.voidsendMessage(Message _message) Send a message or signal to the DBus daemon.voidsetDisconnectCallback(IDisconnectCallback _disconnectCallback) Set the callback which will be notified when a disconnection happens.static voidsetEndianness(byte _b) Set the endianness to use for all connections.voidsetWeakReferences(boolean _weakreferences) If set to true the bus will not hold a strong reference to exported objects.toString()voidunExportObject(String _objectpath) Stop Exporting an object
-
Felddetails
-
FLOAT_SUPPORT
public static final boolean FLOAT_SUPPORT -
BUSNAME_REGEX
-
CONNID_REGEX
-
OBJECT_REGEX_PATTERN
-
DOLLAR_PATTERN
-
MAX_ARRAY_LENGTH
public static final int MAX_ARRAY_LENGTH- Siehe auch:
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTH- Siehe auch:
-
TCP_CONNECT_TIMEOUT
@Deprecated(forRemoval=true, since="4.2.2 - 2022-12-23") public static final int TCP_CONNECT_TIMEOUTVeraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.no longer usedConnect timeout, used for TCP only.- Siehe auch:
-
TCP_ADDRESS_PROPERTY
@Deprecated(since="4.2.0 - 2022-08-04", forRemoval=true) public static final String TCP_ADDRESS_PROPERTYVeraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.is no longer in useSystem property name containing the DBUS TCP SESSION address used by dbus-java DBusDaemon in TCP mode.- Siehe auch:
-
-
Konstruktordetails
-
AbstractConnection
protected AbstractConnection(TransportConfig _transportConfig, ReceivingServiceConfig _rsCfg) throws DBusException - Löst aus:
DBusException
-
-
Methodendetails
-
getExportedObject
Retrieves an remote object using source and path. Will try to find suitable exported DBusInterface automatically.- Parameter:
_source- source_path- path- Gibt zurück:
DBusInterfacecompatible object- Löst aus:
DBusException
-
getExportedObject
public abstract <T extends DBusInterface> T getExportedObject(String _source, String _path, Class<T> _type) throws DBusException Retrieves an remote object using source and path. Will use the given type as object class.- Parameter:
_source- source_path- path_type- class of remote object- Gibt zurück:
DBusInterfacecompatible object- Löst aus:
DBusException
-
removeSigHandler
protected 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.- Typparameter:
T- signal type- Parameter:
_rule- rule to remove_handler- handler to remove- Löst aus:
DBusException- on error
-
addSigHandler
protected 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.- 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
-
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.- Parameter:
_rule- rule to remove_handler- handler to remove- Löst aus:
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.- Parameter:
_rule- rule to add_handler- handler to use- Gibt zurück:
- closeable that removes signal handler
- Löst aus:
DBusException- on error
-
getMachineId
The generated UUID of this machine.- Gibt zurück:
- String
-
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.- Typparameter:
T- any DBusInterface compatible object- Parameter:
_type- type or null_ifaces- interfaces to examining when type is null- Gibt zurück:
- List
-
listen
protected void listen()Start reading and sending messages. -
getExportedObject
- Löst aus:
DBusException
-
changeThreadCount
Veraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.does nothing as threading has been changed significantlyChange the number of worker threads to receive method calls and handle signals. Default is 4 threads- Parameter:
_newPoolSize- The new number of worker Threads to use.
-
setWeakReferences
public void setWeakReferences(boolean _weakreferences) 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.- Parameter:
_weakreferences- reference
-
exportObject
Export an object so that its methods can be called on DBus.- Parameter:
_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.- Löst aus:
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).- Parameter:
_object- The object to export.- Löst aus:
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.- Parameter:
_objectPrefix- The path below which the fallback handles calls. MUST be in slash-notation, like "/org/freedesktop/Local",_object- The object to export.- Löst aus:
DBusException- If the objectpath is incorrectly formatted,
-
removeFallback
Remove a fallback- Parameter:
_objectprefix- The prefix to remove the fallback for.
-
unExportObject
Stop Exporting an object- Parameter:
_objectpath- The objectpath to stop exporting.
-
sendMessage
Send a message or signal to the DBus daemon.- Parameter:
_message- message to send
-
removeSigHandler
public <T extends DBusSignal> void removeSigHandler(Class<T> _type, 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._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, 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._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.
-
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.- Typparameter:
T- class extendingDBusSignal- Parameter:
_type- The signal to watch for._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, 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.- Typparameter:
T- class extendingDBusSignal- Parameter:
_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.- 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.
-
addSigHandlerWithoutMatch
protected <T extends DBusSignal> void addSigHandlerWithoutMatch(Class<? extends DBusSignal> _signal, DBusSigHandler<T> _handler) throws DBusException - Löst aus:
DBusException
-
disconnect
Special disconnect method which may be used whenever some cleanup before or after disconnection to DBus is required.- Parameter:
_before- action execute before actual disconnect, null if not needed_after- action execute after disconnect, null if not needed
-
internalDisconnect
Disconnects the DBus session. This method is private as it should never be overwritten by subclasses, otherwise we have an endless recursion when usingdisconnect(IDisconnectAction, IDisconnectAction)which then will cause a StackOverflowError.- Parameter:
_connectionError- exception caused the disconnection (null if intended disconnect)
-
disconnect
public void disconnect()Disconnect from the Bus. -
close
Disconnect this session (for use in try-with-resources).- Angegeben von:
closein SchnittstelleAutoCloseable- Angegeben von:
closein SchnittstelleCloseable- Löst aus:
IOException
-
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.- Typparameter:
A- whatever- Parameter:
_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.- Parameter:
_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.- Gibt zurück:
- A handle to the call.
-
handleException
-
queueCallback
-
getExportedObjects
-
getCallInfo
Returns a structure with information on the current method call.- Gibt zurück:
- the DBusCallInfo for this method call, or null if we are not in a method call.
-
getError
Return any DBus error which has been received.- Gibt zurück:
- A DBusExecutionException, or null if no error is pending.
-
getAddress
Returns the address this connection is connected to.- Gibt zurück:
- new
BusAddressobject
-
isConnected
public boolean isConnected() -
connect
Connects the underlying transport if it is not already connected.Will work for both, client and server (listening) connections.
- Gibt zurück:
- true if connection established or already connected, false otherwise
- Löst aus:
IOException- when connection was not already established and creating the connnection failed
-
getPendingErrorQueue
-
getHandledSignals
-
getGenericHandledSignals
-
getPendingCalls
-
getImportedObjects
-
getObjectTree
-
getTransportConfig
Returns the transport's configuration.
Please note: changing any value will not change the transport settings!
This is read-only.- Gibt zurück:
- transport config
-
setEndianness
public static void setEndianness(byte _b) Set the endianness to use for all connections. Defaults to the system architectures endianness.- Parameter:
_b- Message.Endian.BIG or Message.Endian.LITTLE
-
getEndianness
public static byte getEndianness()Get current endianness to use.- Gibt zurück:
- Message.Endian.BIG or Message.Endian.LITTLE
-
getSystemEndianness
Veraltet, zur Entfernung: Dieses API-Element wird in einer zukünftigen Version entfernt.useBaseConnectionBuilder.getSystemEndianness()insteadGet the default system endianness.- Gibt zurück:
- LITTLE or BIG
-
getDisconnectCallback
Returns the currently configured disconnect callback.- Gibt zurück:
- callback or null if no callback registered
-
setDisconnectCallback
Set the callback which will be notified when a disconnection happens. Use null to remove.- Parameter:
_disconnectCallback- callback to execute or null to remove
-
toString
-