| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
package net.smartlab.web.config; |
| 24 |
|
|
| 25 |
|
import java.net.URL; |
| 26 |
|
import java.util.Map; |
| 27 |
|
import java.util.TreeMap; |
| 28 |
|
import org.apache.commons.logging.Log; |
| 29 |
|
import org.apache.commons.logging.LogFactory; |
| 30 |
|
import org.hibernate.SessionFactory; |
| 31 |
|
import org.hibernate.cfg.Configuration; |
| 32 |
|
import net.smartlab.web.BusinessObjectFactory; |
| 33 |
|
import net.smartlab.web.Domain; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
@author |
| 42 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0,33 |
|
| 43 |
|
public class TomcatConfigurationStrategy implements FactoryConfigurationStrategy { |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
private Map factories = new TreeMap(); |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
protected final Log logger = LogFactory.getLog(TomcatConfigurationStrategy.class); |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
@see |
| 58 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0,33 |
|
| 59 |
0
|
public SessionFactory getSessionFactory(BusinessObjectFactory bof) {... |
| 60 |
0
|
synchronized (BusinessObjectFactory.class) { |
| 61 |
0
|
String archive = Domain.getLastArchiveName(bof.getClass()); |
| 62 |
0
|
URL file = Domain.getResource(bof.getClass(), new String[] {"/META-INF/" + archive + ".hcf", |
| 63 |
|
"/META-INF/smartweb.jar.hcf"}); |
| 64 |
0
|
try { |
| 65 |
0
|
if (!factories.containsKey(file.toString())) { |
| 66 |
|
|
| 67 |
0
|
logger.warn("getSessionFactory() - configure hibernate without JNDI"); |
| 68 |
0
|
SessionFactory factory = new Configuration().configure(file).buildSessionFactory(); |
| 69 |
0
|
factories.put(file.toString(), factory); |
| 70 |
|
} |
| 71 |
0
|
return (SessionFactory)factories.get(file.toString()); |
| 72 |
|
} catch (Exception e) { |
| 73 |
|
logger.error("getSessionFactory() - error", e); |
| 74 |
|
return null; |
| 75 |
|
} |
| 76 |
|
} |
| 77 |
|
} |
| 78 |
|
} |