engine-java: make the 'a JavaDelegate must NOT be a @Component' rule observable (#7223) - #7272
Open
NicoleNG18 wants to merge 1 commit into
Conversation
…observable (eclipse-dirigible#7223) The rule that a BPMN JavaDelegate must not be annotated @component was documented in several places but nothing in the runtime enforced, warned about, or even noticed a violation - and after eclipse-dirigible#7189 the old symptom (injected fields reading null at runtime) is gone, because both the container-built singleton and the Flowable-built instance are now wired. So a developer had no signal at all: an annotated delegate silently becomes a registered bean nobody runs, a stray candidate for every List<JavaDelegate> injection. Change: - ComponentContainer.createUnmanaged now emits one LOGGER.warn naming the class and the rule when the delegate type is a bean, making the violation observable at the moment it happens. A unit test asserts the warn fires. - ComponentContainerUnmanagedTest.an_unsatisfied_dependency_is_refused_and_is_not_a_rebuild_error built the container from NO classes, so its wiringErrors().isEmpty() assertion was trivially true; it now builds with a registered bean and a delegate needing an absent type, so the "not a rebuild error" half is load-bearing. - DirigibleJavaCallDelegate: the fallback instantiation error no longer advises "declare the collaborators it injects as @component" - that branch is reached only when the class declares no injection point, so the advice can never apply; reverted to the plain message the camel sibling (DirigibleJavaInvokerImpl) already uses. Its class javadoc now lists @PostConstruct alongside constructor and @Inject field as an injection point (both are counted). - ComponentContainer / JavaLoader javadoc no longer list @extension among the consumers - the SDK has no such annotation. Verified: mvn formatter:validate (BUILD SUCCESS, cache wiped); engine-java + engine-bpm-flowable unit suites green (129 tests, incl. the new warn test); JavaDelegateInjectionIT green (3/3); release-profile javadoc build green on both modules. Fixes eclipse-dirigible#7223 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cause
The rule that a BPMN
JavaDelegatemust not be annotated@Componentwas documented in four places (.claude/docs/client-java.md,engine-java/CLAUDE.md, the two assistant guides, and a scaffold stub comment) but nothing in the runtime enforced, warned about, or even noticed a violation. After #7189 the old symptom - injected fields readingnullat runtime - is gone, because both the container-built singleton and the Flowable-built instance are now wired. So a developer had no signal at all: an annotated delegate silently becomes a registered bean nobody runs, and a stray candidate for everyList<JavaDelegate>injection.Change
ComponentContainer.createUnmanagednow emits oneLOGGER.warnnaming the class and the rule when the delegate type is a bean, making the violation observable at the moment it happens. A unit test asserts the warn fires.ComponentContainerUnmanagedTest.an_unsatisfied_dependency_is_refused_and_is_not_a_rebuild_errorbuilt the container from no classes, so itswiringErrors().isEmpty()assertion was trivially true whatevercreateUnmanageddid; it now builds with a registered bean and a delegate needing an absent type, so the "not a rebuild error" half is load-bearing.DirigibleJavaCallDelegate: the fallback instantiation error no longer advises "or declare the collaborators it injects as @component" - that branch is reached only when the class declares no injection point, so the advice can never apply; reverted to the plain message the camel sibling (DirigibleJavaInvokerImpl) already uses. Its class javadoc now lists@PostConstructalongside constructor and@Injectfield as an injection point (all three are counted bydeclaresInjectionPoint/ClientBeanFactory).ComponentContainer/JavaLoaderjavadoc no longer list@Extensionamong the consumers - the SDK has no such annotation (sdk/component/holds onlyBeans,Component,Inject,Repository).The documented rule itself is correct and unchanged; this PR only makes it observable and corrects the stale text from #7189.
Verification
mvn formatter:validateafter wiping the formatter cache - BUILD SUCCESS.ComponentContainerUnmanagedTest).JavaDelegateInjectionIT- green (3/3); confirms both delegate paths still wire and the unsatisfiable-dependency step still dead-letters rather than failing the deployment.Not run: the full IT suite (unchanged runtime behaviour beyond a log line and text; CI covers it).
Fixes #7223