1/*2 * Copyright 2000-2001,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.services.db;
181920import javax.servlet.ServletConfig;
2122// OJB23import ojb.broker.PersistenceBroker;
24import ojb.broker.PersistenceBrokerFactory;
2526// turbine.services27import org.apache.turbine.services.TurbineBaseService;
28import org.apache.turbine.services.InitializationException;
2930// Jetspeed31import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
32import org.apache.jetspeed.services.logging.JetspeedLogger;
3334/***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 */4142publicclassObjectBridgeDatabaseServiceextends TurbineBaseService
43 implements JetspeedDatabaseService44 {
45/***46 * Static initialization of the logger for this class47 */48privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(ObjectBridgeDatabaseService.class.getName());
4950 PersistenceBroker pm = null;
5152/***53 * This is the early initialization method called by the 54 * Turbine <code>Service</code> framework55 * @param conf The <code>ServletConfig</code>56 * @exception throws a <code>InitializationException</code> if the service57 * fails to initialize58 */59publicsynchronizedvoid init(ServletConfig conf) throws InitializationException {
6061// already initialized62if (getInit()) return;
6364try65 {
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 }
69catch (Exception e)
70 {
71 logger.error("Failed to load ObjectBridge Manager: " + e.toString(), e);
72thrownew InitializationException(e.toString());
73 }
74// initialization done75 setInit(true);
7677 }
787980public Object getPersistenceManager()
81 {
82return pm;
83 }
8485/***86 * This is the lateinitialization method called by the 87 * Turbine <code>Service</code> framework88 *89 * @exception throws a <code>InitializationException</code> if the service90 * fails to initialize91 */92publicvoid init() throws InitializationException {
93 logger.info( "Late init for ObjectBridgeDatabaseService called" );
94 }
9596/***97 * This is the shutdown method called by the 98 * Turbine <code>Service</code> framework99 */100publicvoid shutdown()
101 {
102 }
103104 }