01: /* Copyright 2002 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.layout.restrictions.alm;
07:
08: import org.jasig.portal.PortalException;
09: import org.jasig.portal.layout.IUserLayout;
10: import org.jasig.portal.layout.restrictions.IRestrictionManager;
11: import org.jasig.portal.properties.PropertiesManager;
12: import org.apache.commons.logging.Log;
13: import org.apache.commons.logging.LogFactory;
14:
15: /**
16: * A factory class for obtaining {@link IRestrictionManager} implementations.
17: *
18: * @author <a href="mailto:mvi@immagic.com">Michael Ivanov</a>
19: * @version 1.1 $Revision: 35731 $ $Date: 2005-05-03 13:46:02 -0700 (Tue, 03 May 2005) $
20: * @since uPortal 2.5
21: */
22: public class RestrictionManagerFactory {
23:
24: private static final Log log = LogFactory
25: .getLog(RestrictionManagerFactory.class);
26:
27: private static Class restrictionManagerClass = ALRestrictionManager.class;
28:
29: static {
30: // Retrieve the class name of the core IRestrictionManager implementation
31: String className = PropertiesManager
32: .getProperty("org.jasig.portal.layout.restrictions.IRestrictionManager.implementation");
33: if (className == null)
34: log
35: .error("RestrictionManagerFactory: org.jasig.portal.layout.restrictions.IRestrictionManager.implementation must be specified in portal.properties");
36: try {
37: Class newClass = Class.forName(className);
38: restrictionManagerClass = newClass;
39: } catch (Exception e) {
40: log.error(
41: "RestrictionManagerFactory: Could not instantiate "
42: + className, e);
43: }
44: }
45:
46: /**
47: * Obtain a regular restriction manager implementation
48: *
49: * @return an <code>IRestrictionManager</code> value
50: */
51: public static IRestrictionManager getRestrictionManager(
52: IUserLayout layout) throws PortalException {
53: try {
54: IRestrictionManager restrictionManager = (IRestrictionManager) restrictionManagerClass
55: .newInstance();
56: restrictionManager.setUserLayout(layout);
57: return restrictionManager;
58: } catch (Exception e) {
59: throw new PortalException("Unable to instantiate a \""
60: + restrictionManagerClass.getName() + "\"", e);
61: }
62: }
63:
64: }
|