1 package org.apache.stratum.ojb;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import ojb.broker.PersistenceBroker;
21 import ojb.broker.PersistenceBrokerFactory;
22
23 import org.apache.commons.configuration.Configuration;
24 import org.apache.commons.lang.exception.NestableException;
25 import org.apache.stratum.lifecycle.Configurable;
26 import org.apache.stratum.lifecycle.Initializable;
27
28 /***
29 * This class is the Object Bridege component that
30 *
31 * @author <a href="mailto:john@zenplex.com">John Thorhauer</a>
32 * @version $Id: OJBComponent.java 264191 2005-08-29 18:07:52Z henning $
33 */
34 public class OJBComponent
35 implements Configurable, Initializable
36 {
37 /*** TODO: DOCUMENT ME! */
38 private PersistenceBroker pBroker = null;
39
40 /*** The location of the OJB properties file */
41 private String propLocation;
42
43 /*** The location of the OJB repository file */
44 private String repositoryLocation;
45
46 /***
47 * Configure the Broker
48 *
49 * @param configuration TODO: DOCUMENT ME!
50 *
51 * @throws NestableException TODO: DOCUMENT ME!
52 */
53 public void configure(Configuration configuration)
54 throws NestableException
55 {
56 propLocation = configuration.getString("ojb.properties.location");
57 repositoryLocation = configuration.getString("ojb.repository.location");
58 }
59
60 /***
61 * Initialize the OJB Broker
62 *
63 * @throws Exception TODO: DOCUMENT ME!
64 */
65 public void initialize()
66 throws Exception
67 {
68 if (propLocation == null)
69 {
70 throw new Exception("The property ojb.properties.location was not" + " found in the properties file");
71 }
72
73 if (repositoryLocation == null)
74 {
75 throw new Exception("The property ojb.repository.location was not" + " found in the properties file");
76 }
77
78 System.setProperty("OJB.properties", propLocation);
79 pBroker = PersistenceBrokerFactory.createPersistenceBroker(repositoryLocation);
80 }
81
82 /***
83 * Retrieves the initialized persistence broker
84 *
85 * @return the initialized Persistence Broker
86 */
87 public PersistenceBroker getPersistenceBroker()
88 {
89 return pBroker;
90 }
91 }