/** * This method is used to register a {@link Listener} to the events of the same * name. It is similar to addListener(listener.getName(), listener) * * @param listener the listener to notify any time an even of the same name is * triggered */ public void addListener(Listener listener) { addListener(listener.getName(), listener); }
@Override public void setDescription(String s) { listener.setDescription(s); }
@Override public String getName() { return listener.getName(); }
@Override public void onEvent(Event<PortalContainer, HttpSessionEvent> event) throws Exception { String eventName = event.getEventName(); SessionEvent.SessionEventType eventType; if (SESSION_CREATED.equals(eventName)) { eventType = SessionEvent.SessionEventType.SESSION_CREATED; } else if (SESSION_DESTROYED.equals(eventName)) { eventType = SessionEvent.SessionEventType.SESSION_DESTROYED; } else { // do nothing return; } notifyListenersOf(new SimpleSessionEvent(eventType, event.getData().getSession())); }
@Override public void onEvent(Event<PortalContainer, HttpSessionEvent> event) throws Exception { PortalContainer container = event.getSource(); HttpSession session = event.getData().getSession(); UploadService uploadService = (UploadService)container.getComponentInstanceOfType(UploadService.class); uploadService.cleanUp(session); } }
List<Listener> list = listeners_.get(event.getEventName()); if (list == null) listener.onEvent(event);
public void saveUser(User user, boolean broadcast) throws Exception { UserImpl userImpl = (UserImpl)user; if (broadcast) listenerService_.broadcast(UserHandler.PRE_UPDATE_USER_EVENT, this, userImpl); super.update(userImpl); if (broadcast) listenerService_.broadcast(UserHandler.POST_UPDATE_USER_EVENT, this, userImpl); }
@Override public void setName(String s) { listener.setName(s); }
@Override public String getDescription() { return listener.getDescription(); }
@Asynchronous public class LoginHistoryListener extends Listener<ConversationRegistry, ConversationState> { private static final Log LOG = ExoLogger.getLogger(LoginHistoryListener.class);
@Override public void onEvent(Event<S, D> event) throws Exception { executor.execute(new RunListener<S, D>(listener, event)); } }
/** * Construct a listener service. */ public ListenerService(ExoContainerContext ctx, InitialContextInitializer initializer, InitParams params) { container = ctx.getContainer(); listeners_ = new HashMap<String, List<Listener>>(); int poolSize = 1; if (params != null && params.getValueParam("asynchPoolSize") != null) { poolSize = Integer.parseInt(params.getValueParam("asynchPoolSize").getValue()); } executor = Executors.newFixedThreadPool(poolSize, new ListenerThreadFactory()); }
@SuppressWarnings("unchecked") public void onEvent(Event<GroupDAOImpl, Group> event) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("Remove all Child of Group: " + event.getData().getId()); } GroupHandler membershipHanler = service_.getGroupHandler(); List<Group> children = (List<Group>)membershipHanler.findGroups(event.getData()); for (Group child : children) { membershipHanler.removeGroup(child, true); } } }
public void saveGroup(Group group, boolean broadcast) throws Exception { GroupImpl groupImpl = (GroupImpl)group; if (broadcast) listenerService_.broadcast(GroupHandler.PRE_UPDATE_GROUP_EVENT, this, groupImpl); super.update(groupImpl); if (broadcast) listenerService_.broadcast(GroupHandler.POST_UPDATE_GROUP_EVENT, this, groupImpl); }
/** * {@inheritDoc} */ public void onEvent(Event<ConversationRegistry, ConversationState> event) throws Exception { if (!organizationIntegrationService.isEnabled()) { return; } String userId = event.getData().getIdentity().getUserId(); if (LOG.isDebugEnabled()) { LOG.debug("Apply listeners for user " + userId); } organizationIntegrationService.syncUser(userId, EventType.ADDED.toString()); if (LOG.isDebugEnabled()) { LOG.debug("User listeners applied for " + userId); } } }
public User removeUser(String userName, boolean broadcast) throws Exception { UserImpl userImpl = (UserImpl)findUserByName(userName); if (userImpl == null) return null; if (broadcast) listenerService_.broadcast(UserHandler.PRE_DELETE_USER_EVENT, this, userImpl); super.remove(userImpl); if (broadcast) listenerService_.broadcast(UserHandler.POST_DELETE_USER_EVENT, this, userImpl); return userImpl; }
public UserProfile removeUserProfile(String userName, boolean broadcast) throws Exception { UserProfileData userImpl = findUserProfileDataByName(userName); if (userImpl == null) return null; if (broadcast) listenerService_.broadcast("organization.userProfile.preDelete", this, userImpl); super.remove(userImpl); if (broadcast) listenerService_.broadcast("organization.userProfile.postDelete", this, userImpl); return userImpl.getUserProfile(); }
public void createUser(User user, boolean broadcast) throws Exception { if (LOG.isDebugEnabled()) LOG.debug("----------- CREATE USER " + user.getUserName()); UserImpl userImpl = (UserImpl)user; if (broadcast) listenerService_.broadcast(UserHandler.PRE_CREATE_USER_EVENT, this, userImpl); super.save(userImpl); if (broadcast) listenerService_.broadcast(UserHandler.POST_CREATE_USER_EVENT, this, userImpl); }