Java Code Examples for org.springframework.context.ApplicationEvent

The following are top voted examples for showing how to use org.springframework.context.ApplicationEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: alfresco-repository   File: ModuleStarter.java   Source Code and License 8 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    PropertyCheck.mandatory(this, "moduleService", moduleService);
    final RetryingTransactionCallback<Object> startModulesCallback = new RetryingTransactionCallback<Object>()
    {
        public Object execute() throws Throwable
        {
            moduleService.startModules();
            return null;
        }
    };
    
    AuthenticationUtil.runAs(new RunAsWork<Object>()
    {
        @Override
        public Object doWork() throws Exception 
        {
            transactionService.getRetryingTransactionHelper().doInTransaction(startModulesCallback, transactionService.isReadOnly());
            return null;
        }
    	
    }, AuthenticationUtil.getSystemUserName());       
}
 
Example 2
Project: lams   File: SimpleApplicationEventMulticaster.java   Source Code and License 7 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void multicastEvent(final ApplicationEvent event) {
	for (final ApplicationListener listener : getApplicationListeners(event)) {
		Executor executor = getTaskExecutor();
		if (executor != null) {
			executor.execute(new Runnable() {
				@Override
				public void run() {
					listener.onApplicationEvent(event);
				}
			});
		}
		else {
			listener.onApplicationEvent(event);
		}
	}
}
 
Example 3
Project: alfresco-core   File: RuntimeExecShutdownBean.java   Source Code and License 6 votes vote down vote up
@Override
protected void onShutdown(ApplicationEvent event)
{
    // remove shutdown hook and execute
    if (shutdownHook != null)
    {
        // execute
        execute();
        // remove hook
        try
        {
            Runtime.getRuntime().removeShutdownHook(shutdownHook);
        }
        catch (IllegalStateException e)
        {
            // VM is already shutting down
        }
        shutdownHook = null;
        
        if (logger.isDebugEnabled())
        {
            logger.debug("Deregistered shutdown hook");
        }
    }
}
 
Example 4
Project: spring-domain-events   File: PersistentApplicationEventMulticaster.java   Source Code and License 6 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void multicastEvent(ApplicationEvent event, ResolvableType eventType) {

	ResolvableType type = eventType == null ? ResolvableType.forInstance(event) : eventType;
	Collection<ApplicationListener<?>> listeners = getApplicationListeners(event, type);

	if (listeners.isEmpty()) {
		return;
	}

	List<ApplicationListener<?>> transactionalListeners = listeners.stream()//
			.filter(PersistentApplicationEventMulticaster::isTransactionalApplicationEventListener)//
			.collect(Collectors.toList());

	if (!transactionalListeners.isEmpty()) {

		Object eventToPersist = getEventToPersist(event);

		registry.getObject().store(eventToPersist, transactionalListeners);
		// EventStore.persist(eventThis)
		// SpringMVC Controller Atom Feed
	}

	for (ApplicationListener listener : listeners) {
		listener.onApplicationEvent(event);
	}
}
 
Example 5
Project: alfresco-repository   File: EmailServer.java   Source Code and License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void onBootstrap(ApplicationEvent event)
{
    if (!enabled)
    {
        return;
    }
    // Check properties
    PropertyCheck.mandatory(this, "domain", domain);
    if (port <= 0 || port > 65535)
    {
        throw new AlfrescoRuntimeException("Property 'port' is incorrect");
    }
    PropertyCheck.mandatory(this, "emailService", emailService);
    // Startup
    startup();
}
 
Example 6
Project: alfresco-repository   File: DictionaryRepositoryBootstrap.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    // Reset the dictionary (destroy and reload) in order to ensure that we have a basic version of
    // the dictionary (static models) loaded at least
    dictionaryDAO.reset();

    // Register listeners, which will be called when the dictionary is next reloaded
    register();
    
    // Trigger a reload.  The callbacks will occur immediately on the current thread, however,
    // the model created in reset() will still be available for the basic necessities
    dictionaryDAO.init();
    
    // The listeners can now know about this
    // However, the listeners will be needing to access the dictionary themselves, hence the earlier 'reset'
    // to ensure that there is no deadlock waiting for a new dictionary
    ((ApplicationContext) event.getSource()).publishEvent(new DictionaryRepositoryBootstrappedEvent(this));
}
 
Example 7
Project: alfresco-repository   File: ChainingUserRegistrySynchronizer.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    // Do an initial differential sync on startup, using transaction splitting. This ensures that on the very
    // first startup, we don't have to wait for a very long login operation to trigger the first sync!
    if (this.syncOnStartup)
    {
        AuthenticationUtil.runAs(new RunAsWork<Object>()
        {
            public Object doWork() throws Exception
            {
                try
                {
                    synchronizeInternal(false, false, true);
                }
                catch (Exception e)
                {
                    ChainingUserRegistrySynchronizer.logger.warn("Failed initial synchronize with user registries",
                            e);
                }
                return null;
            }
        }, AuthenticationUtil.getSystemUserName());
    }
}
 
Example 8
Project: gemini.blueprint   File: BlueprintContainerProcessor.java   Source Code and License 6 votes vote down vote up
public void onApplicationEvent(ApplicationEvent event) {
	if (event instanceof ContextClosedEvent) {
		enabled = false;
		return;
	}

	if (event instanceof ContextRefreshedEvent) {
		initialized = true;
		return;
	}

	if (event instanceof OsgiServiceDependencyWaitStartingEvent) {
		if (enabled) {
			OsgiServiceDependencyWaitStartingEvent evt = (OsgiServiceDependencyWaitStartingEvent) event;
			String[] filter = new String[] { evt.getServiceDependency().getServiceFilter().toString() };
			BlueprintEvent waitingEvent =
					new BlueprintEvent(BlueprintEvent.WAITING, bundleContext.getBundle(), extenderBundle,
							filter);

			listenerManager.blueprintEvent(waitingEvent);
			dispatcher.waiting(waitingEvent);
		}
		return;
	}
}
 
Example 9
Project: alfresco-repository   File: OptionalPatchApplicationCheckBootstrapBean.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    Descriptor descriptor = descriptorService.getInstalledRepositoryDescriptor();
    if (patch == null)
    {
        patchApplied = true;
    }
    else
    {
        AppliedPatch appliedPatch = patchService.getPatch(patch.getId());
        if (appliedPatch == null)
        {
            patchApplied = patch.getFixesToSchema() < descriptor.getSchema();
        }
        else
        {
            patchApplied = appliedPatch.getSucceeded();
        }
    }
}
 
Example 10
Project: alfresco-remote-api   File: RepositoryContainer.java   Source Code and License 6 votes vote down vote up
@Override
public void onApplicationEvent(ApplicationEvent event)
{
    if (event instanceof ContextRefreshedEvent)
    {
        ContextRefreshedEvent refreshEvent = (ContextRefreshedEvent)event;
        ApplicationContext refreshContext = refreshEvent.getApplicationContext();
        if (refreshContext != null && refreshContext.equals(applicationContext))
        {
            RunAsWork<Object> work = new RunAsWork<Object>()
            {
                public Object doWork() throws Exception
                {
                    reset();
                    return null;
                }
            };
            AuthenticationUtil.runAs(work, AuthenticationUtil.getSystemUserName());
        }
    }
}
 
Example 11
Project: alfresco-repository   File: ConfigurationChecker.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    RetryingTransactionCallback<Object> checkWork = new RetryingTransactionCallback<Object>()
    {
        public Object execute() throws Throwable {
            // run as System on bootstrap
            return AuthenticationUtil.runAs(new RunAsWork<Object>()
            {
                public Object doWork()
                {
                    check();
                    return null;
                }
            }, AuthenticationUtil.getSystemUserName());
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(checkWork, true);
}
 
Example 12
Project: alfresco-repository   File: ImapServiceImpl.java   Source Code and License 6 votes vote down vote up
@Override
protected void onShutdown(ApplicationEvent event)
{
    AuthenticationUtil.runAs(new RunAsWork<Void>()
    {
        @Override
        public Void doWork() throws Exception
        {
            if (service.getImapServerEnabled())
            {
                service.shutdown();
            }
            return null;
        }
    }, AuthenticationUtil.getSystemUserName());
}
 
Example 13
Project: alfresco-repository   File: FullTextSearchIndexerBootstrapBean.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    String majorVersion = I18NUtil.getMessage("version.major");
    String minorVersion = I18NUtil.getMessage("version.minor");
    
    // Internationalizes the message
    String errorMsg = I18NUtil.getMessage("system.err.lucene_not_supported", majorVersion + "." + minorVersion);
    log.error(errorMsg);

    List<StoreRef> storeRefs = nodeService.getStores();
    for (StoreRef storeRef : storeRefs)
    {
        fullTextSearchIndexer.requiresIndex(storeRef);
    }
}
 
Example 14
Project: alfresco-repository   File: EncryptionChecker.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
    txnHelper.setForceWritable(true);      // Force write in case server is read-only
    
    txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            try
            {
                keyStoreChecker.validateKeyStores();
            }
            catch(Throwable e)
            {
                // Just throw as a runtime exception
                throw new AlfrescoRuntimeException("Keystores are invalid", e);
            }

            return null;
        }
    });
}
 
Example 15
Project: alfresco-repository   File: WorkflowDeployer.java   Source Code and License 6 votes vote down vote up
@Override
  protected void onBootstrap(ApplicationEvent event)
  {
  	RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
  	txnHelper.setForceWritable(true);
  	txnHelper.doInTransaction(new RetryingTransactionCallback<Object>() {

	@Override
	public Object execute() throws Throwable {
		// run as System on bootstrap
        return AuthenticationUtil.runAs(new RunAsWork<Object>()
        {
            public Object doWork()
            {
                init();
                return null;
            }
        }, AuthenticationUtil.getSystemUserName());
	}
  		
}, false, true);
      
      tenantAdminService.register(this);
  }
 
Example 16
Project: incubator-servicecomb-java-chassis   File: MetricsPublisher.java   Source Code and License 5 votes vote down vote up
@Override
public void onApplicationEvent(ApplicationEvent event) {
  if (!ContextClosedEvent.class.isInstance(event) || httpServer == null) {
    return;
  }

  httpServer.stop();
  httpServer = null;
  LOGGER.info("Prometheus httpServer stopped.");
}
 
Example 17
Project: lemon   File: SpringSecurityListener.java   Source Code and License 5 votes vote down vote up
public void onApplicationEvent(ApplicationEvent event) {
    try {
        if (event instanceof InteractiveAuthenticationSuccessEvent) {
            this.logLoginSuccess(event);
        }

        if (event instanceof AuthenticationFailureBadCredentialsEvent) {
            this.logBadCredential(event);
        }

        if (event instanceof AuthenticationFailureLockedEvent) {
            this.logLocked(event);
        }

        if (event instanceof AuthenticationFailureDisabledEvent) {
            this.logDisabled(event);
        }

        if (event instanceof AuthenticationFailureExpiredEvent) {
            this.logAccountExpired(event);
        }

        if (event instanceof AuthenticationFailureCredentialsExpiredEvent) {
            this.logCredentialExpired(event);
        }
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }
}
 
Example 18
Project: alfresco-core   File: RuntimeExecShutdownBean.java   Source Code and License 5 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    // register shutdown hook
    shutdownHook = new ShutdownThread();
    Runtime.getRuntime().addShutdownHook(shutdownHook);

    if (logger.isDebugEnabled())
    {
        logger.debug("Registered shutdown hook");
    }
}
 
Example 19
Project: star-map   File: ScheduleSender.java   Source Code and License 5 votes vote down vote up
@Override
public void onApplicationEvent(ApplicationEvent event) {
    if (event.getClass() == ContextRefreshedEvent.class) {
        extensionLoader.loadExtension(Registry.class).subscribe();
        extensionLoader.loadExtension(ProtocolFactory.class).client().open();
        extensionLoader.loadExtension(Selector.class).start();
        logger.info("subscribe:" + extensionLoader.loadExtension(Registry.class).getDirectory().list());
        latch.countDown();
    } else if (event.getClass() == ContextClosedEvent.class) {
        logger.info("unSubscribe task");
        extensionLoader.loadExtension(Registry.class).unSubscribe();
        extensionLoader.loadExtension(ProtocolFactory.class).client().close();
        extensionLoader.loadExtension(Selector.class).close();
    }
}
 
Example 20
Project: alfresco-core   File: HierarchicalSqlSessionFactoryBean.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void onApplicationEvent(ApplicationEvent event) {
    if (failFast && event instanceof ContextRefreshedEvent) {
        // fail-fast -> check all statements are completed
        this.sqlSessionFactory.getConfiguration().getMappedStatementNames();
    }
}
 
Example 21
Project: cas-5.1.0   File: AbstractCentralAuthenticationService.java   Source Code and License 5 votes vote down vote up
/**
 * Publish CAS events.
 *
 * @param e the event
 */
protected void doPublishEvent(final ApplicationEvent e) {
    if (applicationEventPublisher != null) {
        LOGGER.debug("Publishing [{}]", e);
        this.applicationEventPublisher.publishEvent(e);
    }
}
 
Example 22
Project: lemon   File: SpringSecurityListener.java   Source Code and License 5 votes vote down vote up
public void logCredentialExpired(ApplicationEvent event) throws Exception {
    AuthenticationFailureCredentialsExpiredEvent authenticationFailureCredentialsExpiredEvent = (AuthenticationFailureCredentialsExpiredEvent) event;
    Authentication authentication = authenticationFailureCredentialsExpiredEvent
            .getAuthentication();
    logger.info("{}", authentication);

    String tenantId = this.getTenantId(authentication);

    Object principal = authentication.getPrincipal();
    String userId = null;

    if (principal instanceof SpringSecurityUserAuth) {
        userId = ((SpringSecurityUserAuth) principal).getId();
    } else {
        userId = authentication.getName();
    }

    AuditDTO auditDto = new AuditDTO();
    auditDto.setUserId(userId);
    auditDto.setAuditTime(new Date());
    auditDto.setAction("login");
    auditDto.setResult("failure");
    auditDto.setApplication("lemon");
    auditDto.setClient(getUserIp(authentication));
    auditDto.setServer(InetAddress.getLocalHost().getHostAddress());
    auditDto.setDescription(authenticationFailureCredentialsExpiredEvent
            .getException().getMessage());
    auditDto.setTenantId(tenantId);
    auditConnector.log(auditDto);

    ctx.publishEvent(new LoginEvent(authentication, userId, this
            .getSessionId(authentication), "credentialExpired", "default",
            tenantId));
}
 
Example 23
Project: vertx-spring   File: EventPublishingVertxListener.java   Source Code and License 5 votes vote down vote up
private <T extends ApplicationEvent> void publish(Supplier<T> eventSupplier) {
    if (applicationEventPublisher != null) {
        T event = eventSupplier.get();
        logger.debug("Publishing {} with source {}", event.getClass().getSimpleName(), event.getSource());
        applicationEventPublisher.publishEvent(event);
    }
}
 
Example 24
Project: springboot-analysis   File: SimpleApplicationListener.java   Source Code and License 5 votes vote down vote up
@Override
public void onApplicationEvent(ApplicationEvent event) {
    if(event instanceof ApplicationStartedEvent) {
        System.out.println("===== custom started event in initializer");
    } else if(event instanceof ApplicationReadyEvent) {
        System.out.println("===== custom ready event in initializer");
    }
}
 
Example 25
Project: alfresco-repository   File: CIFSServerBean.java   Source Code and License 5 votes vote down vote up
@Override
protected void onShutdown(ApplicationEvent event)
{
    stopServer();
    
    // Clear the configuration
    m_filesysConfig = null;
}
 
Example 26
Project: alfresco-repository   File: EmailServer.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void onShutdown(ApplicationEvent event)
{
    if (enabled)
    {
        shutdown();
    }
}
 
Example 27
Project: lemon   File: SpringSecurityListener.java   Source Code and License 5 votes vote down vote up
public void logBadCredential(ApplicationEvent event) throws Exception {
    AuthenticationFailureBadCredentialsEvent authenticationFailureBadCredentialsEvent = (AuthenticationFailureBadCredentialsEvent) event;
    Authentication authentication = authenticationFailureBadCredentialsEvent
            .getAuthentication();
    logger.info("{}", authentication);

    String tenantId = this.getTenantId(authentication);
    Object principal = authentication.getPrincipal();
    String userId = null;

    if (principal instanceof SpringSecurityUserAuth) {
        userId = ((SpringSecurityUserAuth) principal).getId();
    } else {
        userId = authentication.getName();
    }

    AuditDTO auditDto = new AuditDTO();
    auditDto.setUserId(userId);
    auditDto.setAuditTime(new Date());
    auditDto.setAction("login");
    auditDto.setResult("failure");
    auditDto.setApplication("lemon");
    auditDto.setClient(getUserIp(authentication));
    auditDto.setServer(InetAddress.getLocalHost().getHostAddress());
    auditDto.setDescription(authenticationFailureBadCredentialsEvent
            .getException().getMessage());
    auditDto.setTenantId(tenantId);
    auditConnector.log(auditDto);

    ctx.publishEvent(new LoginEvent(authentication, userId, this
            .getSessionId(authentication), "badCredentials", "default",
            tenantId));
}
 
Example 28
Project: alfresco-core   File: SchedulerStarterBean.java   Source Code and License 5 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    try
    {
        log.info("Scheduler started");
        scheduler.start();
    }
    catch (SchedulerException e)
    {
        throw new AlfrescoRuntimeException("Scheduler failed to start", e);
    }
}
 
Example 29
Project: spring-session-data-mongodb   File: MongoOperationsSessionRepository.java   Source Code and License 5 votes vote down vote up
private void publishEvent(ApplicationEvent event) {
	try {
		this.eventPublisher.publishEvent(event);
	}
	catch (Throwable ex) {
		logger.error("Error publishing " + event + ".", ex);
	}
}
 
Example 30
Project: alfresco-repository   File: CheckAndFixPersonPermissionsBootstrapBean.java   Source Code and License 5 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    log.info("Checking person permissions ...");
    int count = checkandFixPermissions();
    log.info("... updated " + count);
}
 
Example 31
Project: alfresco-repository   File: SolrFacetConfigTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testOverrideOrder() throws Exception
{
    ApplicationEvent applicationEvent = new ApplicationEvent(this)
    {
        private static final long serialVersionUID = 1L;
    };

    /*
     * Override order: default,custom
     */
    SolrFacetConfig config = new SolrFacetConfig(rawProperties, "default,custom");
    config.setNamespaceService(context.getBean("namespaceService", NamespaceService.class));
    config.onBootstrap(applicationEvent);

    SolrFacetProperties creatorFP = config.getDefaultFacets().get("test_filter_creator");
    assertEquals("Incorrect QNAME", "{http://www.alfresco.org/model/content/1.0}creator", creatorFP.getFacetQName().toString());
    assertEquals(10, creatorFP.getMaxFilters());
    assertEquals(5, creatorFP.getHitThreshold());
    assertEquals(14, creatorFP.getMinFilterValueLength());
    assertEquals(1, creatorFP.getScopedSites().size());
    assertEquals("site1", creatorFP.getScopedSites().iterator().next());

    /*
     * Override order: custom,default
     */
    config = new SolrFacetConfig(rawProperties, "custom,default");
    config.setNamespaceService(context.getBean("namespaceService", NamespaceService.class));
    config.onBootstrap(applicationEvent);

    creatorFP = config.getDefaultFacets().get("test_filter_creator");
    assertEquals("Incorrect QNAME", "{http://www.alfresco.org/model/content/1.0}creator", creatorFP.getFacetQName().toString());
    assertEquals(5, creatorFP.getMaxFilters());
    assertEquals(1, creatorFP.getHitThreshold());
    assertEquals(4, creatorFP.getMinFilterValueLength());
    assertEquals(0, creatorFP.getScopedSites().size());
}
 
Example 32
Project: simple-hostel-management   File: UpdateFilesListener.java   Source Code and License 5 votes vote down vote up
@Override
public void onApplicationEvent(ApplicationEvent event) {

    if (event instanceof ApplicationStartedEvent) {
       update();
    }

}
 
Example 33
Project: jsf-core   File: WorkerManager.java   Source Code and License 5 votes vote down vote up
@Override
public void onApplicationEvent(ApplicationEvent applicationEvent) {
    //spring 容器加载完毕
    if ( applicationEvent instanceof ContextRefreshedEvent){
        initWorker();
        if ( workers.size() > 0 ){
            createScheduleManager();
            startScanMasterStatTask();
        }
    }
}
 
Example 34
Project: lemon   File: SpringSecurityListener.java   Source Code and License 5 votes vote down vote up
public void logLocked(ApplicationEvent event) throws Exception {
    AuthenticationFailureLockedEvent authenticationFailureLockedEvent = (AuthenticationFailureLockedEvent) event;
    Authentication authentication = authenticationFailureLockedEvent
            .getAuthentication();
    logger.info("{}", authentication);

    String tenantId = this.getTenantId(authentication);

    Object principal = authentication.getPrincipal();
    String userId = null;

    if (principal instanceof SpringSecurityUserAuth) {
        userId = ((SpringSecurityUserAuth) principal).getId();
    } else {
        userId = authentication.getName();
    }

    AuditDTO auditDto = new AuditDTO();
    auditDto.setUserId(userId);
    auditDto.setAuditTime(new Date());
    auditDto.setAction("login");
    auditDto.setResult("failure");
    auditDto.setApplication("lemon");
    auditDto.setClient(getUserIp(authentication));
    auditDto.setServer(InetAddress.getLocalHost().getHostAddress());
    auditDto.setDescription(authenticationFailureLockedEvent.getException()
            .getMessage());
    auditDto.setTenantId(tenantId);
    auditConnector.log(auditDto);

    ctx.publishEvent(new LoginEvent(authentication, userId, this
            .getSessionId(authentication), "locked", "default", tenantId));
}
 
Example 35
Project: lams   File: EventPublicationInterceptor.java   Source Code and License 5 votes vote down vote up
/**
 * Set the application event class to publish.
 * <p>The event class <b>must</b> have a constructor with a single
 * {@code Object} argument for the event source. The interceptor
 * will pass in the invoked object.
 * @throws IllegalArgumentException if the supplied {@code Class} is
 * {@code null} or if it is not an {@code ApplicationEvent} subclass or
 * if it does not expose a constructor that takes a single {@code Object} argument
 */
public void setApplicationEventClass(Class<?> applicationEventClass) {
	if (ApplicationEvent.class.equals(applicationEventClass) ||
		!ApplicationEvent.class.isAssignableFrom(applicationEventClass)) {
		throw new IllegalArgumentException("applicationEventClass needs to extend ApplicationEvent");
	}
	try {
		this.applicationEventClassConstructor =
				applicationEventClass.getConstructor(new Class<?>[] {Object.class});
	}
	catch (NoSuchMethodException ex) {
		throw new IllegalArgumentException("applicationEventClass [" +
				applicationEventClass.getName() + "] does not have the required Object constructor: " + ex);
	}
}
 
Example 36
Project: alfresco-repository   File: AlfrescoImapServer.java   Source Code and License 5 votes vote down vote up
protected void onBootstrap(ApplicationEvent event)
{
    if (imapServerEnabled)
    {
        startup();
    }
    else
    {
        if (logger.isDebugEnabled())
        {
            logger.debug("IMAP service is disabled.");
        }
    }
}
 
Example 37
Project: alfresco-repository   File: MultiTenantBootstrap.java   Source Code and License 5 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    PropertyCheck.mandatory(this, "tenantAdminService", tenantAdminService);
    PropertyCheck.mandatory(this, "patchService", patchService);
    PropertyCheck.mandatory(this, "descriptorService", descriptorService);

    // TODO: Is it really necessary to count the tenants?
    if (tenantAdminService.getAllTenants().size() > 0)
    {
        tenantAdminService.startTenants();
    }
}
 
Example 38
Project: alfresco-repository   File: IndexInfo.java   Source Code and License 5 votes vote down vote up
private void publishDiscoveryEvent()
{
    if (this.config == null)
    {
        return;
    }
    final IndexEvent discoveryEvent = new IndexEvent(this, "Discovery", 1);
    final ConfigurableApplicationContext applicationContext = this.config.getApplicationContext();
    try
    {
        applicationContext.publishEvent(discoveryEvent);
    }
    catch (IllegalStateException e)
    {
        // There's a possibility that the application context hasn't fully refreshed yet, so register a listener
        // that will fire when it has
        applicationContext.addApplicationListener(new ApplicationListener()
        {

            public void onApplicationEvent(ApplicationEvent event)
            {
                if (event instanceof ContextRefreshedEvent)
                {
                    applicationContext.publishEvent(discoveryEvent);
                }
            }
        });
    }
}
 
Example 39
Project: alfresco-repository   File: ShutdownBackstop.java   Source Code and License 5 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event) 
{
	// Do logging here for side effect of initialising log object.
	if (log.isDebugEnabled())
	{
		log.debug("Shutdown backstop onBootstrap");
	}	
	
	// Nothing to do here
}
 
Example 40
Project: alfresco-data-model   File: CMISAbstractDictionaryService.java   Source Code and License 5 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    afterDictionaryInit();

    // TODO revisit (for KS and/or 1.1)
    if (dictionaryDAO != null)
    {
        dictionaryDAO.registerListener(this);
    }
    else
    {
        logger.error("DictionaryDAO is null - hence CMIS Dictionary not registered for updates");
    }
}
 
Example 41
Project: alfresco-repository   File: NodeIndexer.java   Source Code and License 5 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    // Dig the indexer out of the context
    indexer = (Indexer) super.getApplicationContext().getBean("indexerComponent");
    started = true;
}
 
Example 42
Project: lemon   File: SpringSecurityListener.java   Source Code and License 5 votes vote down vote up
public void logAccountExpired(ApplicationEvent event) throws Exception {
    AuthenticationFailureExpiredEvent authenticationFailureExpiredEvent = (AuthenticationFailureExpiredEvent) event;
    Authentication authentication = authenticationFailureExpiredEvent
            .getAuthentication();
    logger.info("{}", authentication);

    String tenantId = this.getTenantId(authentication);

    Object principal = authentication.getPrincipal();
    String userId = null;

    if (principal instanceof SpringSecurityUserAuth) {
        userId = ((SpringSecurityUserAuth) principal).getId();
    } else {
        userId = authentication.getName();
    }

    AuditDTO auditDto = new AuditDTO();
    auditDto.setUserId(userId);
    auditDto.setAuditTime(new Date());
    auditDto.setAction("login");
    auditDto.setResult("failure");
    auditDto.setApplication("lemon");
    auditDto.setClient(getUserIp(authentication));
    auditDto.setServer(InetAddress.getLocalHost().getHostAddress());
    auditDto.setDescription(authenticationFailureExpiredEvent
            .getException().getMessage());
    auditDto.setTenantId(tenantId);
    auditConnector.log(auditDto);

    ctx.publishEvent(new LoginEvent(authentication, userId, this
            .getSessionId(authentication), "accountExpired", "default",
            tenantId));
}
 
Example 43
Project: alfresco-repository   File: CryptodocSwitchableApplicationContextFactory.java   Source Code and License 5 votes vote down vote up
public void onApplicationEvent(ApplicationEvent event)
{
	
	if(logger.isDebugEnabled())
	{
		logger.debug("event : " + event);
	}
	
	if (event instanceof DescriptorServiceAvailableEvent)
	{
		descriptorService = ((DescriptorServiceAvailableEvent)event).getDescriptorService();
	}
    super.onApplicationEvent(event);
}
 
Example 44
Project: alfresco-file-transfer-receiver   File: SchemaBootstrap.java   Source Code and License 5 votes vote down vote up
@Override
protected void onShutdown(ApplicationEvent arg0)
{
    if (log.isDebugEnabled())
    {
        log.warn("FTR shutting down");
    }
}
 
Example 45
Project: incubator-servicecomb-java-chassis   File: CseApplicationListener.java   Source Code and License 4 votes vote down vote up
@Override
public void onApplicationEvent(ApplicationEvent event) {
  if (initEventClass.isInstance(event)) {
    //TODO to load when webapplication context is used for discovery client, need to check if can use the order and undo this change with proper fix.
    if (!isInit) {
      try {
        bootListenerList = applicationContext.getBeansOfType(BootListener.class).values();

        AbstractEndpointsCache.init(RegistryUtils.getInstanceCacheManager(), transportManager);

        triggerEvent(EventType.BEFORE_HANDLER);
        HandlerConfigUtils.init();
        triggerEvent(EventType.AFTER_HANDLER);

        triggerEvent(EventType.BEFORE_PRODUCER_PROVIDER);
        producerProviderManager.init();
        triggerEvent(EventType.AFTER_PRODUCER_PROVIDER);

        triggerEvent(EventType.BEFORE_CONSUMER_PROVIDER);
        consumerProviderManager.init();
        triggerEvent(EventType.AFTER_CONSUMER_PROVIDER);

        triggerEvent(EventType.BEFORE_TRANSPORT);
        transportManager.init();
        triggerEvent(EventType.AFTER_TRANSPORT);

        schemaListenerManager.notifySchemaListener();

        triggerEvent(EventType.BEFORE_REGISTRY);

        triggerAfterRegistryEvent();

        RegistryUtils.run();

        // 当程序退出时,进行相关清理,注意:kill -9 {pid}下无效
        // 1. 去注册实例信息
        // TODO 服务优雅退出
        if (applicationContext instanceof AbstractApplicationContext) {
          ((AbstractApplicationContext) applicationContext).registerShutdownHook();
        }
        isInit = true;
      } catch (Exception e) {
        LOGGER.error("cse init failed, {}", FortifyUtils.getErrorInfo(e));
      }
    }
  } else if (event instanceof ContextClosedEvent) {
    LOGGER.warn("cse is closing now...");
    RegistryUtils.destroy();
    isInit = false;
  }
}
 
Example 46
Project: alfresco-repository   File: SystemInfoBootstrap.java   Source Code and License 4 votes vote down vote up
@Override
protected void onShutdown(ApplicationEvent event)
{
    // NOOP
}
 
Example 47
Project: cas-5.1.0   File: DefaultAuthenticationTransactionManager.java   Source Code and License 4 votes vote down vote up
private void publishEvent(final ApplicationEvent event) {
    if (this.eventPublisher != null) {
        this.eventPublisher.publishEvent(event);
    }
}
 
Example 48
Project: cas-5.1.0   File: DefaultServicesManager.java   Source Code and License 4 votes vote down vote up
private void publishEvent(final ApplicationEvent event) {
    if (this.eventPublisher != null) {
        this.eventPublisher.publishEvent(event);
    }
}
 
Example 49
Project: cas-5.1.0   File: AbstractServiceRegistryDao.java   Source Code and License 4 votes vote down vote up
/**
 * Publish event.
 *
 * @param event the event
 */
protected void publishEvent(final ApplicationEvent event) {
    if (this.eventPublisher != null) {
        this.eventPublisher.publishEvent(event);
    }
}
 
Example 50
Project: alfresco-repository   File: EncryptionChecker.java   Source Code and License 4 votes vote down vote up
@Override
protected void onShutdown(ApplicationEvent event)
{
    
}
 
Example 51
Project: didi-eureka-server   File: InstanceRegistry.java   Source Code and License 4 votes vote down vote up
private void publishEvent(ApplicationEvent applicationEvent) {
	this.ctxt.publishEvent(applicationEvent);
}
 
Example 52
Project: gemini.blueprint   File: ApplicationListenerAdapter.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public void onApplicationEvent(ApplicationEvent event) {
	if (eventType.isInstance(event)) {
		osgiListener.onOsgiApplicationEvent((E) event);
	}
}
 
Example 53
Project: alfresco-repository   File: EmailServiceRemotable.java   Source Code and License 4 votes vote down vote up
@Override
protected void onShutdown(ApplicationEvent event)
{
}
 
Example 54
Project: alfresco-core   File: RuntimeExecBootstrapBean.java   Source Code and License 4 votes vote down vote up
@Override
protected synchronized void onBootstrap(ApplicationEvent event)
{
    // If the command is disabled then do nothing.
    if (this.enabled == false)
    {
        if (logger.isDebugEnabled())
        {
            logger.debug("Bootstrap execution of " + startupCommands.size() + " was not enabled");
        }
        return;
    }
    // execute
    for (RuntimeExec command : startupCommands)
    {
        ExecutionResult result = command.execute();
        // check for failure
        if (!result.getSuccess())
        {
            String msg = "Bootstrap command failed: \n" + result;
            if (failOnError)
            {
                throw new AlfrescoRuntimeException(msg);
            }
            else
            {
                logger.error(msg);
            }
        }
        else
        {
            // It executed, so keep track of it
            executionResults.add(result);
        }
    }
    if (killProcessesOnShutdown)
    {
        // Force a shutdown on VM termination as we can't rely on the Spring context termination
        this.shutdownThread = new KillProcessShutdownThread();
        Runtime.getRuntime().addShutdownHook(this.shutdownThread);
    }
    // done
    if (logger.isDebugEnabled())
    {
        logger.debug("Bootstrap execution of " + startupCommands.size() + " commands was successful");
    }
}
 
Example 55
Project: alfresco-repository   File: AbstractContentStoreMapProvider.java   Source Code and License 4 votes vote down vote up
protected void onShutdown(ApplicationEvent event)
{
	// nothing particular to do
}
 
Example 56
Project: alfresco-repository   File: DictionaryRepositoryBootstrap.java   Source Code and License 4 votes vote down vote up
@Override
protected void onShutdown(ApplicationEvent event)
{
    // NOOP
}
 
Example 57
Project: alfresco-repository   File: PermissionServiceImpl.java   Source Code and License 4 votes vote down vote up
/**
 * No-op
 */
@Override
protected void onShutdown(ApplicationEvent event)
{
}
 
Example 58
Project: alfresco-repository   File: LockOwnerDynamicAuthority.java   Source Code and License 4 votes vote down vote up
/**
 * No-op
 */
@Override
protected void onShutdown(ApplicationEvent event)
{
}
 
Example 59
Project: alfresco-repository   File: RepoXMLConfigService.java   Source Code and License 4 votes vote down vote up
@Override
protected void onShutdown(ApplicationEvent event)
{
    // NOOP
}
 
Example 60
Project: didi-eureka-server   File: EurekaServerInitializerConfiguration.java   Source Code and License 4 votes vote down vote up
private void publish(ApplicationEvent event) {
	this.applicationContext.publishEvent(event);
}