Logo Search packages:      
Sourcecode: dbus-java version File versions  Download package

public<I extends DBusInterface> I org::freedesktop::dbus::DBusConnection::getRemoteObject ( String  busname,
String  objectpath,
Class< I >  type,
boolean  autostart 
) throws DBusException [inline, package]

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:
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.
Returns:
A reference to a remote object.
Exceptions:
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.

Definition at line 436 of file DBusConnection.java.

   {
      if (null == busname) throw new DBusException(_("Invalid bus name: null"));
      if (null == objectpath) throw new DBusException(_("Invalid object path: null"));
      if (null == type) throw new ClassCastException(_("Not A DBus Interface"));
      
      if ((!busname.matches(BUSNAME_REGEX) && !busname.matches(CONNID_REGEX))
         || busname.length() > MAX_NAME_LENGTH)
         throw new DBusException(_("Invalid bus name: ")+busname);
      
      if (!objectpath.matches(OBJECT_REGEX) || objectpath.length() > MAX_NAME_LENGTH) 
         throw new DBusException(_("Invalid object path: ")+objectpath);
      
      if (!DBusInterface.class.isAssignableFrom(type)) throw new ClassCastException(_("Not A DBus Interface"));

      // don't let people import things which don't have a
      // valid D-Bus interface name
      if (type.getName().equals(type.getSimpleName()))
         throw new DBusException(_("DBusInterfaces cannot be declared outside a package"));
      
      RemoteObject ro = new RemoteObject(busname, objectpath, type, autostart);
      I i =  (I) Proxy.newProxyInstance(type.getClassLoader(), 
            new Class[] { type }, new RemoteInvocationHandler(this, ro));
      importedObjects.put(i, ro);
      return i;
   }


Generated by  Doxygen 1.6.0   Back to index