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 |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractConnection(String address) |
| 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) |
<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) |
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 newcount)
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.
|
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.
|
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,List<DBusSigHandler<DBusSignal>>> |
getGenericHandledSignals() |
protected Map<SignalTuple,List<DBusSigHandler<? extends DBusSignal>>> |
getHandledSignals() |
protected Map<DBusInterface,RemoteObject> |
getImportedObjects() |
abstract String |
getMachineId() |
protected ObjectTree |
getObjectTree() |
protected Map<Long,MethodCall> |
getPendingCalls() |
protected Queue<Error> |
getPendingErrorQueue() |
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) |
<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) |
void |
sendMessage(Message _message)
Send a message or signal to the DBus daemon.
|
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 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) 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
DBusExceptionprotected abstract <T extends DBusSignal> void addSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler) throws DBusException
DBusExceptionprotected abstract void removeGenericSigHandler(DBusMatchRule rule, DBusSigHandler<DBusSignal> handler) throws DBusException
DBusExceptionprotected abstract void addGenericSigHandler(DBusMatchRule rule, DBusSigHandler<DBusSignal> handler) throws DBusException
DBusExceptionpublic abstract String getMachineId()
protected void listen()
public void changeThreadCount(byte newcount)
newcount - 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
DBusExceptionpublic 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,List<DBusSigHandler<? extends DBusSignal>>> getHandledSignals()
protected Map<SignalTuple,List<DBusSigHandler<DBusSignal>>> getGenericHandledSignals()
protected Map<Long,MethodCall> getPendingCalls()
protected Map<DBusInterface,RemoteObject> getImportedObjects()
protected ObjectTree getObjectTree()
Copyright © 2020. All rights reserved.