001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.servlet;
022:
023: import com.liferay.portal.job.Scheduler;
024: import com.liferay.portal.kernel.lar.PortletDataHandler;
025: import com.liferay.portal.kernel.pop.MessageListener;
026: import com.liferay.portal.kernel.portlet.ConfigurationAction;
027: import com.liferay.portal.kernel.portlet.FriendlyURLMapper;
028: import com.liferay.portal.kernel.portlet.PortletLayoutListener;
029: import com.liferay.portal.kernel.search.Indexer;
030: import com.liferay.portal.kernel.servlet.URLEncoder;
031: import com.liferay.portal.kernel.util.LocaleUtil;
032: import com.liferay.portal.model.ActivityTrackerInterpreter;
033:
034: import java.util.Locale;
035: import java.util.Map;
036: import java.util.ResourceBundle;
037:
038: import javax.portlet.Portlet;
039: import javax.portlet.PreferencesValidator;
040:
041: import javax.servlet.ServletContext;
042:
043: /**
044: * <a href="PortletContextWrapper.java.html"><b><i>View Source</i></b></a>
045: *
046: * @author Brian Wing Shun Chan
047: *
048: */
049: public class PortletContextWrapper {
050:
051: public PortletContextWrapper(
052: String portletName,
053: ServletContext servletContext,
054: Portlet portletInstance,
055: ConfigurationAction configurationActionInstance,
056: Indexer indexerInstance,
057: Scheduler schedulerInstance,
058: FriendlyURLMapper friendlyURLMapperInstance,
059: URLEncoder urlEncoderInstance,
060: PortletDataHandler portletDataHandlerInstance,
061: PortletLayoutListener portletLayoutListenerInstance,
062: ActivityTrackerInterpreter activityTrackerInterpreterInstance,
063: MessageListener popMessageListenerInstance,
064: PreferencesValidator prefsValidatorInstance,
065: Map resourceBundles, Map customUserAttributes) {
066:
067: _portletName = portletName;
068: _servletContext = servletContext;
069: _portletInstance = portletInstance;
070: _configurationActionInstance = configurationActionInstance;
071: _indexerInstance = indexerInstance;
072: _schedulerInstance = schedulerInstance;
073: _friendlyURLMapperInstance = friendlyURLMapperInstance;
074: _urlEncoderInstance = urlEncoderInstance;
075: _portletDataHandlerInstance = portletDataHandlerInstance;
076: _portletLayoutListenerInstance = portletLayoutListenerInstance;
077: _activityTrackerInterpreterInstance = activityTrackerInterpreterInstance;
078: _popMessageListenerInstance = popMessageListenerInstance;
079: _prefsValidatorInstance = prefsValidatorInstance;
080: _resourceBundles = resourceBundles;
081: _customUserAttributes = customUserAttributes;
082: }
083:
084: public String getPortletName() {
085: return _portletName;
086: }
087:
088: public ServletContext getServletContext() {
089: return _servletContext;
090: }
091:
092: public Portlet getPortletInstance() {
093: return _portletInstance;
094: }
095:
096: public void removePortletInstance() {
097: _portletInstance = null;
098: }
099:
100: public ConfigurationAction getConfigurationActionInstance() {
101: return _configurationActionInstance;
102: }
103:
104: public Indexer getIndexerInstance() {
105: return _indexerInstance;
106: }
107:
108: public Scheduler getSchedulerInstance() {
109: return _schedulerInstance;
110: }
111:
112: public FriendlyURLMapper getFriendlyURLMapperInstance() {
113: return _friendlyURLMapperInstance;
114: }
115:
116: public URLEncoder getURLEncoderInstance() {
117: return _urlEncoderInstance;
118: }
119:
120: public PortletDataHandler getPortletDataHandlerInstance() {
121: return _portletDataHandlerInstance;
122: }
123:
124: public PortletLayoutListener getPortletLayoutListenerInstance() {
125: return _portletLayoutListenerInstance;
126: }
127:
128: public ActivityTrackerInterpreter getActivityTrackerInterpreterInstance() {
129: return _activityTrackerInterpreterInstance;
130: }
131:
132: public MessageListener getPopMessageListenerInstance() {
133: return _popMessageListenerInstance;
134: }
135:
136: public PreferencesValidator getPreferencesValidatorInstance() {
137: return _prefsValidatorInstance;
138: }
139:
140: public ResourceBundle getResourceBundle(Locale locale) {
141: ResourceBundle resourceBundle = (ResourceBundle) _resourceBundles
142: .get(LocaleUtil.toLanguageId(locale));
143:
144: if (resourceBundle == null) {
145: resourceBundle = (ResourceBundle) _resourceBundles
146: .get(locale.getLanguage());
147:
148: if (resourceBundle == null) {
149: resourceBundle = (ResourceBundle) _resourceBundles
150: .get(LocaleUtil.toLanguageId(LocaleUtil
151: .getDefault()));
152: }
153: }
154:
155: return resourceBundle;
156: }
157:
158: public Map getCustomUserAttributes() {
159: return _customUserAttributes;
160: }
161:
162: private String _portletName;
163: private ServletContext _servletContext;
164: private Portlet _portletInstance;
165: private ConfigurationAction _configurationActionInstance;
166: private Indexer _indexerInstance;
167: private Scheduler _schedulerInstance;
168: private FriendlyURLMapper _friendlyURLMapperInstance;
169: private URLEncoder _urlEncoderInstance;
170: private PortletDataHandler _portletDataHandlerInstance;
171: private PortletLayoutListener _portletLayoutListenerInstance;
172: private ActivityTrackerInterpreter _activityTrackerInterpreterInstance;
173: private MessageListener _popMessageListenerInstance;
174: private PreferencesValidator _prefsValidatorInstance;
175: private Map _resourceBundles;
176: private Map _customUserAttributes;
177:
178: }
|