本文整理汇总了Java中org.openspaces.events.TransactionalEvent类的典型用法代码示例。如果您正苦于以下问题:Java TransactionalEvent类的具体用法?Java TransactionalEvent怎么用?Java TransactionalEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TransactionalEvent类属于org.openspaces.events包,在下文中一共展示了TransactionalEvent类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postProcessAfterInitialization
import org.openspaces.events.TransactionalEvent; //导入依赖的package包/类
public Object postProcessAfterInitialization(final Object bean, String beanName) throws BeansException {
if (bean == null) {
return bean;
}
Class<?> beanClass = this.getBeanClass(bean);
if (beanClass == null) {
return bean;
}
Archive archive = AnnotationUtils.findAnnotation(beanClass, Archive.class);
if (archive == null) {
return bean;
}
GigaSpace gigaSpace = AnnotationProcessorUtils.findGigaSpace(bean, archive.gigaSpace(), applicationContext, beanName);
ArchiveOperationHandler archiveHandler = AnnotationProcessorUtils.findArchiveHandler(bean, archive.archiveHandler(), applicationContext, beanName);
EventContainersBus eventContainersBus = AnnotationProcessorUtils.findBus(applicationContext);
ArchivePollingContainerConfigurer archiveContainerConfigurer =
new ArchivePollingContainerConfigurer(gigaSpace)
.archiveHandler(archiveHandler)
.name(beanName)
.concurrentConsumers(archive.concurrentConsumers())
.maxConcurrentConsumers(archive.maxConcurrentConsumers())
.receiveTimeout(archive.receiveTimeout())
.performSnapshot(archive.performSnapshot())
.recoveryInterval(archive.recoveryInterval())
.autoStart(archive.autoStart())
.batchSize(archive.batchSize())
.useFifoGrouping(archive.useFifoGrouping());
Object staticTemplateProvider = AnnotationProcessorUtils.findTemplateFromProvider(bean);
if (staticTemplateProvider != null)
archiveContainerConfigurer.template(staticTemplateProvider);
else {
DynamicEventTemplateProvider templateProvider = AnnotationProcessorUtils.findDynamicEventTemplateProvider(bean);
if (templateProvider != null) {
archiveContainerConfigurer.dynamicTemplate(templateProvider);
}
}
// handle transactions (we support using either @Transactional or @TransactionalEvent or both)
TransactionalEvent transactionalEvent = AnnotationUtils.findAnnotation(beanClass, TransactionalEvent.class);
Transactional transactional = AnnotationUtils.findAnnotation(beanClass, Transactional.class);
if (transactionalEvent != null || transactional != null) {
if (transactionalEvent != null) {
archiveContainerConfigurer.transactionManager(AnnotationProcessorUtils.findTxManager(transactionalEvent.transactionManager(), applicationContext, beanName));
} else {
archiveContainerConfigurer.transactionManager(AnnotationProcessorUtils.findTxManager("", applicationContext, beanName));
}
Isolation isolation = Isolation.DEFAULT;
if (transactional != null && transactional.isolation() != Isolation.DEFAULT) {
isolation = transactional.isolation();
}
if (transactionalEvent != null && transactionalEvent.isolation() != Isolation.DEFAULT) {
isolation = transactionalEvent.isolation();
}
archiveContainerConfigurer.transactionIsolationLevel(isolation.value());
int timeout = TransactionDefinition.TIMEOUT_DEFAULT;
if (transactional != null && transactional.timeout() != TransactionDefinition.TIMEOUT_DEFAULT) {
timeout = transactional.timeout();
}
if (transactionalEvent != null && transactionalEvent.timeout() != TransactionDefinition.TIMEOUT_DEFAULT) {
timeout = transactionalEvent.timeout();
}
archiveContainerConfigurer.transactionTimeout(timeout);
}
eventContainersBus.registerContainer(beanName, archiveContainerConfigurer.create());
return bean;
}
示例2: postProcessAfterInitialization
import org.openspaces.events.TransactionalEvent; //导入依赖的package包/类
public Object postProcessAfterInitialization(final Object bean, String beanName) throws BeansException {
if (bean == null) {
return bean;
}
Class<?> beanClass = this.getBeanClass(bean);
if (beanClass == null) {
return bean;
}
AsyncPolling polling = AnnotationUtils.findAnnotation(beanClass, AsyncPolling.class);
if (polling == null) {
return bean;
}
GigaSpace gigaSpace = AnnotationProcessorUtils.findGigaSpace(bean, polling.gigaSpace(), applicationContext, beanName);
EventContainersBus eventContainersBus = AnnotationProcessorUtils.findBus(applicationContext);
SimpleAsyncPollingContainerConfigurer pollingContainerConfigurer = new SimpleAsyncPollingContainerConfigurer(gigaSpace);
pollingContainerConfigurer.name(beanName);
if (bean instanceof SpaceDataEventListener) {
pollingContainerConfigurer.eventListener((SpaceDataEventListener) bean);
} else {
pollingContainerConfigurer.eventListenerAnnotation(bean);
}
DynamicEventTemplateProvider templateProvider = AnnotationProcessorUtils.findDynamicEventTemplateProvider(bean);
if (templateProvider != null) {
pollingContainerConfigurer.dynamicTemplate(templateProvider);
}
pollingContainerConfigurer.concurrentConsumers(polling.concurrentConsumers());
pollingContainerConfigurer.receiveTimeout(polling.receiveTimeout());
pollingContainerConfigurer.performSnapshot(polling.performSnapshot());
pollingContainerConfigurer.autoStart(polling.autoStart());
// handle transactions (we support using either @Transactional or @TransactionalEvent or both)
TransactionalEvent transactionalEvent = AnnotationUtils.findAnnotation(beanClass, TransactionalEvent.class);
Transactional transactional = AnnotationUtils.findAnnotation(beanClass, Transactional.class);
if (transactionalEvent != null || transactional != null) {
if (transactionalEvent != null) {
pollingContainerConfigurer.transactionManager(AnnotationProcessorUtils.findTxManager(transactionalEvent.transactionManager(), applicationContext, beanName));
} else {
pollingContainerConfigurer.transactionManager(AnnotationProcessorUtils.findTxManager("", applicationContext, beanName));
}
Isolation isolation = Isolation.DEFAULT;
if (transactional != null && transactional.isolation() != Isolation.DEFAULT) {
isolation = transactional.isolation();
}
if (transactionalEvent != null && transactionalEvent.isolation() != Isolation.DEFAULT) {
isolation = transactionalEvent.isolation();
}
pollingContainerConfigurer.transactionIsolationLevel(isolation.value());
int timeout = TransactionDefinition.TIMEOUT_DEFAULT;
if (transactional != null && transactional.timeout() != TransactionDefinition.TIMEOUT_DEFAULT) {
timeout = transactional.timeout();
}
if (transactionalEvent != null && transactionalEvent.timeout() != TransactionDefinition.TIMEOUT_DEFAULT) {
timeout = transactionalEvent.timeout();
}
pollingContainerConfigurer.transactionTimeout(timeout);
}
eventContainersBus.registerContainer(beanName, pollingContainerConfigurer.pollingContainer());
return bean;
}