Package org.freedesktop.dbus
Class DirectConnection
- java.lang.Object
-
- org.freedesktop.dbus.AbstractConnection
-
- org.freedesktop.dbus.DirectConnection
-
public class DirectConnection extends AbstractConnection
Handles a peer to peer connection between two applications withou a bus daemon.Signal Handlers and method calls from remote objects are run in their own threads, you MUST handle the concurrency issues.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.freedesktop.dbus.AbstractConnection
AbstractConnection._thread, AbstractConnection._workerthread, AbstractConnection.FallbackContainer
-
-
Field Summary
-
Fields inherited from class org.freedesktop.dbus.AbstractConnection
_run, addr, connected, EXCEPTION_DEBUG, exportedObjects, fallbackcontainer, handledSignals, importedObjects, pendingCallbackReplys, pendingCallbacks, pendingCalls, runnables, sender, thread, TIMEOUT, transport, weakreferences, workers
-
-
Constructor Summary
Constructors Constructor Description DirectConnection(java.lang.String address)
Create a direct connection to another application.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T extends DBusSignal>
voidaddSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler)
static java.lang.String
createDynamicSession()
Creates a bus address for a randomly generated abstract unix socket.static java.lang.String
createDynamicTCPSession()
Creates a bus address for a randomly generated tcp port.DBusInterface
getRemoteObject(java.lang.String objectpath)
Return a reference to a remote object.DBusInterface
getRemoteObject(java.lang.String objectpath, java.lang.Class<? extends DBusInterface> type)
Return a reference to a remote object.protected <T extends DBusSignal>
voidremoveSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler)
-
Methods inherited from class org.freedesktop.dbus.AbstractConnection
addFallback, addSigHandler, addSigHandler, addSigHandlerWithoutMatch, callMethodAsync, callWithCallback, changeThreadCount, disconnect, exportObject, finalize, getAddress, getCallInfo, getError, listen, removeFallback, removeSigHandler, removeSigHandler, sendMessage, sendSignal, setWeakReferences, unExportObject
-
-
-
-
Constructor Detail
-
DirectConnection
public DirectConnection(java.lang.String address) throws DBusException
Create a direct connection to another application.- Parameters:
address
- The address to connect to. This is a standard D-Bus address, except that the additional parameter 'listen=true' should be added in the application which is creating the socket.- Throws:
DBusException
-
-
Method Detail
-
createDynamicTCPSession
public static java.lang.String createDynamicTCPSession()
Creates a bus address for a randomly generated tcp port.- Returns:
- a random bus address.
-
createDynamicSession
public static java.lang.String createDynamicSession()
Creates a bus address for a randomly generated abstract unix socket.- Returns:
- a random bus address.
-
getRemoteObject
public DBusInterface getRemoteObject(java.lang.String objectpath) 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. 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.- Parameters:
objectpath
- The path on which the process is exporting the object.- Returns:
- A reference to a remote object.
- Throws:
java.lang.ClassCastException
- If type is not a sub-type of DBusInterfaceDBusException
- If busname or objectpath are incorrectly formatted.
-
getRemoteObject
public DBusInterface getRemoteObject(java.lang.String objectpath, java.lang.Class<? extends DBusInterface> 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.- Parameters:
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.- Returns:
- A reference to a remote object.
- Throws:
java.lang.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
protected <T extends DBusSignal> void removeSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler) throws DBusException
- Specified by:
removeSigHandler
in classAbstractConnection
- Throws:
DBusException
-
addSigHandler
protected <T extends DBusSignal> void addSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler) throws DBusException
- Specified by:
addSigHandler
in classAbstractConnection
- Throws:
DBusException
-
-