Skip to content

Commit

Permalink
[JBPM-9880] logging async node enter
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian committed Oct 5, 2021
1 parent 1e6036b commit 0100bd0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2021 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.drools.core.event;

import java.util.Map;

import org.kie.api.event.process.ProcessAsyncNodeScheduledEvent;
import org.kie.api.runtime.KieRuntime;
import org.kie.api.runtime.process.NodeInstance;

public class ProcessAsyncNodeScheduledEventImpl extends ProcessEvent implements ProcessAsyncNodeScheduledEvent {

private static final long serialVersionUID = 510L;

private NodeInstance nodeInstance;

private Map<String, Object> data;

public ProcessAsyncNodeScheduledEventImpl(final NodeInstance nodeInstance, KieRuntime kruntime, Map<String, Object> data) {
super( nodeInstance.getProcessInstance(), kruntime );
this.nodeInstance = nodeInstance;
this.data = data;
}

@Override
public Map<String, Object> getExtraData() {
return data;
}

public NodeInstance getNodeInstance() {
return nodeInstance;
}

public String toString() {
return "==>[ProcessNodeScheduled(nodeId=" + nodeInstance.getNodeId() + "; id=" + nodeInstance.getId()
+ "; nodeName=" + getNodeInstance().getNodeName() + "; processName=" + getProcessInstance().getProcessName() + "; processId=" + getProcessInstance().getProcessId() + ")]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
package org.drools.core.event;

import java.util.List;
import java.util.Map;

import org.drools.core.common.InternalKnowledgeRuntime;
import org.kie.api.event.process.MessageEvent;
import org.kie.api.event.process.ProcessCompletedEvent;
import org.kie.api.event.process.ProcessEventListener;
import org.kie.api.event.process.ProcessNodeLeftEvent;
import org.kie.api.event.process.ProcessAsyncNodeScheduledEvent;
import org.kie.api.event.process.ProcessNodeTriggeredEvent;
import org.kie.api.event.process.ProcessStartedEvent;
import org.kie.api.event.process.ProcessVariableChangedEvent;
Expand Down Expand Up @@ -61,6 +64,14 @@ public void fireAfterProcessCompleted(final ProcessInstance instance, KieRuntime
}
}


public void fireOnAsyncNodeScheduledEvent(final NodeInstance nodeInstance, InternalKnowledgeRuntime kruntime, Map<String, Object> data) {
if ( hasListeners() ) {
final ProcessAsyncNodeScheduledEvent event = new ProcessAsyncNodeScheduledEventImpl(nodeInstance, kruntime, data);
notifyAllListeners( event, ( l, e ) -> l.onAsyncNodeScheduledEvent( e ) );
}
}

public void fireBeforeNodeTriggered(final NodeInstance nodeInstance, KieRuntime kruntime) {
if ( hasListeners() ) {
final ProcessNodeTriggeredEvent event = new ProcessNodeTriggeredEventImpl(nodeInstance, kruntime);
Expand Down Expand Up @@ -171,4 +182,5 @@ public void fireOnMessage(final ProcessInstance instance,
public void reset() {
this.clear();
}

}

0 comments on commit 0100bd0

Please sign in to comment.