KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > db > ObjectBridgeDatabaseService


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 at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * 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 and
14  * limitations under the License.
15  */

16
17 package org.apache.jetspeed.services.db;
18
19
20 import javax.servlet.ServletConfig JavaDoc;
21
22 // OJB
23
import ojb.broker.PersistenceBroker;
24 import ojb.broker.PersistenceBrokerFactory;
25
26 // turbine.services
27
import org.apache.turbine.services.TurbineBaseService;
28 import org.apache.turbine.services.InitializationException;
29
30 // Jetspeed
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 JavaDoc conf) throws InitializationException {
60
61         // already initialized
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 JavaDoc e)
70         {
71             logger.error("Failed to load ObjectBridge Manager: " + e.toString(), e);
72             throw new InitializationException(e.toString());
73         }
74         // initialization done
75
setInit(true);
76
77      }
78
79
80     public Object JavaDoc 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 }
Popular Tags