Package org.jupnp.controlpoint
Klasse ActionCallback
java.lang.Object
org.jupnp.controlpoint.ActionCallback
- Alle implementierten Schnittstellen:
Runnable
- Bekannte direkte Unterklassen:
ActionCallback.Default
Execute actions on any service.
Usage example for asynchronous execution in a background thread:
Service service = device.findService(new UDAServiceId("SwitchPower"));
Action getStatusAction = service.getAction("GetStatus");
ActionInvocation getStatusInvocation = new ActionInvocation(getStatusAction);
ActionCallback getStatusCallback = new ActionCallback(getStatusInvocation) {
public void success(ActionInvocation invocation) {
ActionArgumentValue status = invocation.getOutput("ResultStatus");
assertEquals((Boolean) status.getValue(), Boolean.valueOf(false));
}
public void failure(ActionInvocation invocation, UpnpResponse res) {
System.err.println(
createDefaultFailureMessage(invocation, res)
);
}
};
upnpService.getControlPoint().execute(getStatusCallback)
You can also execute the action synchronously in the same thread using the
ActionCallback.Default implementation:
myActionInvocation.setInput("foo", bar);
new ActionCallback.Default(myActionInvocation, upnpService.getControlPoint()).run();
myActionInvocation.getOutput("baz");
- Autor:
- Christian Bauer
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic final classEmpty implementation of callback methods, simplifies synchronous execution of anActionInvocation. -
Feldübersicht
Felder -
Konstruktorübersicht
KonstruktorenModifiziererKonstruktorBeschreibungprotectedActionCallback(ActionInvocation actionInvocation) protectedActionCallback(ActionInvocation actionInvocation, ControlPoint controlPoint) -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected StringcreateDefaultFailureMessage(ActionInvocation invocation, UpnpResponse operation) protected voidfailure(ActionInvocation invocation, UpnpResponse operation) abstract voidfailure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) Called when the action invocation failed.voidrun()setControlPoint(ControlPoint controlPoint) abstract voidsuccess(ActionInvocation invocation) Called when the action invocation succeeded.toString()
-
Felddetails
-
actionInvocation
-
controlPoint
-
-
Konstruktordetails
-
ActionCallback
-
ActionCallback
-
-
Methodendetails
-
getActionInvocation
-
getControlPoint
-
setControlPoint
-
run
public void run() -
createDefaultFailureMessage
-
failure
-
success
Called when the action invocation succeeded.- Parameter:
invocation- The successful invocation, call itsgetOutput()method for results.
-
failure
public abstract void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) Called when the action invocation failed.- Parameter:
invocation- The failed invocation, call itsgetFailure()method for more details.operation- If the invocation was on a remote service, the response message, otherwise null.defaultMsg- A user-friendly error message generated from the invocation exception and response.- Siehe auch:
-
toString
-