当前位置: 首页>>代码示例>>Java>>正文


Java SmartApplicationListener类代码示例

本文整理汇总了Java中org.springframework.context.event.SmartApplicationListener的典型用法代码示例。如果您正苦于以下问题:Java SmartApplicationListener类的具体用法?Java SmartApplicationListener怎么用?Java SmartApplicationListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SmartApplicationListener类属于org.springframework.context.event包,在下文中一共展示了SmartApplicationListener类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applicationListener

import org.springframework.context.event.SmartApplicationListener; //导入依赖的package包/类
/**
 * Listens ContextClosedEvent and Closes all async http connections
 */
@Bean
ApplicationListener<?> applicationListener() {
    return new SmartApplicationListener() {
        @Override
        public int getOrder() { return 0; }

        @Override
        public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
            return ContextClosedEvent.class.isAssignableFrom(eventType);
        }

        @Override
        public boolean supportsSourceType(Class<?> sourceType) { return true; }

        @Override
        public void onApplicationEvent(ApplicationEvent event) { Closeables.close(proxyInstance); }
    };
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:22,代码来源:BalancerConfiguration.java

示例2: applicationEventListener

import org.springframework.context.event.SmartApplicationListener; //导入依赖的package包/类
/**
    * {@inheritDoc}
    *
    * <p>
    * The {@link org.kuali.rice.coreservice.api.parameter.Parameter} properties need to come from the
    * {@link ConfigContext} instead of the {@link org.kuali.common.util.spring.env.EnvironmentService} for the scenario
    * where nobody has wired in a bootstrap PSC in order to help manage the resetting of the database via RunOnce.
    * </p>
    */
@Override
@Bean
public SmartApplicationListener applicationEventListener() {
	Properties properties = ConfigContext.getCurrentContextConfig().getProperties();
	String applicationId = properties.getProperty(CoreConstants.Config.APPLICATION_ID);
	String namespace = properties.getProperty(NAMESPACE_KEY, NAMESPACE);
	String component = properties.getProperty(COMPONENT_KEY, COMPONENT);
	String name = properties.getProperty(NAME_KEY, NAME);
	String description = properties.getProperty(DESCRIPTION_KEY, DESCRIPTION);
	boolean runOnMissingParameter = Boolean.parseBoolean(properties.getProperty(RUN_ON_MISSING_PARAMETER_KEY, RUN_ON_MISSING_PARAMETER.toString()));
       int order = Integer.parseInt(properties.getProperty(ORDER_KEY, String.valueOf(Ordered.LOWEST_PRECEDENCE)));

	RunOnce runOnce = ParameterServiceRunOnce.builder(applicationId, namespace, component, name)
               .description(description).runOnMissingParameter(runOnMissingParameter).build();
	Executable springExecutable = SpringExecUtils.getSpringExecutable(service, propertySource, IngestXmlExecConfig.class,
               Lists.newArrayList("master"));
       Executable executable = RunOnceExecutable.builder(springExecutable, runOnce).build();

	return ExecutableApplicationEventListener.builder(executable, ContextRefreshedEvent.class).order(order).build();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:30,代码来源:IngestXmlRunOnceConfig.java

示例3: MultiServerUserRegistry

import org.springframework.context.event.SmartApplicationListener; //导入依赖的package包/类
/**
 * Create an instance wrapping the local user registry.
 */
public MultiServerUserRegistry(SimpUserRegistry localRegistry) {
	Assert.notNull(localRegistry, "'localRegistry' is required.");
	this.localRegistry = localRegistry;
	this.listener = (this.localRegistry instanceof SmartApplicationListener ?
			(SmartApplicationListener) this.localRegistry : new NoOpSmartApplicationListener());
	this.id = generateId();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:MultiServerUserRegistry.java

示例4: applicationEventListener

import org.springframework.context.event.SmartApplicationListener; //导入依赖的package包/类
/**
    * {@inheritDoc}
    */
@Override
@Bean
public SmartApplicationListener applicationEventListener() {
	Executable executable = config.ingestXmlExecutable();
       Integer order = env.getInteger(ORDER_KEY, Integer.valueOf(Ordered.LOWEST_PRECEDENCE));

	return ExecutableApplicationEventListener.builder(executable, ContextRefreshedEvent.class).order(order.intValue()).build();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:12,代码来源:IngestXmlConfig.java

示例5: supportsEvent

import org.springframework.context.event.SmartApplicationListener; //导入依赖的package包/类
protected boolean supportsEvent(ApplicationListener<?> listener,
                                Class<? extends ApplicationEvent> eventType, Class<?> sourceType) {

    SmartApplicationListener smartListener = (listener instanceof SmartApplicationListener ?
                                              (SmartApplicationListener) listener :
                                              new SmartApplicationListenerAdapter(listener));
    return (smartListener.supportsEventType(eventType) && smartListener.supportsSourceType(sourceType));
}
 
开发者ID:Kadvin,项目名称:spring-component-framework,代码行数:9,代码来源:SmartApplicationEventMulticaster.java

示例6: supportsEvent

import org.springframework.context.event.SmartApplicationListener; //导入依赖的package包/类
/**
 * Determine whether the given listener supports the given event.
 * <p>
 * The default implementation detects the {@link SmartApplicationListener}
 * interface. In case of a standard {@link ApplicationListener}, a
 * {@link GenericApplicationListenerAdapter} will be used to introspect the
 * generically declared type of the target listener.
 * 
 * @param listener
 *            the target listener to check
 * @param eventType
 *            the event type to check against
 * @param sourceType
 *            the source type to check against
 * @return whether the given listener should be included in the candidates
 *         for the given event type
 */
protected boolean supportsEvent(ApplicationListener listener, Class<? extends ApplicationEvent> eventType,
        Class sourceType)
{

    SmartApplicationListener smartListener = (listener instanceof SmartApplicationListener ? (SmartApplicationListener) listener
            : new GenericApplicationListenerAdapter(listener));
    return (smartListener.supportsEventType(eventType) && smartListener.supportsSourceType(sourceType));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:SafeApplicationEventMulticaster.java


注:本文中的org.springframework.context.event.SmartApplicationListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。