javax.faces.component._MethodBindingToMethodExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of myfaces-api Show documentation
Show all versions of myfaces-api Show documentation
The public API classes of the Apache MyFaces CORE JSF-2.2 project
/*
* 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.
*/
package javax.faces.component;
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.MethodExpression;
import javax.el.MethodInfo;
import javax.el.MethodNotFoundException;
import javax.el.PropertyNotFoundException;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
/**
* Converts a MethodBinding to a MethodExpression
*
* TODO: find a way to share the implementation of class with impl.
*
* @author Stan Silvert
*/
@SuppressWarnings("deprecation")
class _MethodBindingToMethodExpression extends MethodExpression implements StateHolder
{
private static final Class>[] EXPECTED_TYPES = new Class[] { MethodBinding.class, StateHolder.class };
private MethodBinding methodBinding;
private boolean _transientFlag;
private transient MethodInfo methodInfo;
/**
* No-arg constructor used during restoreState
*/
protected _MethodBindingToMethodExpression()
{
}
/** Creates a new instance of MethodBindingToMethodExpression */
public _MethodBindingToMethodExpression(MethodBinding methodBinding)
{
checkNullArgument(methodBinding, "methodBinding");
this.methodBinding = 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.
*/
@Override
public MethodInfo getMethodInfo(ELContext context) throws PropertyNotFoundException, MethodNotFoundException,
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;
}
@Override
public Object invoke(ELContext context, final Object[] params) throws PropertyNotFoundException,
MethodNotFoundException, 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