Package com.google.gerrit.common
Class EventBroker
- java.lang.Object
-
- com.google.gerrit.common.EventBroker
-
- All Implemented Interfaces:
EventDispatcher
public class EventBroker extends Object implements EventDispatcher
Distributes Events to listeners if they are allowed to see them
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EventBroker.Module
-
Field Summary
Fields Modifier and Type Field Description protected com.google.inject.Provider<ReviewDb>
dbProvider
protected DynamicSet<UserScopedEventListener>
listeners
Listeners to receive changes as they happen (limited by visibility of user).protected ChangeNotes.Factory
notesFactory
protected ProjectCache
projectCache
protected DynamicSet<EventListener>
unrestrictedListeners
Listeners to receive all changes as they happen.
-
Constructor Summary
Constructors Constructor Description EventBroker(DynamicSet<UserScopedEventListener> listeners, DynamicSet<EventListener> unrestrictedListeners, PermissionBackend permissionBackend, ProjectCache projectCache, ChangeNotes.Factory notesFactory, com.google.inject.Provider<ReviewDb> dbProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
fireEvent(Branch.NameKey branchName, RefEvent event)
protected void
fireEvent(Change change, ChangeEvent event)
protected void
fireEvent(Project.NameKey project, ProjectEvent event)
protected void
fireEvent(Event event)
protected void
fireEventForUnrestrictedListeners(Event event)
protected boolean
isVisibleTo(Branch.NameKey branchName, CurrentUser user)
protected boolean
isVisibleTo(Change change, CurrentUser user)
protected boolean
isVisibleTo(Project.NameKey project, CurrentUser user)
protected boolean
isVisibleTo(Event event, CurrentUser user)
void
postEvent(Branch.NameKey branchName, RefEvent event)
Post a stream event that is related to a branchvoid
postEvent(Change change, ChangeEvent event)
Post a stream event that is related to a changevoid
postEvent(Project.NameKey projectName, ProjectEvent event)
Post a stream event that is related to a project.void
postEvent(Event event)
Post a stream event generically.
-
-
-
Field Detail
-
listeners
protected final DynamicSet<UserScopedEventListener> listeners
Listeners to receive changes as they happen (limited by visibility of user).
-
unrestrictedListeners
protected final DynamicSet<EventListener> unrestrictedListeners
Listeners to receive all changes as they happen.
-
projectCache
protected final ProjectCache projectCache
-
notesFactory
protected final ChangeNotes.Factory notesFactory
-
dbProvider
protected final com.google.inject.Provider<ReviewDb> dbProvider
-
-
Constructor Detail
-
EventBroker
@Inject public EventBroker(DynamicSet<UserScopedEventListener> listeners, DynamicSet<EventListener> unrestrictedListeners, PermissionBackend permissionBackend, ProjectCache projectCache, ChangeNotes.Factory notesFactory, com.google.inject.Provider<ReviewDb> dbProvider)
-
-
Method Detail
-
postEvent
public void postEvent(Change change, ChangeEvent event) throws com.google.gwtorm.server.OrmException, PermissionBackendException
Description copied from interface:EventDispatcher
Post a stream event that is related to a change- Specified by:
postEvent
in interfaceEventDispatcher
- Parameters:
change
- The change that the event is related toevent
- The event to post- Throws:
com.google.gwtorm.server.OrmException
- on failure to post the event due to DB errorPermissionBackendException
- on failure of permission checks
-
postEvent
public void postEvent(Branch.NameKey branchName, RefEvent event) throws PermissionBackendException
Description copied from interface:EventDispatcher
Post a stream event that is related to a branch- Specified by:
postEvent
in interfaceEventDispatcher
- Parameters:
branchName
- The branch that the event is related toevent
- The event to post- Throws:
PermissionBackendException
- on failure of permission checks
-
postEvent
public void postEvent(Project.NameKey projectName, ProjectEvent event)
Description copied from interface:EventDispatcher
Post a stream event that is related to a project.- Specified by:
postEvent
in interfaceEventDispatcher
- Parameters:
projectName
- The project that the event is related to.event
- The event to post.
-
postEvent
public void postEvent(Event event) throws com.google.gwtorm.server.OrmException, PermissionBackendException
Description copied from interface:EventDispatcher
Post a stream event generically.If you are creating a RefEvent or ChangeEvent from scratch, it is more efficient to use the specific postEvent methods for those use cases.
- Specified by:
postEvent
in interfaceEventDispatcher
- Parameters:
event
- The event to post.- Throws:
com.google.gwtorm.server.OrmException
- on failure to post the event due to DB errorPermissionBackendException
- on failure of permission checks
-
fireEventForUnrestrictedListeners
protected void fireEventForUnrestrictedListeners(Event event)
-
fireEvent
protected void fireEvent(Change change, ChangeEvent event) throws com.google.gwtorm.server.OrmException, PermissionBackendException
- Throws:
com.google.gwtorm.server.OrmException
PermissionBackendException
-
fireEvent
protected void fireEvent(Project.NameKey project, ProjectEvent event)
-
fireEvent
protected void fireEvent(Branch.NameKey branchName, RefEvent event) throws PermissionBackendException
- Throws:
PermissionBackendException
-
fireEvent
protected void fireEvent(Event event) throws com.google.gwtorm.server.OrmException, PermissionBackendException
- Throws:
com.google.gwtorm.server.OrmException
PermissionBackendException
-
isVisibleTo
protected boolean isVisibleTo(Project.NameKey project, CurrentUser user)
-
isVisibleTo
protected boolean isVisibleTo(Change change, CurrentUser user) throws com.google.gwtorm.server.OrmException, PermissionBackendException
- Throws:
com.google.gwtorm.server.OrmException
PermissionBackendException
-
isVisibleTo
protected boolean isVisibleTo(Branch.NameKey branchName, CurrentUser user) throws PermissionBackendException
- Throws:
PermissionBackendException
-
isVisibleTo
protected boolean isVisibleTo(Event event, CurrentUser user) throws com.google.gwtorm.server.OrmException, PermissionBackendException
- Throws:
com.google.gwtorm.server.OrmException
PermissionBackendException
-
-