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


Java UpdateListener类代码示例

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


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

示例1: callInit

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
@BeforeClass
public void callInit() {
    try {
        baseSensor.init(1, 1);
    } catch (Exception e) {
        e.printStackTrace();
    }

    Map<String, UpdateListener> listeners = new HashMap<String, UpdateListener>();
    UpdateListener updateListener = null;
    listeners.put("CloseEventListener", updateListener);
    baseSensor.setListeners(listeners);//needed in allLoaded Statements test

    ThresholdsDao tdMock = (mock(ThresholdsDao.class));
    when(tdMock.getThreshold(anyLong(), anyString())).thenReturn(null); //null only for now
    baseSensor.setTsDao(tdMock);

}
 
开发者ID:oneops,项目名称:oneops,代码行数:19,代码来源:SensorTest.java

示例2: createStmt

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
public static void createStmt(EPServiceProvider epService,
                              int secTimeout,
                              UpdateListener listener) {
    String textOne = "insert into CountZone " +
            "select zone, count(*) as cnt " +
            "from LocationReport#unique(assetId) " +
            "where assetId in ('A1', 'A2', 'A3') " +
            "group by zone";

    EPStatement stmtOne = epService.getEPAdministrator().createEPL(textOne);
    stmtOne.addListener(new UpdateListener() {
        public void update(EventBean[] newEvents, EventBean[] oldEvents) {
            for (int i = 0; i < newEvents.length; i++) {
                System.out.println("Summary: zone " + newEvents[i].get("zone") +
                        " now has count " + newEvents[i].get("cnt"));
            }
        }
    });

    String textTwo = "select Part.zone from pattern [" +
            "  every Part=CountZone(cnt in (1,2)) ->" +
            "  (timer:interval(" + secTimeout + " sec) " +
            "    and not CountZone(zone=Part.zone, cnt in (0,3)))]";
    EPStatement stmtTwo = epService.getEPAdministrator().createEPL(textTwo);
    stmtTwo.addListener(listener);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:27,代码来源:LRMovingZoneStmt.java

示例3: MatchMakingMonitor

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
public MatchMakingMonitor(final EPServiceProvider epService, final MatchAlertListener matchAlertListener) {
    this.epService = epService;
    this.matchAlertListener = matchAlertListener;

    // Get called for any user showing up
    EPStatement factory = epService.getEPAdministrator().createPattern("every user=" + MobileUserBean.class.getName());

    factory.addListener(new UpdateListener() {
        public void update(EventBean[] newEvents, EventBean[] oldEvents) {
            MobileUserBean user = (MobileUserBean) newEvents[0].get("user");

            // No action if user already known
            if (existingUsers.contains(user.getUserId())) {
                return;
            }

            log.debug(".update New user encountered, user=" + user.getUserId());

            existingUsers.add(user.getUserId());
            new MatchMakingMonitor(epService, user, matchAlertListener);
        }
    });
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:24,代码来源:MatchMakingMonitor.java

示例4: setupPatterns

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
private void setupPatterns(MobileUserBean mobileUser) {
    double locXLow = mobileUser.getLocationX() - PROXIMITY_RANGE;
    double locXHigh = mobileUser.getLocationX() + PROXIMITY_RANGE;
    double locYLow = mobileUser.getLocationY() - PROXIMITY_RANGE;
    double locYHigh = mobileUser.getLocationY() + PROXIMITY_RANGE;

    this.locateOther = epService.getEPAdministrator().createPattern(
            "every other=" + MobileUserBean.class.getName() +
                    "(locationX in [" + locXLow + ":" + locXHigh + "]," +
                    "locationY in [" + locYLow + ":" + locYHigh + "]," +
                    "myGender='" + mobileUser.getPreferredGender() + "'," +
                    "myAgeRange='" + mobileUser.getPreferredAgeRange() + "'," +
                    "myHairColor='" + mobileUser.getPreferredHairColor() + "'," +
                    "preferredGender='" + mobileUser.getMyGender() + "'," +
                    "preferredAgeRange='" + mobileUser.getMyAgeRange() + "'," +
                    "preferredHairColor='" + mobileUser.getMyHairColor() + "'" +
                    ")");

    locateOther.addListener(new UpdateListener() {
        public void update(EventBean[] newEvents, EventBean[] oldEvents) {
            MobileUserBean other = (MobileUserBean) newEvents[0].get("other");
            MatchAlertBean alert = new MatchAlertBean(other.getUserId(), MatchMakingMonitor.this.mobileUserId);
            matchAlertListener.emitted(alert);
        }
    });
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:27,代码来源:MatchMakingMonitor.java

示例5: createStatement

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
public static void createStatement(EPAdministrator admin) {
    EPStatement statement = admin.createEPL("select istream ipAddress, avg(duration) from SampleEvent#time(10 sec) group by ipAddress output snapshot every 2 seconds order by ipAddress asc");
    statement.addListener(new UpdateListener() {
        public void update(EventBean[] newEvents, EventBean[] oldEvents) {
            if (newEvents == null) {
                return;
            }

            for (int i = 0; i < newEvents.length; i++) {
                if (log.isInfoEnabled()) {
                    log.info("IPAddress: " + newEvents[i].get("ipAddress") +
                            " Avg Duration: " + newEvents[i].get("avg(duration)"));
                }
            }
        }
    });

}
 
开发者ID:espertechinc,项目名称:esper,代码行数:19,代码来源:SampleStatement.java

示例6: StockTickerMonitor

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
public StockTickerMonitor(EPServiceProvider epService, final StockTickerResultListener stockTickerResultListener) {
    this.epService = epService;
    this.stockTickerResultListener = stockTickerResultListener;

    // Listen to all limits to be set
    String expressionText = "every pricelimit=PriceLimit()";
    EPStatement factory = epService.getEPAdministrator().createPattern(expressionText);

    factory.addListener(new UpdateListener() {
        public void update(EventBean[] newEvents, EventBean[] oldEvents) {
            PriceLimit limitBean = (PriceLimit) newEvents[0].get("pricelimit");

            if (log.isDebugEnabled()) {
                log.debug(".update Received new limit, user=" + limitBean.getUserId() +
                        "  stock=" + limitBean.getStockSymbol() +
                        "  pct=" + limitBean.getLimitPct());
            }

            new StockTickerMonitor(StockTickerMonitor.this.epService, limitBean, stockTickerResultListener);
        }
    });
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:StockTickerMonitor.java

示例7: run

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
public void run(EPServiceProvider epService) throws Exception {
    EPStatement stmt = epService.getEPAdministrator().createEPL("select theString from " + SupportBean.class.getName());

    final List<String> strings = Collections.synchronizedList(new ArrayList<String>());
    stmt.addListener(new UpdateListener() {
        public void update(EventBean[] newEvents, EventBean[] oldEvents) {
            strings.add((String) newEvents[0].get("theString"));
        }
    });

    trySend(epService, 2, 50000);

    boolean found = false;
    for (String value : strings) {
        if (value.equals("a")) {
            found = true;
        }
    }
    assertTrue(found);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:21,代码来源:ExecMTUpdate.java

示例8: execute

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
public void execute() {
    EventBean[] eventArray;

    if (eventList != null) {
        eventArray = eventList.toArray(new EventBean[eventList.size()]);
        eventList = null;
        singleEvent = null;
    } else {
        eventArray = new EventBean[]{singleEvent};
        singleEvent = null;
    }

    for (UpdateListener listener : listeners) {
        try {
            listener.update(eventArray, null);
        } catch (Throwable t) {
            String message = "Unexpected exception invoking listener update method on listener class '" + listener.getClass().getSimpleName() +
                    "' : " + t.getClass().getSimpleName() + " : " + t.getMessage();
            log.error(message, t);
        }
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:PatternListenerDispatch.java

示例9: removeListener

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
/**
 * Remove a listeners to a statement.
 *
 * @param listener to remove
 */
public synchronized void removeListener(UpdateListener listener) {
    if (listener == null) {
        throw new IllegalArgumentException("Null listener reference supplied");
    }

    int index = -1;
    for (int i = 0; i < listeners.length; i++) {
        if (listeners[i] == listener) {
            index = i;
            break;
        }
    }
    if (index == -1) {
        return;
    }
    listeners = (UpdateListener[]) CollectionUtil.arrayShrinkRemoveSingle(listeners, index);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:23,代码来源:EPStatementListenerSet.java

示例10: setEsperExpression

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
/**
 * Use this method to set a new Esper Expression. 
 * @param Name
 * @param expression
 * @param listener
 */
public void setEsperExpression(String Name, String expression, UpdateListener listener) {

	if (Name != null) {
		
		if (Name.equals(expression)) {
			expression = this.getStatement(Name);
		}
		
		logger.debug("Setting new EsperStatement: " + expression);
		EPStatement statement = epa.createEPL(expression, Name);
		
		if (listener != null) {
			statement.addListener(listener);
		}
	}
}
 
开发者ID:sgrotz,项目名称:myopentrader,代码行数:23,代码来源:EsperFactory.java

示例11: getListenerByQuery

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
public LiveQueryListener getListenerByQuery(final QueryWrapper query) {
	final EPStatement statement = this.getStatement(query.getStatementName());
	if (statement != null) {
		final Iterator<UpdateListener> listeners = statement.getUpdateListeners();
		return (LiveQueryListener) listeners.next();
	}
	return null;
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:9,代码来源:StreamProcessingAdapter.java

示例12: addListener

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
/**
 * Add a listener to the statement.
 *
 * @param listener to add
 */
public synchronized void addListener(UpdateListener listener) {
    if (listener == null) {
        throw new IllegalArgumentException("Null listener reference supplied");
    }

    for (UpdateListener existing : listeners) {
        if (existing == listener) {
            return;
        }
    }
    listeners = (UpdateListener[]) CollectionUtil.arrayExpandAddSingle(listeners, listener);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:18,代码来源:EPStatementListenerSet.java

示例13: addListener

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
/**
 * Adds an {@link UpdateListener) to the statement to support
 * the 'push' mode of retrieving results.
 * 
 * @param listener The listener to be invoked when appropriate results according to the EPL filter query.
 */
public void addListener(UpdateListener listener) {
	listeners.add(listener);

	this.refreshEPStatmentListeners();

	this.addEPStatementListener(listener);
}
 
开发者ID:sdcuike,项目名称:esper-2015,代码行数:14,代码来源:EsperStatement.java

示例14: addEPStatementListener

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
/**
 * Adds an listener to the underlying native EPStatement.
 * 
 * @param listener
 *            the listener to add
 */
private void addEPStatementListener(UpdateListener listener) {
	if (this.subscriber == null) {
		if (epStatement != null) {
			epStatement.addListener(listener);
		}
	}
}
 
开发者ID:sdcuike,项目名称:esper-2015,代码行数:14,代码来源:EsperStatement.java

示例15: setEPStatement

import com.espertech.esper.client.UpdateListener; //导入依赖的package包/类
/**
 * Sets the native Esper statement. Typically created by an Esper Template.
 * 
 * @param epStatement
 *            the underlying native Esper statement
 * @see org.opencredo.esper.EsperTemplate
 */
void setEPStatement(EPStatement epStatement) {
	this.epStatement = epStatement;
	if (this.subscriber != null && this.subscriberMethodName == null) {
		epStatement.setSubscriber(this.subscriber);
	} else if (this.subscriber != null && this.subscriberMethodName != null) {
		epStatement.setSubscriber(this.subscriber, subscriberMethodName);
	} else {
		for (UpdateListener listener : listeners) {
			epStatement.addListener(listener);
		}
	}
}
 
开发者ID:sdcuike,项目名称:esper-2015,代码行数:20,代码来源:EsperStatement.java


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