001
014
015 package com.liferay.portal.security.auth;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.InstanceFactory;
020 import com.liferay.portal.security.pacl.PACLClassLoaderUtil;
021 import com.liferay.portal.util.PropsValues;
022
023
026 public class EmailAddressGeneratorFactory {
027
028 public static EmailAddressGenerator getInstance() {
029 if (_emailAddressGenerator == null) {
030 if (_log.isDebugEnabled()) {
031 _log.debug(
032 "Instantiate " + PropsValues.USERS_EMAIL_ADDRESS_GENERATOR);
033 }
034
035 ClassLoader classLoader =
036 PACLClassLoaderUtil.getPortalClassLoader();
037
038 try {
039 _emailAddressGenerator =
040 (EmailAddressGenerator)InstanceFactory.newInstance(
041 classLoader, PropsValues.USERS_EMAIL_ADDRESS_GENERATOR);
042 }
043 catch (Exception e) {
044 _log.error(e, e);
045 }
046 }
047
048 if (_log.isDebugEnabled()) {
049 _log.debug("Return " + _emailAddressGenerator.getClass().getName());
050 }
051
052 return _emailAddressGenerator;
053 }
054
055 public static void setInstance(
056 EmailAddressGenerator emailAddressGenerator) {
057
058 if (_log.isDebugEnabled()) {
059 _log.debug("Set " + emailAddressGenerator.getClass().getName());
060 }
061
062 _emailAddressGenerator = emailAddressGenerator;
063 }
064
065 private static Log _log = LogFactoryUtil.getLog(
066 EmailAddressGeneratorFactory.class);
067
068 private static EmailAddressGenerator _emailAddressGenerator;
069
070 }