Coverage Report - org.kuali.rice.edl.impl.config.EDLConfigurer
 
Classes in this File Line Coverage Branch Coverage Complexity
EDLConfigurer
0%
0/30
0%
0/10
1.625
 
 1  
 /*
 2  
  * Copyright 2006-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.kuali.rice.edl.impl.config;
 18  
 
 19  
 import org.apache.commons.lang.StringUtils;
 20  
 import org.kuali.rice.core.api.config.module.RunMode;
 21  
 import org.kuali.rice.core.api.config.property.ConfigContext;
 22  
 import org.kuali.rice.core.api.lifecycle.Lifecycle;
 23  
 import org.kuali.rice.core.api.resourceloader.ResourceLoader;
 24  
 import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
 25  
 import org.kuali.rice.core.impl.config.module.ModuleConfigurer;
 26  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 27  
 import org.kuali.rice.core.impl.resourceloader.RiceResourceLoaderFactory;
 28  
 import org.kuali.rice.kew.lifecycle.EmbeddedLifeCycle;
 29  
 import org.kuali.rice.kew.plugin.PluginRegistry;
 30  
 import org.kuali.rice.kew.plugin.PluginRegistryFactory;
 31  
 import org.kuali.rice.kew.resourceloader.CoreResourceLoader;
 32  
 import org.kuali.rice.kew.util.KEWConstants.ClientProtocol;
 33  
 
 34  
 import javax.sql.DataSource;
 35  
 import java.util.ArrayList;
 36  
 import java.util.Collection;
 37  
 import java.util.Collections;
 38  
 import java.util.LinkedList;
 39  
 import java.util.List;
 40  
 
 41  
 
 42  
 /**
 43  
  * Configures the EDocLite module. 
 44  
  *
 45  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 46  
  */
 47  0
 public class EDLConfigurer extends ModuleConfigurer {
 48  
 
 49  
         public static final String KEW_DATASOURCE_OBJ = "org.kuali.workflow.datasource";
 50  
 
 51  
         private DataSource dataSource;
 52  
         
 53  
         @Override
 54  
         public List<String> getPrimarySpringFiles() {
 55  
                 final List<String> springFileLocations;
 56  
 //                if (RunMode.REMOTE.equals(getRunMode()) || RunMode.THIN.equals(getRunMode()) ||
 57  
 //                                ClientProtocol.WEBSERVICE.equals(getClientProtocol())) {
 58  
 //                        springFileLocations = Collections.emptyList();
 59  
 //                } else {
 60  0
                         springFileLocations = getEmbeddedSpringFileLocation();
 61  
 //                }
 62  
 
 63  0
                 return springFileLocations;
 64  
         }
 65  
         
 66  
     private List<String> getEmbeddedSpringFileLocation(){
 67  0
             final List<String> springFileLocations = new ArrayList<String>();
 68  0
             springFileLocations.add("classpath:org/kuali/rice/edl/impl/config/EDLSpringBeans.xml");
 69  
 
 70  
 //        if ( isExposeServicesOnBus() ) {
 71  
 //                if (isSetSOAPServicesAsDefault()) {
 72  
 //                        springFileLocations.add("classpath:org/kuali/rice/kew/config/KEWServiceBusSOAPDefaultSpringBeans.xml");
 73  
 //                } else {
 74  
 //                        springFileLocations.add("classpath:org/kuali/rice/kew/config/KEWServiceBusSpringBeans.xml");
 75  
 //                }
 76  
 //        }
 77  
         
 78  
 //        if (OrmUtils.isJpaEnabled("rice.kew")) {
 79  
 //                springFileLocations.add("classpath:org/kuali/rice/kew/config/KEWJPASpringBeans.xml");
 80  
 //        }
 81  
 //        else {
 82  0
                 springFileLocations.add("classpath:org/kuali/rice/edl/impl/config/EDLOJBSpringBeans.xml");
 83  
 //        }
 84  
 
 85  0
             return springFileLocations;
 86  
     }
 87  
 
 88  
         @Override
 89  
         public void addAdditonalToConfig() {
 90  0
                 configureDataSource();
 91  0
         }
 92  
 
 93  
         private void configureDataSource() {
 94  0
                 if (getDataSource() != null) {
 95  0
                         ConfigContext.getCurrentContextConfig().putObject(KEW_DATASOURCE_OBJ, getDataSource());
 96  
                 }
 97  0
         }
 98  
 
 99  
         @Override
 100  
         public Collection<ResourceLoader> getResourceLoadersToRegister() throws Exception {
 101  
                 // create the plugin registry
 102  0
                 PluginRegistry registry = null;
 103  0
                 String pluginRegistryEnabled = ConfigContext.getCurrentContextConfig().getProperty("plugin.registry.enabled");
 104  0
                 if (!StringUtils.isBlank(pluginRegistryEnabled) && Boolean.valueOf(pluginRegistryEnabled).booleanValue()) {
 105  0
                         registry = new PluginRegistryFactory().createPluginRegistry();
 106  
                 }
 107  
 
 108  0
                 final Collection<ResourceLoader> rls = new ArrayList<ResourceLoader>();
 109  0
                 for (ResourceLoader rl : RiceResourceLoaderFactory.getSpringResourceLoaders()) {
 110  0
                         CoreResourceLoader coreResourceLoader = 
 111  
                                 new CoreResourceLoader(rl, registry);
 112  0
                         coreResourceLoader.start();
 113  
 
 114  
                         //wait until core resource loader is started to attach to GRL;  this is so startup
 115  
                         //code can depend on other things hooked into GRL without incomplete KEW resources
 116  
                         //messing things up.
 117  
 
 118  0
                         GlobalResourceLoader.addResourceLoader(coreResourceLoader);
 119  
 
 120  
                         // now start the plugin registry if there is one
 121  0
                         if (registry != null) {
 122  0
                                 registry.start();
 123  
                                 // the registry resourceloader is now being handled by the CoreResourceLoader
 124  
                                 //GlobalResourceLoader.addResourceLoader(registry);
 125  
                         }
 126  0
                         rls.add(coreResourceLoader);
 127  0
                 }
 128  
 
 129  0
                 return rls;
 130  
         }
 131  
 
 132  
         private ClientProtocol getClientProtocol() {
 133  0
                 return ClientProtocol.valueOf(ConfigContext.getCurrentContextConfig().getProperty("client.protocol"));
 134  
         }
 135  
 
 136  
         public DataSource getDataSource() {
 137  0
                 return dataSource;
 138  
         }
 139  
 
 140  
         public void setDataSource(DataSource dataSource) {
 141  0
                 this.dataSource = dataSource;
 142  0
         }
 143  
 }