4 DBusSignal

Signals are also declared as part of an interface. The Java API models these as inner classes within an interface. The containing interface must extend DBusInterface, and the inner classes representing the signals must extend DBusSignal10 . The Signal name is derived from the name of this inner class, and the interface from its containing interface.

Signals can take parameters as methods can (although they cannot return anything). For the reflection to work, a Signal declare a single constructor of the correct type. The constructor must take the object path they are being emitted from as their first (String) argument, followed by the other parameters in order. They must also call the superclass constructor with the same parameters. A full definition of a signal can be seen in figure 5. Again, more complicated definitions are available in the test classes11 .


package org.freedesktop;  
import org.freedesktop.dbus.DBusInterface;  
import org.freedesktop.dbus.DBusSignal;  
import org.freedesktop.dbus.exceptions.DBusException;  
 
public interface DBus extends DBusInterface  
{  
   public class NameAcquired extends DBusSignal  
   {  
      public final String name;  
      public NameAcquired(String path, String name)  
                              throws DBusException  
      {  
         super(path, name);  
         this.name = name;  
      }  
   }  
}


Figure 5: A Signal with one parameter