Hi everybody!
I'm updating MathService_instance_notif example to make it work with GT4.2.X

I read this:
http://www.globus.org/toolkit/docs/4.2/4.2.0/common/javawscore/mig/javawscore-migrating-GT4.html#javawscore-migrating-GT4-consuming-notifications

So I edited ValueListener.java and imported these packages:
import org.globus.wsrf.encoding.DeserializationException; import
org.globus.wsrf.utils.NotificationUtil;
import
org.oasis.wsrf.properties.ResourcePropertyValueChangeNotificationType;

The piece of code I removed was the body of deliver method.

This is GT 4.0.X version:

ResourcePropertyValueChangeNotificationElementType notif_elem;

ResourcePropertyValueChangeNotificationType notif = null;


 try {

notif_elem = (ResourcePropertyValueChangeNotificationElementType) message;

notif = notif_elem.getResourcePropertyValueChangeNotification();

} catch (Exception e) {

System.out.println("Error when casting notification message.");

System.out.println("Message: " + e.getMessage());

}


 if (notif != null) {

System.out.println("A notification has been delivered");


 if (notif.getOldValue() != null) {

System.out.print("Old value: ");

System.out.println(notif.getOldValue().get_any()[0].getValue());

}

System.out.print("New value: ");

System.out.println(notif.getNewValue().get_any()[0].getValue());


 }

This is GT 4.2.X version:
ResourcePropertyValueChangeNotificationType changeMessage = null;

                try{
                        changeMessage =
NotificationUtil.getRPValueChangeNotification(message);

                        System.out.println("A notification has been
delivered");
                        System.out.print("Old value: ");

 System.out.println(changeMessage.getOldValues().get_any()[0].getValue());
                        System.out.print("New value: ");

 System.out.println(changeMessage.getNewValues().get_any()[0].getValue());
                }catch(DeserializationException e){
                        System.out.println("An error occurred while
deserialization: " + e);
                }

Now the first piece of code (GT 4.0) was described in this way:
When using ResourcePropertyTopics to notify changes in RPs, the notification
message is of type ResourcePropertyValueChangeNotificationElementType. This
type, in turn, contains an object of type
ResourcePropertyValueChangeNotificationType. This object is the one that
contains the new value of the RP. Remember that, in this example, we've also
asked that the notification include the old value too.


What happens in GT 4.2 version? The notification message is stored inside
"message" and we must use NotificationUtil class with method
getRPValueChangeNotification to get information about notification. Is this
right?
More, NotificationUtil.getRPValueChangeNotification returns and object of
type ResourcePropertyValueChangeNotificationType, isn't it?

Thanks a lot!
Francesco


ps. Is it right to say that NotificationUtil.getRPValueChangeNotification is
a decorator on "message"?

Reply via email to