forked from liferay/alloy-taglibs
/
servlet_context_util.ftl
57 lines (43 loc) · 1.17 KB
/
servlet_context_util.ftl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<#include "copyright.ftl">
package ${packagePath};
import com.liferay.portal.kernel.util.Validator;
import javax.servlet.ServletContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
/**
<#list taglibAuthors as taglibAuthor>
* @author ${taglibAuthor}
</#list>
* @generated
*/
@Component(immediate = true)
public class ServletContextUtil {
public static final ServletContext getServletContext() {
if (Validator.isNotNull(_instance)) {
return _instance._getServletContext();
}
return null;
}
@Activate
protected void activate() {
_instance = this;
}
@Deactivate
protected void deactivate() {
_instance = null;
}
@Reference(
target = "(osgi.web.symbolicname=${OSGIModuleSymbolicName})",
unbind = "-"
)
protected void setServletContext(ServletContext servletContext) {
_servletContext = servletContext;
}
private ServletContext _getServletContext() {
return _servletContext;
}
private static ServletContextUtil _instance;
private ServletContext _servletContext;
}