Dbus Java - addSigHandler - GNU Classpath

Ed Hemphill ed at izuma.net
Sun Sep 13 20:15:24 PDT 2009


Sorry for the immediate repost...

With Sun JRE:
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Client VM (build 1.5.0_16-b02, mixed mode, sharing)

This problem goes away...

[org.freedesktop.dbus.AbstractConnection$_sender.run()] Got message:
MethodCall(0,5) { Interface=>org.freedesktop.DBus, Signature=>s,
Destination=>org.freedesktop.DBus, Path=>/org/freedesktop/DBus,
Member=>AddMatch } {
type='signal',member='Sig',interface='framez.io.dbus.FrzRemoteSignal' }
[org.freedesktop.dbus.MessageWriter.writeMessage()] <= MethodCall(0,5) {
Interface=>org.freedesktop.DBus, Signature=>s,
Destination=>org.freedesktop.DBus, Path=>/org/freedesktop/DBus,
Member=>AddMatch } {
type='signal',member='Sig',interface='framez.io.dbus.FrzRemoteSignal' }

It looks like GNU Classpath - I will post a patch...  If anyone has more
info please let me know.

thanks
-Ed


On Sun, Sep 13, 2009 at 9:41 PM, Ed Hemphill <ed at izuma.net> wrote:

> Hi,
>
> I was hoping someone could assist with the below issues. It may be
> something obvious to DBus as I am new to it.
> I have seen some posts from Matthew Johnson in the past which were
> quite useful, but 'FrzRemoteSignal' is in a package.
>
>
> When trying to add a SigHandler for a DBusSignal I am getting the
> following exception:
>
> type.getName: org.freedesktop.DBus   type.getSimpleName: DBus
> 0    [main] ERROR Broadcast  - Error: Member name
> 'FrzRemoteSignal$Sig' is invalid--> [
> org.freedesktop.dbus.exceptions.DBusException ] Member name
> 'FrzRemoteSignal$Sig' is invalid -->
> org.freedesktop.dbus.exceptions.DBusException: Member name
> 'FrzRemoteSignal$Sig' is invalid
>   at org.freedesktop.dbus.DBusConnection.addSigHandler(Unknown Source)
>   at org.freedesktop.dbus.AbstractConnection.addSigHandler(Unknown Source)
>   at framez.io.dbus.FrzDBusDrv.startFrzSigListen(FrzDBusDrv.java:96)
>   at framez.io.dbus.FrzDBusDrv.connect(FrzDBusDrv.java:70)
>   at DBusBroadcastSigTest.initApp(DBusBroadcastSigTest.java:96)
>   at
> framez.core.controller.FrzControllerExec.main(FrzControllerExec.java:104)
>
> What I find weird is that the Member name is being called
> FrzRemoteSignal$Sig - where as DBus's own information does not have
> this dollar sign:
>
> [.()] Handling incoming signal: DBusSignal(1,3) { Signature=>s,
> Sender=>org.freedesktop.DBus, Destination=>:1.201,
> Member=>NameAcquired, Interface=>org.freedesktop.DBus,
> Path=>/org/freedesktop/DBus } { framez.tests.dbus.broadcast }
>
> I have ran across a bug in GNU Classpath 0.98 (which is patched now)
> for Class.getName and Class.getSimpleName - where both of these were
> being reported as the same. This bug is patched but wonder if this
> could be another problem like that...
>
>
> As above, using the dbus-java-debug libraries...
>
> [.()] Dequeueing MethodCall(0,3) { Signature=>s,
> Destination=>org.freedesktop.DBus, Member=>AddMatch,
> Interface=>org.freedesktop.DBus, Path=>/org/freedesktop/DBus } {
>
> type='signal',member='FrzRemoteSignal$Sig',interface='framez.io.dbus.FrzRemoteSignal'
> }
> [.()] Got message: MethodCall(0,3) { Signature=>s,
> Destination=>org.freedesktop.DBus, Member=>AddMatch,
> Interface=>org.freedesktop.DBus, Path=>/org/freedesktop/DBus } {
>
> type='signal',member='FrzRemoteSignal$Sig',interface='framez.io.dbus.FrzRemoteSignal'
> }
> [.()] <= MethodCall(0,3) { Signature=>s,
> Destination=>org.freedesktop.DBus, Member=>AddMatch,
> Interface=>org.freedesktop.DBus, Path=>/org/freedesktop/DBus } {
>
> type='signal',member='FrzRemoteSignal$Sig',interface='framez.io.dbus.FrzRemoteSignal'
> }
> [.()] Writing all 40 buffers simultaneously to Unix Socket
> [.()] => Error(1,5) { Signature=>s, Sender=>org.freedesktop.DBus,
> Destination=>:1.195, Reply Serial=>3, Error
> Name=>org.freedesktop.DBus.Error.MatchRuleInvalid } { Member name
> 'FrzRemoteSignal$Sig' is invalid
>  }
> [.()] Handling incoming error: Error(1,5) { Signature=>s,
> Sender=>org.freedesktop.DBus, Destination=>:1.195, Reply Serial=>3,
> Error Name=>org.freedesktop.DBus.Error.MatchRuleInvalid } { Member
> name 'FrzRemoteSignal$Sig' is invalid
>  }
>
>
>
> FrzRemoteSignal DBusInterface----------->
>
> package framez.io.dbus;
>
> import org.freedesktop.dbus.DBusSignal;
> import org.freedesktop.dbus.DBusInterface;
> import org.freedesktop.dbus.Struct;
> import org.freedesktop.dbus.exceptions.DBusException;
>
> import framez.core.signal.FrzSignal;
>
> /** This class is used by d-bus for transmission of a FrzSignal<br>
>  * The FrzSignal is essentially represented by two Struct(s) <br>
>  * See org.freedesktop.dbus for why this must be DBusSignal inside a
> DBusInterface.
>  * @author ed
>  * @see FrzSignal
>  */
> public interface FrzRemoteSignal extends DBusInterface {
>    /** We only have one signal for this class right now, Send a signal   */
>    public static class Sig extends DBusSignal {
>        public final Struct signal;
>        public final Struct data;
>        public Sig(String path, Struct signal, Struct data )
>        throws DBusException {
>                super(path, signal, data);
>                this.signal = signal;
>                this.data = data;
>        }
>    }
> }
>
>
>
>
>
> in other code - adding the sigHandler---------->
>
>        public void startFrzSigListen() {
>                if (remoteSigHandler != null)
>                        try {
>
>  conn.addSigHandler(FrzRemoteSignal.Sig.class, remoteSigHandler);
>                        } catch (DBusException e) {
>                                FrzLog.error("Error: " + e.getMessage() +
> "-->" + FrzLog.stringifyTrace(e));
>                        } catch (ClassCastException e) {
>                                FrzLog.error("Error: " + e.getMessage() +
> "-->" + FrzLog.stringifyTrace(e));
>                        }
>                else
>                        FrzLog.error("remoteSigHandler is uninitialized.");
>        }
>
>
> remoteSigHandler is just an instance of...
>
>        public class FrzRemoteSigHandler implements DBusSigHandler {
>                public void handle(DBusSignal s) {
>                        if(s instanceof FrzRemoteSignal.Sig) {
>                                FrzRemoteSignal.Sig sig =
> (FrzRemoteSignal.Sig) s;
>                                FrzSignal frzsig = null;
>                                FrzLog.debug("Got incoming remote signal: "
> +
> ((FrzSignal.SigStruct) sig.signal).Code);
>
>  if(((FrzSignal.SigStruct)sig.signal).dataTypeName != "") // if the
> signal had a type, then...
>                                         frzsig = new FrzSignal(
> (FrzSignal.SigStruct) sig.signal,
> sig.data ); // try to create with data
>                                else // otherwise just a Signal, but no
> FrzSigData
>                                         frzsig = new FrzSignal(
> (FrzSignal.SigStruct) sig.signal, null );
>                                sigQueue.enqueSignal(frzsig); // send to
> event queue
>                        }
>                }
>        }
>
>
> I am happy to post more code, but this is the crux of the DBus
> related... any help appreciated
>
> -Ed
>



-- 
Ed Hemphill
+1.512.417.8600
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20090913/3304dc1d/attachment.html 


More information about the dbus mailing list