01: /* Copyright 2001 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.utils;
07:
08: import org.jasig.portal.PortalException;
09: import org.jasig.portal.properties.PropertiesManager;
10:
11: /**
12: * Produces an implementation of ICounterStore
13: * @author <a href="mailto:pkharchenko@unicon.net">Peter Kharchenko</a>
14: * @author Ken Weiner, kweiner@unicon.net
15: * @version $Revision: 34797 $
16: */
17: public class CounterStoreFactory {
18: private static ICounterStore counterStoreImpl = null;
19:
20: /**
21: * Returns an instance of the ICounterStore specified in portal.properties
22: * @return an ICounterStore implementation
23: * @exception PortalException if an error occurs
24: */
25: public static ICounterStore getCounterStoreImpl()
26: throws PortalException {
27: if (counterStoreImpl == null) {
28: initialize();
29: }
30: return counterStoreImpl;
31: }
32:
33: private static void initialize() throws PortalException {
34: // Retrieve the class name of the concrete ICounterStore implementation
35: String className = PropertiesManager
36: .getProperty("org.jasig.portal.utils.CounterStoreFactory.implementation");
37: // Fail if this is not found
38: if (className == null)
39: throw new PortalException(
40: "CounterStoreFactory: org.jasig.portal.utils.CounterStoreFactory.implementation must be specified in portal.properties");
41: try {
42: // Create an instance of the ICounterStore as specified in portal.properties
43: counterStoreImpl = (ICounterStore) Class.forName(className)
44: .newInstance();
45: } catch (Exception e) {
46: throw new PortalException(
47: "CounterStoreFactory: Could not instantiate "
48: + className, e);
49: }
50: }
51:
52: }
|