private void filter() { for (int x = 0; x < arrayCurrentFilterStage_.length; ++x) { boolean _forward = false; if (!arrayCurrentFilterStage_[x].isDestroyed()) { Message _currentMessage = getMessage(); if (arrayCurrentFilterStage_[x].hasPriorityFilter()) { _currentMessage = updatePriority(x, _currentMessage); } if (arrayCurrentFilterStage_[x].hasLifetimeFilter()) { _currentMessage = updateTimeout(x, _currentMessage); } if (_currentMessage != getMessage()) { // MappingFilter attached to a particular // FilterStage did change (Timeout or Priority) // the current Message. // store changed Message in Map for later use. changedMessages_.putAlternateMessage(arrayCurrentFilterStage_[x], _currentMessage); } _forward = _currentMessage.match(arrayCurrentFilterStage_[x]); } if (_forward) { // the subsequent destination filters need to be eval'd addFilterStage(arrayCurrentFilterStage_[x].getSubsequentFilterStages()); } } }
private Message updateTimeout(int indexOfCurrentFilterStage, Message message) { AnyHolder _lifetimeFilterResult = new AnyHolder(); Message _currentMessage = message; try { boolean lifetimeMatch = _currentMessage.match( arrayCurrentFilterStage_[indexOfCurrentFilterStage].getLifetimeFilter(), _lifetimeFilterResult); if (lifetimeMatch && (_currentMessage == getMessage())) { // LifeTime Mapping Filter matched and current Message // was not copied yet. This depends on the fact that // updatePriority was run before. _currentMessage = (Message) getMessage().clone(); _currentMessage.setTimeout(_lifetimeFilterResult.value.extract_long()); } } catch (UnsupportedFilterableData e) { if (logger_.isDebugEnabled()) { logger_.debug("unable to evaluate PriorityFilter", e); } else if (logger_.isInfoEnabled()) { logger_.info("unable to evaluate PriorityFilter"); } } return _currentMessage; }
private Message updatePriority(int indexOfCurrentEvent, Message message) { AnyHolder _priorityFilterResult = new AnyHolder(); Message _currentMessage = message; try { boolean priorityMatch = message.match( arrayCurrentFilterStage_[indexOfCurrentEvent].getPriorityFilter(), _priorityFilterResult); if (priorityMatch) { _currentMessage = (Message) getMessage().clone(); _currentMessage.setPriority(_priorityFilterResult.value.extract_long()); } } catch (UnsupportedFilterableData e) { if (logger_.isDebugEnabled()) { logger_.debug("unable to evaluate PriorityFilter", e); } else if (logger_.isInfoEnabled()) { logger_.info("unable to evaluate PriorityFilter"); } } return _currentMessage; }
@Test public void testStructuredEventWithStartTimeProperty() throws Exception { structuredEvent_.header.variable_header = new Property[1]; Date _now = new Date(); Any _startTimeAny = getORB().create_any(); UtcT _startTime = Time.corbaTime(_now); UtcTHelper.insert(_startTimeAny, _startTime); structuredEvent_.header.variable_header[0] = new Property(StartTime.value, _startTimeAny); Message _event = messageFactory_.newMessage(structuredEvent_, proxyConsumerMock_); assertTrue(_event.hasStartTime()); assertEquals(_now.getTime(), _event.getStartTime()); }
public EvaluationResult evaluate(EvaluationContext context) throws EvaluationException { final Message _event = context.getCurrentMessage(); final EvaluationResult _result; switch (_event.getType()) { case Message.TYPE_ANY: _result = expandedPath_.evaluate(context); break; case Message.TYPE_STRUCTURED: String _domainName = _event.toStructuredEvent().header.fixed_header.event_type.domain_name; _result = new EvaluationResult(); _result.setString(_domainName); break; default: throw new RuntimeException(); } return _result; }
@Test public void testAnyEventHasNoStartTime() throws Exception { Message _event = messageFactory_.newMessage(getORB().create_any()); assertTrue(!_event.hasStartTime()); }
@Test public void testStructuredEventWithoutStartTimeProperty() throws Exception { Message _event = messageFactory_.newMessage(structuredEvent_); assertTrue(!_event.hasStartTime()); }