public abstract class AbstractConnection extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
static String |
BUSNAME_REGEX |
static String |
CONNID_REGEX |
static Pattern |
DOLLAR_PATTERN |
static boolean |
FLOAT_SUPPORT |
static int |
MAX_ARRAY_LENGTH |
static int |
MAX_NAME_LENGTH |
static String |
OBJECT_REGEX |
static int |
TCP_CONNECT_TIMEOUT
Connect timeout, used for TCP only
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractConnection(String address,
int timeout) |
| Modifier and Type | Method and Description |
|---|---|
void |
addFallback(String _objectPrefix,
DBusInterface _object)
Export an object as a fallback object.
|
protected abstract void |
addGenericSigHandler(DBusMatchRule _rule,
DBusSigHandler<DBusSignal> _handler)
Adds a
DBusMatchRule to with a generic signal handler. |
<T extends DBusSignal> |
addSigHandler(Class<T> type,
DBusInterface object,
DBusSigHandler<T> handler)
Add a Signal Handler.
|
<T extends DBusSignal> |
addSigHandler(Class<T> type,
DBusSigHandler<T> handler)
Add a Signal Handler.
|
protected abstract <T extends DBusSignal> |
addSigHandler(DBusMatchRule _rule,
DBusSigHandler<T> _handler)
Add a signal handler with the given
DBusMatchRule to DBus. |
protected <T extends DBusSignal> |
addSigHandlerWithoutMatch(Class<? extends DBusSignal> signal,
DBusSigHandler<T> handler) |
DBusAsyncReply<?> |
callMethodAsync(DBusInterface object,
String m,
Object... parameters)
Call a method asynchronously and get a handle with which to get the reply.
|
<A> void |
callWithCallback(DBusInterface object,
String m,
CallbackHandler<A> callback,
Object... parameters)
Call a method asynchronously and set a callback.
|
void |
changeThreadCount(byte _newPoolSize)
Change the number of worker threads to receive method calls and handle signals.
|
void |
close()
Disconnect this session (for use in try-with-resources).
|
void |
disconnect()
Disconnect from the Bus.
|
protected void |
disconnect(IDisconnectAction _before,
IDisconnectAction _after)
Special disconnect method which may be used whenever some cleanup before or after
disconnection to DBus is required.
|
void |
exportObject(String objectpath,
DBusInterface object)
Export an object so that its methods can be called on DBus.
|
BusAddress |
getAddress()
Returns the address this connection is connected to.
|
static DBusCallInfo |
getCallInfo()
Returns a structure with information on the current method call.
|
static byte |
getEndianness()
Get current endianness to use.
|
DBusExecutionException |
getError()
Return any DBus error which has been received.
|
String |
getExportedObject(DBusInterface _interface) |
abstract DBusInterface |
getExportedObject(String source,
String path) |
protected Map<String,ExportedObject> |
getExportedObjects() |
protected Map<SignalTuple,Queue<DBusSigHandler<DBusSignal>>> |
getGenericHandledSignals() |
protected Map<SignalTuple,Queue<DBusSigHandler<? extends DBusSignal>>> |
getHandledSignals() |
protected Map<DBusInterface,RemoteObject> |
getImportedObjects() |
abstract String |
getMachineId()
The generated UUID of this machine.
|
protected ObjectTree |
getObjectTree() |
protected Map<Long,MethodCall> |
getPendingCalls() |
protected Queue<Error> |
getPendingErrorQueue() |
static byte |
getSystemEndianness()
Get the default system endianness.
|
protected void |
handleException(AbstractConnection dbusConnection,
Message methodOrSignal,
DBusExecutionException exception) |
boolean |
isConnected() |
protected void |
listen()
Start reading and sending messages.
|
void |
queueCallback(MethodCall _call,
Method _method,
CallbackHandler<?> _callback) |
void |
removeFallback(String _objectprefix)
Remove a fallback
|
protected abstract void |
removeGenericSigHandler(DBusMatchRule _rule,
DBusSigHandler<DBusSignal> _handler)
Remove a generic signal handler with the given
DBusMatchRule. |
<T extends DBusSignal> |
removeSigHandler(Class<T> type,
DBusInterface object,
DBusSigHandler<T> handler)
Remove a Signal Handler.
|
<T extends DBusSignal> |
removeSigHandler(Class<T> type,
DBusSigHandler<T> handler)
Remove a Signal Handler.
|
protected abstract <T extends DBusSignal> |
removeSigHandler(DBusMatchRule _rule,
DBusSigHandler<T> _handler)
Remove a match rule with the given
DBusSigHandler. |
void |
sendMessage(Message _message)
Send a message or signal to the DBus daemon.
|
static void |
setEndianness(byte _b)
Set the endianness to use for all connections.
|
void |
setWeakReferences(boolean _weakreferences)
If set to true the bus will not hold a strong reference to exported objects.
|
void |
unExportObject(String _objectpath)
Stop Exporting an object
|
public static final int TCP_CONNECT_TIMEOUT
public static final boolean FLOAT_SUPPORT
public static final String BUSNAME_REGEX
public static final String CONNID_REGEX
public static final String OBJECT_REGEX
public static final Pattern DOLLAR_PATTERN
public static final int MAX_ARRAY_LENGTH
public static final int MAX_NAME_LENGTH
protected AbstractConnection(String address, int timeout) throws DBusException
DBusExceptionpublic abstract DBusInterface getExportedObject(String source, String path) throws DBusException
DBusExceptionprotected abstract <T extends DBusSignal> void removeSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) throws DBusException
DBusSigHandler.
The rule will only be removed from DBus if no other additional handlers are registered to the same rule._rule - rule to remove_handler - handler to removeDBusException - on errorprotected abstract <T extends DBusSignal> void addSigHandler(DBusMatchRule _rule, DBusSigHandler<T> _handler) throws DBusException
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._rule - rule to add_handler - handler to useDBusException - on errorprotected abstract void removeGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException
DBusMatchRule.
The rule will only be removed from DBus if no other additional handlers are registered to the same rule._rule - rule to remove_handler - handler to removeDBusException - on errorprotected abstract void addGenericSigHandler(DBusMatchRule _rule, DBusSigHandler<DBusSignal> _handler) throws DBusException
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._rule - rule to add_handler - handler to useDBusException - on errorpublic abstract String getMachineId()
protected void listen()
public void changeThreadCount(byte _newPoolSize)
_newPoolSize - The new number of worker Threads to use.public String getExportedObject(DBusInterface _interface) throws DBusException
DBusExceptionpublic void setWeakReferences(boolean _weakreferences)
_weakreferences - referencepublic void exportObject(String objectpath, DBusInterface object) throws DBusException
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.DBusException - If the objectpath is already exporting an object. or if objectpath is incorrectly formatted,public void addFallback(String _objectPrefix, DBusInterface _object) throws DBusException
_objectPrefix - The path below which the fallback handles calls. MUST be in slash-notation, like
"/org/freedesktop/Local",_object - The object to export.DBusException - If the objectpath is incorrectly formatted,public void removeFallback(String _objectprefix)
_objectprefix - The prefix to remove the fallback for.public void unExportObject(String _objectpath)
_objectpath - The objectpath to stop exporting.public void sendMessage(Message _message)
_message - message to sendpublic <T extends DBusSignal> void removeSigHandler(Class<T> type, DBusSigHandler<T> handler) throws DBusException
T - class extending DBusSignaltype - The signal to watch for.handler - the handlerDBusException - If listening for the signal on the bus failed.ClassCastException - If type is not a sub-type of DBusSignal.public <T extends DBusSignal> void removeSigHandler(Class<T> type, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
T - class extending DBusSignaltype - The signal to watch for.object - The object emitting the signal.handler - the handlerDBusException - If listening for the signal on the bus failed.ClassCastException - If type is not a sub-type of DBusSignal.public <T extends DBusSignal> void addSigHandler(Class<T> type, DBusSigHandler<T> handler) throws DBusException
T - class extending DBusSignaltype - The signal to watch for.handler - The handler to call when a signal is received.DBusException - If listening for the signal on the bus failed.ClassCastException - If type is not a sub-type of DBusSignal.public <T extends DBusSignal> void addSigHandler(Class<T> type, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
T - class extending DBusSignaltype - The signal to watch for.object - The object from which the signal will be emittedhandler - The handler to call when a signal is received.DBusException - If listening for the signal on the bus failed.ClassCastException - If type is not a sub-type of DBusSignal.protected <T extends DBusSignal> void addSigHandlerWithoutMatch(Class<? extends DBusSignal> signal, DBusSigHandler<T> handler) throws DBusException
DBusExceptionprotected void disconnect(IDisconnectAction _before, IDisconnectAction _after)
_before - action execute before actual disconnect, null if not needed_after - action execute after disconnect, null if not neededpublic void disconnect()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic <A> void callWithCallback(DBusInterface object, String m, CallbackHandler<A> callback, Object... parameters)
A - whateverobject - 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.public DBusAsyncReply<?> callMethodAsync(DBusInterface object, String m, Object... parameters)
object - The remote object on which to call the method.m - The name of the method on the interface to call.parameters - The parameters to call the method with.protected void handleException(AbstractConnection dbusConnection, Message methodOrSignal, DBusExecutionException exception)
public void queueCallback(MethodCall _call, Method _method, CallbackHandler<?> _callback)
protected Map<String,ExportedObject> getExportedObjects()
public static DBusCallInfo getCallInfo()
public DBusExecutionException getError()
public BusAddress getAddress()
BusAddress objectpublic boolean isConnected()
protected Map<SignalTuple,Queue<DBusSigHandler<? extends DBusSignal>>> getHandledSignals()
protected Map<SignalTuple,Queue<DBusSigHandler<DBusSignal>>> getGenericHandledSignals()
protected Map<Long,MethodCall> getPendingCalls()
protected Map<DBusInterface,RemoteObject> getImportedObjects()
protected ObjectTree getObjectTree()
public static void setEndianness(byte _b)
_b - Message.Endian.BIG or Message.Endian.LITTLEpublic static byte getEndianness()
public static byte getSystemEndianness()
Copyright © 2020. All rights reserved.