1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.core.jpa.spring; |
17 | |
|
18 | |
import javax.persistence.EntityManagerFactory; |
19 | |
import javax.sql.DataSource; |
20 | |
|
21 | |
import org.kuali.rice.core.util.OrmUtils; |
22 | |
import org.springframework.beans.factory.FactoryBean; |
23 | |
import org.springframework.beans.factory.InitializingBean; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
public class RiceEntityManagerProxyFactoryBean implements FactoryBean, InitializingBean { |
29 | |
|
30 | |
private RiceLocalContainerEntityManagerFactoryBean factoryBean; |
31 | |
private String prefix; |
32 | |
private DataSource datasource; |
33 | |
|
34 | 0 | public RiceEntityManagerProxyFactoryBean(String prefix, DataSource datasource) { |
35 | 0 | this.prefix = prefix; |
36 | 0 | this.datasource = datasource; |
37 | 0 | } |
38 | |
|
39 | |
public void afterPropertiesSet() throws Exception { |
40 | 0 | if (OrmUtils.isJpaEnabled(prefix)) { |
41 | 0 | factoryBean = new RiceLocalContainerEntityManagerFactoryBean(prefix, datasource); |
42 | 0 | factoryBean.afterPropertiesSet(); |
43 | |
} |
44 | 0 | } |
45 | |
|
46 | |
public Class getObjectType() { |
47 | 0 | return (factoryBean != null ? factoryBean.getObjectType() : EntityManagerFactory.class); |
48 | |
} |
49 | |
|
50 | |
public Object getObject() throws Exception { |
51 | 0 | return (factoryBean != null ? factoryBean.getObject() : new NullEntityManagerFactory()); |
52 | |
} |
53 | |
|
54 | |
public boolean isSingleton() { |
55 | 0 | return true; |
56 | |
} |
57 | |
|
58 | |
} |