be.unamur.inference.web
Class UserSessionBuilder<T extends UserSession<U>,U extends UserRequest>

java.lang.Object
  extended by be.unamur.inference.web.UserSessionBuilder<T,U>
Type Parameters:
T - The type of UserSession to consider.
U - The type of UserRequest to consider.
Direct Known Subclasses:
ApacheUserSessionBuilder

public abstract class UserSessionBuilder<T extends UserSession<U>,U extends UserRequest>
extends Object

Represents an abstract UserSessionBuilder. This object encapsulates methods to manage the building, filtering and dispatching the UserSessions get from an InputStream. The filtering is done using include and exclude UserRequestFilters and the processing is delegated to UserSessionProcessors registered as listeners of this builder object.

Author:
Xavier Devroey - xavier.devroey@unamur.be

Constructor Summary
UserSessionBuilder()
          Creates a new user session builder.
 
Method Summary
 UserSessionBuilder<T,U> addListener(UserSessionProcessor<T> listener)
          Add a listener notified when a session is built (during buildSession call).
abstract  void buildSessions(InputStream input)
          Build the session from the different request of the InputStream.
 UserSessionBuilder<T,U> exclude(UserRequestFilter<U> filter)
          Add an include filter to this builder.
 UserSessionBuilder<T,U> include(UserRequestFilter<U> filter)
          Add an include filter to this builder.
protected  boolean isAcceptedRequest(U req)
          Check if the request is accepted according to the include and exclude filters.
protected  void sessionCompleted(T session)
          Notifies the listeners that the given session has been built.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserSessionBuilder

public UserSessionBuilder()
Creates a new user session builder.

Method Detail

addListener

public UserSessionBuilder<T,U> addListener(UserSessionProcessor<T> listener)
Add a listener notified when a session is built (during buildSession call).

Parameters:
listener - The listener to add.
Returns:
This object.

sessionCompleted

protected void sessionCompleted(T session)
Notifies the listeners that the given session has been built.

Parameters:
session - The session given to the listeners.

include

public UserSessionBuilder<T,U> include(UserRequestFilter<U> filter)
Add an include filter to this builder. Only requests satisfying all the include filters are added to sessions.

Parameters:
filter - The filter to add
Returns:
This object.

exclude

public UserSessionBuilder<T,U> exclude(UserRequestFilter<U> filter)
Add an include filter to this builder. Only requests that does not satisfy all the exclude filters are added to sessions.

Parameters:
filter - The filter to add
Returns:
This object.

isAcceptedRequest

protected boolean isAcceptedRequest(U req)
Check if the request is accepted according to the include and exclude filters.

Parameters:
req - The request to process.
Returns:
True if the request satisfy all the include filters and does not satisfy all the exclude filters.

buildSessions

public abstract void buildSessions(InputStream input)
                            throws SessionBuildException
Build the session from the different request of the InputStream. Each time a session is build, the sessionCompleted(Session) method is called to notify the listeners of the builder. All the requests in the builded sessions have to satisfy isAcceptedRequest(Request).

Parameters:
input - The InputStream to read.
Throws:
SessionBuildException - If an exception occurs during the building of the sessions.


Copyright © 2014 PReCISE, University of Namur. All rights reserved.