keycloak-federation
クラス | 公開メンバ関数 | 静的公開メンバ関数 | 静的公開変数類 | 限定公開メンバ関数 | 限定公開変数類 | 静的限定公開変数類 | 関数 | 静的関数 | 変数 | 静的変数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.freedesktop.dbus.DBusConnection クラス
org.freedesktop.dbus.DBusConnection の継承関係図
Inheritance graph
org.freedesktop.dbus.DBusConnection 連携図
Collaboration graph

クラス

class  _sighandler
 
class  PeerSet
 

公開メンバ関数

void releaseBusName (String busname) throws DBusException
 
void requestBusName (String busname) throws DBusException
 
String getUniqueName ()
 
String [] getNames ()
 
DBusInterface getPeerRemoteObject (String busname, String objectpath) throws DBusException
 
DBusInterface getRemoteObject (String busname, String objectpath) throws DBusException
 
void disconnect ()
 
void changeThreadCount (byte newcount)
 
void setWeakReferences (boolean weakreferences)
 
void exportObject (String objectpath, DBusInterface object) throws DBusException
 
void addFallback (String objectprefix, DBusInterface object) throws DBusException
 
void removeFallback (String objectprefix)
 
void unExportObject (String objectpath)
 
void sendSignal (DBusSignal signal)
 
void finalize ()
 
DBusExecutionException getError ()
 
DBusAsyncReply callMethodAsync (DBusInterface object, String m, Object... parameters)
 
BusAddress getAddress () throws ParseException
 

静的公開メンバ関数

static DBusConnection getConnection (String address) throws DBusException
 
static DBusConnection getConnection (int bustype) throws DBusException
 
static DBusCallInfo getCallInfo ()
 

静的公開変数類

static final int SYSTEM = 0
 
static final int SESSION = 1
 
static final String DEFAULT_SYSTEM_BUS_ADDRESS = "unix:path=/var/run/dbus/system_bus_socket"
 
static final boolean EXCEPTION_DEBUG
 

限定公開メンバ関数

void listen ()
 
void sendMessage (Message m)
 

限定公開変数類

Map< String, ExportedObjectexportedObjects
 
Map< DBusInterface, RemoteObjectimportedObjects
 
Map< SignalTuple, Vector< DBusSigHandler<? extends DBusSignal > > > handledSignals
 
EfficientMap pendingCalls
 
Map< MethodCall, CallbackHandler<? extends Object > > pendingCallbacks
 
Map< MethodCall, DBusAsyncReply<? extends Object > > pendingCallbackReplys
 
LinkedList< Runnable > runnables
 
LinkedList< _workerthreadworkers
 
FallbackContainer fallbackcontainer
 
boolean _run
 
_thread thread
 
_sender sender
 
Transport transport
 
String addr
 
boolean weakreferences = false
 
boolean connected = false
 

静的限定公開変数類

static final int TIMEOUT = 100000
 

関数

DBusInterface dynamicProxy (String source, String path) throws DBusException
 
DBusInterface getExportedObject (String source, String path) throws DBusException
 
public< I extends DBusInterface > I getPeerRemoteObject (String busname, String objectpath, Class< I > type) throws DBusException
 
public< I extends DBusInterface > I getPeerRemoteObject (String busname, String objectpath, Class< I > type, boolean autostart) throws DBusException
 
public< I extends DBusInterface > I getRemoteObject (String busname, String objectpath, Class< I > type) throws DBusException
 
public< I extends DBusInterface > I getRemoteObject (String busname, String objectpath, Class< I > type, boolean autostart) throws DBusException
 
public< T extends DBusSignal > void removeSigHandler (Class< T > type, String source, DBusSigHandler< T > handler) throws DBusException
 
public< T extends DBusSignal > void removeSigHandler (Class< T > type, String source, DBusInterface object, DBusSigHandler< T > handler) throws DBusException
 
protected< T extends DBusSignal > void removeSigHandler (DBusMatchRule rule, DBusSigHandler< T > handler) throws DBusException
 
public< T extends DBusSignal > void addSigHandler (Class< T > type, String source, DBusSigHandler< T > handler) throws DBusException
 
public< T extends DBusSignal > void addSigHandler (Class< T > type, String source, DBusInterface object, DBusSigHandler< T > handler) throws DBusException
 
protected< T extends DBusSignal > void addSigHandler (DBusMatchRule rule, DBusSigHandler< T > handler) throws DBusException
 
String getExportedObject (DBusInterface i) throws DBusException
 
void queueOutgoing (Message m)
 
public< T extends DBusSignal > void removeSigHandler (Class< T > type, DBusSigHandler< T > handler) throws DBusException
 
public< T extends DBusSignal > void removeSigHandler (Class< T > type, DBusInterface object, DBusSigHandler< T > handler) throws DBusException
 
public< T extends DBusSignal > void addSigHandler (Class< T > type, DBusSigHandler< T > handler) throws DBusException
 
public< T extends DBusSignal > void addSigHandler (Class< T > type, DBusInterface object, DBusSigHandler< T > handler) throws DBusException
 
protected< T extends DBusSignal > void addSigHandlerWithoutMatch (Class<? extends DBusSignal > signal, DBusSigHandler< T > handler) throws DBusException
 
public< A > void callWithCallback (DBusInterface object, String m, CallbackHandler< A > callback, Object... parameters)
 

静的関数

 [static initializer]
 

変数

EfficientQueue outgoing
 
LinkedList< ErrorpendingErrors
 

静的変数

static final String BUSNAME_REGEX = "^[-_a-zA-Z][-_a-zA-Z0-9]*(\\.[-_a-zA-Z][-_a-zA-Z0-9]*)*$"
 
static final String CONNID_REGEX = "^:[0-9]*\\.[0-9]*$"
 
static final String OBJECT_REGEX = "^/([-_a-zA-Z0-9]+(/[-_a-zA-Z0-9]+)*)?$"
 
static final byte THREADCOUNT = 4
 
static final int MAX_ARRAY_LENGTH = 67108864
 
static final int MAX_NAME_LENGTH = 255
 
static final Pattern dollar_pattern = Pattern.compile("[$]")
 
static final boolean FLOAT_SUPPORT
 

非公開メンバ関数

 DBusConnection (String address) throws DBusException
 

非公開変数類

List< String > busnames
 
int _refcount = 0
 
Object _reflock = new Object()
 
DBus _dbus
 

静的非公開変数類

static final Map< Object, DBusConnectionconn = new HashMap<Object, 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.

構築子と解体子

◆ DBusConnection()

org.freedesktop.dbus.DBusConnection.DBusConnection ( String  address) throws DBusException
inlineprivate
292  {
293  super(address);
294  busnames = new Vector<String>();
295 
296  synchronized (_reflock) {
297  _refcount = 1;
298  }
299 
300  try {
301  transport = new Transport(addr, AbstractConnection.TIMEOUT);
302  connected = true;
303  } catch (IOException IOe) {
304  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
305  disconnect();
306  throw new DBusException(getString("connectionFailure") + IOe.getMessage());
307  } catch (ParseException Pe) {
308  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, Pe);
309  disconnect();
310  throw new DBusException(getString("connectionFailure") + Pe.getMessage());
311  }
312 
313  // start listening for calls
314  listen();
315 
316  // register disconnect handlers
317  DBusSigHandler h = new _sighandler();
320 
321  // register ourselves
322  _dbus = getRemoteObject("org.freedesktop.DBus", "/org/freedesktop/DBus", DBus.class);
323  try {
324  busnames.add(_dbus.Hello());
325  } catch (DBusExecutionException DBEe) {
326  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
327  throw new DBusException(DBEe.getMessage());
328  }
329  }
DBusInterface getRemoteObject(String busname, String objectpath)
Definition: DBusConnection.java:527
Transport transport
Definition: AbstractConnection.java:257
void listen()
Definition: AbstractConnection.java:317
DBus _dbus
Definition: DBusConnection.java:197
String addr
Definition: AbstractConnection.java:258
Definition: DBus.java:32
List< String > busnames
Definition: DBusConnection.java:192
protected< T extends DBusSignal > void addSigHandlerWithoutMatch(Class<? extends DBusSignal > signal, DBusSigHandler< T > handler)
Definition: AbstractConnection.java:558
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261
Object _reflock
Definition: DBusConnection.java:196
Definition: DBus.java:102
AbstractConnection(String address)
Definition: AbstractConnection.java:289
int _refcount
Definition: DBusConnection.java:195
boolean connected
Definition: AbstractConnection.java:263
Definition: DBus.java:251
void disconnect()
Definition: DBusConnection.java:763

関数詳解

◆ [static initializer]()

org.freedesktop.dbus.AbstractConnection.[static initializer] ( )
inlinestaticpackageinherited

◆ addFallback()

void org.freedesktop.dbus.AbstractConnection.addFallback ( String  objectprefix,
DBusInterface  object 
) throws DBusException
inlineinherited

Export an object as a fallback object. This object will have it's methods invoked for all paths starting with this object path.

引数
objectprefixThe path below which the fallback handles calls. MUST be in slash-notation, like "/org/freedesktop/Local",
objectThe object to export.
例外
DBusExceptionIf the objectpath is incorrectly formatted,
429  {
430  if (null == objectprefix || "".equals(objectprefix))
431  throw new DBusException(getString("missingObjectPath"));
432  if (!objectprefix.matches(OBJECT_REGEX) || objectprefix.length() > MAX_NAME_LENGTH)
433  throw new DBusException(getString("invalidObjectPath") + objectprefix);
434  ExportedObject eo = new ExportedObject(object, weakreferences);
435  fallbackcontainer.add(objectprefix, eo);
436  }
synchronized void add(String path, ExportedObject eo)
Definition: AbstractConnection.java:46
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
FallbackContainer fallbackcontainer
Definition: AbstractConnection.java:250
static final String OBJECT_REGEX
Definition: AbstractConnection.java:236
boolean weakreferences
Definition: AbstractConnection.java:259

◆ addSigHandler() [1/5]

public<T extends DBusSignal> void org.freedesktop.dbus.AbstractConnection.addSigHandler ( Class< T >  type,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackageinherited

Add a Signal Handler. Adds a signal handler to call when a signal is received which matches the specified type and name.

引数
typeThe signal to watch for.
handlerThe handler to call when a signal is received.
例外
DBusExceptionIf listening for the signal on the bus failed.
ClassCastExceptionIf type is not a sub-type of DBusSignal.
532  {
533  if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(getString("notDBusSignal"));
534  addSigHandler(new DBusMatchRule(type), (DBusSigHandler<? extends DBusSignal>) handler);
535  }
public< T extends DBusSignal > void addSigHandler(Class< T > type, DBusSigHandler< T > handler)
Definition: AbstractConnection.java:532

◆ addSigHandler() [2/5]

public<T extends DBusSignal> void org.freedesktop.dbus.AbstractConnection.addSigHandler ( Class< T >  type,
DBusInterface  object,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackageinherited

Add a Signal Handler. Adds a signal handler to call when a signal is received which matches the specified type, name and object.

引数
typeThe signal to watch for.
objectThe object from which the signal will be emitted
handlerThe handler to call when a signal is received.
例外
DBusExceptionIf listening for the signal on the bus failed.
ClassCastExceptionIf type is not a sub-type of DBusSignal.
548  {
549  if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(getString("notDBusSignal"));
550  String objectpath = importedObjects.get(object).objectpath;
551  if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
552  throw new DBusException(getString("invalidObjectPath") + objectpath);
553  addSigHandler(new DBusMatchRule(type, null, objectpath), (DBusSigHandler<? extends DBusSignal>) handler);
554  }
Map< DBusInterface, RemoteObject > importedObjects
Definition: AbstractConnection.java:243
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
public< T extends DBusSignal > void addSigHandler(Class< T > type, DBusSigHandler< T > handler)
Definition: AbstractConnection.java:532
static final String OBJECT_REGEX
Definition: AbstractConnection.java:236

◆ addSigHandler() [3/5]

public<T extends DBusSignal> void org.freedesktop.dbus.DBusConnection.addSigHandler ( Class< T >  type,
String  source,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackage

Add a Signal Handler. Adds a signal handler to call when a signal is received which matches the specified type, name and source.

引数
typeThe signal to watch for.
sourceThe process which will send the signal. This MUST be a unique bus name and not a well known name.
handlerThe handler to call when a signal is received.
例外
DBusExceptionIf listening for the signal on the bus failed.
ClassCastExceptionIf type is not a sub-type of DBusSignal.
708  {
709  if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(getString("notDBusSignal"));
710  if (source.matches(BUSNAME_REGEX)) throw new DBusException(getString("cannotWatchSignalsWellKnownBussName"));
711  if (!source.matches(CONNID_REGEX) || source.length() > MAX_NAME_LENGTH)
712  throw new DBusException(getString("invalidBusName") + source);
713  addSigHandler(new DBusMatchRule(type, source, null), (DBusSigHandler<? extends DBusSignal>) handler);
714  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
public< T extends DBusSignal > void addSigHandler(Class< T > type, String source, DBusSigHandler< T > handler)
Definition: DBusConnection.java:708
static final String CONNID_REGEX
Definition: AbstractConnection.java:235
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239

◆ addSigHandler() [4/5]

public<T extends DBusSignal> void org.freedesktop.dbus.DBusConnection.addSigHandler ( Class< T >  type,
String  source,
DBusInterface  object,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackage

Add a Signal Handler. Adds a signal handler to call when a signal is received which matches the specified type, name, source and object.

引数
typeThe signal to watch for.
sourceThe process which will send the signal. This MUST be a unique bus name and not a well known name.
objectThe object from which the signal will be emitted
handlerThe handler to call when a signal is received.
例外
DBusExceptionIf listening for the signal on the bus failed.
ClassCastExceptionIf type is not a sub-type of DBusSignal.
728  {
729  if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(getString("notDBusSignal"));
730  if (source.matches(BUSNAME_REGEX)) throw new DBusException(getString("cannotWatchSignalsWellKnownBussName"));
731  if (!source.matches(CONNID_REGEX) || source.length() > MAX_NAME_LENGTH)
732  throw new DBusException(getString("invalidBusName") + source);
733  String objectpath = importedObjects.get(object).objectpath;
734  if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
735  throw new DBusException(getString("invalidObjectPath") + objectpath);
736  addSigHandler(new DBusMatchRule(type, source, objectpath), (DBusSigHandler<? extends DBusSignal>) handler);
737  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
Map< DBusInterface, RemoteObject > importedObjects
Definition: AbstractConnection.java:243
public< T extends DBusSignal > void addSigHandler(Class< T > type, String source, DBusSigHandler< T > handler)
Definition: DBusConnection.java:708
static final String CONNID_REGEX
Definition: AbstractConnection.java:235
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
static final String OBJECT_REGEX
Definition: AbstractConnection.java:236

◆ addSigHandler() [5/5]

protected<T extends DBusSignal> void org.freedesktop.dbus.DBusConnection.addSigHandler ( DBusMatchRule  rule,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackage
739  {
740  try {
741  _dbus.AddMatch(rule.toString());
742  } catch (DBusExecutionException DBEe) {
743  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
744  throw new DBusException(DBEe.getMessage());
745  }
746  SignalTuple key = new SignalTuple(rule.getInterface(), rule.getMember(), rule.getObject(), rule.getSource());
747  synchronized (handledSignals) {
748  Vector<DBusSigHandler<? extends DBusSignal>> v = handledSignals.get(key);
749  if (null == v) {
750  v = new Vector<DBusSigHandler<? extends DBusSignal>>();
751  v.add(handler);
752  handledSignals.put(key, v);
753  } else
754  v.add(handler);
755  }
756  }
DBus _dbus
Definition: DBusConnection.java:197
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261
void AddMatch(String matchrule)
Map< SignalTuple, Vector< DBusSigHandler<? extends DBusSignal > > > handledSignals
Definition: AbstractConnection.java:244

◆ addSigHandlerWithoutMatch()

protected<T extends DBusSignal> void org.freedesktop.dbus.AbstractConnection.addSigHandlerWithoutMatch ( Class<? extends DBusSignal signal,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackageinherited
558  {
559  DBusMatchRule rule = new DBusMatchRule(signal);
560  SignalTuple key = new SignalTuple(rule.getInterface(), rule.getMember(), rule.getObject(), rule.getSource());
561  synchronized (handledSignals) {
562  Vector<DBusSigHandler<? extends DBusSignal>> v = handledSignals.get(key);
563  if (null == v) {
564  v = new Vector<DBusSigHandler<? extends DBusSignal>>();
565  v.add(handler);
566  handledSignals.put(key, v);
567  } else
568  v.add(handler);
569  }
570  }
Map< SignalTuple, Vector< DBusSigHandler<? extends DBusSignal > > > handledSignals
Definition: AbstractConnection.java:244

◆ callMethodAsync()

DBusAsyncReply org.freedesktop.dbus.AbstractConnection.callMethodAsync ( DBusInterface  object,
String  m,
Object...  parameters 
)
inlineinherited

Call a method asynchronously and get a handle with which to get the reply.

引数
objectThe remote object on which to call the method.
mThe name of the method on the interface to call.
parametersThe parameters to call the method with.
戻り値
A handle to the call.
680  {
681  Class<?>[] types = new Class[parameters.length];
682  for (int i = 0; i < parameters.length; i++)
683  types[i] = parameters[i].getClass();
684  RemoteObject ro = importedObjects.get(object);
685 
686  try {
687  Method me;
688  if (null == ro.iface)
689  me = object.getClass().getMethod(m, types);
690  else
691  me = ro.iface.getMethod(m, types);
692  return (DBusAsyncReply) RemoteInvocationHandler.executeRemoteMethod(ro, me, this, RemoteInvocationHandler.CALL_TYPE_ASYNC, null, parameters);
693  } catch (DBusExecutionException DBEe) {
694  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
695  throw DBEe;
696  } catch (Exception e) {
697  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
698  throw new DBusExecutionException(e.getMessage());
699  }
700  }
Map< DBusInterface, RemoteObject > importedObjects
Definition: AbstractConnection.java:243
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261

◆ callWithCallback()

public<A> void org.freedesktop.dbus.AbstractConnection.callWithCallback ( DBusInterface  object,
String  m,
CallbackHandler< A >  callback,
Object...  parameters 
)
inlinepackageinherited

Call a method asynchronously and set a callback. This handler will be called in a separate thread.

引数
objectThe remote object on which to call the method.
mThe name of the method on the interface to call.
callbackThe callback handler.
parametersThe parameters to call the method with.
648  {
649  if (Debug.debug) Debug.print(Debug.VERBOSE, "callWithCallback(" + object + "," + m + ", " + callback);
650  Class[] types = new Class[parameters.length];
651  for (int i = 0; i < parameters.length; i++)
652  types[i] = parameters[i].getClass();
653  RemoteObject ro = importedObjects.get(object);
654 
655  try {
656  Method me;
657  if (null == ro.iface)
658  me = object.getClass().getMethod(m, types);
659  else
660  me = ro.iface.getMethod(m, types);
661  RemoteInvocationHandler.executeRemoteMethod(ro, me, this, RemoteInvocationHandler.CALL_TYPE_CALLBACK, callback, parameters);
662  } catch (DBusExecutionException DBEe) {
663  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
664  throw DBEe;
665  } catch (Exception e) {
666  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
667  throw new DBusExecutionException(e.getMessage());
668  }
669  }
Map< DBusInterface, RemoteObject > importedObjects
Definition: AbstractConnection.java:243
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261

◆ changeThreadCount()

void org.freedesktop.dbus.AbstractConnection.changeThreadCount ( byte  newcount)
inlineinherited

Change the number of worker threads to receive method calls and handle signals. Default is 4 threads

引数
newcountThe new number of worker Threads to use.
331  {
332  synchronized (workers) {
333  if (workers.size() > newcount) {
334  int n = workers.size() - newcount;
335  for (int i = 0; i < n; i++) {
336  _workerthread t = workers.removeFirst();
337  t.halt();
338  }
339  } else if (workers.size() < newcount) {
340  int n = newcount - workers.size();
341  for (int i = 0; i < n; i++) {
342  _workerthread t = new _workerthread();
343  t.start();
344  workers.add(t);
345  }
346  }
347  }
348  }
LinkedList< _workerthread > workers
Definition: AbstractConnection.java:249

◆ disconnect()

void org.freedesktop.dbus.DBusConnection.disconnect ( )
inline

Disconnect from the Bus. This only disconnects when the last reference to the bus has disconnect called on it or has been destroyed.

763  {
764  synchronized (conn) {
765  synchronized (_reflock) {
766  if (0 == --_refcount) {
767  if (Debug.debug) Debug.print(Debug.INFO, "Disconnecting DBusConnection");
768  // Set all pending messages to have an error.
769  try {
770  Error err = new Error(
771  "org.freedesktop.DBus.Local", "org.freedesktop.DBus.Local.disconnected", 0, "s", new Object[]{getString("disconnected")});
772  synchronized (pendingCalls) {
773  long[] set = pendingCalls.getKeys();
774  for (long l : set)
775  if (-1 != l) {
776  MethodCall m = pendingCalls.remove(l);
777  if (null != m)
778  m.setReply(err);
779  }
780  pendingCalls = null;
781  }
782  synchronized (pendingErrors) {
783  pendingErrors.add(err);
784  }
785  } catch (DBusException DBe) {
786  }
787 
788  conn.remove(addr);
789  super.disconnect();
790  }
791  }
792  }
793  }
MethodCall remove(long l)
Definition: EfficientMap.java:85
String addr
Definition: AbstractConnection.java:258
long [] getKeys()
Definition: EfficientMap.java:50
Object _reflock
Definition: DBusConnection.java:196
static final Map< Object, DBusConnection > conn
Definition: DBusConnection.java:194
synchronized void setReply(Message reply)
Definition: MethodCall.java:131
EfficientMap pendingCalls
Definition: AbstractConnection.java:245
int _refcount
Definition: DBusConnection.java:195
LinkedList< Error > pendingErrors
Definition: AbstractConnection.java:253

◆ dynamicProxy()

DBusInterface org.freedesktop.dbus.DBusConnection.dynamicProxy ( String  source,
String  path 
) throws DBusException
inlinepackage
332  {
333  if (Debug.debug)
334  Debug.print(Debug.INFO, "Introspecting " + path + " on " + source + " for dynamic proxy creation");
335  try {
336  DBus.Introspectable intro = getRemoteObject(source, path, DBus.Introspectable.class);
337  String data = intro.Introspect();
338  if (Debug.debug) Debug.print(Debug.VERBOSE, "Got introspection data: " + data);
339  String[] tags = data.split("[<>]");
340  Vector<String> ifaces = new Vector<String>();
341  for (String tag : tags) {
342  if (tag.startsWith("interface")) {
343  ifaces.add(tag.replaceAll("^interface *name *= *['\"]([^'\"]*)['\"].*$", "$1"));
344  }
345  }
346  Vector<Class<? extends Object>> ifcs = new Vector<Class<? extends Object>>();
347  for (String iface : ifaces) {
348  if (Debug.debug) Debug.print(Debug.DEBUG, "Trying interface " + iface);
349  int j = 0;
350  while (j >= 0) {
351  try {
352  Class ifclass = Class.forName(iface);
353  if (!ifcs.contains(ifclass))
354  ifcs.add(ifclass);
355  break;
356  } catch (Exception e) {
357  }
358  j = iface.lastIndexOf(".");
359  char[] cs = iface.toCharArray();
360  if (j >= 0) {
361  cs[j] = '$';
362  iface = String.valueOf(cs);
363  }
364  }
365  }
366 
367  if (ifcs.size() == 0) throw new DBusException(getString("interfaceToCastNotFound"));
368 
369  RemoteObject ro = new RemoteObject(source, path, null, false);
370  DBusInterface newi = (DBusInterface)
371  Proxy.newProxyInstance(ifcs.get(0).getClassLoader(),
372  ifcs.toArray(new Class[0]),
373  new RemoteInvocationHandler(this, ro));
374  importedObjects.put(newi, ro);
375  return newi;
376  } catch (Exception e) {
377  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
378  throw new DBusException(MessageFormat.format(getString("createProxyExportFailure"), new Object[]{path, source, e.getMessage()}));
379  }
380  }
Map< DBusInterface, RemoteObject > importedObjects
Definition: AbstractConnection.java:243
DBusInterface getRemoteObject(String busname, String objectpath)
Definition: DBusConnection.java:527
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261

◆ exportObject()

void org.freedesktop.dbus.AbstractConnection.exportObject ( String  objectpath,
DBusInterface  object 
) throws DBusException
inlineinherited

Export an object so that its methods can be called on DBus.

引数
objectpathThe 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.
objectThe object to export.
例外
DBusExceptionIf the objectpath is already exporting an object. or if objectpath is incorrectly formatted,
405  {
406  if (null == objectpath || "".equals(objectpath))
407  throw new DBusException(getString("missingObjectPath"));
408  if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
409  throw new DBusException(getString("invalidObjectPath") + objectpath);
410  synchronized (exportedObjects) {
411  if (null != exportedObjects.get(objectpath))
412  throw new DBusException(getString("objectAlreadyExported"));
413  ExportedObject eo = new ExportedObject(object, weakreferences);
414  exportedObjects.put(objectpath, eo);
415  objectTree.add(objectpath, eo, eo.introspectiondata);
416  }
417  }
void add(String path, ExportedObject object, String data)
Definition: ObjectTree.java:110
Map< String, ExportedObject > exportedObjects
Definition: AbstractConnection.java:240
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
static final String OBJECT_REGEX
Definition: AbstractConnection.java:236
boolean weakreferences
Definition: AbstractConnection.java:259
ObjectTree objectTree
Definition: AbstractConnection.java:241

◆ finalize()

void org.freedesktop.dbus.AbstractConnection.finalize ( )
inlineinherited
621  {
622  disconnect();
623  }
void disconnect()
Definition: AbstractConnection.java:575

◆ getAddress()

BusAddress org.freedesktop.dbus.AbstractConnection.getAddress ( ) throws ParseException
inlineinherited

Returns the address this connection is connected to.

1056  {
1057  return new BusAddress(addr);
1058  }
String addr
Definition: AbstractConnection.java:258

◆ getCallInfo()

static DBusCallInfo org.freedesktop.dbus.AbstractConnection.getCallInfo ( )
inlinestaticinherited

Returns a structure with information on the current method call.

戻り値
the DBusCallInfo for this method call, or null if we are not in a method call.
377  {
378  DBusCallInfo info;
379  synchronized (infomap) {
380  info = infomap.get(Thread.currentThread());
381  }
382  return info;
383  }
static final Map< Thread, DBusCallInfo > infomap
Definition: AbstractConnection.java:254

◆ getConnection() [1/2]

static DBusConnection org.freedesktop.dbus.DBusConnection.getConnection ( String  address) throws DBusException
inlinestatic

Connect to the BUS. If a connection already exists to the specified Bus, a reference to it is returned.

引数
addressThe address of the bus to connect to
例外
DBusExceptionIf there is a problem connecting to the Bus.
205  {
206  synchronized (conn) {
207  DBusConnection c = conn.get(address);
208  if (null != c) {
209  synchronized (c._reflock) {
210  c._refcount++;
211  }
212  return c;
213  } else {
214  c = new DBusConnection(address);
215  conn.put(address, c);
216  return c;
217  }
218  }
219  }
static final Map< Object, DBusConnection > conn
Definition: DBusConnection.java:194
DBusConnection(String address)
Definition: DBusConnection.java:292

◆ getConnection() [2/2]

static DBusConnection org.freedesktop.dbus.DBusConnection.getConnection ( int  bustype) throws DBusException
inlinestatic

Connect to the BUS. If a connection already exists to the specified Bus, a reference to it is returned.

引数
bustypeThe Bus to connect to.
例外
DBusExceptionIf there is a problem connecting to the Bus.
参照
SYSTEM
SESSION
229  {
230  synchronized (conn) {
231  String s = null;
232  switch (bustype) {
233  case SYSTEM:
234  s = System.getenv("DBUS_SYSTEM_BUS_ADDRESS");
235  if (null == s) s = DEFAULT_SYSTEM_BUS_ADDRESS;
236  break;
237  case SESSION:
238  s = System.getenv("DBUS_SESSION_BUS_ADDRESS");
239  if (null == s) {
240  // address gets stashed in $HOME/.dbus/session-bus/`dbus-uuidgen --get`-`sed 's/:\(.\)\..*/\1/' <<< $DISPLAY`
241  String display = System.getenv("DISPLAY");
242  if (null == display) throw new DBusException(getString("cannotResolveSessionBusAddress"));
243  File uuidfile = new File("/var/lib/dbus/machine-id");
244  if (!uuidfile.exists()) throw new DBusException(getString("cannotResolveSessionBusAddress"));
245  try {
246  BufferedReader r = new BufferedReader(new FileReader(uuidfile));
247  String uuid = r.readLine();
248  String homedir = System.getProperty("user.home");
249  File addressfile = new File(homedir + "/.dbus/session-bus",
250  uuid + "-" + display.replaceAll(":([0-9]*)\\..*", "$1"));
251  if (!addressfile.exists())
252  throw new DBusException(getString("cannotResolveSessionBusAddress"));
253  r = new BufferedReader(new FileReader(addressfile));
254  String l;
255  while (null != (l = r.readLine())) {
256  if (Debug.debug) Debug.print(Debug.VERBOSE, "Reading D-Bus session data: " + l);
257  if (l.matches("DBUS_SESSION_BUS_ADDRESS.*")) {
258  s = l.replaceAll("^[^=]*=", "");
259  if (Debug.debug) Debug.print(Debug.VERBOSE, "Parsing " + l + " to " + s);
260  }
261  }
262  if (null == s || "".equals(s))
263  throw new DBusException(getString("cannotResolveSessionBusAddress"));
264  if (Debug.debug)
265  Debug.print(Debug.INFO, "Read bus address " + s + " from file " + addressfile.toString());
266  } catch (Exception e) {
267  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
268  throw new DBusException(getString("cannotResolveSessionBusAddress"));
269  }
270  }
271  break;
272  default:
273  throw new DBusException(getString("invalidBusType") + bustype);
274  }
275  DBusConnection c = conn.get(s);
276  if (Debug.debug) Debug.print(Debug.VERBOSE, "Getting bus connection for " + s + ": " + c);
277  if (null != c) {
278  synchronized (c._reflock) {
279  c._refcount++;
280  }
281  return c;
282  } else {
283  if (Debug.debug) Debug.print(Debug.DEBUG, "Creating new bus connection to: " + s);
284  c = new DBusConnection(s);
285  conn.put(s, c);
286  return c;
287  }
288  }
289  }
static final int SESSION
Definition: DBusConnection.java:188
static final String DEFAULT_SYSTEM_BUS_ADDRESS
Definition: DBusConnection.java:190
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261
static final Map< Object, DBusConnection > conn
Definition: DBusConnection.java:194
DBusConnection(String address)
Definition: DBusConnection.java:292
static final int SYSTEM
Definition: DBusConnection.java:184

◆ getError()

DBusExecutionException org.freedesktop.dbus.AbstractConnection.getError ( )
inlineinherited

Return any DBus error which has been received.

戻り値
A DBusExecutionException, or null if no error is pending.
630  {
631  synchronized (pendingErrors) {
632  if (pendingErrors.size() == 0) return null;
633  else
634  return pendingErrors.removeFirst().getException();
635  }
636  }
LinkedList< Error > pendingErrors
Definition: AbstractConnection.java:253

◆ getExportedObject() [1/2]

String org.freedesktop.dbus.AbstractConnection.getExportedObject ( DBusInterface  i) throws DBusException
inlinepackageinherited
357  {
358  synchronized (exportedObjects) {
359  for (String s : exportedObjects.keySet())
360  if (i.equals(exportedObjects.get(s).object.get()))
361  return s;
362  }
363 
364  String s = importedObjects.get(i).objectpath;
365  if (null != s) return s;
366 
367  throw new DBusException("Not an object exported or imported by this connection");
368  }
Map< DBusInterface, RemoteObject > importedObjects
Definition: AbstractConnection.java:243
Map< String, ExportedObject > exportedObjects
Definition: AbstractConnection.java:240

◆ getExportedObject() [2/2]

DBusInterface org.freedesktop.dbus.DBusConnection.getExportedObject ( String  source,
String  path 
) throws DBusException
inlinepackage
382  {
383  ExportedObject o = null;
384  synchronized (exportedObjects) {
385  o = exportedObjects.get(path);
386  }
387  if (null != o && null == o.object.get()) {
388  unExportObject(path);
389  o = null;
390  }
391  if (null != o) return o.object.get();
392  if (null == source) throw new DBusException(getString("objectNotExportedNoRemoteSpecified"));
393  return dynamicProxy(source, path);
394  }
DBusInterface dynamicProxy(String source, String path)
Definition: DBusConnection.java:332
void unExportObject(String objectpath)
Definition: AbstractConnection.java:452
Map< String, ExportedObject > exportedObjects
Definition: AbstractConnection.java:240

◆ getNames()

String [] org.freedesktop.dbus.DBusConnection.getNames ( )
inline

Returns all the names owned by this connection.

465  {
466  Set<String> names = new TreeSet<String>();
467  names.addAll(busnames);
468  return names.toArray(new String[0]);
469  }
List< String > busnames
Definition: DBusConnection.java:192

◆ getPeerRemoteObject() [1/3]

public<I extends DBusInterface> I org.freedesktop.dbus.DBusConnection.getPeerRemoteObject ( String  busname,
String  objectpath,
Class< I >  type 
) throws DBusException
inlinepackage
471  {
472  return getPeerRemoteObject(busname, objectpath, type, true);
473  }
public< I extends DBusInterface > I getPeerRemoteObject(String busname, String objectpath, Class< I > type)
Definition: DBusConnection.java:471

◆ getPeerRemoteObject() [2/3]

DBusInterface org.freedesktop.dbus.DBusConnection.getPeerRemoteObject ( String  busname,
String  objectpath 
) throws DBusException
inline

Return a reference to a remote object. This method will resolve the well known name (if given) to a unique bus name when you call it. This means that if a well known name is released by one process and acquired by another calls to objects gained from this method will continue to operate on the original process.

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.

引数
busnameThe 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".
objectpathThe path on which the process is exporting the object.$
戻り値
A reference to a remote object.
例外
ClassCastExceptionIf type is not a sub-type of DBusInterface
DBusExceptionIf busname or objectpath are incorrectly formatted.
495  {
496  if (null == busname) throw new DBusException(getString("nullBusName"));
497 
498  if ((!busname.matches(BUSNAME_REGEX) && !busname.matches(CONNID_REGEX))
499  || busname.length() > MAX_NAME_LENGTH)
500  throw new DBusException(getString("invalidBusName") + busname);
501 
502  String unique = _dbus.GetNameOwner(busname);
503 
504  return dynamicProxy(unique, objectpath);
505  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
DBusInterface dynamicProxy(String source, String path)
Definition: DBusConnection.java:332
DBus _dbus
Definition: DBusConnection.java:197
String GetNameOwner(String name)
static final String CONNID_REGEX
Definition: AbstractConnection.java:235
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239

◆ getPeerRemoteObject() [3/3]

public<I extends DBusInterface> I org.freedesktop.dbus.DBusConnection.getPeerRemoteObject ( String  busname,
String  objectpath,
Class< I >  type,
boolean  autostart 
) throws DBusException
inlinepackage

Return a reference to a remote object. This method will resolve the well known name (if given) to a unique bus name when you call it. This means that if a well known name is released by one process and acquired by another calls to objects gained from this method will continue to operate on the original process.

引数
busnameThe 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".
objectpathThe path on which the process is exporting the object.$
typeThe 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.
autostartDisable/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.
戻り値
A reference to a remote object.
例外
ClassCastExceptionIf type is not a sub-type of DBusInterface
DBusExceptionIf busname or objectpath are incorrectly formatted or type is not in a package.
560  {
561  if (null == busname) throw new DBusException(getString("nullBusName"));
562 
563  if ((!busname.matches(BUSNAME_REGEX) && !busname.matches(CONNID_REGEX))
564  || busname.length() > MAX_NAME_LENGTH)
565  throw new DBusException(getString("invalidBusName") + busname);
566 
567  String unique = _dbus.GetNameOwner(busname);
568 
569  return getRemoteObject(unique, objectpath, type, autostart);
570  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
DBusInterface getRemoteObject(String busname, String objectpath)
Definition: DBusConnection.java:527
DBus _dbus
Definition: DBusConnection.java:197
String GetNameOwner(String name)
static final String CONNID_REGEX
Definition: AbstractConnection.java:235
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239

◆ getRemoteObject() [1/3]

DBusInterface org.freedesktop.dbus.DBusConnection.getRemoteObject ( String  busname,
String  objectpath 
) throws DBusException
inline

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.

引数
busnameThe 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".
objectpathThe path on which the process is exporting the object.
戻り値
A reference to a remote object.
例外
ClassCastExceptionIf type is not a sub-type of DBusInterface
DBusExceptionIf busname or objectpath are incorrectly formatted.
527  {
528  if (null == busname) throw new DBusException(getString("nullBusName"));
529  if (null == objectpath) throw new DBusException(getString("nullObjectPath"));
530 
531  if ((!busname.matches(BUSNAME_REGEX) && !busname.matches(CONNID_REGEX))
532  || busname.length() > MAX_NAME_LENGTH)
533  throw new DBusException(getString("invalidBusName") + busname);
534 
535  if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
536  throw new DBusException(getString("invalidObjectPath") + objectpath);
537 
538  return dynamicProxy(busname, objectpath);
539  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
DBusInterface dynamicProxy(String source, String path)
Definition: DBusConnection.java:332
static final String CONNID_REGEX
Definition: AbstractConnection.java:235
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
static final String OBJECT_REGEX
Definition: AbstractConnection.java:236

◆ getRemoteObject() [2/3]

public<I extends DBusInterface> I org.freedesktop.dbus.DBusConnection.getRemoteObject ( String  busname,
String  objectpath,
Class< I >  type 
) throws DBusException
inlinepackage

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.

引数
busnameThe 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".
objectpathThe path on which the process is exporting the object.
typeThe 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.
戻り値
A reference to a remote object.
例外
ClassCastExceptionIf type is not a sub-type of DBusInterface
DBusExceptionIf busname or objectpath are incorrectly formatted or type is not in a package.
587  {
588  return getRemoteObject(busname, objectpath, type, true);
589  }
DBusInterface getRemoteObject(String busname, String objectpath)
Definition: DBusConnection.java:527

◆ getRemoteObject() [3/3]

public<I extends DBusInterface> I org.freedesktop.dbus.DBusConnection.getRemoteObject ( String  busname,
String  objectpath,
Class< I >  type,
boolean  autostart 
) throws DBusException
inlinepackage

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.

引数
busnameThe 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".
objectpathThe path on which the process is exporting the object.
typeThe 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.
autostartDisable/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.
戻り値
A reference to a remote object.
例外
ClassCastExceptionIf type is not a sub-type of DBusInterface
DBusExceptionIf busname or objectpath are incorrectly formatted or type is not in a package.
611  {
612  if (null == busname) throw new DBusException(getString("nullBusName"));
613  if (null == objectpath) throw new DBusException(getString("nullObjectPath"));
614  if (null == type) throw new ClassCastException(getString("notDBusInterface"));
615 
616  if ((!busname.matches(BUSNAME_REGEX) && !busname.matches(CONNID_REGEX))
617  || busname.length() > MAX_NAME_LENGTH)
618  throw new DBusException(getString("invalidBusName") + busname);
619 
620  if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
621  throw new DBusException(getString("invalidObjectPath") + objectpath);
622 
623  if (!DBusInterface.class.isAssignableFrom(type)) throw new ClassCastException(getString("notDBusInterface"));
624 
625  // don't let people import things which don't have a
626  // valid D-Bus interface name
627  if (type.getName().equals(type.getSimpleName()))
628  throw new DBusException(getString("interfaceNotAllowedOutsidePackage"));
629 
630  RemoteObject ro = new RemoteObject(busname, objectpath, type, autostart);
631  I i = (I) Proxy.newProxyInstance(type.getClassLoader(),
632  new Class[]{type}, new RemoteInvocationHandler(this, ro));
633  importedObjects.put(i, ro);
634  return i;
635  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
Map< DBusInterface, RemoteObject > importedObjects
Definition: AbstractConnection.java:243
static final String CONNID_REGEX
Definition: AbstractConnection.java:235
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
static final String OBJECT_REGEX
Definition: AbstractConnection.java:236

◆ getUniqueName()

String org.freedesktop.dbus.DBusConnection.getUniqueName ( )
inline

Returns the unique name of this connection.

458  {
459  return busnames.get(0);
460  }
List< String > busnames
Definition: DBusConnection.java:192

◆ listen()

void org.freedesktop.dbus.AbstractConnection.listen ( )
inlineprotectedinherited
317  {
318  // start listening
319  thread = new _thread();
320  thread.start();
321  sender = new _sender();
322  sender.start();
323  }
_sender sender
Definition: AbstractConnection.java:256
_thread thread
Definition: AbstractConnection.java:255

◆ queueOutgoing()

void org.freedesktop.dbus.AbstractConnection.queueOutgoing ( Message  m)
inlinepackageinherited
481  {
482  synchronized (outgoing) {
483  if (null == outgoing) return;
484  outgoing.add(m);
485  if (Debug.debug) Debug.print(Debug.DEBUG, "Notifying outgoing thread");
486  outgoing.notifyAll();
487  }
488  }
void add(Message m)
Definition: EfficientQueue.java:73
EfficientQueue outgoing
Definition: AbstractConnection.java:252

◆ releaseBusName()

void org.freedesktop.dbus.DBusConnection.releaseBusName ( String  busname) throws DBusException
inline

Release a bus name. Releases the name so that other people can use it

引数
busnameThe name to release. MUST be in dot-notation like "org.freedesktop.local"
例外
DBusExceptionIf the busname is incorrectly formatted.
403  {
404  if (!busname.matches(BUSNAME_REGEX) || busname.length() > MAX_NAME_LENGTH)
405  throw new DBusException(getString("invalidBusName"));
406  synchronized (this.busnames) {
407  UInt32 rv;
408  try {
409  rv = _dbus.ReleaseName(busname);
410  } catch (DBusExecutionException DBEe) {
411  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
412  throw new DBusException(DBEe.getMessage());
413  }
414  this.busnames.remove(busname);
415  }
416  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
DBus _dbus
Definition: DBusConnection.java:197
List< String > busnames
Definition: DBusConnection.java:192
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
UInt32 ReleaseName(String name)

◆ removeFallback()

void org.freedesktop.dbus.AbstractConnection.removeFallback ( String  objectprefix)
inlineinherited

Remove a fallback

引数
objectprefixThe prefix to remove the fallback for.
443  {
444  fallbackcontainer.remove(objectprefix);
445  }
FallbackContainer fallbackcontainer
Definition: AbstractConnection.java:250
synchronized void remove(String path)
Definition: AbstractConnection.java:51

◆ removeSigHandler() [1/5]

public<T extends DBusSignal> void org.freedesktop.dbus.AbstractConnection.removeSigHandler ( Class< T >  type,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackageinherited

Remove a Signal Handler. Stops listening for this signal.

引数
typeThe signal to watch for.
例外
DBusExceptionIf listening for the signal on the bus failed.
ClassCastExceptionIf type is not a sub-type of DBusSignal.
498  {
499  if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(getString("notDBusSignal"));
500  removeSigHandler(new DBusMatchRule(type), handler);
501  }
public< T extends DBusSignal > void removeSigHandler(Class< T > type, DBusSigHandler< T > handler)
Definition: AbstractConnection.java:498

◆ removeSigHandler() [2/5]

public<T extends DBusSignal> void org.freedesktop.dbus.AbstractConnection.removeSigHandler ( Class< T >  type,
DBusInterface  object,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackageinherited

Remove a Signal Handler. Stops listening for this signal.

引数
typeThe signal to watch for.
objectThe object emitting the signal.
例外
DBusExceptionIf listening for the signal on the bus failed.
ClassCastExceptionIf type is not a sub-type of DBusSignal.
512  {
513  if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(getString("notDBusSignal"));
514  String objectpath = importedObjects.get(object).objectpath;
515  if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
516  throw new DBusException(getString("invalidObjectPath") + objectpath);
517  removeSigHandler(new DBusMatchRule(type, null, objectpath), handler);
518  }
Map< DBusInterface, RemoteObject > importedObjects
Definition: AbstractConnection.java:243
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
static final String OBJECT_REGEX
Definition: AbstractConnection.java:236
public< T extends DBusSignal > void removeSigHandler(Class< T > type, DBusSigHandler< T > handler)
Definition: AbstractConnection.java:498

◆ removeSigHandler() [3/5]

public<T extends DBusSignal> void org.freedesktop.dbus.DBusConnection.removeSigHandler ( Class< T >  type,
String  source,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackage

Remove a Signal Handler. Stops listening for this signal.

引数
typeThe signal to watch for.
sourceThe source of the signal.
例外
DBusExceptionIf listening for the signal on the bus failed.
ClassCastExceptionIf type is not a sub-type of DBusSignal.
646  {
647  if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(getString("notDBusSignal"));
648  if (source.matches(BUSNAME_REGEX)) throw new DBusException(getString("cannotWatchSignalsWellKnownBussName"));
649  if (!source.matches(CONNID_REGEX) || source.length() > MAX_NAME_LENGTH)
650  throw new DBusException(getString("invalidBusName") + source);
651  removeSigHandler(new DBusMatchRule(type, source, null), handler);
652  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
static final String CONNID_REGEX
Definition: AbstractConnection.java:235
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
public< T extends DBusSignal > void removeSigHandler(Class< T > type, String source, DBusSigHandler< T > handler)
Definition: DBusConnection.java:646

◆ removeSigHandler() [4/5]

public<T extends DBusSignal> void org.freedesktop.dbus.DBusConnection.removeSigHandler ( Class< T >  type,
String  source,
DBusInterface  object,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackage

Remove a Signal Handler. Stops listening for this signal.

引数
typeThe signal to watch for.
sourceThe source of the signal.
objectThe object emitting the signal.
例外
DBusExceptionIf listening for the signal on the bus failed.
ClassCastExceptionIf type is not a sub-type of DBusSignal.
664  {
665  if (!DBusSignal.class.isAssignableFrom(type)) throw new ClassCastException(getString("notDBusSignal"));
666  if (source.matches(BUSNAME_REGEX)) throw new DBusException(getString("cannotWatchSignalsWellKnownBussName"));
667  if (!source.matches(CONNID_REGEX) || source.length() > MAX_NAME_LENGTH)
668  throw new DBusException(getString("invalidBusName") + source);
669  String objectpath = importedObjects.get(object).objectpath;
670  if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH)
671  throw new DBusException(getString("invalidObjectPath") + objectpath);
672  removeSigHandler(new DBusMatchRule(type, source, objectpath), handler);
673  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
Map< DBusInterface, RemoteObject > importedObjects
Definition: AbstractConnection.java:243
static final String CONNID_REGEX
Definition: AbstractConnection.java:235
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239
public< T extends DBusSignal > void removeSigHandler(Class< T > type, String source, DBusSigHandler< T > handler)
Definition: DBusConnection.java:646
static final String OBJECT_REGEX
Definition: AbstractConnection.java:236

◆ removeSigHandler() [5/5]

protected<T extends DBusSignal> void org.freedesktop.dbus.DBusConnection.removeSigHandler ( DBusMatchRule  rule,
DBusSigHandler< T >  handler 
) throws DBusException
inlinepackage
675  {
676 
677  SignalTuple key = new SignalTuple(rule.getInterface(), rule.getMember(), rule.getObject(), rule.getSource());
678  synchronized (handledSignals) {
679  Vector<DBusSigHandler<? extends DBusSignal>> v = handledSignals.get(key);
680  if (null != v) {
681  v.remove(handler);
682  if (0 == v.size()) {
683  handledSignals.remove(key);
684  try {
685  _dbus.RemoveMatch(rule.toString());
686  } catch (NotConnected NC) {
687  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, NC);
688  } catch (DBusExecutionException DBEe) {
689  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
690  throw new DBusException(DBEe.getMessage());
691  }
692  }
693  }
694  }
695  }
DBus _dbus
Definition: DBusConnection.java:197
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261
void RemoveMatch(String matchrule)
Map< SignalTuple, Vector< DBusSigHandler<? extends DBusSignal > > > handledSignals
Definition: AbstractConnection.java:244

◆ requestBusName()

void org.freedesktop.dbus.DBusConnection.requestBusName ( String  busname) throws DBusException
inline

Request a bus name. Request the well known name that this should respond to on the Bus.

引数
busnameThe name to respond to. MUST be in dot-notation like "org.freedesktop.local"
例外
DBusExceptionIf the register name failed, or our name already exists on the bus. or if busname is incorrectly formatted.
426  {
427  if (!busname.matches(BUSNAME_REGEX) || busname.length() > MAX_NAME_LENGTH)
428  throw new DBusException(getString("invalidBusName"));
429  synchronized (this.busnames) {
430  UInt32 rv;
431  try {
432  rv = _dbus.RequestName(busname,
433  new UInt32(DBus.DBUS_NAME_FLAG_REPLACE_EXISTING |
434  DBus.DBUS_NAME_FLAG_DO_NOT_QUEUE));
435  } catch (DBusExecutionException DBEe) {
436  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, DBEe);
437  throw new DBusException(DBEe.getMessage());
438  }
439  switch (rv.intValue()) {
440  case DBus.DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
441  break;
442  case DBus.DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
443  throw new DBusException(getString("dbusRegistrationFailure"));
444  case DBus.DBUS_REQUEST_NAME_REPLY_EXISTS:
445  throw new DBusException(getString("dbusRegistrationFailure"));
446  case DBus.DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
447  break;
448  default:
449  break;
450  }
451  this.busnames.add(busname);
452  }
453  }
static final String BUSNAME_REGEX
Definition: AbstractConnection.java:234
DBus _dbus
Definition: DBusConnection.java:197
UInt32 RequestName(String name, UInt32 flags)
List< String > busnames
Definition: DBusConnection.java:192
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261
static final int MAX_NAME_LENGTH
Definition: AbstractConnection.java:239

◆ sendMessage()

void org.freedesktop.dbus.AbstractConnection.sendMessage ( Message  m)
inlineprotectedinherited
995  {
996  try {
997  if (!connected) throw new NotConnected(getString("disconnected"));
998  if (m instanceof DBusSignal)
999  ((DBusSignal) m).appendbody(this);
1000 
1001  if (m instanceof MethodCall) {
1002  if (0 == (m.getFlags() & Message.Flags.NO_REPLY_EXPECTED))
1003  if (null == pendingCalls)
1004  ((MethodCall) m).setReply(new Error("org.freedesktop.DBus.Local", "org.freedesktop.DBus.Local.disconnected", 0, "s", new Object[]{getString("disconnected")}));
1005  else synchronized (pendingCalls) {
1006  pendingCalls.put(m.getSerial(), (MethodCall) m);
1007  }
1008  }
1009 
1011 
1012  } catch (Exception e) {
1013  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
1014  if (m instanceof MethodCall && e instanceof NotConnected)
1015  try {
1016  ((MethodCall) m).setReply(new Error("org.freedesktop.DBus.Local", "org.freedesktop.DBus.Local.disconnected", 0, "s", new Object[]{getString("disconnected")}));
1017  } catch (DBusException DBe) {
1018  }
1019  if (m instanceof MethodCall && e instanceof DBusExecutionException)
1020  try {
1021  ((MethodCall) m).setReply(new Error(m, e));
1022  } catch (DBusException DBe) {
1023  }
1024  else if (m instanceof MethodCall)
1025  try {
1026  if (Debug.debug) Debug.print(Debug.INFO, "Setting reply to " + m + " as an error");
1027  ((MethodCall) m).setReply(new Error(m, new DBusExecutionException(getString("messageFailedSend") + e.getMessage())));
1028  } catch (DBusException DBe) {
1029  }
1030  else if (m instanceof MethodReturn)
1031  try {
1032  transport.mout.writeMessage(new Error(m, e));
1033  } catch (IOException IOe) {
1034  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, IOe);
1035  } catch (DBusException IOe) {
1036  if (EXCEPTION_DEBUG && Debug.debug) Debug.print(Debug.ERR, e);
1037  }
1038  if (e instanceof IOException) disconnect();
1039  }
1040  }
void disconnect()
Definition: AbstractConnection.java:575
Transport transport
Definition: AbstractConnection.java:257
void put(long l, MethodCall m)
Definition: EfficientMap.java:74
static final boolean EXCEPTION_DEBUG
Definition: AbstractConnection.java:261
MessageWriter mout
Definition: Transport.java:735
EfficientMap pendingCalls
Definition: AbstractConnection.java:245
boolean connected
Definition: AbstractConnection.java:263
void writeMessage(Message m)
Definition: MessageWriter.java:37

◆ sendSignal()

void org.freedesktop.dbus.AbstractConnection.sendSignal ( DBusSignal  signal)
inlineinherited

Return a reference to a remote object. This method will resolve the well known name (if given) to a unique bus name when you call it. This means that if a well known name is released by one process and acquired by another calls to objects gained from this method will continue to operate on the original process.

引数
busnameThe 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".
objectpathThe path on which the process is exporting the object.$
typeThe 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.
戻り値
A reference to a remote object.
例外
ClassCastExceptionIf type is not a sub-type of DBusInterface
DBusExceptionIf busname or objectpath are incorrectly formatted or type is not in a package. Send a signal.
引数
signalThe signal to send.
477  {
478  queueOutgoing(signal);
479  }
void queueOutgoing(Message m)
Definition: AbstractConnection.java:481

◆ setWeakReferences()

void org.freedesktop.dbus.AbstractConnection.setWeakReferences ( boolean  weakreferences)
inlineinherited

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.

391  {
393  }
boolean weakreferences
Definition: AbstractConnection.java:259

◆ unExportObject()

void org.freedesktop.dbus.AbstractConnection.unExportObject ( String  objectpath)
inlineinherited

Stop Exporting an object

引数
objectpathThe objectpath to stop exporting.
452  {
453  synchronized (exportedObjects) {
454  exportedObjects.remove(objectpath);
455  objectTree.remove(objectpath);
456  }
457  }
Map< String, ExportedObject > exportedObjects
Definition: AbstractConnection.java:240
void remove(String path)
Definition: ObjectTree.java:115
ObjectTree objectTree
Definition: AbstractConnection.java:241

メンバ詳解

◆ _dbus

DBus org.freedesktop.dbus.DBusConnection._dbus
private

◆ _refcount

int org.freedesktop.dbus.DBusConnection._refcount = 0
private

◆ _reflock

Object org.freedesktop.dbus.DBusConnection._reflock = new Object()
private

◆ _run

boolean org.freedesktop.dbus.AbstractConnection._run
protectedinherited

◆ addr

String org.freedesktop.dbus.AbstractConnection.addr
protectedinherited

◆ BUSNAME_REGEX

final String org.freedesktop.dbus.AbstractConnection.BUSNAME_REGEX = "^[-_a-zA-Z][-_a-zA-Z0-9]*(\\.[-_a-zA-Z][-_a-zA-Z0-9]*)*$"
staticpackageinherited

◆ busnames

List<String> org.freedesktop.dbus.DBusConnection.busnames
private

◆ conn

final Map<Object, DBusConnection> org.freedesktop.dbus.DBusConnection.conn = new HashMap<Object, DBusConnection>()
staticprivate

◆ connected

boolean org.freedesktop.dbus.AbstractConnection.connected = false
protectedinherited

◆ CONNID_REGEX

final String org.freedesktop.dbus.AbstractConnection.CONNID_REGEX = "^:[0-9]*\\.[0-9]*$"
staticpackageinherited

◆ DEFAULT_SYSTEM_BUS_ADDRESS

final String org.freedesktop.dbus.DBusConnection.DEFAULT_SYSTEM_BUS_ADDRESS = "unix:path=/var/run/dbus/system_bus_socket"
static

◆ dollar_pattern

final Pattern org.freedesktop.dbus.AbstractConnection.dollar_pattern = Pattern.compile("[$]")
staticpackageinherited

◆ EXCEPTION_DEBUG

final boolean org.freedesktop.dbus.AbstractConnection.EXCEPTION_DEBUG
staticinherited

◆ exportedObjects

Map<String, ExportedObject> org.freedesktop.dbus.AbstractConnection.exportedObjects
protectedinherited

◆ fallbackcontainer

FallbackContainer org.freedesktop.dbus.AbstractConnection.fallbackcontainer
protectedinherited

◆ FLOAT_SUPPORT

final boolean org.freedesktop.dbus.AbstractConnection.FLOAT_SUPPORT
staticpackageinherited

◆ handledSignals

Map<SignalTuple, Vector<DBusSigHandler<? extends DBusSignal> > > org.freedesktop.dbus.AbstractConnection.handledSignals
protectedinherited

◆ importedObjects

Map<DBusInterface, RemoteObject> org.freedesktop.dbus.AbstractConnection.importedObjects
protectedinherited

◆ MAX_ARRAY_LENGTH

final int org.freedesktop.dbus.AbstractConnection.MAX_ARRAY_LENGTH = 67108864
staticpackageinherited

◆ MAX_NAME_LENGTH

final int org.freedesktop.dbus.AbstractConnection.MAX_NAME_LENGTH = 255
staticpackageinherited

◆ OBJECT_REGEX

final String org.freedesktop.dbus.AbstractConnection.OBJECT_REGEX = "^/([-_a-zA-Z0-9]+(/[-_a-zA-Z0-9]+)*)?$"
staticpackageinherited

◆ outgoing

EfficientQueue org.freedesktop.dbus.AbstractConnection.outgoing
packageinherited

◆ pendingCallbackReplys

Map<MethodCall, DBusAsyncReply<? extends Object> > org.freedesktop.dbus.AbstractConnection.pendingCallbackReplys
protectedinherited

◆ pendingCallbacks

Map<MethodCall, CallbackHandler<? extends Object> > org.freedesktop.dbus.AbstractConnection.pendingCallbacks
protectedinherited

◆ pendingCalls

EfficientMap org.freedesktop.dbus.AbstractConnection.pendingCalls
protectedinherited

◆ pendingErrors

LinkedList<Error> org.freedesktop.dbus.AbstractConnection.pendingErrors
packageinherited

◆ runnables

LinkedList<Runnable> org.freedesktop.dbus.AbstractConnection.runnables
protectedinherited

◆ sender

_sender org.freedesktop.dbus.AbstractConnection.sender
protectedinherited

◆ SESSION

final int org.freedesktop.dbus.DBusConnection.SESSION = 1
static

Session Bus

◆ SYSTEM

final int org.freedesktop.dbus.DBusConnection.SYSTEM = 0
static

System Bus

◆ thread

_thread org.freedesktop.dbus.AbstractConnection.thread
protectedinherited

◆ THREADCOUNT

final byte org.freedesktop.dbus.AbstractConnection.THREADCOUNT = 4
staticpackageinherited

◆ TIMEOUT

final int org.freedesktop.dbus.AbstractConnection.TIMEOUT = 100000
staticprotectedinherited

Timeout in us on checking the BUS for incoming messages and sending outgoing messages

◆ transport

Transport org.freedesktop.dbus.AbstractConnection.transport
protectedinherited

◆ weakreferences

boolean org.freedesktop.dbus.AbstractConnection.weakreferences = false
protectedinherited

◆ workers

LinkedList<_workerthread> org.freedesktop.dbus.AbstractConnection.workers
protectedinherited

このクラス詳解は次のファイルから抽出されました: