Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.fourthline.cling.controlpoint
Class ActionCallback

    java.lang.Object
      org.fourthline.cling.controlpoint.ActionCallback

All Implemented Interfaces:
  Runnable

Direct Known Subclasses:
  ActionCallback.Default

    public abstract class ActionCallback

extends Object
implements Runnable

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");

Author:
  Christian Bauer

Nested Class Summary
`static class` | `ActionCallback.Default` Empty implementation of callback methods, simplifies synchronous execution of an `ActionInvocation`.

Field Summary
`protected ActionInvocation` | `actionInvocation`
`protected ControlPoint` | `controlPoint`

Constructor Summary
`protected` | `ActionCallback(ActionInvocation actionInvocation)`
`protected` | `ActionCallback(ActionInvocation actionInvocation, ControlPoint controlPoint)`

Method Summary
`protected String` | `createDefaultFailureMessage(ActionInvocation invocation, UpnpResponse operation)`
`protected void` | `failure(ActionInvocation invocation, UpnpResponse operation)`
`abstract void` | `failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg)` Called when the action invocation failed.
`ActionInvocation` | `getActionInvocation()`
`ControlPoint` | `getControlPoint()`
`void` | `run()`
`ActionCallback` | `setControlPoint(ControlPoint controlPoint)`
`abstract void` | `success(ActionInvocation invocation)` Called when the action invocation succeeded.
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### actionInvocation

    protected final ActionInvocation actionInvocation

### controlPoint

    protected ControlPoint controlPoint

Constructor Detail

### ActionCallback

    protected ActionCallback(ActionInvocation actionInvocation,
                             ControlPoint controlPoint)

### ActionCallback

    protected ActionCallback(ActionInvocation actionInvocation)

Method Detail

### getActionInvocation

    public ActionInvocation getActionInvocation()

### getControlPoint

    public ControlPoint getControlPoint()

### setControlPoint

    public ActionCallback setControlPoint(ControlPoint controlPoint)

### run

    public void run()

  Specified by:
    `run` in interface `Runnable`

### createDefaultFailureMessage

    protected String createDefaultFailureMessage(ActionInvocation invocation,
                                                 UpnpResponse operation)

### failure

    protected void failure(ActionInvocation invocation,
                           UpnpResponse operation)

### success

    public abstract void success(ActionInvocation invocation)

  Called when the action invocation succeeded.

  Parameters:
    `invocation` - The successful invocation, call its `getOutput()` method for results.

### failure

    public abstract void failure(ActionInvocation invocation,
                                 UpnpResponse operation,
                                 String defaultMsg)

  Called when the action invocation failed.

  Parameters:
    `invocation` - The failed invocation, call its `getFailure()` 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.
  See Also:
    `createDefaultFailureMessage(org.fourthline.cling.model.action.ActionInvocation, org.fourthline.cling.model.message.UpnpResponse)`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2013 4th Line GmbH, Switzerland. All Rights Reserved.