Java Reference
In-Depth Information
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = {ElementType.METHOD})
public @interface OnError {}
Only one method in a class can possess this annotation. The annotation itself has no para-
meters, but the method can optionally take any one of the following:
Throwable— Exception representing the error
Session— WebSocket session
@PathParam— Annotated parameters
To get a better grasp of how this callback works, let's look at an example from the Bul-
letinService in ActionBazaar in the following listing.
Listing 14.18. Handling WebSocket errors in BulletinService
The @OnError annotation in the listing marks the handleFailure method as handling
WebSocket errors . It accepts three parameters. The first parameter is the exception
and will contain the cause of the error. The second parameter is the WebSocket session
, and the third parameter is the client type as pulled from the URL used to invoke the We-
You now have a handle on both programmatic endpoints and annotated endpoints. The next
question is how you can use them in the context of EJB.
Search WWH ::

Custom Search