Java Code Examples for org.springframework.context.ApplicationEventPublisher

The following examples show how to use org.springframework.context.ApplicationEventPublisher. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: synapse   Source File: SqsMessageQueueReceiverEndpoint.java    License: Apache License 2.0 6 votes vote down vote up
public SqsMessageQueueReceiverEndpoint(final @Nonnull String channelName,
                                       final @Nonnull MessageInterceptorRegistry interceptorRegistry,
                                       final @Nonnull SqsAsyncClient sqsAsyncClient,
                                       final @Nonnull ExecutorService executorService,
                                       final @Nullable ApplicationEventPublisher eventPublisher) {
    super(channelName, interceptorRegistry, eventPublisher);
    this.sqsAsyncClient = sqsAsyncClient;
    this.executorService = executorService;
    try {
        this.queueUrl = sqsAsyncClient.getQueueUrl(GetQueueUrlRequest
                .builder()
                .queueName(channelName)
                .overrideConfiguration(AwsRequestOverrideConfiguration.builder()
                        .apiCallAttemptTimeout(ofMillis(2000))
                        .build())
                .build())
                .get()
                .queueUrl();
    } catch (Exception e) {
        stopped.complete(null);
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
Example 2
Source Project: halo   Source File: BackupServiceImpl.java    License: GNU General Public License v3.0 6 votes vote down vote up
public BackupServiceImpl(AttachmentService attachmentService, CategoryService categoryService, CommentBlackListService commentBlackListService, JournalService journalService, JournalCommentService journalCommentService, LinkService linkService, LogService logService, MenuService menuService, OptionService optionService, PhotoService photoService, PostService postService, PostCategoryService postCategoryService, PostCommentService postCommentService, PostMetaService postMetaService, PostTagService postTagService, SheetService sheetService, SheetCommentService sheetCommentService, SheetMetaService sheetMetaService, TagService tagService, ThemeSettingService themeSettingService, UserService userService, OneTimeTokenService oneTimeTokenService, HaloProperties haloProperties, ApplicationEventPublisher eventPublisher) {
    this.attachmentService = attachmentService;
    this.categoryService = categoryService;
    this.commentBlackListService = commentBlackListService;
    this.journalService = journalService;
    this.journalCommentService = journalCommentService;
    this.linkService = linkService;
    this.logService = logService;
    this.menuService = menuService;
    this.optionService = optionService;
    this.photoService = photoService;
    this.postService = postService;
    this.postCategoryService = postCategoryService;
    this.postCommentService = postCommentService;
    this.postMetaService = postMetaService;
    this.postTagService = postTagService;
    this.sheetService = sheetService;
    this.sheetCommentService = sheetCommentService;
    this.sheetMetaService = sheetMetaService;
    this.tagService = tagService;
    this.themeSettingService = themeSettingService;
    this.userService = userService;
    this.oneTimeTokenService = oneTimeTokenService;
    this.haloProperties = haloProperties;
    this.eventPublisher = eventPublisher;
}
 
Example 3
Source Project: jetlinks-community   Source File: JetLinksConfiguration.java    License: Apache License 2.0 6 votes vote down vote up
@Bean(destroyMethod = "shutdown")
public DefaultDecodedClientMessageHandler defaultDecodedClientMessageHandler(MessageHandler handler,
                                                                             DeviceMessageConnector messageConnector,
                                                                             DeviceSessionManager deviceSessionManager,
                                                                             ApplicationEventPublisher eventPublisher) {
    DefaultDecodedClientMessageHandler clientMessageHandler = new DefaultDecodedClientMessageHandler(handler, deviceSessionManager,
        EmitterProcessor.create(false)
    );
    // TODO: 2019/12/31 应该统一由消息网关处理
    clientMessageHandler
        .subscribe()
        .parallel()
        .runOn(Schedulers.parallel())
        .flatMap(msg -> messageConnector.onMessage(msg).onErrorContinue((err, r) -> log.error(err.getMessage(), err)))
        .subscribe();

    return clientMessageHandler;
}
 
Example 4
Source Project: joal   Source File: JoalConfigProviderTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void shouldWriteConfigurationFile() throws IOException {
    new ObjectMapper().writeValue(rewritableJoalFoldersPath.getConfPath().resolve("config.json").toFile(), defaultConfig);
    try {
        final JoalConfigProvider provider = new JoalConfigProvider(new ObjectMapper(), rewritableJoalFoldersPath, Mockito.mock(ApplicationEventPublisher.class));
        final Random rand = new Random();
        final AppConfiguration newConf = new AppConfiguration(
                rand.longs(1, 200).findFirst().getAsLong(),
                rand.longs(201, 400).findFirst().getAsLong(),
                rand.ints(1, 5).findFirst().getAsInt(),
                RandomStringUtils.random(60),
                false
        );

        provider.saveNewConf(newConf);

        assertThat(provider.loadConfiguration()).isEqualTo(newConf);
    } finally {
        Files.deleteIfExists(rewritableJoalFoldersPath.getConfPath().resolve("config.json"));
    }
}
 
Example 5
Source Project: edison-microservice   Source File: JobService.java    License: Apache License 2.0 6 votes vote down vote up
JobService(final JobRepository jobRepository,
           final JobMetaService jobMetaService,
           final List<JobRunnable> jobRunnables,
           final ScheduledExecutorService executor,
           final ApplicationEventPublisher applicationEventPublisher,
           final Clock clock,
           final SystemInfo systemInfo,
           final UuidProvider uuidProvider) {
    this.jobRepository = jobRepository;
    this.jobMetaService = jobMetaService;
    this.jobRunnables = jobRunnables;
    this.executor = executor;
    this.applicationEventPublisher = applicationEventPublisher;
    this.clock = clock;
    this.systemInfo = systemInfo;
    this.uuidProvider = uuidProvider;
}
 
Example 6
Source Project: zhcet-web   Source File: AttendanceUploadService.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public AttendanceUploadService(
        AttendanceUploadAdapter attendanceUploadAdapter,
        AttendanceService attendanceService, ApplicationEventPublisher eventPublisher) {
    this.attendanceUploadAdapter = attendanceUploadAdapter;
    this.attendanceService = attendanceService;
    this.eventPublisher = eventPublisher;
}
 
Example 7
Source Project: java-microservice   Source File: EventSourcingServiceImpl.java    License: MIT License 5 votes vote down vote up
@Autowired
public EventSourcingServiceImpl(
        EventStoreRepository eventStore,
        EventSerializer eventSerializer,
        ApplicationEventPublisher eventPublisher
) {
    this.eventStoreRepository = eventStore;
    this.eventSerializer = eventSerializer;
}
 
Example 8
Source Project: gorm-hibernate5   Source File: AbstractHibernateQuery.java    License: Apache License 2.0 5 votes vote down vote up
public List listForCriteria() {
    Datastore datastore = session.getDatastore();
    ApplicationEventPublisher publisher = datastore.getApplicationEventPublisher();
    if(publisher != null) {
        publisher.publishEvent(new PreQueryEvent(datastore, this));
    }

    List results = criteria.list();
    if(publisher != null) {
        publisher.publishEvent(new PostQueryEvent(datastore, this, results));
    }
    return results;
}
 
Example 9
Source Project: apollo   Source File: ReleaseController.java    License: Apache License 2.0 5 votes vote down vote up
public ReleaseController(
    final ReleaseService releaseService,
    final ApplicationEventPublisher publisher,
    final PortalConfig portalConfig,
    final PermissionValidator permissionValidator,
    final UserInfoHolder userInfoHolder) {
  this.releaseService = releaseService;
  this.publisher = publisher;
  this.portalConfig = portalConfig;
  this.permissionValidator = permissionValidator;
  this.userInfoHolder = userInfoHolder;
}
 
Example 10
Source Project: halo   Source File: BaseCommentServiceImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
public BaseCommentServiceImpl(BaseCommentRepository<COMMENT> baseCommentRepository,
                              OptionService optionService,
                              UserService userService, ApplicationEventPublisher eventPublisher) {
    super(baseCommentRepository);
    this.baseCommentRepository = baseCommentRepository;
    this.optionService = optionService;
    this.userService = userService;
    this.eventPublisher = eventPublisher;
}
 
Example 11
Source Project: difido-reports   Source File: HtmlReportsEraserScheduler.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public HtmlReportsEraserScheduler(MetadataRepository metadataRepository, ExecutionStateRepository stateRepository,
		ApplicationEventPublisher publisher) {
	this.metadataRepository = metadataRepository;
	this.stateRepository = stateRepository;
	this.publisher = publisher;
	daysToKeep = Configuration.INSTANCE.readInt(ConfigProps.DAYS_TO_KEEP_HTML_REPORTS);
	if (daysToKeep > 0) {
		enabled = true;
	} else {
		log.debug("Html reports eraser is disabled");
	}
}
 
Example 12
Source Project: apollo   Source File: NamespaceBranchController.java    License: Apache License 2.0 5 votes vote down vote up
public NamespaceBranchController(
    final PermissionValidator permissionValidator,
    final ReleaseService releaseService,
    final NamespaceBranchService namespaceBranchService,
    final ApplicationEventPublisher publisher,
    final PortalConfig portalConfig) {
  this.permissionValidator = permissionValidator;
  this.releaseService = releaseService;
  this.namespaceBranchService = namespaceBranchService;
  this.publisher = publisher;
  this.portalConfig = portalConfig;
}
 
Example 13
Source Project: joal   Source File: ClientTest.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"unchecked", "ResultOfMethodCallIgnored"})
@Test
public void shouldRemoveAnnouncerFromRunningListOnTooManyFailsAndEnqueueAnother() {
    final AppConfiguration appConfiguration = this.createMockedConf();
    doReturn(1).when(appConfiguration).getSimultaneousSeed();

    final TorrentFileProvider torrentFileProvider = createMockedTorrentFileProviderWithTorrent(Lists.newArrayList(
            MockedTorrentTest.createOneMock("abc"),
            MockedTorrentTest.createOneMock("def")
    ));

    final DelayQueue<AnnounceRequest> delayQueue = mock(DelayQueue.class);
    final AnnouncerFactory mockedAnnouncerFactory = createMockedAnnouncerFactory();

    final Client client = (Client) ClientBuilder.builder()
            .withAnnouncerFactory(mockedAnnouncerFactory)
            .withBandwidthDispatcher(mock(BandwidthDispatcher.class))
            .withAppConfiguration(appConfiguration)
            .withTorrentFileProvider(torrentFileProvider)
            .withEventPublisher(mock(ApplicationEventPublisher.class))
            .withDelayQueue(delayQueue)
            .build();

    final AnnouncerExecutor announcerExecutor = mock(AnnouncerExecutor.class);
    client.setAnnouncerExecutor(announcerExecutor);
    final ArgumentCaptor<AnnounceRequest> argumentCaptor = ArgumentCaptor.forClass(AnnounceRequest.class);

    client.start();
    verify(delayQueue, times(1)).addOrReplace(argumentCaptor.capture(), anyInt(), any(TemporalUnit.class));
    assertThat(client.getCurrentlySeedingAnnouncer()).hasSize(1);

    final Announcer firstAnnouncer = argumentCaptor.getValue().getAnnouncer();

    client.onTooManyFailedInARaw(firstAnnouncer);
    verify(torrentFileProvider, times(1)).moveToArchiveFolder(eq(firstAnnouncer.getTorrentInfoHash()));
    verify(delayQueue, times(2)).addOrReplace(argumentCaptor.capture(), anyInt(), any(TemporalUnit.class));
    assertThat(argumentCaptor.getValue().getInfoHash()).isNotEqualTo(firstAnnouncer.getTorrentInfoHash());
    assertThat(argumentCaptor.getValue().getInfoHash().value()).isEqualTo("def");
    assertThat(client.getCurrentlySeedingAnnouncer()).hasSize(1);
}
 
Example 14
@Bean( "org.hisp.dhis.pushanalysis.PushAnalysisStore" )
public HibernateIdentifiableObjectStore<PushAnalysis> indicatorTypeStore( SessionFactory sessionFactory,
    JdbcTemplate jdbcTemplate, ApplicationEventPublisher publisher, CurrentUserService currentUserService,
    AclService aclService )
{
    return new HibernateIdentifiableObjectStore<PushAnalysis>( sessionFactory,
        jdbcTemplate, publisher, PushAnalysis.class, currentUserService, aclService, false );
}
 
Example 15
public HibernateDataApprovalAuditStore( SessionFactory sessionFactory, JdbcTemplate jdbcTemplate,
    ApplicationEventPublisher publisher, CurrentUserService currentUserService )
{
    super( sessionFactory, jdbcTemplate, publisher, DataApprovalAudit.class, false );

    checkNotNull( currentUserService );

    this.currentUserService = currentUserService;
}
 
Example 16
public HibernateMinMaxDataElementStore( SessionFactory sessionFactory, JdbcTemplate jdbcTemplate,
    ApplicationEventPublisher publisher, QueryParser queryParser, QueryPlanner queryPlanner, SchemaService schemaService )
{
    super( sessionFactory, jdbcTemplate, publisher, MinMaxDataElement.class, false );

    checkNotNull(queryParser);
    checkNotNull(queryPlanner);
    checkNotNull(schemaService);

    this.queryParser = queryParser;
    this.queryPlanner = queryPlanner;
    this.schemaService = schemaService;
}
 
Example 17
Source Project: webanno   Source File: RelationLayerSupport.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public RelationLayerSupport(FeatureSupportRegistry aFeatureSupportRegistry,
        ApplicationEventPublisher aEventPublisher,
        LayerBehaviorRegistry aLayerBehaviorsRegistry)
{
    super(aFeatureSupportRegistry);
    eventPublisher = aEventPublisher;
    layerBehaviorsRegistry = aLayerBehaviorsRegistry;
}
 
Example 18
Source Project: cf-butler   Source File: TkTask.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired
public TkTask(
        TkService tkService,
		ApplicationEventPublisher publisher) {
    this.tkService = tkService;
    this.publisher = publisher;
}
 
Example 19
Source Project: spring-boot-security-saml   Source File: SSOConfigurer.java    License: MIT License 5 votes vote down vote up
@Override
public void init(ServiceProviderBuilder builder) throws Exception {
    authenticationManager = builder.getSharedObject(AuthenticationManager.class);
    config = builder.getSharedObject(SAMLSSOProperties.class);
    endpoints = builder.getSharedObject(ServiceProviderEndpoints.class);
    
    if ( config.isEnableEventPublisher() )
        eventPublisher = builder.getSharedObject(ApplicationEventPublisher.class);
    else eventPublisher = null;
}
 
Example 20
Source Project: joal   Source File: ClientTest.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored", "unchecked"})
@Test
public void shouldClearDelayQueueOnStopAndSendStopAnnounceToExecutor() throws AnnounceException, TooMuchAnnouncesFailedInARawException {
    final AppConfiguration appConfiguration = this.createMockedConf();
    doReturn(1).when(appConfiguration).getSimultaneousSeed();

    final TorrentFileProvider torrentFileProvider = createMockedTorrentFileProviderWithTorrent(Lists.newArrayList(
            MockedTorrentTest.createOneMock("abc")
    ));

    final DelayQueue<AnnounceRequest> delayQueue = mock(DelayQueue.class);
    doReturn(Lists.newArrayList(AnnounceRequest.createRegular(null))).when(delayQueue).drainAll();
    final AnnouncerFactory mockedAnnouncerFactory = mock(AnnouncerFactory.class);

    final Client client = (Client) ClientBuilder.builder()
            .withAnnouncerFactory(mockedAnnouncerFactory)
            .withBandwidthDispatcher(mock(BandwidthDispatcher.class))
            .withAppConfiguration(appConfiguration)
            .withTorrentFileProvider(torrentFileProvider)
            .withEventPublisher(mock(ApplicationEventPublisher.class))
            .withDelayQueue(delayQueue)
            .build();

    final AnnouncerExecutor announcerExecutor = mock(AnnouncerExecutor.class);
    client.setAnnouncerExecutor(announcerExecutor);

    client.start();
    verify(delayQueue, times(1)).addOrReplace(any(AnnounceRequest.class), anyInt(), any(TemporalUnit.class));
    Thread.yield();

    client.stop();
    verify(delayQueue, times(1)).drainAll();
    verify(announcerExecutor, times(1)).execute(argThat(new ArgumentMatcher<AnnounceRequest>() {
        @Override
        public boolean matches(final AnnounceRequest argument) {
            return argument.getEvent() == RequestEvent.STOPPED;
        }
    }));
}
 
Example 21
Source Project: spring-cloud-netflix   Source File: CloudEurekaClient.java    License: Apache License 2.0 5 votes vote down vote up
public CloudEurekaClient(ApplicationInfoManager applicationInfoManager,
		EurekaClientConfig config, AbstractDiscoveryClientOptionalArgs<?> args,
		ApplicationEventPublisher publisher) {
	super(applicationInfoManager, config, args);
	this.applicationInfoManager = applicationInfoManager;
	this.publisher = publisher;
	this.eurekaTransportField = ReflectionUtils.findField(DiscoveryClient.class,
			"eurekaTransport");
	ReflectionUtils.makeAccessible(this.eurekaTransportField);
}
 
Example 22
Source Project: spring-data   Source File: ArangoExtCursor.java    License: Apache License 2.0 5 votes vote down vote up
protected ArangoExtCursor(final InternalArangoDatabase<?, ?> db, final ArangoCursorExecute execute,
	final Class<T> type, final CursorEntity result, final ArangoConverter converter,
	final ApplicationEventPublisher eventPublisher) {
	super(db, execute, type, result);
	final ArangoExtCursorIterator<?> it = (ArangoExtCursorIterator<?>) iterator;
	it.setConverter(converter);
	it.setEventPublisher(eventPublisher);
}
 
Example 23
Source Project: kork   Source File: EurekaComponents.java    License: Apache License 2.0 5 votes vote down vote up
public EurekaStatusSubscriber(
    ApplicationEventPublisher publisher, EventBus eventBus, DiscoveryClient discoveryClient) {
  this.publisher = Objects.requireNonNull(publisher, "publisher");
  this.eventBus = Objects.requireNonNull(eventBus, "eventBus");
  publish(
      new StatusChangeEvent(
          InstanceInfo.InstanceStatus.UNKNOWN, discoveryClient.getInstanceRemoteStatus()));
  try {
    eventBus.registerSubscriber(this);
  } catch (InvalidSubscriberException ise) {
    throw new SystemException(ise);
  }
}
 
Example 24
Source Project: soul   Source File: AppAuthServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Autowired(required = false)
public AppAuthServiceImpl(final AppAuthMapper appAuthMapper,
                          final ApplicationEventPublisher eventPublisher,
                          final AuthParamMapper authParamMapper,
                          final AuthPathMapper authPathMapper) {
    this.appAuthMapper = appAuthMapper;
    this.eventPublisher = eventPublisher;
    this.authParamMapper = authParamMapper;
    this.authPathMapper = authPathMapper;
}
 
Example 25
@Autowired
public EventPublishingEntityListenerAdapter(EntityManager eventRepository, ApplicationEventPublisher eventPublisher,
    ObjectMapper objectMapper) {
    this.eventRepository = eventRepository;
    this.eventPublisher = eventPublisher;
    this.objectMapper = objectMapper;
}
 
Example 26
Source Project: spring-cloud-formula   Source File: ConfigWatchTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void watchPublishesEvent() {
    ApplicationEventPublisher eventPublisher = mock(ApplicationEventPublisher.class);

    setupWatch(eventPublisher, "/app/");

    verify(eventPublisher, times(1)).publishEvent(ArgumentMatchers.any(RefreshEvent.class));
}
 
Example 27
Source Project: halo   Source File: AdminServiceImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
public AdminServiceImpl(PostService postService,
                        SheetService sheetService,
                        AttachmentService attachmentService,
                        PostCommentService postCommentService,
                        SheetCommentService sheetCommentService,
                        JournalCommentService journalCommentService,
                        OptionService optionService,
                        UserService userService,
                        LinkService linkService,
                        MailService mailService,
                        AbstractStringCacheStore cacheStore,
                        RestTemplate restTemplate,
                        HaloProperties haloProperties,
                        ApplicationEventPublisher eventPublisher) {
    this.postService = postService;
    this.sheetService = sheetService;
    this.attachmentService = attachmentService;
    this.postCommentService = postCommentService;
    this.sheetCommentService = sheetCommentService;
    this.journalCommentService = journalCommentService;
    this.optionService = optionService;
    this.userService = userService;
    this.linkService = linkService;
    this.mailService = mailService;
    this.cacheStore = cacheStore;
    this.restTemplate = restTemplate;
    this.haloProperties = haloProperties;
    this.eventPublisher = eventPublisher;
}
 
Example 28
Source Project: webanno   Source File: TelemetryServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
public TelemetryServiceImpl(
        @Lazy @Autowired(required = false) List<TelemetrySupport> aTelemetrySupports,
        ApplicationEventPublisher aEventPublisher)
{
    telemetrySupportsProxy = aTelemetrySupports;
    eventPublisher = aEventPublisher;
}
 
Example 29
Source Project: spring-cloud-formula   Source File: ConfigWatchTests.java    License: Apache License 2.0 5 votes vote down vote up
private void setupWatchThrowException(ApplicationEventPublisher eventPublisher, String context) {
    ConsulClient consul = mock(ConsulClient.class);
    OperationException operationException = new OperationException(403, null, null);
    when(consul.getKVValues(ArgumentMatchers.eq(context), nullable(String.class),
            ArgumentMatchers.any(QueryParams.class))).thenThrow(operationException);

    LinkedHashMap<String, Long> initialIndexes = new LinkedHashMap<>();
    initialIndexes.put(context, 0L);
    startWatch(eventPublisher, consul, initialIndexes);
}
 
Example 30
Source Project: eds-starter6-jpa   Source File: SecurityService.java    License: Apache License 2.0 5 votes vote down vote up
public SecurityService(JPAQueryFactory jpaQueryFactory,
		PasswordEncoder passwordEncoder, MailService mailService,
		ApplicationEventPublisher applicationEventPublisher) {
	this.jpaQueryFactory = jpaQueryFactory;
	this.passwordEncoder = passwordEncoder;
	this.mailService = mailService;
	this.applicationEventPublisher = applicationEventPublisher;
}