Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-2552

Add javax.portlet.faces.BridgeFactory and javax.portlet.faces.BridgeWrapper to the Bridge API

    Details

      Description

      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:

      BridgeFactory.java
      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();
      }
      
      BridgeWrapper.java
      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:

      GenericFacesPortlet.java
      @Deprecated
      public static final String BRIDGE_SERVICE_CLASSPATH = "META-INF/services/javax.portlet.faces.Bridge";
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: