1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.services.db;
18
19
20 import javax.servlet.ServletConfig;
21
22
23 import ojb.broker.PersistenceBroker;
24 import ojb.broker.PersistenceBrokerFactory;
25
26
27 import org.apache.turbine.services.TurbineBaseService;
28 import org.apache.turbine.services.InitializationException;
29
30
31 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
32 import org.apache.jetspeed.services.logging.JetspeedLogger;
33
34 /***
35 * <p>This is an implementation of the <code>JetspeedDatabase</code> interface.
36 *
37 *
38 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
39 * @version $Id: ObjectBridgeDatabaseService.java,v 1.4 2004/02/23 03:28:10 jford Exp $
40 */
41
42 public class ObjectBridgeDatabaseService extends TurbineBaseService
43 implements JetspeedDatabaseService
44 {
45 /***
46 * Static initialization of the logger for this class
47 */
48 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(ObjectBridgeDatabaseService.class.getName());
49
50 PersistenceBroker pm = null;
51
52 /***
53 * This is the early initialization method called by the
54 * Turbine <code>Service</code> framework
55 * @param conf The <code>ServletConfig</code>
56 * @exception throws a <code>InitializationException</code> if the service
57 * fails to initialize
58 */
59 public synchronized void init(ServletConfig conf) throws InitializationException {
60
61
62 if (getInit()) return;
63
64 try
65 {
66 System.setProperty("OJB.properties", "org/apache/jetspeed/services/db/conf/OJB.properties");
67 pm = PersistenceBrokerFactory.createPersistenceBroker("org/apache/jetspeed/services/db/conf/repository.xml");
68 }
69 catch (Exception e)
70 {
71 logger.error("Failed to load ObjectBridge Manager: " + e.toString(), e);
72 throw new InitializationException(e.toString());
73 }
74
75 setInit(true);
76
77 }
78
79
80 public Object getPersistenceManager()
81 {
82 return pm;
83 }
84
85 /***
86 * This is the lateinitialization method called by the
87 * Turbine <code>Service</code> framework
88 *
89 * @exception throws a <code>InitializationException</code> if the service
90 * fails to initialize
91 */
92 public void init() throws InitializationException {
93 logger.info( "Late init for ObjectBridgeDatabaseService called" );
94 }
95
96 /***
97 * This is the shutdown method called by the
98 * Turbine <code>Service</code> framework
99 */
100 public void shutdown()
101 {
102 }
103
104 }