jakarta.faces.application.ApplicationWrapper Maven / Gradle / Ivy
/*
* Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package jakarta.faces.application;
import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import jakarta.el.ELContextListener;
import jakarta.el.ELException;
import jakarta.el.ELResolver;
import jakarta.el.ExpressionFactory;
import jakarta.el.ValueExpression;
import jakarta.faces.FacesException;
import jakarta.faces.FacesWrapper;
import jakarta.faces.component.UIComponent;
import jakarta.faces.component.behavior.Behavior;
import jakarta.faces.component.search.SearchExpressionHandler;
import jakarta.faces.component.search.SearchKeywordResolver;
import jakarta.faces.context.FacesContext;
import jakarta.faces.convert.Converter;
import jakarta.faces.el.MethodBinding;
import jakarta.faces.el.PropertyResolver;
import jakarta.faces.el.ReferenceSyntaxException;
import jakarta.faces.el.ValueBinding;
import jakarta.faces.el.VariableResolver;
import jakarta.faces.event.ActionListener;
import jakarta.faces.event.SystemEvent;
import jakarta.faces.event.SystemEventListener;
import jakarta.faces.flow.FlowHandler;
import jakarta.faces.validator.Validator;
/**
*
* Provides a simple implementation of {@link Application} that can be
* subclassed by developers wishing to provide specialized behavior to an existing {@link Application} instance. The
* default implementation of all methods is to call through to the wrapped {@link Application}.
*
*
*
* Usage: extend this class and push the implementation being wrapped to the constructor and use {@link #getWrapped} to
* access the instance being wrapped.
*
*
* @since 2.0
*/
public abstract class ApplicationWrapper extends Application implements FacesWrapper {
private Application wrapped;
/**
* @deprecated Use the other constructor taking the implementation being wrapped.
*/
@Deprecated
public ApplicationWrapper() {
}
/**
*
* If this application has been decorated, the implementation doing the decorating should push the implementation being
* wrapped to this constructor. The {@link #getWrapped()} will then return the implementation being wrapped.
*
*
* @param wrapped The implementation being wrapped.
* @since 2.3
*/
public ApplicationWrapper(Application wrapped) {
this.wrapped = wrapped;
}
@Override
public Application getWrapped() {
return wrapped;
}
/**
*
* The default behavior of this method is to call {@link Application#getActionListener} on the wrapped
* {@link Application} object.
*
*/
@Override
public ActionListener getActionListener() {
return getWrapped().getActionListener();
}
/**
*
* The default behavior of this method is to call
* {@link Application#setActionListener(jakarta.faces.event.ActionListener)} on the wrapped {@link Application} object.
*
*/
@Override
public void setActionListener(ActionListener listener) {
getWrapped().setActionListener(listener);
}
/**
*
* The default behavior of this method is to call {@link Application#getDefaultLocale} on the wrapped
* {@link Application} object.
*
*/
@Override
public Locale getDefaultLocale() {
return getWrapped().getDefaultLocale();
}
/**
*
* The default behavior of this method is to call {@link Application#setDefaultLocale(java.util.Locale)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void setDefaultLocale(Locale locale) {
getWrapped().setDefaultLocale(locale);
}
/**
*
* The default behavior of this method is to call {@link Application#getDefaultRenderKitId} on the wrapped
* {@link Application} object.
*
*/
@Override
public String getDefaultRenderKitId() {
return getWrapped().getDefaultRenderKitId();
}
/**
*
* The default behavior of this method is to call {@link Application#addDefaultValidatorId(String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void addDefaultValidatorId(String validatorId) {
getWrapped().addDefaultValidatorId(validatorId);
}
/**
*
* The default behavior of this method is to call {@link Application#getDefaultValidatorInfo} on the wrapped
* {@link Application} object.
*
*/
@Override
public Map getDefaultValidatorInfo() {
return getWrapped().getDefaultValidatorInfo();
}
/**
*
* The default behavior of this method is to call {@link Application#setDefaultRenderKitId(String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void setDefaultRenderKitId(String renderKitId) {
getWrapped().setDefaultRenderKitId(renderKitId);
}
/**
*
* The default behavior of this method is to call {@link Application#getMessageBundle} on the wrapped
* {@link Application} object.
*
*/
@Override
public String getMessageBundle() {
return getWrapped().getMessageBundle();
}
/**
*
* The default behavior of this method is to call {@link Application#setMessageBundle(String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void setMessageBundle(String bundle) {
getWrapped().setMessageBundle(bundle);
}
/**
*
* The default behavior of this method is to call {@link Application#getNavigationHandler} on the wrapped
* {@link Application} object.
*
*/
@Override
public NavigationHandler getNavigationHandler() {
return getWrapped().getNavigationHandler();
}
/**
*
* The default behavior of this method is to call {@link Application#setNavigationHandler(NavigationHandler)} on the
* wrapped {@link Application} object.
*
*/
@Override
public void setNavigationHandler(NavigationHandler handler) {
getWrapped().setNavigationHandler(handler);
}
/**
*
* The default behavior of this method is to call {@link Application#getPropertyResolver} on the wrapped
* {@link Application} object.
*
*
* @deprecated See superclass for alternative.
*/
@Override
@Deprecated
public PropertyResolver getPropertyResolver() {
return getWrapped().getPropertyResolver();
}
/**
*
* The default behavior of this method is to call
* {@link Application#setPropertyResolver(jakarta.faces.el.PropertyResolver)} on the wrapped {@link Application} object.
*
*
* @deprecated See superclass for alternative.
*/
@Override
@Deprecated
public void setPropertyResolver(PropertyResolver resolver) {
getWrapped().setPropertyResolver(resolver);
}
/**
*
* The default behavior of this method is to call {@link Application#getVariableResolver} on the wrapped
* {@link Application} object.
*
*
* @deprecated See superclass for alternative.
*/
@Override
@Deprecated
public VariableResolver getVariableResolver() {
return getWrapped().getVariableResolver();
}
/**
*
* The default behavior of this method is to call
* {@link Application#setVariableResolver(jakarta.faces.el.VariableResolver)} on the wrapped {@link Application} object.
*
*
* @deprecated See superclass for alternative.
*/
@Override
@Deprecated
public void setVariableResolver(VariableResolver resolver) {
getWrapped().setVariableResolver(resolver);
}
/**
*
* The default behavior of this method is to call {@link Application#getViewHandler} on the wrapped {@link Application}
* object.
*
*/
@Override
public ViewHandler getViewHandler() {
return getWrapped().getViewHandler();
}
/**
*
* The default behavior of this method is to call
* {@link Application#setViewHandler(ViewHandler)} on the wrapped {@link Application} object.
*
*
* @throws IllegalStateException if this method is called after at least one request
* has been processed by the Lifecycle
instance for this application.
* @throws NullPointerException if manager
is null
*/
@Override
public void setViewHandler(ViewHandler handler) {
getWrapped().setViewHandler(handler);
}
/**
*
* The default behavior of this method is to call {@link Application#getStateManager} on the wrapped {@link Application}
* object.
*
*/
@Override
public StateManager getStateManager() {
return getWrapped().getStateManager();
}
/**
*
* The default behavior of this method is to call
* {@link Application#setStateManager(StateManager)} on the wrapped {@link Application} object.
*
*
* @throws IllegalStateException if this method is called after at least one request has
* been processed by the Lifecycle
instance for this application.
* @throws NullPointerException if manager
is null
*/
@Override
public void setStateManager(StateManager manager) {
getWrapped().setStateManager(manager);
}
/**
*
* The default behavior of this method is to call {@link Application#addComponent(String, String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void addComponent(String componentType, String componentClass) {
getWrapped().addComponent(componentType, componentClass);
}
/**
*
* The default behavior of this method is to call {@link Application#createComponent(String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public UIComponent createComponent(String componentType) throws FacesException {
return getWrapped().createComponent(componentType);
}
/**
*
* The default behavior of this method is to call
* {@link Application#createComponent(jakarta.faces.el.ValueBinding, jakarta.faces.context.FacesContext, String)} on the
* wrapped {@link Application} object.
*
*
* @deprecated See superclass for alternative.
*/
@Override
@Deprecated
public UIComponent createComponent(ValueBinding componentBinding, FacesContext context, String componentType) throws FacesException {
return getWrapped().createComponent(componentBinding, context, componentType);
}
/**
*
* The default behavior of this method is to call {@link Application#getComponentTypes} on the wrapped
* {@link Application} object.
*
*/
@Override
public Iterator getComponentTypes() {
return getWrapped().getComponentTypes();
}
/**
*
* The default behavior of this method is to call {@link Application#addConverter(String, String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void addConverter(String converterId, String converterClass) {
getWrapped().addConverter(converterId, converterClass);
}
/**
*
* The default behavior of this method is to call {@link Application#addConverter(Class, String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void addConverter(Class> targetClass, String converterClass) {
getWrapped().addConverter(targetClass, converterClass);
}
/**
*
* The default behavior of this method is to call {@link Application#createConverter(String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public Converter createConverter(String converterId) {
return getWrapped().createConverter(converterId);
}
/**
*
* The default behavior of this method is to call {@link Application#createConverter(Class)} on the wrapped
* {@link Application} object.
*
*/
@Override
public Converter createConverter(Class> targetClass) {
return getWrapped().createConverter(targetClass);
}
/**
*
* The default behavior of this method is to call {@link Application#getConverterIds} on the wrapped {@link Application}
* object.
*
*/
@Override
public Iterator getConverterIds() {
return getWrapped().getConverterIds();
}
/**
*
* The default behavior of this method is to call {@link Application#getConverterTypes} on the wrapped
* {@link Application} object.
*
*/
@Override
public Iterator> getConverterTypes() {
return getWrapped().getConverterTypes();
}
/**
*
* The default behavior of this method is to call {@link Application#createMethodBinding(String, Class[])} on the
* wrapped {@link Application} object.
*
*
* @deprecated See superclass for alternative.
*/
@Override
@Deprecated
public MethodBinding createMethodBinding(String ref, Class>[] params) throws ReferenceSyntaxException {
return getWrapped().createMethodBinding(ref, params);
}
/**
*
* The default behavior of this method is to call {@link Application#getSupportedLocales} on the wrapped
* {@link Application} object.
*
*/
@Override
public Iterator getSupportedLocales() {
return getWrapped().getSupportedLocales();
}
/**
*
* The default behavior of this method is to call {@link Application#setSupportedLocales(java.util.Collection)} on the
* wrapped {@link Application} object.
*
*/
@Override
public void setSupportedLocales(Collection locales) {
getWrapped().setSupportedLocales(locales);
}
/**
*
* The default behavior of this method is to call {@link Application#addBehavior(String, String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void addBehavior(String behaviorId, String behaviorClass) {
getWrapped().addBehavior(behaviorId, behaviorClass);
}
/**
*
* The default behavior of this method is to call {@link Application#createBehavior(String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public Behavior createBehavior(String behaviorId) throws FacesException {
return getWrapped().createBehavior(behaviorId);
}
/**
*
* The default behavior of this method is to call {@link Application#getBehaviorIds} on the wrapped {@link Application}
* object.
*
*/
@Override
public Iterator getBehaviorIds() {
return getWrapped().getBehaviorIds();
}
/**
*
* The default behavior of this method is to call {@link Application#addValidator(String, String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void addValidator(String validatorId, String validatorClass) {
getWrapped().addValidator(validatorId, validatorClass);
}
/**
*
* The default behavior of this method is to call {@link Application#createValidator(String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public Validator createValidator(String validatorId) throws FacesException {
return getWrapped().createValidator(validatorId);
}
/**
*
* The default behavior of this method is to call {@link Application#getValidatorIds} on the wrapped {@link Application}
* object.
*
*/
@Override
public Iterator getValidatorIds() {
return getWrapped().getValidatorIds();
}
/**
*
* The default behavior of this method is to call {@link Application#createValueBinding(String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public ValueBinding createValueBinding(String ref) throws ReferenceSyntaxException {
return getWrapped().createValueBinding(ref);
}
/**
*
* The default behavior of this method is to call {@link Application#getResourceHandler} on the wrapped
* {@link Application} object.
*
*/
@Override
public ResourceHandler getResourceHandler() {
return getWrapped().getResourceHandler();
}
/**
*
* The default behavior of this method is to call
* {@link Application#setResourceHandler(ResourceHandler)} on the wrapped {@link Application} object.
*
*
* @throws IllegalStateException if this method is called after at least one request has
* been processed by the Lifecycle
instance for this application.
* @throws NullPointerException if resourceHandler
is null
*/
@Override
public void setResourceHandler(ResourceHandler resourceHandler) {
getWrapped().setResourceHandler(resourceHandler);
}
/**
*
* The default behavior of this method is to call
* {@link Application#getResourceBundle(jakarta.faces.context.FacesContext, String)} on the wrapped {@link Application}
* object.
*
*/
@Override
public ResourceBundle getResourceBundle(FacesContext ctx, String name) {
return getWrapped().getResourceBundle(ctx, name);
}
/**
*
* The default behavior of this method is to call {@link Application#getProjectStage} on the wrapped {@link Application}
* object.
*
*/
@Override
public ProjectStage getProjectStage() {
return getWrapped().getProjectStage();
}
/**
*
* The default behavior of this method is to call
* {@link Application#addELResolver(jakarta.el.ELResolver)} on the wrapped {@link Application} object.
*
*
* @throws IllegalStateException if called after the first request to the
* {@link jakarta.faces.webapp.FacesServlet} has been serviced.
*/
@Override
public void addELResolver(ELResolver resolver) {
getWrapped().addELResolver(resolver);
}
/**
*
* The default behavior of this method is to call {@link Application#getELResolver} on the wrapped {@link Application}
* object.
*
*/
@Override
public ELResolver getELResolver() {
return getWrapped().getELResolver();
}
/**
*
* The default behavior of this method is to call
* {@link Application#createComponent(jakarta.el.ValueExpression, jakarta.faces.context.FacesContext, String)} on the
* wrapped {@link Application} object.
*
*/
@Override
public UIComponent createComponent(ValueExpression componentExpression, FacesContext context, String componentType) throws FacesException {
return getWrapped().createComponent(componentExpression, context, componentType);
}
/**
*
* The default behavior of this method is to call
* {@link Application#createComponent(jakarta.el.ValueExpression, jakarta.faces.context.FacesContext, String, String)}
* on the wrapped {@link Application} object.
*
*/
@Override
public UIComponent createComponent(ValueExpression componentExpression, FacesContext context, String componentType, String rendererType) {
return getWrapped().createComponent(componentExpression, context, componentType, rendererType);
}
/**
*
* The default behavior of this method is to call
* {@link Application#createComponent(jakarta.faces.context.FacesContext, String, String)} on the wrapped
* {@link Application} object.
*
*/
@Override
public UIComponent createComponent(FacesContext context, String componentType, String rendererType) {
return getWrapped().createComponent(context, componentType, rendererType);
}
/**
*
* The default behavior of this method is to call
* {@link Application#createComponent(jakarta.faces.context.FacesContext, Resource)} on the wrapped {@link Application}
* object.
*
*/
@Override
public UIComponent createComponent(FacesContext context, Resource componentResource) {
return getWrapped().createComponent(context, componentResource);
}
/**
*
* The default behavior of this method is to call {@link Application#getExpressionFactory} on the wrapped
* {@link Application} object.
*
*/
@Override
public ExpressionFactory getExpressionFactory() {
return getWrapped().getExpressionFactory();
}
@Override
public FlowHandler getFlowHandler() {
return getWrapped().getFlowHandler();
}
@Override
public void setFlowHandler(FlowHandler newHandler) {
super.setFlowHandler(newHandler);
}
/**
*
* The default behavior of this method is to call
* {@link Application#evaluateExpressionGet(jakarta.faces.context.FacesContext, String, Class)} on the wrapped
* {@link Application} object.
*
*
* @deprecated See superclass for alternative.
*/
@Override
@Deprecated
public T evaluateExpressionGet(FacesContext context, String expression, Class extends T> expectedType) throws ELException {
return getWrapped().evaluateExpressionGet(context, expression, expectedType);
}
/**
*
* The default behavior of this method is to call {@link Application#addELContextListener(jakarta.el.ELContextListener)}
* on the wrapped {@link Application} object.
*
*/
@Override
public void addELContextListener(ELContextListener listener) {
getWrapped().addELContextListener(listener);
}
/**
*
* The default behavior of this method is to call
* {@link Application#removeELContextListener(jakarta.el.ELContextListener)} on the wrapped {@link Application} object.
*
*/
@Override
public void removeELContextListener(ELContextListener listener) {
getWrapped().removeELContextListener(listener);
}
/**
*
* The default behavior of this method is to call {@link Application#getELContextListeners} on the wrapped
* {@link Application} object.
*
*/
@Override
public ELContextListener[] getELContextListeners() {
return getWrapped().getELContextListeners();
}
/**
*
* The default behavior of this method is to call
* {@link Application#publishEvent(jakarta.faces.context.FacesContext, Class, Object)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void publishEvent(FacesContext context, Class extends SystemEvent> systemEventClass, Object source) {
getWrapped().publishEvent(context, systemEventClass, source);
}
/**
*
* The default behavior of this method is to call
* {@link Application#publishEvent(jakarta.faces.context.FacesContext, Class, Class, Object)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void publishEvent(FacesContext context, Class extends SystemEvent> systemEventClass, Class> sourceBaseType, Object source) {
getWrapped().publishEvent(context, systemEventClass, sourceBaseType, source);
}
/**
*
* The default behavior of this method is to call
* {@link Application#subscribeToEvent(Class, Class, jakarta.faces.event.SystemEventListener)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void subscribeToEvent(Class extends SystemEvent> systemEventClass, Class> sourceClass, SystemEventListener listener) {
getWrapped().subscribeToEvent(systemEventClass, sourceClass, listener);
}
/**
*
* The default behavior of this method is to call
* {@link Application#subscribeToEvent(Class, jakarta.faces.event.SystemEventListener)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void subscribeToEvent(Class extends SystemEvent> systemEventClass, SystemEventListener listener) {
getWrapped().subscribeToEvent(systemEventClass, listener);
}
/**
*
* The default behavior of this method is to call
* {@link Application#unsubscribeFromEvent(Class, Class, jakarta.faces.event.SystemEventListener)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void unsubscribeFromEvent(Class extends SystemEvent> systemEventClass, Class> sourceClass, SystemEventListener listener) {
getWrapped().unsubscribeFromEvent(systemEventClass, sourceClass, listener);
}
/**
*
* The default behavior of this method is to call
* {@link Application#unsubscribeFromEvent(Class, jakarta.faces.event.SystemEventListener)} on the wrapped
* {@link Application} object.
*
*/
@Override
public void unsubscribeFromEvent(Class extends SystemEvent> systemEventClass, SystemEventListener listener) {
getWrapped().unsubscribeFromEvent(systemEventClass, listener);
}
@Override
public SearchExpressionHandler getSearchExpressionHandler() {
return getWrapped().getSearchExpressionHandler();
}
@Override
public void setSearchExpressionHandler(SearchExpressionHandler searchExpressionHandler) {
getWrapped().setSearchExpressionHandler(searchExpressionHandler);
}
@Override
public void addSearchKeywordResolver(SearchKeywordResolver resolver) {
getWrapped().addSearchKeywordResolver(resolver);
}
@Override
public SearchKeywordResolver getSearchKeywordResolver() {
return getWrapped().getSearchKeywordResolver();
}
}