If a portlet is a web application, then why portlet preferences are taken from ServletRequest (at request scope)?
How is it possible to take preferences object at application scope?
UPDATE 1
I am obtaining portlet preferences in the following way. Is it correct? prefs member below is at application scope.
private synchronized void setupPreferences(HttpServletRequest request) {
// creating preferences
if( prefs == null ) {
prefs = PortalUtil.getPreferences(request);
if( prefs != null ) {
System.out.println("Preferences were taken from request");
}
String portletResource = ParamUtil.getString(request, "portletResource");
if (Validator.isNotNull(portletResource)) {
try {
System.out.println("Replacing preferences from 'portletRecource' parameter");
prefs = PortletPreferencesFactoryUtil.getPortletSetup(request, portletResource);
} catch (SystemException e) {
e.printStackTrace();
} catch (PortalException e) {
e.printStackTrace();
}
}
if( prefs == null ) {
System.out.println("Preferences were NOT obtained yet");
}
else {
System.out.println("Preferences are OK");
}
}
}
UPDATE 2
I am using also servlets and static objects in my application. Static objects are in application scope as one can know. I wonder can I keep portlet preferences object in some static object or I need to reobtain it from request each time?
Actually I already assumed this and it works but I wish to know is it correct?