org.springframework.context.ApplicationContextAware#org.springframework.context.ApplicationEventPublisher源码实例Demo

下面列出了org.springframework.context.ApplicationContextAware#org.springframework.context.ApplicationEventPublisher 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: synapse   文件: SqsMessageQueueReceiverEndpoint.java
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);
    }
}
 
源代码2 项目: halo   文件: BackupServiceImpl.java
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;
}
 
@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;
}
 
源代码4 项目: joal   文件: JoalConfigProviderTest.java
@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"));
    }
}
 
源代码5 项目: edison-microservice   文件: JobService.java
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;
}
 
源代码6 项目: zhcet-web   文件: AttendanceUploadService.java
@Autowired
public AttendanceUploadService(
        AttendanceUploadAdapter attendanceUploadAdapter,
        AttendanceService attendanceService, ApplicationEventPublisher eventPublisher) {
    this.attendanceUploadAdapter = attendanceUploadAdapter;
    this.attendanceService = attendanceService;
    this.eventPublisher = eventPublisher;
}
 
@Autowired
public EventSourcingServiceImpl(
        EventStoreRepository eventStore,
        EventSerializer eventSerializer,
        ApplicationEventPublisher eventPublisher
) {
    this.eventStoreRepository = eventStore;
    this.eventSerializer = eventSerializer;
}
 
源代码8 项目: gorm-hibernate5   文件: AbstractHibernateQuery.java
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;
}
 
源代码9 项目: apollo   文件: ReleaseController.java
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;
}
 
源代码10 项目: halo   文件: BaseCommentServiceImpl.java
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;
}
 
@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");
	}
}
 
源代码12 项目: apollo   文件: NamespaceBranchController.java
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;
}
 
源代码13 项目: joal   文件: ClientTest.java
@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);
}
 
源代码14 项目: dhis2-core   文件: StoreConfig.java
@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 );
}
 
public HibernateDataApprovalAuditStore( SessionFactory sessionFactory, JdbcTemplate jdbcTemplate,
    ApplicationEventPublisher publisher, CurrentUserService currentUserService )
{
    super( sessionFactory, jdbcTemplate, publisher, DataApprovalAudit.class, false );

    checkNotNull( currentUserService );

    this.currentUserService = currentUserService;
}
 
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;
}
 
源代码17 项目: webanno   文件: RelationLayerSupport.java
@Autowired
public RelationLayerSupport(FeatureSupportRegistry aFeatureSupportRegistry,
        ApplicationEventPublisher aEventPublisher,
        LayerBehaviorRegistry aLayerBehaviorsRegistry)
{
    super(aFeatureSupportRegistry);
    eventPublisher = aEventPublisher;
    layerBehaviorsRegistry = aLayerBehaviorsRegistry;
}
 
源代码18 项目: cf-butler   文件: TkTask.java
@Autowired
public TkTask(
        TkService tkService,
		ApplicationEventPublisher publisher) {
    this.tkService = tkService;
    this.publisher = publisher;
}
 
源代码19 项目: spring-boot-security-saml   文件: SSOConfigurer.java
@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;
}
 
源代码20 项目: joal   文件: ClientTest.java
@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;
        }
    }));
}
 
源代码21 项目: spring-cloud-netflix   文件: CloudEurekaClient.java
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);
}
 
源代码22 项目: spring-data   文件: ArangoExtCursor.java
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);
}
 
源代码23 项目: kork   文件: EurekaComponents.java
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);
  }
}
 
源代码24 项目: soul   文件: AppAuthServiceImpl.java
@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;
}
 
@Autowired
public EventPublishingEntityListenerAdapter(EntityManager eventRepository, ApplicationEventPublisher eventPublisher,
    ObjectMapper objectMapper) {
    this.eventRepository = eventRepository;
    this.eventPublisher = eventPublisher;
    this.objectMapper = objectMapper;
}
 
源代码26 项目: spring-cloud-formula   文件: ConfigWatchTests.java
@Test
public void watchPublishesEvent() {
    ApplicationEventPublisher eventPublisher = mock(ApplicationEventPublisher.class);

    setupWatch(eventPublisher, "/app/");

    verify(eventPublisher, times(1)).publishEvent(ArgumentMatchers.any(RefreshEvent.class));
}
 
源代码27 项目: halo   文件: AdminServiceImpl.java
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;
}
 
源代码28 项目: webanno   文件: TelemetryServiceImpl.java
public TelemetryServiceImpl(
        @Lazy @Autowired(required = false) List<TelemetrySupport> aTelemetrySupports,
        ApplicationEventPublisher aEventPublisher)
{
    telemetrySupportsProxy = aTelemetrySupports;
    eventPublisher = aEventPublisher;
}
 
源代码29 项目: spring-cloud-formula   文件: ConfigWatchTests.java
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);
}
 
源代码30 项目: eds-starter6-jpa   文件: SecurityService.java
public SecurityService(JPAQueryFactory jpaQueryFactory,
		PasswordEncoder passwordEncoder, MailService mailService,
		ApplicationEventPublisher applicationEventPublisher) {
	this.jpaQueryFactory = jpaQueryFactory;
	this.passwordEncoder = passwordEncoder;
	this.mailService = mailService;
	this.applicationEventPublisher = applicationEventPublisher;
}