Here are the examples of the java api org.springframework.context.ApplicationEventPublisher.publishEvent() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
577 Examples
19
View Source File : CustomizePublisher.java
License : Apache License 2.0
Project Creator : zq2599
License : Apache License 2.0
Project Creator : zq2599
/**
* 发送一条广播
*/
public void publishEvent() {
applicationEventPublisher.publishEvent(new CustomizeEvent(applicationContext));
}
19
View Source File : AbstractPluginExecutor.java
License : GNU Affero General Public License v3.0
Project Creator : xggz
License : GNU Affero General Public License v3.0
Project Creator : xggz
/**
* 插件主动推送消息事件
*
* @param messageEvent
*/
protected void pushMessage(MessageEvent messageEvent) {
eventPublisher.publishEvent(messageEvent);
}
19
View Source File : JdbcRouteLocator.java
License : MIT License
Project Creator : uhonliu
License : MIT License
Project Creator : uhonliu
@Override
public void doRefresh() {
super.doRefresh();
// 发布本地刷新事件, 更新相关本地缓存, 解决动态加载完,新路由映射无效的问题
publisher.publishEvent(new RoutesRefreshedEvent(this));
}
19
View Source File : OpenRestTemplate.java
License : MIT License
Project Creator : uhonliu
License : MIT License
Project Creator : uhonliu
/**
* 刷新网关
* 注:不要频繁调用!
* 1.资源权限发生变化时可以调用
* 2.流量限制变化时可以调用
* 3.IP访问发生变化时可以调用
* 4.智能路由发生变化时可以调用
*/
public void refreshGateway() {
try {
publisher.publishEvent(new RemoteRefreshRouteEvent(this, busProperties.getId(), null));
log.info("refreshGateway:success");
} catch (Exception e) {
log.error("refreshGateway error:{}", e.getMessage());
}
}
19
View Source File : EventHandlingConfiguration.java
License : Apache License 2.0
Project Creator : TheBund1st
License : Apache License 2.0
Project Creator : TheBund1st
@Bean
public DomainEventPublisher eventPublisher() {
return event -> {
log.debug("Attempt to publish {}", event);
applicationEventPublisher.publishEvent(event);
};
}
19
View Source File : BrokerClientConnectionListener.java
License : Apache License 2.0
Project Creator : spring-cloud-incubator
License : Apache License 2.0
Project Creator : spring-cloud-incubator
private Consumer<RSocketRequester> publishEvent() {
return requester -> publisher.publishEvent(new RSocketRequesterEvent<>(BrokerClientConnectionListener.this, requester));
}
19
View Source File : WeightCalculatorWebFilterConcurrentTests.java
License : Apache License 2.0
Project Creator : spring-cloud
License : Apache License 2.0
Project Creator : spring-cloud
private void generateEvents() {
executorService.execute(() -> {
while (isContinue()) {
eventPublisher.publishEvent(createWeightDefinedEvent());
}
});
}
19
View Source File : AdminController.java
License : Apache License 2.0
Project Creator : spinnaker
License : Apache License 2.0
Project Creator : spinnaker
private void setInstanceEnabled(boolean enabled) {
InstanceStatus currentStatus = enabled ? UP : OUT_OF_SERVICE;
InstanceStatus previousStatus = currentStatus == OUT_OF_SERVICE ? UP : UNKNOWN;
publisher.publishEvent(new RemoteStatusChangedEvent(new DiscoveryStatusChangeEvent(previousStatus, currentStatus)));
}
19
View Source File : RqueueMessageListenerContainer.java
License : Apache License 2.0
Project Creator : sonus21
License : Apache License 2.0
Project Creator : sonus21
@Override
public void stop() {
log.info("Stopping Rqueue Message container");
synchronized (lifecycleMgr) {
running = false;
applicationEventPublisher.publishEvent(new RqueueBootstrapEvent("Container", false));
doStop();
lifecycleMgr.notifyAll();
}
}
19
View Source File : RqueueMessageListenerContainer.java
License : Apache License 2.0
Project Creator : sonus21
License : Apache License 2.0
Project Creator : sonus21
@Override
public void start() {
log.info("Starting Rqueue Message container");
synchronized (lifecycleMgr) {
running = true;
doStart();
applicationEventPublisher.publishEvent(new RqueueBootstrapEvent("Container", true));
lifecycleMgr.notifyAll();
}
}
19
View Source File : MQCloudConfigHelper.java
License : Apache License 2.0
Project Creator : sohutv
License : Apache License 2.0
Project Creator : sohutv
@Override
public void run(String... args) throws Exception {
publisher.publishEvent(new MQCloudConfigEvent());
}
19
View Source File : InvoiceService.java
License : MIT License
Project Creator : puzzle
License : MIT License
Project Creator : puzzle
public void sendEvent(InvoiceDTO invoice, boolean firstSettleEvent) {
eventPublisher.publishEvent(new InvoiceEvent(this, invoice, firstSettleEvent));
}
19
View Source File : OpenIdConnectFilter.java
License : MIT License
Project Creator : PacktPublishing
License : MIT License
Project Creator : PacktPublishing
private void publish(ApplicationEvent event) {
if (eventPublisher != null) {
eventPublisher.publishEvent(event);
}
}
19
View Source File : ApiKeyEventsPublisher.java
License : GNU Affero General Public License v3.0
Project Creator : overture-stack
License : GNU Affero General Public License v3.0
Project Creator : overture-stack
public void requestApiKeyCleanup(@NonNull final Set<ApiKey> apiKeys) {
applicationEventPublisher.publishEvent(new RevokeApiKeysEvent(this, apiKeys));
}
19
View Source File : ApiKeyEventsPublisher.java
License : GNU Affero General Public License v3.0
Project Creator : overture-stack
License : GNU Affero General Public License v3.0
Project Creator : overture-stack
public void requestApiKeyCleanupByUsers(@NonNull final Set<User> users) {
applicationEventPublisher.publishEvent(new CleanupUserApiKeysEvent(this, users));
}
19
View Source File : EventListenerTest.java
License : Apache License 2.0
Project Creator : otaviof
License : Apache License 2.0
Project Creator : otaviof
@BeforeEach
void prepare() {
publisher.publishEvent(new Event(this, "test", null));
}
19
View Source File : GroupsController.java
License : Mozilla Public License 2.0
Project Creator : opfab
License : Mozilla Public License 2.0
Project Creator : opfab
// Remove the link between the group and all its members (this link is in "user" mongo collection)
private void removeTheReferenceToTheGroupForMemberUsers(String idGroup) {
List<UserData> foundUsers = userRepository.findByGroupSetContaining(idGroup);
if (foundUsers != null) {
for (UserData userData : foundUsers) {
userData.deleteGroup(idGroup);
publisher.publishEvent(new UpdatedUserEvent(this, busServiceMatcher.getServiceId(), userData.getLogin()));
}
userRepository.saveAll(foundUsers);
}
}
19
View Source File : OrderManagement.java
License : Apache License 2.0
Project Creator : odrotbohm
License : Apache License 2.0
Project Creator : odrotbohm
void completeOrder(Order order) {
publisher.publishEvent(new SomeOtherEvent());
order.complete();
log.info("Completing order {}.", order);
orders.save(order);
publisher.publishEvent(new OrderCompleted(order));
}
19
View Source File : ServiceComponentA.java
License : Apache License 2.0
Project Creator : odrotbohm
License : Apache License 2.0
Project Creator : odrotbohm
public void fireEvent() {
publisher.publishEvent(new SomeEventA("Message"));
}
19
View Source File : AbstractNacosPropertySourceBuilder.java
License : Apache License 2.0
Project Creator : nacos-group
License : Apache License 2.0
Project Creator : nacos-group
private void publishMetadataEvent(NacosConfigMetadataEvent metadataEvent) {
applicationEventPublisher.publishEvent(metadataEvent);
}
19
View Source File : EventPublishingConfigService.java
License : Apache License 2.0
Project Creator : nacos-group
License : Apache License 2.0
Project Creator : nacos-group
private void publishEvent(NacosConfigEvent nacosConfigEvent) {
applicationEventPublisher.publishEvent(nacosConfigEvent);
}
19
View Source File : DelegatingEventPublishingListener.java
License : Apache License 2.0
Project Creator : nacos-group
License : Apache License 2.0
Project Creator : nacos-group
private void publishEvent(String content) {
NacosConfigReceivedEvent event = new NacosConfigReceivedEvent(configService, dataId, groupId, content, configType);
applicationEventPublisher.publishEvent(event);
}
19
View Source File : RefreshRoute.java
License : Apache License 2.0
Project Creator : my-dlq
License : Apache License 2.0
Project Creator : my-dlq
public void refreshRoute() {
publisher.publishEvent(new RoutesRefreshedEvent(this.routeLocator));
}
19
View Source File : GRpcServerApplicationService.java
License : Apache License 2.0
Project Creator : minbox-projects
License : Apache License 2.0
Project Creator : minbox-projects
/**
* Start eliminate expired client
* <p>
* If the client's last heartbeat time is greater than the timeout threshold,
* the update status is performed
*/
private void startEliminateExpiredClient() {
this.expiredScheduledExecutor.scheduleAtFixedRate(() -> {
// Publish expired event
ServiceEvent serviceEvent = new ServiceEvent(this, ServiceEventType.EXPIRE);
applicationEventPublisher.publishEvent(serviceEvent);
}, 5, configuration.getCheckClientExpiredIntervalSeconds(), TimeUnit.SECONDS);
}
19
View Source File : InjectingApplicationEventPublisherDemo.java
License : Apache License 2.0
Project Creator : mercyblitz
License : Apache License 2.0
Project Creator : mercyblitz
@PostConstruct
public void init() {
// # 3
applicationEventPublisher.publishEvent(new MySpringEvent("The event from @Autowired ApplicationEventPublisher"));
// #4
applicationContext.publishEvent(new MySpringEvent("The event from @Autowired ApplicationContext"));
}
19
View Source File : MyHouse.java
License : MIT License
Project Creator : loda-kun
License : MIT License
Project Creator : loda-kun
/**
* Hành động bấm chuông cửa
*/
public void rangDoorbellBy(String guestName) {
// Phát ra một sự kiện DoorBellEvent
// source (Nguồn phát ra) chính là clreplaced này
applicationEventPublisher.publishEvent(new DoorBellEvent(this, guestName));
}
19
View Source File : ZkClient.java
License : GNU General Public License v2.0
Project Creator : liuht777
License : GNU General Public License v2.0
Project Creator : liuht777
/**
* 监听指定节点
* <p>
* 主要做重新分配任务使用
*
* @param path
*/
private void watchPath(String path) {
try {
// 监听子节点变化情况
final PathChildrenCache watcher = new PathChildrenCache(this.client, path, true);
watcher.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
watcher.getListenable().addListener((client, event) -> {
switch(event.getType()) {
case CHILD_ADDED:
log.info("监听到节点变化: 新增path=: {}", event.getData().getPath());
// 新增server节点和task节点都需要触发重新分配任务事件
if (event.getData().getPath().startsWith(this.serverPath)) {
// 新增server节点触发 ServerNodeAddEvent
eventPublisher.publishEvent(new ServerNodeAddEvent(event.getData().getPath()));
} else {
// 新增task节点需要触发重新分配任务事件
eventPublisher.publishEvent(new replacedignScheduleTaskEvent(event.getData().getPath()));
}
break;
case CHILD_REMOVED:
log.info("监听到节点变化: 删除path=: {}", event.getData().getPath());
// 删除task节点不需要发布重新分配任务事件
if (event.getData().getPath().startsWith(this.serverPath)) {
eventPublisher.publishEvent(new replacedignScheduleTaskEvent(event.getData().getPath()));
}
break;
default:
break;
}
});
} catch (Exception e) {
log.error("watchPath failed", e);
}
}
19
View Source File : MyEventPublisher.java
License : Apache License 2.0
Project Creator : linnykoleh
License : Apache License 2.0
Project Creator : linnykoleh
public void publish() {
eventPublisher.publishEvent(new DrawEvent(this));
}
19
View Source File : SolverManager.java
License : Apache License 2.0
Project Creator : kiegroup
License : Apache License 2.0
Project Creator : kiegroup
void startSolver(VehicleRoutingSolution solution) {
if (solverFuture != null) {
throw new IllegalStateException("Solver start has already been requested");
}
solverFuture = executor.submitListenable((SolvingTask) () -> solver.solve(solution));
solverFuture.addCallback(// IMPORTANT: This is happening on the solver thread.
// TODO in both cases restart or somehow recover?
result -> {
if (!solver.isTerminateEarly()) {
// This is impossible. Solver in daemon mode can't return from solve() unless it has been
// terminated (see #stopSolver()) or throws an exception.
logger.error("Solver stopped solving but that shouldn't happen in daemon mode.");
eventPublisher.publishEvent(new ErrorEvent(this, "Solver stopped solving unexpectedly."));
}
}, exception -> {
logger.error("Solver failed", exception);
eventPublisher.publishEvent(new ErrorEvent(this, exception.toString()));
});
}
19
View Source File : PasswordRecoveryServiceImpl.java
License : MIT License
Project Creator : ita-social-projects
License : MIT License
Project Creator : ita-social-projects
/**
* {@inheritDoc}
*/
@Transactional
@Override
public void updatePreplacedwordUsingToken(String token, String newPreplacedword) {
RestorePreplacedwordEmail restorePreplacedwordEmail = restorePreplacedwordEmailRepo.findByToken(token).orElseThrow(() -> new BadVerifyEmailTokenException(NO_ANY_EMAIL_TO_VERIFY_BY_THIS_TOKEN));
if (isNotExpired(restorePreplacedwordEmail.getExpiryDate())) {
applicationEventPublisher.publishEvent(new UpdatePreplacedwordEvent(this, newPreplacedword, restorePreplacedwordEmail.getUser().getId()));
restorePreplacedwordEmailRepo.delete(restorePreplacedwordEmail);
log.info("User with email " + restorePreplacedwordEmail.getUser().getEmail() + " has successfully restored the preplacedword using token " + token);
} else {
log.info("Preplacedword restoration token of user with email " + restorePreplacedwordEmail.getUser().getEmail() + " has been expired. Token: " + token);
throw new UserActivationEmailTokenExpiredException(EMAIL_TOKEN_EXPIRED);
}
}
19
View Source File : HttpTraceEventHandler.java
License : Apache License 2.0
Project Creator : International-Data-Spaces-Association
License : Apache License 2.0
Project Creator : International-Data-Spaces-Association
/**
* Raise an HttpTraceEvent.
*
* @param trace The http trace that others should be notified about.
*/
public void sendHttpTraceEvent(HttpTrace trace) {
publisher.publishEvent(trace);
}
19
View Source File : RestIdentityProviderService.java
License : MIT License
Project Creator : InnovateUKGitHub
License : MIT License
Project Creator : InnovateUKGitHub
@Override
public ServiceResult<String> createUserRecordWithUid(String emailAddress, String preplacedword) {
return handlingErrors(() -> {
CreateUserResource createUserRequest = new CreateUserResource(emailAddress, preplacedword);
Either<ResponseEnreplacedy<IdenreplacedyProviderError[]>, CreateUserResponse> response = restPost(idpBaseURL + idpUserPath, createUserRequest, CreateUserResponse.clreplaced, IdenreplacedyProviderError[].clreplaced, CREATED);
return response.mapLeftOrRight(failure -> serviceFailure(errors(failure.getStatusCode(), failure.getBody())), success -> {
applicationEventPublisher.publishEvent(new UserCreationEvent(this, success.getUuid(), emailAddress));
return serviceSuccess(success.getUuid());
});
});
}
19
View Source File : DocumentServiceImpl.java
License : Apache License 2.0
Project Creator : inception-project
License : Apache License 2.0
Project Creator : inception-project
@Override
@Transactional
public SourceDoreplacedentState setSourceDoreplacedentState(SourceDoreplacedent aDoreplacedent, SourceDoreplacedentState aState) {
Validate.notNull(aDoreplacedent, "Source doreplacedent must be specified");
Validate.notNull(aState, "State must be specified");
SourceDoreplacedentState oldState = aDoreplacedent.getState();
aDoreplacedent.setState(aState);
createSourceDoreplacedent(aDoreplacedent);
// Notify about change in doreplacedent state
if (!Objects.equals(oldState, aDoreplacedent.getState())) {
applicationEventPublisher.publishEvent(new DoreplacedentStateChangedEvent(this, aDoreplacedent, oldState));
}
return oldState;
}
19
View Source File : TypeAdapter_ImplBase.java
License : Apache License 2.0
Project Creator : inception-project
License : Apache License 2.0
Project Creator : inception-project
public void publishEvent(ApplicationEvent aEvent) {
if (applicationEventPublisher != null) {
applicationEventPublisher.publishEvent(aEvent);
}
}
19
View Source File : QueuedTaskHolderManagerImpl.java
License : Apache License 2.0
Project Creator : igloo-project
License : Apache License 2.0
Project Creator : igloo-project
@Override
public void onTaskFinish(Long taskId) {
eventPublisher.publishEvent(new QueuedTaskFinishedEvent(taskId));
}
19
View Source File : RemoteAppEventController.java
License : Apache License 2.0
Project Creator : huifer
License : Apache License 2.0
Project Creator : huifer
@GetMapping("/send/remote/event")
public String sendEvent(@RequestParam String message) {
publisher.publishEvent(message);
return "发送完毕";
}
19
View Source File : SpringEventService.java
License : Apache License 2.0
Project Creator : herowzz
License : Apache License 2.0
Project Creator : herowzz
public void post(Object obj) {
publisher.publishEvent(obj);
}
19
View Source File : AnnouncementServiceImpl.java
License : MIT License
Project Creator : Hccake
License : MIT License
Project Creator : Hccake
/**
* 关闭公告信息
* @param announcementId 公告ID
* @return boolean
*/
@Override
public boolean close(Long announcementId) {
Announcement announcement = new Announcement();
announcement.setId(announcementId);
announcement.setStatus(AnnouncementStatusEnum.DISABLED.getValue());
int flag = baseMapper.updateById(announcement);
boolean isUpdated = SqlHelper.retBool(flag);
if (isUpdated) {
publisher.publishEvent(new AnnouncementCloseEvent(announcementId));
}
return isUpdated;
}
19
View Source File : JobServiceImpl.java
License : MIT License
Project Creator : hb0730
License : MIT License
Project Creator : hb0730
@Override
public boolean updateIsPause(Long id, Integer isEnabled) {
if (0 == isEnabled) {
eventPublisher.publishEvent(new JobEvent(this, JobActionEnum.PAUSE, Collections.singletonList(id)));
} else {
eventPublisher.publishEvent(new JobEvent(this, JobActionEnum.RESUME, Collections.singletonList(id)));
}
return false;
}
19
View Source File : JobServiceImpl.java
License : MIT License
Project Creator : hb0730
License : MIT License
Project Creator : hb0730
@Override
public void execution(Long id) {
eventPublisher.publishEvent(new JobEvent(this, JobActionEnum.RUN, Collections.singletonList(id)));
}
19
View Source File : JobServiceImpl.java
License : MIT License
Project Creator : hb0730
License : MIT License
Project Creator : hb0730
@Override
public boolean removeById(Serializable id) {
boolean result = super.removeById(id);
eventPublisher.publishEvent(new JobEvent(this, JobActionEnum.DELETE, Collections.singletonList(id)));
return result;
}
19
View Source File : JobServiceImpl.java
License : MIT License
Project Creator : hb0730
License : MIT License
Project Creator : hb0730
@Override
public boolean removeByIds(Collection<? extends Serializable> idList) {
boolean result = super.removeByIds(idList);
eventPublisher.publishEvent(new JobEvent(this, JobActionEnum.DELETE, idList));
return result;
}
19
View Source File : ThemeServiceImpl.java
License : GNU General Public License v3.0
Project Creator : halo-dev
License : GNU General Public License v3.0
Project Creator : halo-dev
@Override
public void reload() {
eventPublisher.publishEvent(new ThemeUpdatedEvent(this));
}
19
View Source File : StaticStorageServiceImpl.java
License : GNU General Public License v3.0
Project Creator : halo-dev
License : GNU General Public License v3.0
Project Creator : halo-dev
private void onChange() {
eventPublisher.publishEvent(new StaticStorageChangedEvent(this, staticDir));
}
19
View Source File : SheetServiceImpl.java
License : GNU General Public License v3.0
Project Creator : halo-dev
License : GNU General Public License v3.0
Project Creator : halo-dev
@Override
public void publishVisitEvent(Integer sheetId) {
eventPublisher.publishEvent(new SheetVisitEvent(this, sheetId));
}
19
View Source File : SheetServiceImpl.java
License : GNU General Public License v3.0
Project Creator : halo-dev
License : GNU General Public License v3.0
Project Creator : halo-dev
@Override
public Sheet updateBy(Sheet sheet, boolean autoSave) {
Sheet updatedSheet = createOrUpdateBy(sheet);
if (!autoSave) {
// Log the creation
LogEvent logEvent = new LogEvent(this, updatedSheet.getId().toString(), LogType.SHEET_EDITED, updatedSheet.getreplacedle());
eventPublisher.publishEvent(logEvent);
}
return updatedSheet;
}
19
View Source File : SheetServiceImpl.java
License : GNU General Public License v3.0
Project Creator : halo-dev
License : GNU General Public License v3.0
Project Creator : halo-dev
@Override
public Sheet updateBy(Sheet sheet, Set<SheetMeta> metas, boolean autoSave) {
Sheet updatedSheet = createOrUpdateBy(sheet);
// Create sheet meta data
List<SheetMeta> sheetMetaList = sheetMetaService.createOrUpdateByPostId(updatedSheet.getId(), metas);
log.debug("Created sheet metas: [{}]", sheetMetaList);
if (!autoSave) {
// Log the creation
LogEvent logEvent = new LogEvent(this, updatedSheet.getId().toString(), LogType.SHEET_EDITED, updatedSheet.getreplacedle());
eventPublisher.publishEvent(logEvent);
}
return updatedSheet;
}
19
View Source File : SheetServiceImpl.java
License : GNU General Public License v3.0
Project Creator : halo-dev
License : GNU General Public License v3.0
Project Creator : halo-dev
@Override
public Sheet createBy(Sheet sheet, Set<SheetMeta> metas, boolean autoSave) {
Sheet createdSheet = createOrUpdateBy(sheet);
// Create sheet meta data
List<SheetMeta> sheetMetaList = sheetMetaService.createOrUpdateByPostId(sheet.getId(), metas);
log.debug("Created sheet metas: [{}]", sheetMetaList);
if (!autoSave) {
// Log the creation
LogEvent logEvent = new LogEvent(this, createdSheet.getId().toString(), LogType.SHEET_PUBLISHED, createdSheet.getreplacedle());
eventPublisher.publishEvent(logEvent);
}
return createdSheet;
}
19
View Source File : SheetServiceImpl.java
License : GNU General Public License v3.0
Project Creator : halo-dev
License : GNU General Public License v3.0
Project Creator : halo-dev
@Override
public Sheet createBy(Sheet sheet, boolean autoSave) {
Sheet createdSheet = createOrUpdateBy(sheet);
if (!autoSave) {
// Log the creation
LogEvent logEvent = new LogEvent(this, createdSheet.getId().toString(), LogType.SHEET_PUBLISHED, createdSheet.getreplacedle());
eventPublisher.publishEvent(logEvent);
}
return createdSheet;
}
19
View Source File : OptionServiceImpl.java
License : GNU General Public License v3.0
Project Creator : halo-dev
License : GNU General Public License v3.0
Project Creator : halo-dev
@Override
public Option removePermanently(Integer id) {
Option deletedOption = removeById(id);
eventPublisher.publishEvent(new OptionUpdatedEvent(this));
return deletedOption;
}
See More Examples