当前位置: 首页>>代码示例>>Java>>正文


Java MethodExpression类代码示例

本文整理汇总了Java中javax.el.MethodExpression的典型用法代码示例。如果您正苦于以下问题:Java MethodExpression类的具体用法?Java MethodExpression怎么用?Java MethodExpression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MethodExpression类属于javax.el包,在下文中一共展示了MethodExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIsParametersProvided

import javax.el.MethodExpression; //导入依赖的package包/类
@Test
public void testIsParametersProvided() {
    TesterBeanB beanB = new TesterBeanB();
    beanB.setName("Tomcat");
    ValueExpression var =
        factory.createValueExpression(beanB, TesterBeanB.class);
    context.getVariableMapper().setVariable("beanB", var);

    MethodExpression me1 = factory.createMethodExpression(
            context, "${beanB.getName}", String.class, new Class<?>[] {});
    MethodExpression me2 = factory.createMethodExpression(
            context, "${beanB.sayHello('JUnit')}", String.class,
            new Class<?>[] { String.class });

    assertFalse(me1.isParmetersProvided());
    assertTrue(me2.isParmetersProvided());
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:18,代码来源:TestMethodExpressionImpl.java

示例2: createMethodExpression

import javax.el.MethodExpression; //导入依赖的package包/类
public MethodExpression createMethodExpression(Class<?> expectedReturnType,
        Class<?>[] expectedParamTypes) throws ELException {
    Node n = this.build();
    if (!n.isParametersProvided() && expectedParamTypes == null) {
        throw new NullPointerException(MessageFactory
                .get("error.method.nullParms"));
    }
    if (n instanceof AstValue || n instanceof AstIdentifier) {
        return new MethodExpressionImpl(expression, n, this.fnMapper,
                this.varMapper, expectedReturnType, expectedParamTypes);
    } else if (n instanceof AstLiteralExpression) {
        return new MethodExpressionLiteral(expression, expectedReturnType,
                expectedParamTypes);
    } else {
        throw new ELException("Not a Valid Method Expression: "
                + expression);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:ExpressionBuilder.java

示例3: testBug53792a

import javax.el.MethodExpression; //导入依赖的package包/类
@Test
public void testBug53792a() {
    MethodExpression me = factory.createMethodExpression(context,
            "${beanA.setBean(beanB)}", null ,
            new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);
    me = factory.createMethodExpression(context,
            "${beanB.setName('" + BUG53792 + "')}", null ,
            new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);

    ValueExpression ve = factory.createValueExpression(context,
            "#{beanA.getBean().name}", java.lang.String.class);
    String actual = (String) ve.getValue(context);
    assertEquals(BUG53792, actual);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:17,代码来源:TestMethodExpressionImpl.java

示例4: invokeTarget

import javax.el.MethodExpression; //导入依赖的package包/类
private final Object invokeTarget(EvaluationContext ctx, Object target,
        Object[] paramValues) throws ELException {
    if (target instanceof MethodExpression) {
        MethodExpression me = (MethodExpression) target;
        return me.invoke(ctx.getELContext(), paramValues);
    } else if (target == null) {
        throw new MethodNotFoundException("Identity '" + this.image
                + "' was null and was unable to invoke");
    } else {
        throw new ELException(
                "Identity '"
                        + this.image
                        + "' does not reference a MethodExpression instance, returned type: "
                        + target.getClass().getName());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:AstIdentifier.java

示例5: testInvokeWithVarArgsAAAB

import javax.el.MethodExpression; //导入依赖的package包/类
@Test
public void testInvokeWithVarArgsAAAB() throws Exception {
    MethodExpression me7 = factory.createMethodExpression(context,
            "${beanC.sayHello(beanAAA,beanB,beanB)}", null , null);
    Exception e = null;
    try {
        me7.invoke(context, null);
    } catch (Exception e1) {
        e = e1;
    }
    // Expected to fail
    assertNotNull(e);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:14,代码来源:TestMethodExpressionImpl.java

示例6: testBug53792b

import javax.el.MethodExpression; //导入依赖的package包/类
@Test
public void testBug53792b() {
    MethodExpression me = factory.createMethodExpression(context,
            "${beanA.setBean(beanB)}", null ,
            new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);
    me = factory.createMethodExpression(context,
            "${beanB.setName('" + BUG53792 + "')}", null ,
            new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);

    ValueExpression ve = factory.createValueExpression(context,
            "#{beanA.getBean().name.length()}", java.lang.Integer.class);
    Integer actual = (Integer) ve.getValue(context);
    assertEquals(Integer.valueOf(BUG53792.length()), actual);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:17,代码来源:TestMethodExpressionImpl.java

示例7: actionListener

import javax.el.MethodExpression; //导入依赖的package包/类
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]
    { event });
  }

}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:20,代码来源:ImmutableItemNode.java

示例8: doAction

import javax.el.MethodExpression; //导入依赖的package包/类
public String doAction()
{
  String value = _action;

  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();
    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value,
            String.class, new Class<?>[]
            {});
    value = (String) methodExpression.invoke(context, null);
  }

  // Post me as the selected Node for the request
  postSelectedNode(this);

  return value;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:23,代码来源:ImmutableItemNode.java

示例9: actionListener

import javax.el.MethodExpression; //导入依赖的package包/类
public void actionListener(ActionEvent event)
{
  String value = _actionListener;
  if (value != null)
  {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExpressionFactory expressionFactory =
        facesContext.getApplication().getExpressionFactory();
    ELContext context = facesContext.getELContext();

    MethodExpression methodExpression =
        expressionFactory.createMethodExpression(context, value, Void.TYPE,
            new Class<?>[]
            { ActionEvent.class });
    methodExpression.invoke(context, new Object[]{ event });
  }

}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:19,代码来源:ItemNode.java

示例10: broadcastToMethodExpression

import javax.el.MethodExpression; //导入依赖的package包/类
/**
 * Broadcast an event to a MethodExpression.
 * This can be used to support MethodBindings such as the "actionListener"
 * binding on ActionSource components:
 * &lt;tr:commandButton actionListener="#{mybean.myActionListener}">
 */
protected final void broadcastToMethodExpression(
  FacesEvent event,
  MethodExpression method) throws AbortProcessingException
{
  if (method != null)
  {
    try
    {
      FacesContext context = getFacesContext();
      method.invoke(context.getELContext(), new Object[] { event });
    }
    catch (ELException ee)
    {
      Throwable t = ee.getCause();
      // Unwrap AbortProcessingExceptions
      if (t instanceof AbortProcessingException)
        throw ((AbortProcessingException) t);
      throw ee;
    }
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:28,代码来源:UIXComponentBase.java

示例11: __handleBroadcast

import javax.el.MethodExpression; //导入依赖的package包/类
static void __handleBroadcast(
  UIXHierarchy  comp,
  FacesEvent    event,
  RowKeySet     state,
  MethodExpression method) throws AbortProcessingException
{
  // Notify the specified disclosure listener method (if any)
  if (event instanceof RowDisclosureEvent)
  {
    RowDisclosureEvent dEvent = (RowDisclosureEvent) event;
    state.removeAll(dEvent.getRemovedSet());
    state.addAll(dEvent.getAddedSet());
    //pu: Implicitly record a Change for 'disclosedRowKeys' attribute
    comp.addAttributeChange("disclosedRowKeys", state);
    comp.broadcastToMethodExpression(event, method);
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:18,代码来源:HierarchyUtils.java

示例12: createMethodExpression

import javax.el.MethodExpression; //导入依赖的package包/类
@Override
public MethodExpression createMethodExpression(ELContext context,
        String expression, Class<?> expectedReturnType,
        Class<?>[] expectedParamTypes) {
    ExpressionBuilder builder = new ExpressionBuilder(expression, context);
    return builder.createMethodExpression(expectedReturnType,
            expectedParamTypes);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:9,代码来源:ExpressionFactoryImpl.java

示例13: testInvoke

import javax.el.MethodExpression; //导入依赖的package包/类
@Test
public void testInvoke() {
    TesterBeanB beanB = new TesterBeanB();
    beanB.setName("B");

    context.getVariableMapper().setVariable("beanB",
            factory.createValueExpression(beanB, TesterBeanB.class));

    MethodExpression me1 = factory.createMethodExpression(
            context, "${beanB.getName}", String.class, new Class<?>[] {});
    MethodExpression me2 = factory.createMethodExpression(
            context, "${beanB.sayHello('JUnit')}", String.class,
            new Class<?>[] { String.class });
    MethodExpression me3 = factory.createMethodExpression(
            context, "${beanB.sayHello}", String.class,
            new Class<?>[] { String.class });

    assertEquals("B", me1.invoke(context, null));
    assertEquals("Hello JUnit from B", me2.invoke(context, null));
    assertEquals("Hello JUnit from B",
            me2.invoke(context, new Object[] { "JUnit2" }));
    assertEquals("Hello JUnit2 from B",
            me3.invoke(context, new Object[] { "JUnit2" }));
    assertEquals("Hello JUnit from B",
            me2.invoke(context, new Object[] { null }));
    assertEquals("Hello  from B",
            me3.invoke(context, new Object[] { null }));
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:29,代码来源:TestMethodExpressionImpl.java

示例14: testInvokeWithSuper

import javax.el.MethodExpression; //导入依赖的package包/类
@Test
public void testInvokeWithSuper() {
    MethodExpression me = factory.createMethodExpression(context,
            "${beanA.setBean(beanBB)}", null ,
            new Class<?>[] { TesterBeanB.class });
    me.invoke(context, null);
    ValueExpression ve = factory.createValueExpression(context,
            "${beanA.bean.name}", String.class);
    Object r = ve.getValue(context);
    assertEquals("BB", r);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:12,代码来源:TestMethodExpressionImpl.java

示例15: testInvokeWithSuperABNoReturnTypeNoParamTypes

import javax.el.MethodExpression; //导入依赖的package包/类
@Test
public void testInvokeWithSuperABNoReturnTypeNoParamTypes() {
    MethodExpression me2 = factory.createMethodExpression(context,
            "${beanC.sayHello(beanA,beanB)}", null , null);
    Object r2 = me2.invoke(context, null);
    assertEquals("AB: Hello A from B", r2.toString());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:8,代码来源:TestMethodExpressionImpl.java


注:本文中的javax.el.MethodExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。