01: /* Copyright 2002, 2005 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.services.PersonDirectory;
09: import org.jasig.portal.services.persondir.IPersonAttributeDao;
10:
11: /**
12: * Factory for creating and obtaining reference to
13: * a static singleton <code>PersonDirNameFinder</code>.
14: * @author Alex Vigdor
15: * @version $Revision: 35535 $
16: */
17: public class PersonDirNameFinderFactory implements
18: IEntityNameFinderFactory {
19:
20: /**
21: * Lazily initialized static singleton PersonDirNameFinder backed
22: * by the IPersonAttributeDao provided by the PersonDirectory static service.
23: */
24: private static PersonDirNameFinder PERSON_DIR_NAME_FINDER_INSTANCE;
25:
26: /**
27: * Do-nothing constructor.
28: */
29: public PersonDirNameFinderFactory() {
30: super ();
31: }
32:
33: /**
34: * Get the static singleton PersonDirNameFinder instance backed by
35: * PersonDirectory.
36: *
37: * @return the static singleton PersonDirNameFinder backed by PersonDirectory
38: */
39: public IEntityNameFinder newFinder() {
40:
41: if (PERSON_DIR_NAME_FINDER_INSTANCE == null) {
42: PersonDirNameFinderFactory.storeSingleton();
43: }
44:
45: return PERSON_DIR_NAME_FINDER_INSTANCE;
46:
47: }
48:
49: /**
50: * Intantiates the static singleton field PERSON_DIR_NAME_FINDER_INSTANCE.
51: * Synchronized to guarantee singletonness of the field.
52: */
53: private synchronized static void storeSingleton() {
54: // recheck that we need to run because field could have been
55: // set since we decided to invoke this method but before we acquired
56: // the lock on this object
57: if (PERSON_DIR_NAME_FINDER_INSTANCE == null) {
58: IPersonAttributeDao personAttributeDao = PersonDirectory
59: .getPersonAttributeDao();
60: PERSON_DIR_NAME_FINDER_INSTANCE = new PersonDirNameFinder(
61: personAttributeDao);
62: }
63: }
64:
65: }
|