本文整理汇总了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);
}
示例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);
}
示例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);
}
});
}
示例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);
}
});
}
示例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)"));
}
}
}
});
}
示例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);
}
});
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
}