|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.freedesktop.dbus.AbstractConnection org.freedesktop.dbus.DBusConnection
public class DBusConnection
Handles a connection to DBus.
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.
Nested Class Summary | |
---|---|
class |
DBusConnection.PeerSet
Add addresses of peers to a set which will watch for them to disappear and automatically remove them from the set. |
Nested classes/interfaces inherited from class org.freedesktop.dbus.AbstractConnection |
---|
AbstractConnection._thread, AbstractConnection._workerthread, AbstractConnection.FallbackContainer |
Field Summary | |
---|---|
static String |
DEFAULT_SYSTEM_BUS_ADDRESS
|
static int |
SESSION
Session Bus |
static int |
SYSTEM
System Bus |
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 |
Method Summary | ||
---|---|---|
|
addSigHandler(Class<T> type,
String source,
DBusInterface object,
DBusSigHandler<T> handler)
Add a Signal Handler. |
|
|
addSigHandler(Class<T> type,
String source,
DBusSigHandler<T> handler)
Add a Signal Handler. |
|
protected
|
addSigHandler(DBusMatchRule rule,
DBusSigHandler<T> handler)
|
|
void |
disconnect()
Disconnect from the Bus. |
|
static DBusConnection |
getConnection(int bustype)
Connect to the BUS. |
|
static DBusConnection |
getConnection(String address)
Connect to the BUS. |
|
String[] |
getNames()
Returns all the names owned by this connection. |
|
DBusInterface |
getPeerRemoteObject(String busname,
String objectpath)
Return a reference to a remote object. |
|
|
getPeerRemoteObject(String busname,
String objectpath,
Class<I> type)
|
|
|
getPeerRemoteObject(String busname,
String objectpath,
Class<I> type,
boolean autostart)
Return a reference to a remote object. |
|
DBusInterface |
getRemoteObject(String busname,
String objectpath)
Return a reference to a remote object. |
|
|
getRemoteObject(String busname,
String objectpath,
Class<I> type)
Return a reference to a remote object. |
|
|
getRemoteObject(String busname,
String objectpath,
Class<I> type,
boolean autostart)
Return a reference to a remote object. |
|
String |
getUniqueName()
Returns the unique name of this connection. |
|
void |
releaseBusName(String busname)
Release a bus name. |
|
|
removeSigHandler(Class<T> type,
String source,
DBusInterface object,
DBusSigHandler<T> handler)
Remove a Signal Handler. |
|
|
removeSigHandler(Class<T> type,
String source,
DBusSigHandler<T> handler)
Remove a Signal Handler. |
|
protected
|
removeSigHandler(DBusMatchRule rule,
DBusSigHandler<T> handler)
|
|
void |
requestBusName(String busname)
Request a bus name. |
Methods inherited from class org.freedesktop.dbus.AbstractConnection |
---|
addFallback, addSigHandler, addSigHandler, addSigHandlerWithoutMatch, callMethodAsync, callWithCallback, changeThreadCount, exportObject, finalize, getAddress, getCallInfo, getError, listen, removeFallback, removeSigHandler, removeSigHandler, sendMessage, sendSignal, setWeakReferences, unExportObject |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SYSTEM
public static final int SESSION
public static final String DEFAULT_SYSTEM_BUS_ADDRESS
Method Detail |
---|
public static DBusConnection getConnection(String address) throws DBusException
address
- The address of the bus to connect to
DBusException
- If there is a problem connecting to the Bus.public static DBusConnection getConnection(int bustype) throws DBusException
bustype
- The Bus to connect to.
DBusException
- If there is a problem connecting to the Bus.SYSTEM
,
SESSION
public void releaseBusName(String busname) throws DBusException
busname
- The name to release. MUST be in dot-notation like "org.freedesktop.local"
DBusException
- If the busname is incorrectly formatted.public void requestBusName(String busname) throws DBusException
busname
- The name to respond to. MUST be in dot-notation like "org.freedesktop.local"
DBusException
- If the register name failed, or our name already exists on the bus.
or if busname is incorrectly formatted.public String getUniqueName()
public String[] getNames()
public <I extends DBusInterface> I getPeerRemoteObject(String busname, String objectpath, Class<I> type) throws DBusException
DBusException
public DBusInterface getPeerRemoteObject(String busname, String objectpath) throws DBusException
busname
- 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".objectpath
- The path on which the process is exporting the object.$
ClassCastException
- If type is not a sub-type of DBusInterface
DBusException
- If busname or objectpath are incorrectly formatted.public DBusInterface getRemoteObject(String busname, String objectpath) throws DBusException
busname
- 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".objectpath
- The path on which the process is exporting the object.
ClassCastException
- If type is not a sub-type of DBusInterface
DBusException
- If busname or objectpath are incorrectly formatted.public <I extends DBusInterface> I getPeerRemoteObject(String busname, String objectpath, Class<I> type, boolean autostart) throws DBusException
busname
- 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".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.autostart
- 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.
ClassCastException
- If type is not a sub-type of DBusInterface
DBusException
- If busname or objectpath are incorrectly formatted or type is not in a package.public <I extends DBusInterface> I getRemoteObject(String busname, String objectpath, Class<I> type) throws DBusException
busname
- 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".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.
ClassCastException
- If type is not a sub-type of DBusInterface
DBusException
- If busname or objectpath are incorrectly formatted or type is not in a package.public <I extends DBusInterface> I getRemoteObject(String busname, String objectpath, Class<I> type, boolean autostart) throws DBusException
busname
- 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".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.autostart
- 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.
ClassCastException
- If type is not a sub-type of DBusInterface
DBusException
- If busname or objectpath are incorrectly formatted or type is not in a package.public <T extends DBusSignal> void removeSigHandler(Class<T> type, String source, DBusSigHandler<T> handler) throws DBusException
type
- The signal to watch for.source
- The source of the signal.
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 removeSigHandler(Class<T> type, String source, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
type
- The signal to watch for.source
- The source of the signal.object
- The object emitting the signal.
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 removeSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler) throws DBusException
removeSigHandler
in class AbstractConnection
DBusException
public <T extends DBusSignal> void addSigHandler(Class<T> type, String source, DBusSigHandler<T> handler) throws DBusException
type
- The signal to watch for.source
- The process which will send the signal. This MUST be a unique bus name and not a well known name.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, String source, DBusInterface object, DBusSigHandler<T> handler) throws DBusException
type
- The signal to watch for.source
- The process which will send the signal. This MUST be a unique bus name and not a well known name.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 addSigHandler(DBusMatchRule rule, DBusSigHandler<T> handler) throws DBusException
addSigHandler
in class AbstractConnection
DBusException
public void disconnect()
disconnect
in class AbstractConnection
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |