1
22
23 package com.liferay.portal.security.auth;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
28 import com.liferay.portal.util.PropsValues;
29
30
36 public class EmailAddressGeneratorFactory {
37
38 public static EmailAddressGenerator getInstance() {
39 if (_emailAddressGenerator == null) {
40 if (_log.isDebugEnabled()) {
41 _log.debug(
42 "Instantiate " + PropsValues.USERS_EMAIL_ADDRESS_GENERATOR);
43 }
44
45 ClassLoader classLoader = PortalClassLoaderUtil.getClassLoader();
46
47 try {
48 _emailAddressGenerator =
49 (EmailAddressGenerator)classLoader.loadClass(
50 PropsValues.USERS_EMAIL_ADDRESS_GENERATOR)
51 .newInstance();
52 }
53 catch (Exception e) {
54 _log.error(e, e);
55 }
56 }
57
58 if (_log.isDebugEnabled()) {
59 _log.debug("Return " + _emailAddressGenerator.getClass().getName());
60 }
61
62 return _emailAddressGenerator;
63 }
64
65 public static void setInstance(
66 EmailAddressGenerator emailAddressGenerator) {
67
68 if (_log.isDebugEnabled()) {
69 _log.debug("Set " + emailAddressGenerator.getClass().getName());
70 }
71
72 _emailAddressGenerator = emailAddressGenerator;
73 }
74
75 private static Log _log =
76 LogFactoryUtil.getLog(EmailAddressGeneratorFactory.class);
77
78 private static EmailAddressGenerator _emailAddressGenerator = null;
79
80 }