1
22
23 package com.liferay.portal.velocity;
24
25 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
26 import com.liferay.portal.kernel.bean.PortletBeanLocatorUtil;
27 import com.liferay.portal.kernel.log.Log;
28 import com.liferay.portal.kernel.log.LogFactoryUtil;
29
30
35 public class ServiceLocator {
36
37 public static ServiceLocator getInstance() {
38 return _instance;
39 }
40
41 public Object findService(String serviceName) {
42 if (serviceName.endsWith(_SERVICE)) {
43 serviceName += _VELOCITY;
44 }
45
46 Object obj = null;
47
48 try {
49 obj = PortalBeanLocatorUtil.locate(serviceName);
50 }
51 catch (Exception e) {
52 _log.error(e);
53 }
54
55 return obj;
56 }
57
58 public Object findService(String servletContextName, String serviceName) {
59 if (serviceName.endsWith(_SERVICE)) {
60 serviceName += _VELOCITY;
61 }
62
63 Object obj = null;
64
65 try {
66 obj = PortletBeanLocatorUtil.locate(
67 servletContextName, serviceName);
68 }
69 catch (Exception e) {
70 _log.error(e);
71 }
72
73 return obj;
74 }
75
76 private ServiceLocator() {
77 }
78
79 private static final String _SERVICE = "Service";
80
81 private static final String _VELOCITY = ".velocity";
82
83 private static ServiceLocator _instance = new ServiceLocator();
84
85 private static Log _log = LogFactoryUtil.getLog(ServiceLocator.class);
86
87 }