Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2012 The Kuali Foundation Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php 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.kuali.rice.ksb.messaging.quartz;
 
 
An implementation of the Quartz SchedulerFactoryBean which uses a database-backed quartz if the useQuartzDatabase property is set.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class KSBSchedulerFactoryBean extends SchedulerFactoryBean {
 
     private DataSource dataSource;
     private boolean transactionManagerSet = false;
     private boolean nonTransactionalDataSourceSet = false;
     private boolean nonTransactionalDataSourceNull = true;
     private boolean dataSourceSet = false;
     private boolean schedulerInjected = false;
     
     @Override
     protected Scheduler createScheduler(SchedulerFactory schedulerFactoryString schedulerNamethrows SchedulerException {
             try {
 	             = true;
                 Scheduler scheduler = (Scheduler) ConfigContext.getCurrentContextConfig().getObject(..);
                 scheduler.addJobListener(new MessageServiceExecutorJobListener());
                 return scheduler;
             } catch (Exception e) {
                 throw new ConfigurationException(e);
             }
         }
         return super.createScheduler(schedulerFactoryschedulerName);
     }
 
     @Override
     public void afterPropertiesSet() throws Exception {
 
         boolean useQuartzDatabase = new Boolean(ConfigContext.getCurrentContextConfig().getProperty(..));
         if (useQuartzDatabase && !) {
             // require a transaction manager
             if ( == null) {
                 throw new ConfigurationException("No jta transaction manager was configured for the KSB Quartz Scheduler");
             }
             if (!) {
             	// since transaction manager is required... require a non transactional datasource
             	 = KSBServiceLocator.getMessageNonTransactionalDataSource();
             	if ( == null) {
             		throw new ConfigurationException("No non-transactional data source was found but is required for the KSB Quartz Scheduler");
             	}
             }
             if (!) {
             	 = KSBServiceLocator.getMessageDataSource();
             }
             super.setDataSource();
             if ( && ) {
                 throw new ConfigurationException("A valid transaction manager was set but no non-transactional data source was found");
             }
         }
         super.afterPropertiesSet();
     }
    
    
This overridden method is used simply to keep track of whether the transactionManager property has been set

 
     @Override
     public void setTransactionManager(PlatformTransactionManager jtaTransactionManager) {
         = jtaTransactionManager != null;
        this. = jtaTransactionManager;
    }
    
    
This overridden method is used to keep track of whether the non transactional data source is null

    @Override
    public void setNonTransactionalDataSource(DataSource nonTransactionalDataSource) {
         = true;
         = (nonTransactionalDataSource == null);
        this. = nonTransactionalDataSource;
    }
    
    @Override
    public void setDataSource(DataSource dataSource) {
    	 = true;
    	this. = dataSource;
    }
New to GrepCode? Check out our FAQ X