%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.stratum.ojb.OJBComponent |
|
|
1 | package org.apache.stratum.ojb; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation or its licensors, |
|
5 | * as applicable. |
|
6 | * |
|
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 | * you may not use this file except in compliance with the License. |
|
9 | * You may obtain a copy of the License at |
|
10 | * |
|
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
12 | * |
|
13 | * Unless required by applicable law or agreed to in writing, software |
|
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 | * See the License for the specific language governing permissions and |
|
17 | * limitations under the License. |
|
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 | 0 | public class OJBComponent |
35 | implements Configurable, Initializable |
|
36 | { |
|
37 | /** TODO: DOCUMENT ME! */ |
|
38 | 0 | 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 | 0 | 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 | 0 | propLocation = configuration.getString("ojb.properties.location"); |
57 | 0 | repositoryLocation = configuration.getString("ojb.repository.location"); |
58 | 0 | } |
59 | ||
60 | /** |
|
61 | * Initialize the OJB Broker |
|
62 | * |
|
63 | * @throws Exception TODO: DOCUMENT ME! |
|
64 | */ |
|
65 | public void initialize() |
|
66 | throws Exception |
|
67 | { |
|
68 | 0 | if (propLocation == null) |
69 | { |
|
70 | 0 | throw new Exception("The property ojb.properties.location was not" + " found in the properties file"); |
71 | } |
|
72 | ||
73 | 0 | if (repositoryLocation == null) |
74 | { |
|
75 | 0 | throw new Exception("The property ojb.repository.location was not" + " found in the properties file"); |
76 | } |
|
77 | ||
78 | 0 | System.setProperty("OJB.properties", propLocation); |
79 | 0 | pBroker = PersistenceBrokerFactory.createPersistenceBroker(repositoryLocation); |
80 | 0 | } |
81 | ||
82 | /** |
|
83 | * Retrieves the initialized persistence broker |
|
84 | * |
|
85 | * @return the initialized Persistence Broker |
|
86 | */ |
|
87 | public PersistenceBroker getPersistenceBroker() |
|
88 | { |
|
89 | 0 | return pBroker; |
90 | } |
|
91 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |