@Override public void prepareRuleInstance(RuleInstance<Match> ruleInstance, EventFilter<? super Match> filter) { Preconditions.checkArgument(ruleInstance != null, "Cannot prepare null rule instance!"); ViatraQueryEventSource<Match> source = realm.createSource(sourceSpecification); ViatraQueryEventHandler<Match> handler = new ViatraQueryEventHandler<Match>(source, filter, ruleInstance); handler.prepareEventHandler(); }
@Override protected void prepareEventHandler() { super.prepareEventHandler(); attributeMonitor = Objects.requireNonNull(prepareAttributeMonitor(), "Prepared attribute monitor is null!"); ViatraQueryEventSource<Match> eventSource = (ViatraQueryEventSource<Match>) getSource(); eventSource.addHandler(this); attributeMonitor.addAttributeMonitorListener(eventSource.getAttributeMonitorListener()); unregisterListener = Objects.requireNonNull(prepareActivationNotificationListener(), "Prepared activation notification listener is null!"); getInstance().addActivationNotificationListener(unregisterListener, false); }
@Override public void dispose() { getInstance().removeActivationNotificationListener(unregisterListener); ((ViatraQueryEventSource<Match>) getSource()).removeHandler(this); attributeMonitor.dispose(); }
processors.put(CRUDEventTypeEnum.CREATED, new EventProcessorAdapter<Match>(getInstance()) { @Override protected void activationExists(Event<Match> event, Activation<Match> activation) { processors.put(CRUDEventTypeEnum.UPDATED, new EventProcessorAdapter<Match>(getInstance()) { @Override protected void activationExists(Event<Match> event, Activation<Match> activation) { processors.put(CRUDEventTypeEnum.DELETED, new EventProcessorAdapter<Match>(getInstance()) { @Override protected void activationExists(Event<Match> event, Activation<Match> activation) {
protected AttributeMonitor<Match> prepareAttributeMonitor(){ //return new DefaultAttributeMonitor<Match>(); LightweightAttributeMonitor<Match> monitor = null; ViatraQueryEventSource<Match> eventSource = (ViatraQueryEventSource<Match>) getSource(); try { monitor = new LightweightAttributeMonitor<Match>(eventSource.getMatcher().getEngine().getBaseIndex()); } catch (ViatraQueryException e) { ViatraQueryLoggingUtil.getLogger(getClass()).error("Error happened while accessing base index", e); } return monitor; }