Package com.google.gerrit.server.events
Class EventBroker
- java.lang.Object
-
- com.google.gerrit.server.events.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.EventBrokerModule
-
Field Summary
Fields Modifier and Type Field Description protected String
gerritInstanceId
protected PluginSetContext<UserScopedEventListener>
listeners
Listeners to receive changes as they happen (limited by visibility of user).protected ChangeNotes.Factory
notesFactory
protected ProjectCache
projectCache
protected PluginSetContext<EventListener>
unrestrictedListeners
Listeners to receive all changes as they happen.
-
Constructor Summary
Constructors Constructor Description EventBroker(PluginSetContext<UserScopedEventListener> listeners, PluginSetContext<EventListener> unrestrictedListeners, PermissionBackend permissionBackend, ProjectCache projectCache, ChangeNotes.Factory notesFactory, String gerritInstanceId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
fireEvent(BranchNameKey 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(BranchNameKey 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(BranchNameKey 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.protected void
setInstanceIdWhenEmpty(Event event)
-
-
-
Field Detail
-
listeners
protected final PluginSetContext<UserScopedEventListener> listeners
Listeners to receive changes as they happen (limited by visibility of user).
-
unrestrictedListeners
protected final PluginSetContext<EventListener> unrestrictedListeners
Listeners to receive all changes as they happen.
-
projectCache
protected final ProjectCache projectCache
-
notesFactory
protected final ChangeNotes.Factory notesFactory
-
gerritInstanceId
protected final String gerritInstanceId
-
-
Constructor Detail
-
EventBroker
@Inject public EventBroker(PluginSetContext<UserScopedEventListener> listeners, PluginSetContext<EventListener> unrestrictedListeners, PermissionBackend permissionBackend, ProjectCache projectCache, ChangeNotes.Factory notesFactory, String gerritInstanceId)
-
-
Method Detail
-
postEvent
public void postEvent(Change change, ChangeEvent event) throws 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:
PermissionBackendException
- on failure of permission checks
-
postEvent
public void postEvent(BranchNameKey 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 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:
PermissionBackendException
- on failure of permission checks
-
fireEventForUnrestrictedListeners
protected void fireEventForUnrestrictedListeners(Event event)
-
fireEvent
protected void fireEvent(Change change, ChangeEvent event) throws PermissionBackendException
- Throws:
PermissionBackendException
-
fireEvent
protected void fireEvent(Project.NameKey project, ProjectEvent event)
-
fireEvent
protected void fireEvent(BranchNameKey branchName, RefEvent event) throws PermissionBackendException
- Throws:
PermissionBackendException
-
fireEvent
protected void fireEvent(Event event) throws PermissionBackendException
- Throws:
PermissionBackendException
-
setInstanceIdWhenEmpty
protected void setInstanceIdWhenEmpty(Event event)
-
isVisibleTo
protected boolean isVisibleTo(Project.NameKey project, CurrentUser user)
-
isVisibleTo
protected boolean isVisibleTo(Change change, CurrentUser user) throws PermissionBackendException
- Throws:
PermissionBackendException
-
isVisibleTo
protected boolean isVisibleTo(BranchNameKey branchName, CurrentUser user) throws PermissionBackendException
- Throws:
PermissionBackendException
-
isVisibleTo
protected boolean isVisibleTo(Event event, CurrentUser user) throws PermissionBackendException
- Throws:
PermissionBackendException
-
-