Skip to content

Conversation

karthikNousher
Copy link
Contributor

@karthikNousher karthikNousher commented Jun 17, 2025

What's changed?

  • Added a xml scanning to detect the session beans and also apply the recipe to those classes.
  • Recipe now updates the classes that are specified in the ejb-jar.xml file
  • Added new test case to test the xml scanning functionality.

What's your motivation?

  • To create a recipe that can not only be used to add a static variable to session beans annotated with @Stateless, @Stateful, or @Singleton, but also to those defined in the xml file.

Any additional context

  • Extended the recipe to scan ejb-jar.xml for session bean definitions and incorporate these beans in the recipe processing.
  • This way it allows the recipe to apply changes to classes that does not have @Stateless, @Stateful, or @Singleton
    annotation but are specified as session beans in the XML configuration.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jun 17, 2025
@karthikNousher karthikNousher marked this pull request as ready for review June 18, 2025 13:29
@rlsanders4 rlsanders4 marked this pull request as draft June 18, 2025 14:04
@rlsanders4
Copy link
Contributor

@timtebeek Could we also get @karthikNousher added to the IBM team? Thanks!
https://github.com/orgs/openrewrite/teams/ibm

@rlsanders4 rlsanders4 self-requested a review June 18, 2025 19:34
Copy link
Contributor

@rlsanders4 rlsanders4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Karthik, could you look though my comments from the last review? Several did not get addressed, such as:

  • Using a Set instead of a Map as the accumulator
  • Checking for ejb-jar.xml in a precondition for the scanner (this is more efficient than visitDocument)
  • Ensuring that the scanner is only executing on tags with this path ejb-jar/enterprise-beans/session

Copy link
Contributor

@rlsanders4 rlsanders4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I think you are ready to have someone from the OpenRewrite team take a look.

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Jun 20, 2025
@rlsanders4 rlsanders4 marked this pull request as ready for review June 20, 2025 15:32
@rlsanders4 rlsanders4 changed the title added a new xml scanner Update AddStaticVariableOnProducerSessionBean to modify XML defined EJBs Jun 20, 2025
@karthikNousher karthikNousher removed the status in OpenRewrite Jun 20, 2025
@karthikNousher karthikNousher requested a review from timtebeek June 20, 2025 16:06
@rlsanders4 rlsanders4 moved this to Ready to Review in OpenRewrite Jun 20, 2025
@timtebeek timtebeek merged commit f32db12 into openrewrite:main Jun 24, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Jun 24, 2025
@timtebeek
Copy link
Member

Thanks both! Neat addition to cover these cases as well, and perfect use of a ScanningRecipe to do so.

Comment on lines +24 to 25
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.Space;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.Space;
import org.openrewrite.java.tree.Space;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants