Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2010-2011. Axon Framework
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.axonframework.eventhandling.scheduling.java;
 
 
Spring FactoryBean that creates a SimpleEventScheduler instance using resources found in the Spring Application Context. The SimpleEventScheduler uses Java's ScheduledExecutorService as scheduling and triggering mechanism.

Note that this mechanism is non-persistent. Scheduled tasks will be lost when the JVM is shut down, unless special measures have been taken to prevent that. For more flexible and powerful scheduling options, see org.axonframework.eventhandling.scheduling.quartz.QuartzEventScheduler.

Author(s):
Allard Buijze
Since:
1.1
 
         ApplicationContextAware {
 
     private EventBus eventBus;
 
     @Override
     public SimpleEventScheduler getObject() throws Exception {
         return ;
     }
 
     @Override
     public Class<?> getObjectType() {
         return SimpleEventScheduler.class;
     }
 
     @Override
     public boolean isSingleton() {
         return true;
     }
 
     @Override
     public void afterPropertiesSet() throws Exception {
         if ( == null) {
              = Executors.newSingleThreadScheduledExecutor();
         }
         if ( == null) {
              = .getBean(EventBus.class);
         }
         if ( == null) {
             this. = new SimpleEventScheduler();
         } else {
             SpringTransactionalTriggerCallback callback = new SpringTransactionalTriggerCallback();
             callback.setTransactionManager();
             if ( != null) {
                 callback.setTransactionDefinition();
             }
             this. = new SimpleEventScheduler(callback);
         }
     }

    
Sets the eventBus that scheduled events should be published to. Defaults to the EventBus found in the application context. If there is more than one EventBus in the application context, you must specify which one to use.

Parameters:
eventBus The EventBus to publish scheduled events to
 
     public void setEventBus(EventBus eventBus) {
         this. = eventBus;
     }

    
Sets the ExecutorService implementation that monitors the triggers and provides the Threads to publish events. Defaults to a single-threaded executor.

Parameters:
executorService The executor service providing the scheduling and execution resources
    public void setExecutorService(ScheduledExecutorService executorService) {
        this. = executorService;
    }

    
Sets the transaction manager that manages the transaction around the publication of an event. If a transaction manager is not specified, no transactions are managed around the event publication.

Parameters:
transactionManager the transaction manager that takes care of transactions around event publication
    public void setTransactionManager(PlatformTransactionManager transactionManager) {
        this. = transactionManager;
    }

    
The TransactionDefinition to use by the transaction manager. Default to a org.springframework.transaction.support.DefaultTransactionDefinition. Is ignored if no transaction manager is configured.

Parameters:
transactionDefinition the TransactionDefinition to use by the transaction manager
    public void setTransactionDefinition(TransactionDefinition transactionDefinition) {
        this. = transactionDefinition;
    }
    @Override
    public void setApplicationContext(ApplicationContext applicationContextthrows BeansException {
        this. = applicationContext;
    }
New to GrepCode? Check out our FAQ X