01: /* Copyright 2001, 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.groups;
07:
08: import org.jasig.portal.EntityTypes;
09:
10: /**
11: * Reference implementation for IEntityStore.
12: * @author Dan Ellentuck
13: * @version $Revision: 34930 $
14: */
15: public class RDBMEntityStore implements IEntityStore {
16: private static IEntityStore singleton;
17:
18: /**
19: * RDBMEntityStore constructor.
20: */
21: public RDBMEntityStore() {
22: super ();
23: }
24:
25: /**
26: * @return org.jasig.portal.groups.IEntity
27: * @param key java.lang.String
28: */
29: public IEntity newInstance(String key) throws GroupsException {
30: return newInstance(key, null);
31: }
32:
33: /**
34: * @return org.jasig.portal.groups.IEntity
35: * @param key java.lang.String
36: * @param type java.lang.Class
37: */
38: public IEntity newInstance(String key, Class type)
39: throws GroupsException {
40: if (EntityTypes.getEntityTypeID(type) == null) {
41: throw new GroupsException("Invalid group type: " + type);
42: }
43: return new EntityImpl(key, type);
44: }
45:
46: /**
47: * @return org.jasig.portal.groups.IEntityStore
48: */
49: public static synchronized IEntityStore singleton() {
50: if (singleton == null) {
51: singleton = new RDBMEntityStore();
52: }
53: return singleton;
54: }
55: }
|