-
Type:
New Feature
-
Status: Closed
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: facesbridge-api-5.0.0, facesbridge-spec-5.0.0
-
Component/s: FacesBridge API, FacesBridge Spec
-
Labels:None
The JSR 329 Bridge API defined the javax.portlet.faces.Bridge interface and requirements in Section 3.1 of the Spec titled "Discovering and Instantiating the Bridge" and Section 4.1 titled "Configuration." However, the JSR 329 requirements to not utilize the factory delegation chain pattern that is utilized in the JSF API. (For an example, see Application.java, ApplicationWrapper.java, and ApplicationFactory.java).
In order to enable this pattern, this issue serves as a proposal for adding the following classes to the Bridge API:
package javax.portlet.faces; public abstract class BridgeFactory implements FacesWrapper<BridgeFactory> { /** * Gets an instance of {@link Bridge} from the {@link BridgeFactory} found by the {@link BridgeFactoryFinder}. */ public static Bridge getBridgeInstance() throws PortletException { BridgeFactory bridgeFactory = (BridgeFactory) BridgeFactoryFinder.getFactory(BridgeFactory.class); return bridgeFactory.getBridge(); } /** * Gets an instance of {@link Bridge} from the {@link BridgeFactory} found by the {@link BridgeFactoryFinder}. * * @param bridgeClassName The fully-qualified class name of a class that implements {@link Bridge} interface. */ public static Bridge getBridgeInstance(String bridgeClassName) throws PortletException { BridgeFactory bridgeFactory = (BridgeFactory) BridgeFactoryFinder.getFactory(BridgeFactory.class); return bridgeFactory.getBridge(bridgeClassName); } /** * Gets the {@link Bridge} instance which is the first member of the delegation chain. */ public abstract Bridge getBridge() throws PortletException; /** * Returns an {@link Bridge} instance of the specified bridge class name. * * @param bridgeClassName The fully-qualified class name of a class that implements {@link Bridge} interface. */ public abstract Bridge getBridge(String bridgeClassName) throws PortletException; /** * If this factory has been decorated then this method provides access to the wrapped factory instance. */ @Override public abstract BridgeFactory getWrapped(); }
package javax.portlet.faces; public abstract class BridgeWrapper implements Bridge, FacesWrapper<Bridge> { @Override public void destroy() { getWrapped().destroy(); } @Override public void doFacesRequest(ActionRequest actionRequest, ActionResponse actionResponse) throws BridgeDefaultViewNotSpecifiedException, BridgeUninitializedException, BridgeException { getWrapped().doFacesRequest(actionRequest, actionResponse); } @Override public void doFacesRequest(EventRequest eventRequest, EventResponse eventResponse) throws BridgeUninitializedException, BridgeException { getWrapped().doFacesRequest(eventRequest, eventResponse); } @Override public void doFacesRequest(RenderRequest renderRequest, RenderResponse renderResponse) throws BridgeDefaultViewNotSpecifiedException, BridgeUninitializedException, BridgeException { getWrapped().doFacesRequest(renderRequest, renderResponse); } @Override public void doFacesRequest(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws BridgeUninitializedException, BridgeException { getWrapped().doFacesRequest(resourceRequest, resourceResponse); } @Override public abstract Bridge getWrapped(); }
It would also be necessary to modify the text of Section 3.1 and Section 4.1 titled "Configuration" to specify that the default implementation must implement the requirements regarding the javax.portlet.faces.BridgeClassName init parameter and the META-INF/services/javax.portlet.faces.Bridge context resource file.
Aside from enabling the factory delegation chain pattern, another benefit is that the bridge discovery code can be moved out of the javax.portlet.faces.GenericFacesPortlet class to a com.liferay.faces.bridge.internal.BridgeFactoryImpl class.
Finally, the following constant in GenericFacesPortlet is to be deprecated:
@Deprecated public static final String BRIDGE_SERVICE_CLASSPATH = "META-INF/services/javax.portlet.faces.Bridge";