if (null == config) {
throw new NullPointerException(
"No PortletConfig at the bridge initialization");
}
if (initialized) {
throw new BridgeException("JSF portlet bridge already initialized");
}
String portletName = config.getPortletName();
if (log.isLoggable(Level.FINE)) {
log.fine("Start portletbridge initialization for " + portletName);
}
this.portletConfig = config;
PortletContext portletContext = config.getPortletContext();
WebXML webXml = new WebXML();
webXml.parse(portletContext);
this.filterInitParams = webXml.getFilterInitParams();
initFaces(portletContext);
// add locales to faces application
transferLocales(config);
// Register exception handler.
exceptionHandler = createExceptionHandler();
// Parse web.xml for a Faces Servlet mappings.
this.facesServletMappings = webXml.getFacesServletMappings();
errorPages = webXml.getErrorViews();
// Get all excluded request attributes names.
this.excludedAttributes = new HashSet<ExcludedRequestAttribute>();
String bridgeParametersPrefix = Bridge.BRIDGE_PACKAGE_PREFIX
+ portletName + ".";
List<String> excluded = (List<String>) portletContext
.getAttribute(bridgeParametersPrefix
+ Bridge.EXCLUDED_REQUEST_ATTRIBUTES);
if (null != excluded) {
for (String name : excluded) {
excludedAttributes.add(new ExcludedRequestAttribute(name));
}
}
String maxScopesParameter = portletContext.getInitParameter(Bridge.MAX_MANAGED_REQUEST_SCOPES);
if (null != maxScopesParameter) {
numberOfRequestScopes = Integer.parseInt(maxScopesParameter);
}
FacesConfig facesConfig = new FacesConfig();
facesConfig.parse(portletContext);
excluded = facesConfig.getExcludedAttributes();
if (null != excluded) {
for (String name : excluded) {
excludedAttributes.add(new ExcludedRequestAttribute(name));
}
}
publicParameterMapping = facesConfig.getParameterMapping();
// Get preserve action parameters flag
Boolean preserveParams = (Boolean) portletContext
.getAttribute(bridgeParametersPrefix
+ Bridge.PRESERVE_ACTION_PARAMS);
this.preserveActionParams = Boolean.TRUE.equals(preserveParams);
// Get devault view's Map.
this.defaultViewIdMap = (Map<String, String>) portletContext
.getAttribute(bridgeParametersPrefix
+ Bridge.DEFAULT_VIEWID_MAP);
if (null == this.defaultViewIdMap || 0 == this.defaultViewIdMap.size()) {
throw new BridgeException("No JSF view id's defined in portlet");
}
// Event Handler
eventHandler = (BridgeEventHandler) portletContext
.getAttribute(bridgeParametersPrefix
+ Bridge.BRIDGE_EVENT_HANDLER);