-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature][adapter]: Use execution listener (#280)
* Camunda Summit 2023: CamundaPlatform7DelegationWorker extended with support for executionListener.start and executionListener.end header fields, which will trigger calls to the specified beans, use to simulate the execution listener support of C7. * prepare worker example * prepare worker example * Camunda Summit 2023: Repositioned the RuntimeException and extended its trigger to exclude situations where only one or both listeners are defined. * working, reducer of result needs fixing * finalize and provide tests * run spotless * implement required changes * Remove the cast on the variableStore * listeners do not count as implementations * append docs --------- Co-authored-by: Martin Karsten <[email protected]> Co-authored-by: Jonathan Lukas <[email protected]>
- Loading branch information
1 parent
f79df84
commit cd3da69
Showing
10 changed files
with
310 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...a-7-adapter/src/main/java/org/camunda/community/migration/adapter/juel/ClassResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.camunda.community.migration.adapter.juel; | ||
|
||
import org.camunda.bpm.engine.ArtifactFactory; | ||
import org.camunda.bpm.engine.delegate.ExecutionListener; | ||
import org.camunda.bpm.engine.delegate.JavaDelegate; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* This wraps the access to {@link ClassLoader} and {@link ArtifactFactory} for loading of {@link | ||
* org.camunda.bpm.engine.delegate.ExecutionListener} and {@link | ||
* org.camunda.bpm.engine.delegate.JavaDelegate} by FQN String. | ||
*/ | ||
@Component | ||
public class ClassResolver { | ||
|
||
private final ArtifactFactory artifactFactory; | ||
|
||
public ClassResolver(ArtifactFactory artifactFactory) { | ||
this.artifactFactory = artifactFactory; | ||
} | ||
|
||
public JavaDelegate loadJavaDelegate(String delegateName) { | ||
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); | ||
try { | ||
Class<? extends JavaDelegate> clazz = | ||
(Class<? extends JavaDelegate>) contextClassLoader.loadClass(delegateName); | ||
return artifactFactory.getArtifact(clazz); | ||
} catch (Exception e) { | ||
throw new RuntimeException( | ||
"Could not load delegation class '" + delegateName + "': " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
public ExecutionListener loadExecutionListener(String listenerName) { | ||
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); | ||
try { | ||
Class<? extends ExecutionListener> clazz = | ||
(Class<? extends ExecutionListener>) contextClassLoader.loadClass(listenerName); | ||
return artifactFactory.getArtifact(clazz); | ||
} catch (Exception e) { | ||
throw new RuntimeException( | ||
"Could not load listener class '" + listenerName + "': " + e.getMessage(), e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.