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


Java EPStatement.removeListener方法代码示例

本文整理汇总了Java中com.espertech.esper.client.EPStatement.removeListener方法的典型用法代码示例。如果您正苦于以下问题:Java EPStatement.removeListener方法的具体用法?Java EPStatement.removeListener怎么用?Java EPStatement.removeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.espertech.esper.client.EPStatement的用法示例。


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

示例1: runAssertionAddRemoveListener

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionAddRemoveListener(EPServiceProvider epService) {
    String epl = "@IterableUnbound every tag=" + SupportBean.class.getName();
    EPStatement patternStmt = epService.getEPAdministrator().createPattern(epl, "MyPattern");
    assertEquals(StatementType.PATTERN, ((EPStatementSPI) patternStmt).getStatementMetadata().getStatementType());
    SupportUpdateListener listener = new SupportUpdateListener();

    // Pattern started when created

    // Add listener
    patternStmt.addListener(listener);
    assertNull(listener.getLastNewData());
    assertFalse(patternStmt.iterator().hasNext());

    // Send event
    SupportBean theEvent = sendEvent(epService);
    assertEquals(theEvent, listener.getAndResetLastNewData()[0].get("tag"));
    assertSame(theEvent, patternStmt.iterator().next().get("tag"));

    // Remove listener
    patternStmt.removeListener(listener);
    theEvent = sendEvent(epService);
    assertSame(theEvent, patternStmt.iterator().next().get("tag"));
    assertNull(listener.getLastNewData());

    // Add listener back
    patternStmt.addListener(listener);
    theEvent = sendEvent(epService);
    assertSame(theEvent, patternStmt.iterator().next().get("tag"));
    assertEquals(theEvent, listener.getAndResetLastNewData()[0].get("tag"));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:31,代码来源:ExecPatternStartStop.java

示例2: tryFilterRelationalOpRange

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void tryFilterRelationalOpRange(EPServiceProvider epService, String text, int[] testData, boolean[] isReceived) {
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    assertEquals(testData.length, isReceived.length);
    for (int i = 0; i < testData.length; i++) {
        sendBeanIntDouble(epService, testData[i], 0D);
        assertEquals("failed testing index " + i, isReceived[i], listener.getAndClearIsInvoked());
    }
    stmt.removeListener(listener);

    stmt.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:15,代码来源:ExecFilterExpressions.java

示例3: tryFilter

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void tryFilter(EPServiceProvider epService, String text, boolean isReceived) {
    EPStatement stmt = epService.getEPAdministrator().createEPL(text);
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);

    sendBeanString(epService, "a");
    assertFalse(listener.getAndClearIsInvoked());
    sendBeanString(epService, "b");
    assertEquals(isReceived, listener.getAndClearIsInvoked());
    sendBeanString(epService, "c");
    assertFalse(listener.getAndClearIsInvoked());

    stmt.removeListener(listener);
    stmt.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:16,代码来源:ExecFilterExpressions.java

示例4: runAssertionAddRemoveListener

import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionAddRemoveListener(EPServiceProvider epService) {
    String epl = "select count(*) as size from " + SupportBean.class.getName();
    EPStatement sizeStmt = epService.getEPAdministrator().createEPL(epl);
    SupportUpdateListener listener = new SupportUpdateListener();

    // View is started when created

    // Add listener send event
    sizeStmt.addListener(listener);
    assertNull(listener.getLastNewData());
    assertEquals(0L, sizeStmt.iterator().next().get("size"));
    sendEvent(epService);
    assertEquals(1L, listener.getAndResetLastNewData()[0].get("size"));
    assertEquals(1L, sizeStmt.iterator().next().get("size"));

    // Stop view, send event, view
    sizeStmt.stop();
    sendEvent(epService);
    assertNull(sizeStmt.iterator());
    assertNull(listener.getLastNewData());

    // Start again
    sizeStmt.removeListener(listener);
    sizeStmt.addListener(listener);
    sizeStmt.start();

    sendEvent(epService);
    assertEquals(1L, listener.getAndResetLastNewData()[0].get("size"));
    assertEquals(1L, sizeStmt.iterator().next().get("size"));

    // Stop again, leave listeners
    sizeStmt.stop();
    sizeStmt.start();
    sendEvent(epService);
    assertEquals(1L, listener.getAndResetLastNewData()[0].get("size"));

    // Remove listener, send event
    sizeStmt.removeListener(listener);
    sendEvent(epService);
    assertNull(listener.getLastNewData());

    // Add listener back, send event
    sizeStmt.addListener(listener);
    sendEvent(epService);
    assertEquals(3L, listener.getAndResetLastNewData()[0].get("size"));

    sizeStmt.destroy();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:49,代码来源:ExecViewStartStop.java


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