org.xlightweb
Annotation Type SynchronizedOn
@Target(value={TYPE,METHOD})
@Retention(value=RUNTIME)
public @interface SynchronizedOn
Annotation which defines the synchronization context by performing call back methods.
By default the synchronization scope is CONNECTION. If the synchronization
mode is set to SESSION, the call back will be synchronized around
the HttpSession, to serialize invocations from the same client. If there
is no session, the synchronization scope will be CONNECTION
Typically SESSION synchronization will be used to avoid side-effects by accessing
the IHttpSession by different requests simultaneously. Such overlapping requests on
a session can occur in applications such as AJAX applications which generate requests
programmatically. Example:
class MyRequestHandler implements IHttpRequestHandler {
@SynchronizedOn(SynchronizedOn.SESSION) // overrides default CONNECTION
public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
IHttpSesssion session = exchange.getSession(true);
Integer counter = (Integer) session.getAttribute("myCounter");
session.setAttribute("myCounter", value);
//...
}
}
|
Optional Element Summary |
int |
value
|
value
public abstract int value
- Default:
- 0