org.apache.myfaces.tobago.component.MethodBindingToMethodExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tobago-jsf-compat Show documentation
Show all versions of tobago-jsf-compat Show documentation
Tobago JSF 1.1-1.2 Compatibility Bridge
(makes Tobago independent from differences between JSF 1.1 and JSF 1.2).
package org.apache.myfaces.tobago.component;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.MethodExpression;
import javax.el.MethodInfo;
import javax.el.MethodNotFoundException;
import javax.faces.FacesException;
import javax.faces.component.StateHolder;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
@SuppressWarnings("deprecation")
public class MethodBindingToMethodExpression extends MethodExpression implements StateHolder {
private MethodBinding methodBinding;
private boolean transientFlag;
private transient MethodInfo methodInfo;
/**
* No-arg constructor used during restoreState
*/
public MethodBindingToMethodExpression() {
}
/**
* Creates a new instance of MethodBindingToMethodExpression
* @param methodBinding The MethodBinding to wrap.
*/
public MethodBindingToMethodExpression(MethodBinding methodBinding) {
checkNullArgument(methodBinding, "methodBinding");
this.methodBinding = methodBinding;
}
/**
* Return the wrapped MethodBinding.
* @return the wrapped MethodBinding
*/
public MethodBinding getMethodBinding() {
return methodBinding;
}
void setMethodBinding(MethodBinding methodBinding) {
this.methodBinding = methodBinding;
}
/**
* Note: MethodInfo.getParamTypes() may incorrectly return an empty class array if invoke() has not been called.
*
* @throws IllegalStateException if expected params types have not been determined.
*/
public MethodInfo getMethodInfo(ELContext context) throws ELException {
checkNullArgument(context, "elcontext");
checkNullState(methodBinding, "methodBinding");
if (methodInfo == null) {
final FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
if (facesContext != null) {
methodInfo = invoke(new Invoker() {
public MethodInfo invoke() {
return new MethodInfo(null, methodBinding.getType(facesContext), null);
}
});
}
}
return methodInfo;
}
public Object invoke(ELContext context, final Object[] params) throws ELException {
checkNullArgument(context, "elcontext");
checkNullState(methodBinding, "methodBinding");
final FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
if (facesContext != null) {
return invoke(new Invoker
© 2015 - 2025 Weber Informatics LLC | Privacy Policy