org.springframework.context.ApplicationEventPublisher Java Examples

The following examples show how to use org.springframework.context.ApplicationEventPublisher. 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 File: SqsMessageQueueReceiverEndpoint.java    From synapse with 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 File: BackupServiceImpl.java    From halo with 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 File: JobService.java    From edison-microservice with 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 #4
Source File: JoalConfigProviderTest.java    From joal with 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 File: JetLinksConfiguration.java    From jetlinks-community with 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 #6
Source File: NamespaceController.java    From apollo with Apache License 2.0 5 votes vote down vote up
public NamespaceController(
    final NamespaceLockService namespaceLockService,
    final NamespaceService namespaceService,
    final AppNamespaceService appNamespaceService,
    final ApplicationEventPublisher publisher,
    final UserService userService) {
  this.namespaceLockService = namespaceLockService;
  this.namespaceService = namespaceService;
  this.appNamespaceService = appNamespaceService;
  this.publisher = publisher;
  this.userService = userService;
}
 
Example #7
Source File: StoreConfig.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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 #8
Source File: ClientTest.java    From joal with 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 #9
Source File: ConfigWatchTests.java    From spring-cloud-formula with 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 #10
Source File: AssetService.java    From ddd-java with MIT License 5 votes vote down vote up
public AssetService(
        DefaultRepository rep,
        PlatformTransactionManager txm,
        AuditHandler audit,
        IdLockHandler idLock,
        ApplicationEventPublisher event) {
    this.rep = rep;
    this.txm = txm;
    this.audit = audit;
    this.idLock = idLock;
    this.event = event;
}
 
Example #11
Source File: DependencySourceDemo.java    From geekbang-lessons with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void initByLookup() {
    getBean(BeanFactory.class);
    getBean(ApplicationContext.class);
    getBean(ResourceLoader.class);
    getBean(ApplicationEventPublisher.class);
}
 
Example #12
Source File: RelationLayerSupport.java    From webanno with 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 #13
Source File: SecurityService.java    From eds-starter6-jpa with 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;
}
 
Example #14
Source File: ThemeServiceImpl.java    From halo with GNU General Public License v3.0 5 votes vote down vote up
public ThemeServiceImpl(HaloProperties haloProperties,
                        OptionService optionService,
                        AbstractStringCacheStore cacheStore,
                        ThemeConfigResolver themeConfigResolver,
                        RestTemplate restTemplate,
                        ApplicationEventPublisher eventPublisher) {
    this.optionService = optionService;
    this.cacheStore = cacheStore;
    this.themeConfigResolver = themeConfigResolver;
    this.restTemplate = restTemplate;

    themeWorkDir = Paths.get(haloProperties.getWorkDir(), THEME_FOLDER);
    this.eventPublisher = eventPublisher;
}
 
Example #15
Source File: EventSourcingServiceImpl.java    From java-microservice with MIT License 5 votes vote down vote up
@Autowired
public EventSourcingServiceImpl(
        EventStoreRepository eventStore,
        EventSerializer eventSerializer,
        ApplicationEventPublisher eventPublisher
) {
    this.eventStoreRepository = eventStore;
    this.eventSerializer = eventSerializer;
}
 
Example #16
Source File: AttendanceUploadService.java    From zhcet-web with 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 #17
Source File: LogbackAccessTomcatValve.java    From logback-access-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an instance.
 *
 * @param logbackAccessProperties the configuration properties for Logback-access.
 * @param environment the environment.
 * @param applicationEventPublisher the application event publisher.
 */
public LogbackAccessTomcatValve(
        LogbackAccessProperties logbackAccessProperties,
        Environment environment,
        ApplicationEventPublisher applicationEventPublisher
) {
    this.logbackAccessContext = new LogbackAccessContext(
            logbackAccessProperties, environment, applicationEventPublisher);
    setAsyncSupported(true);
    if (logbackAccessProperties.getTomcat().getEnableRequestAttributes() != null) {
        setRequestAttributesEnabled(logbackAccessProperties.getTomcat().getEnableRequestAttributes());
    }
}
 
Example #18
Source File: HibernateMinMaxDataElementStore.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #19
Source File: HibernateDataApprovalAuditStore.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public HibernateDataApprovalAuditStore( SessionFactory sessionFactory, JdbcTemplate jdbcTemplate,
    ApplicationEventPublisher publisher, CurrentUserService currentUserService )
{
    super( sessionFactory, jdbcTemplate, publisher, DataApprovalAudit.class, false );

    checkNotNull( currentUserService );

    this.currentUserService = currentUserService;
}
 
Example #20
Source File: TkTask.java    From cf-butler with Apache License 2.0 5 votes vote down vote up
@Autowired
public TkTask(
        TkService tkService,
		ApplicationEventPublisher publisher) {
    this.tkService = tkService;
    this.publisher = publisher;
}
 
Example #21
Source File: SSOConfigurer.java    From spring-boot-security-saml with 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 #22
Source File: ClientTest.java    From joal with 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 #23
Source File: TelemetryServiceImpl.java    From webanno with 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 #24
Source File: AdminServiceImpl.java    From halo with 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 #25
Source File: CloudEurekaClient.java    From spring-cloud-netflix with 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 #26
Source File: ArangoExtCursor.java    From spring-data with 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 #27
Source File: EurekaComponents.java    From kork with 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 #28
Source File: ConfigWatchTests.java    From spring-cloud-formula with 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 #29
Source File: AppAuthServiceImpl.java    From soul with 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 #30
Source File: EventPublishingEntityListenerAdapter.java    From integration-patterns with MIT License 5 votes vote down vote up
@Autowired
public EventPublishingEntityListenerAdapter(EntityManager eventRepository, ApplicationEventPublisher eventPublisher,
    ObjectMapper objectMapper) {
    this.eventRepository = eventRepository;
    this.eventPublisher = eventPublisher;
    this.objectMapper = objectMapper;
}