public class OnlineActivityBuilder {
public static OnlineActivity build(Object principal, Object userDetails, String sessionid,
Date lastRequest) {
OnlineActivityBean activity = new OnlineActivityBean();
activity.setSessionid(sessionid);
activity.setPrincipal(principal);
activity.setLastAccessAt(lastRequest);
UserDetails details = (UserDetails) userDetails;
activity.setUserid(details.getUserid());
activity.setFullname(details.getFullname());
activity.setCategory(details.getCategory());
if (details instanceof WebUserDetails) {
activity.setHost(((WebUserDetails) details).getHost());
}
activity.setLoginAt(new Date());
return activity;
}