com.ibm.wbi
Class RequestRejectedException
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--com.ibm.wbi.RequestRejectedException
- All Implemented Interfaces:
- java.io.Serializable
- public class RequestRejectedException
- extends java.lang.Exception
This exception may be thrown by a Meg to indicate that it does not
want to accept the request is was given. The request will be
handled by some other Meg, if appropriate.
Important: The Meg forfeits its opportunity to reject the
request, that is, it must handle the request, if
either of two things occur:
- The Meg generates any output. That means any of the
following:
- The Meg writes to its output stream by calling
MegOutputStream.write().
- The Meg writes to its output writer by calling
MegWriter.write().
- The Meg passes a
MegObject as output by
calling RequestEvent.putMegObject().
- The Meg consumes any of its input without properly
notifying the
RequestEvent first. "Consuming
input" means any of the following:
- The Meg reads from its input stream by calling
MegInputStream.read().
- The Meg reads from its input reader by calling
MegReader.read().
- The Meg receives its object input by calling
RequestEvent.getMegObject().
See below for a discussion of how to "properly notify" the
RequestEvent.
The issue of how to properly notify the RequestEvent
deserves some explanation. The Meg can call peek() on
the MegReader or MegInputStream all it
wants before rejecting the request, and that is not a problem.
However, there may be only a limited amount of data available via
peek(). In this case read() will allow
access to the full amount of data, but this is considered
"consumption" of input. If the Meg is receiving a
MegObject as input, simply calling
RequestEvent.getMegObject() is considered consumption
of input. In these cases, the Meg must notify the
RequestEvent before consuming input. Otherwise it is
obligated to handle the request. To notify the
RequestEvent, the Meg calls
RequestEvent.mayReject(). This must be done before
calling ,
RequestEvent.getMegReader(), or
RequestEvent.getMegObject().
Note that there is no equivalent mechanism to reject a request
after writing some output. A Meg that has written output must
always handle the request.
If a Meg that has called mayReject() decides that it definitely
will not reject the request, it MAY call
RequestEvent.wontReject(). This method is optional,
because it is always called for the Meg at the time of the first
write to the MegOutputStream or MegWriter. But if a Meg knows it
will be handling the request, and that it will read and buffer a
large amount of data from the MegInputStream/MegReader before doing
any writes to the MegOutputStream/MegWriter, calling wontReject()
at the earliest opportunity may free up some memory.
- See Also:
RequestEvent.mayReject(),
RequestEvent.wontReject(), Serialized Form
| Methods inherited from class java.lang.Throwable |
fillInStackTrace, getLocalizedMessage, getMessage, printStackTrace, printStackTrace, printStackTrace, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
RequestRejectedException
public RequestRejectedException()
- Construct a new RequestRejectedException.
RequestRejectedException
public RequestRejectedException(java.lang.String msg)
- Construct a new RequestRejectedException with specified message.
- Parameters:
msg - The detailed message.