Coverage Report - org.kuali.rice.krad.app.persistence.jpa.RiceEntityManagerProxyFactoryBean
 
Classes in this File Line Coverage Branch Coverage Complexity
RiceEntityManagerProxyFactoryBean
0%
0/17
0%
0/6
1.5
 
 1  
 /**
 2  
  * Copyright 2005-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  
 package org.kuali.rice.krad.app.persistence.jpa;
 17  
 
 18  
 import org.kuali.rice.core.framework.persistence.jpa.NullEntityManagerFactory;
 19  
 import org.kuali.rice.core.framework.persistence.jpa.OrmUtils;
 20  
 import org.springframework.beans.factory.FactoryBean;
 21  
 import org.springframework.beans.factory.InitializingBean;
 22  
 
 23  
 import javax.persistence.EntityManagerFactory;
 24  
 import javax.sql.DataSource;
 25  
 
 26  
 /**
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 public class RiceEntityManagerProxyFactoryBean implements FactoryBean, InitializingBean {
 30  
 
 31  
         private RiceLocalContainerEntityManagerFactoryBean factoryBean;
 32  
         private String prefix;
 33  
         private DataSource datasource;
 34  
         private String moduleJpaEnabledPropertyPrefix;
 35  
         
 36  0
         public RiceEntityManagerProxyFactoryBean(String prefix, DataSource datasource) {
 37  0
                 this.prefix = prefix;
 38  0
                 this.datasource = datasource;
 39  0
                 this.moduleJpaEnabledPropertyPrefix = prefix;
 40  0
         }
 41  
                 
 42  0
         public RiceEntityManagerProxyFactoryBean(String prefix, DataSource datasource, String moduleJpaEnabledPropertyPrefix) {
 43  0
                 this.prefix = prefix;
 44  0
                 this.datasource = datasource;
 45  0
                 this.moduleJpaEnabledPropertyPrefix = moduleJpaEnabledPropertyPrefix;
 46  0
         }        
 47  
 
 48  
         public void afterPropertiesSet() throws Exception {
 49  0
                 if (OrmUtils.isJpaEnabled(moduleJpaEnabledPropertyPrefix)) {
 50  0
                         factoryBean = new RiceLocalContainerEntityManagerFactoryBean(prefix, datasource);
 51  0
                         factoryBean.afterPropertiesSet();
 52  
                 }
 53  0
         }
 54  
         
 55  
         public Class getObjectType() {
 56  0
                 return (factoryBean != null ? factoryBean.getObjectType() : EntityManagerFactory.class);
 57  
         }
 58  
 
 59  
         public Object getObject() throws Exception {
 60  0
                 return (factoryBean != null ? factoryBean.getObject() : new NullEntityManagerFactory());
 61  
         }
 62  
 
 63  
         public boolean isSingleton() {
 64  0
                 return true;
 65  
         }
 66  
 
 67  
 }