-
Notifications
You must be signed in to change notification settings - Fork 101
Add recipe to replace ManagedBean with Named annotation #753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/test/java/org/openrewrite/java/migrate/jakarta/UpdateManagedBeanToNamedTest.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/jakarta/UpdateManagedBeanToNamedTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple quick comments; great to see already! Ought to be quick to address and then merge.
src/main/java/org/openrewrite/java/migrate/jakarta/UpdateManagedBeanToNamed.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/jakarta/UpdateManagedBeanToNamed.java
Outdated
Show resolved
Hide resolved
maybeRemoveImport("javax.faces.bean.ManagedBean"); | ||
maybeRemoveImport("jakarta.faces.bean.ManagedBean"); | ||
} | ||
return annotation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's any chance of these appearing in nested annotations, then it might make sense to call super.visitAnnotation
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's any chance of nested annotations here.
src/main/java/org/openrewrite/java/migrate/jakarta/UpdateManagedBeanToNamed.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/jakarta/UpdateManagedBeanToNamed.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/jakarta/UpdateManagedBeanToNamedTest.java
Outdated
Show resolved
Hide resolved
Review suggestions Co-authored-by: Tim te Beek <tim@moderne.io>
src/test/java/org/openrewrite/java/migrate/jakarta/UpdateManagedBeanToNamedTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/jakarta/UpdateManagedBeanToNamed.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fixes!
Should org.openrewrite.java.migrate.jakartaUpdateManagedBeanToNamed
be added to any larger declarative migration recipe before we merge?
Yes, it would for sure be in the EE10/Faces 4.x migration, where ManagedBean is removed. It could be called manually for EE9/Faces 3.0. But I am wondering if it should also be available to run in EE8/Faces 2.3 where ManagedBean was already deprecated in favor of CDI. The recipe would have to change slightly to allow migrating to the javax inject |
Thanks for that context! Maybe best to for now add it to EE9 then? Optional to also add it to EE8, but I imagine that'd need a different |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again!
Just to clarify the final decision:
The managed bean migration recipe can still be invoked separately for anyone on EE9 wanting to get off the deprecated package. |
What's changed?
New recipe to migrate
@ManagedBean
from JSF/Jakarta Faces to the recommended CDI-based approach using@jakarta.inject.Named
What's your motivation?
ManagedBean is removed from EE10/Faces 4.0, and the existing recipe doesn't migrate the
@ManagedBean
annotation.It seems using the CDI
@Named
is the general approach to replacing@ManagedBean
.Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
This current recipe converts both javax and jakarta ManagedBean to the jakarta CDI Named annotation, making this appropriate for EE9/10 migration, but not for EE8 users wanting to switch to CDI.
Should this be made more flexible to maintain either
javax
orjakarta
based on the original code?Checklist