/**
   * This method is called when the handler receives a request. This class needs to be set as the
   * listener on the <code>ContentHandlerServer</code>. See {@link #register}.
   *
   * @see RequestListener#invocationRequestNotify(ContentHandlerServer)
   */
  public void invocationRequestNotify(final ContentHandlerServer server) {
    // Retrieve Invocation from the content handler server
    final Invocation invoc = server.getRequest(false);

    if (invoc == null) {
      return; // Nothing to do
    }

    int invocationStatus = invoc.getStatus();

    try {
      final Registry registry = Registry.getRegistry(getClass().getName());
      final DefaultContentHandlerRegistry defaultRegistry =
          DefaultContentHandlerRegistry.getDefaultContentHandlerRegistry(registry);
      final ApplicationDescriptor descriptor =
          defaultRegistry.getApplicationDescriptor(server.getID());

      Dialog.alert(descriptor.getName() + " invoked for: " + invoc.getURL());

      // ...
      // Other processing could be done here
      // ...

      // If there are errors or exceptions, the invocation status
      // should be updated. In this case everything is OK.
      invocationStatus = Invocation.OK;
    } finally {
      server.finish(invoc, invocationStatus);
    }
  }
 /**
  * Gets the next Invocation request pending for this ContentHandlerServer. The method can be
  * unblocked with a call to {@link #cancelGetRequest cancelGetRequest}. The application should
  * process the Invocation as a request to perform the <code>action</code> on the content.
  *
  * @param wait <code>true</code> if the method must wait for for an Invocation if one is not
  *     available; <code>false</code> if the method MUST NOT wait.
  * @return the next pending Invocation or <code>null</code> if no Invocation is available; <code>
  *     null</code> if cancelled with {@link #cancelGetRequest cancelGetRequest}
  * @see javax.microedition.content.Registry#invoke
  * @see javax.microedition.content.ContentHandlerServer#finish
  */
 public Invocation getRequest(boolean wait) {
   Invocation request = new Invocation((InvocationImpl) null);
   InvocationImpl invoc = super.getRequest(wait, request);
   if (invoc != null) {
     // Wrap it in an Invocation instance
     request.setInvocImpl(invoc);
     return request;
   }
   return null;
 }
 /**
  * Finish this Invocation and set the status for the response. The <code>finish</code> method may
  * only be called when this Invocation has a status of <code>ACTIVE</code> or <code>HOLD</code>.
  *
  * <p>The content handler may modify the URL, type, action, or arguments before invoking <code>
  * finish</code>. If the method {@link Invocation#getResponseRequired} returns <code>true</code>
  * then the modified values MUST be returned to the invoking application.
  *
  * @param invoc the Invocation to finish
  * @param status the new status of the Invocation. This MUST be either <code>OK</code> or <code>
  *     CANCELLED</code>.
  * @return <code>true</code> if the MIDlet suite MUST voluntarily exit before the response can be
  *     returned to the invoking application
  * @exception IllegalArgumentException if the new <code>status</code> of the Invocation is not
  *     <code>OK</code> or <code>CANCELLED</code>
  * @exception IllegalStateException if the current <code>status</code> of the Invocation is not
  *     <code>ACTIVE</code> or <code>HOLD</code>
  * @exception NullPointerException if the invocation is <code>null</code>
  */
 public boolean finish(Invocation invoc, int status) {
   return finish(invoc.getInvocImpl(), status);
 }