1
14
15 package com.liferay.portal.image;
16
17 import com.liferay.portal.kernel.log.Log;
18 import com.liferay.portal.kernel.log.LogFactoryUtil;
19 import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
20 import com.liferay.portal.util.PropsValues;
21
22
27 public class HookFactory {
28
29 public static Hook getInstance() {
30 if (_hook == null) {
31 if (_log.isDebugEnabled()) {
32 _log.debug("Instantiate " + PropsValues.IMAGE_HOOK_IMPL);
33 }
34
35 ClassLoader classLoader = PortalClassLoaderUtil.getClassLoader();
36
37 try {
38 _hook = (Hook)classLoader.loadClass(
39 PropsValues.IMAGE_HOOK_IMPL).newInstance();
40 }
41 catch (Exception e) {
42 _log.error(e, e);
43 }
44 }
45
46 if (_log.isDebugEnabled()) {
47 _log.debug("Return " + _hook.getClass().getName());
48 }
49
50 return _hook;
51 }
52
53 public static void setInstance(Hook hook) {
54 if (_log.isDebugEnabled()) {
55 _log.debug("Set " + hook.getClass().getName());
56 }
57
58 _hook = hook;
59 }
60
61 private static Log _log = LogFactoryUtil.getLog(HookFactory.class);
62
63 private static Hook _hook = null;
64
65 }