package client; import org.globus.ogsa.client.managers.NotificationSinkManager; import org.globus.ogsa.NotificationSinkCallback; import org.globus.ogsa.impl.core.service.ServicePropertiesImpl; import org.gridforum.ogsi.ExtensibilityType; import org.gridforum.ogsi.HandleType; import DefaultNamespace.service.CalculatorImplServiceGridLocator; import DefaultNamespace.CalculatorImplPortType; import java.net.URL; import java.rmi.RemoteException; public class CalcListener extends ServicePropertiesImpl implements NotificationSinkCallback { private CalculatorImplPortType calc; public static void main(String[] args) { try { // Get command-line arguments HandleType GSH = new HandleType(args[0]); CalcListener calcListener = new CalcListener(GSH); }catch(Exception e) { System.out.println("ERROR1!"); e.printStackTrace(); } } public CalcListener(HandleType GSH) throws Exception { // Get a reference to the Grid Service instance CalculatorImplServiceGridLocator calcServiceLocator = new CalculatorImplServiceGridLocator(); calc = calcServiceLocator.getCalculatorImplPort(GSH); // Start listening to the CalculatorImplService NotificationSinkManager notifManager = NotificationSinkManager.getManager(); notifManager.startListening(NotificationSinkManager.MAIN_THREAD); String sink = notifManager.addListener("DummySDE", null, GSH, this); System.out.println("Listening..."); // Wait for key press System.in.read(); // Stop listening notifManager.removeListener(sink); notifManager.stopListening(); System.out.println("Not listening anymore!"); } public void deliverNotification(ExtensibilityType any) throws RemoteException { try { System.out.println("Operation performed!"); }catch(Exception exc) { System.out.println("ERROR2!"); exc.printStackTrace(); } } }