FileDocCategorySizeDatePackage
ContentHandlerServerImpl.javaAPI DocphoneME MR2 API (J2ME)5249Wed May 02 18:00:44 BST 2007javax.microedition.content

ContentHandlerServerImpl

public final class ContentHandlerServerImpl extends com.sun.midp.content.ContentHandlerImpl implements javax.microedition.content.ContentHandlerServer
The internal structure of a registered content handler.

Fields Summary
private javax.microedition.content.RequestListener
listener
The listener to notify.
Constructors Summary
ContentHandlerServerImpl(com.sun.midp.content.ContentHandlerImpl handler)
Construct an empty ContentHandlerServerImpl that has the same fields as the existing handler.

param
handler the ContentHandlerImpl to clone

	super(handler);
    
Methods Summary
public booleanfinish(javax.microedition.content.Invocation invoc, int status)
Finish this Invocation and set the status for the response. The finish method may only be called when this Invocation has a status of ACTIVE or HOLD.

The content handler may modify the URL, type, action, or arguments before invoking finish. If the method {@link Invocation#getResponseRequired} returns true 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 OK or CANCELLED.
return
true if the MIDlet suite MUST voluntarily exit before the response can be returned to the invoking application
exception
IllegalArgumentException if the new status of the Invocation is not OK or CANCELLED
exception
IllegalStateException if the current status of the Invocation is not ACTIVE or HOLD
exception
NullPointerException if the invocation is null

	return finish(invoc.getInvocImpl(), status);
    
public javax.microedition.content.InvocationgetRequest(boolean wait)
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 action on the content.

param
wait true if the method must wait for for an Invocation if one is not available; false if the method MUST NOT wait.
return
the next pending Invocation or null if no Invocation is available; null if cancelled with {@link #cancelGetRequest cancelGetRequest}
see
javax.microedition.content.Registry#invoke
see
javax.microedition.content.ContentHandlerServer#finish

	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;
    
protected voidrequestNotify()
Notify the listener of a pending Request.

	RequestListener l = listener;
	if (l != null) {
	    l.invocationRequestNotify(this);
	}
    
public voidsetListener(javax.microedition.content.RequestListener listener)
Set the listener to be notified when a new request is available for this content handler. The request MUST be retrieved using {@link #getRequest}.

param
listener the listener to register; null to remove the listener.

	// Start/set the thread needed to monitor the InvocationStore
	this.listener = listener;
	super.setListener(listener);