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.channels.permissionsmanager;
07:
08: import java.util.HashMap;
09:
10: import org.apache.commons.logging.Log;
11: import org.apache.commons.logging.LogFactory;
12:
13: /**
14: * CommadFactory provides IPermissionCommand objects to CPermissionsManager
15: *
16: * @author Alex Vigdor
17: * @version $Revision: 34837 $
18: */
19: public class CommandFactory {
20: private static final Log log = LogFactory
21: .getLog(CommandFactory.class);
22: private static CommandFactory _instance = null;
23: private static HashMap commands = new HashMap();
24:
25: /** Creates new CommandFactory */
26: protected CommandFactory() {
27: try {
28: String commandBase = "org.jasig.portal.channels.permissionsmanager.commands.";
29: commands.put("AssignPermissions", Class.forName(
30: commandBase + "AssignPermissions").newInstance());
31: commands.put("SelectActivities", Class.forName(
32: commandBase + "SelectActivities").newInstance());
33: commands.put("SelectOwners", Class.forName(
34: commandBase + "SelectOwners").newInstance());
35: commands.put("SelectTargets", Class.forName(
36: commandBase + "SelectTargets").newInstance());
37: commands.put("Cancel", Class
38: .forName(commandBase + "Cancel").newInstance());
39: } catch (Exception e) {
40: log.error(e, e);
41: }
42: }
43:
44: /**
45: * put your documentation comment here
46: * @return a <code>CommandFactory</code> singleton
47: */
48: protected static synchronized CommandFactory instance() {
49: if (_instance == null) {
50: _instance = new CommandFactory();
51: }
52: return _instance;
53: }
54:
55: /**
56: * put your documentation comment here
57: * @param key
58: * @return the <code>IPermissionCommand</code> for the key
59: */
60: public static IPermissionCommand get(String key) {
61: return instance().getCommand(key);
62: }
63:
64: /**
65: * put your documentation comment here
66: * @param key
67: * @return the <code>IPermissionCommand</code> for the key
68: */
69: protected IPermissionCommand getCommand(String key) {
70: return (IPermissionCommand) commands.get(key);
71: }
72: }
|