forked from liferay/liferay-portal
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LPS-55800 Add servletContext property
- Loading branch information
Leonardo Barros
committed
Jul 27, 2015
1 parent
05296b6
commit 3bb88f4
Showing
5 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...a-mapping-taglib/src/com/liferay/dynamic/data/mapping/taglib/util/ServletContextUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU Lesser General Public License as published by the Free | ||
* Software Foundation; either version 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | ||
* details. | ||
*/ | ||
|
||
package com.liferay.dynamic.data.mapping.taglib.util; | ||
|
||
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; | ||
|
||
/** | ||
* @author Leonardo Barros | ||
*/ | ||
@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=com.liferay.dynamic.data.mapping.taglib)", | ||
unbind = "-" | ||
) | ||
protected void setServletContext(ServletContext servletContext) { | ||
_servletContext = servletContext; | ||
} | ||
|
||
private ServletContext _getServletContext() { | ||
return _servletContext; | ||
} | ||
|
||
private static ServletContextUtil _instance; | ||
|
||
private ServletContext _servletContext; | ||
|
||
} |