Skip to content
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

[WINDUPRULE-1048] JSF to Qute rules #1062

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 143 additions & 13 deletions rules/rules-reviewed/quarkus/java-ee/cdi-to-quarkus.windup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,150 @@
<!-- explain beans.xml descriptor content is ignored -->
<rule id="cdi-to-quarkus-00030">
<when>
<xmlfile in="beans.xml" matches="/b:beans" as="root">
<namespace prefix="b" uri="http://xmlns.jcp.org/xml/ns/javaee" />
</xmlfile>
<or>
<xmlfile in="beans.xml" matches="/b:beans">
<namespace prefix="b" uri="http://xmlns.jcp.org/xml/ns/javaee" />
</xmlfile>
<xmlfile in="beans.xml" matches="/b:beans">
<namespace prefix="b" uri="https://jakarta.ee/xml/ns/jakartaee" />
</xmlfile>
</or>
</when>
<perform>
<iteration over="root">
<hint title="`beans.xml` descriptor content is ignored" effort="3" category-id="potential">
<message>
`beans.xml` descriptor content is ignored and it could be removed from the application.
Refer to the guide referenced below to check the supported CDI feature in Quarkus.
</message>
<link title="Quarkus - Guide" href="https://quarkus.io/guides/cdi-reference#limitations" />
</hint>
</iteration>
<hint title="`beans.xml` descriptor content is ignored" effort="1" category-id="optional">
<message>
`beans.xml` descriptor content is ignored by Quarkus and can be removed from the application.
Refer to the guide referenced below to check the supported CDI feature in Quarkus.
</message>
<link title="Quarkus - CDI reference - Bean discovery" href="https://quarkus.io/guides/cdi-reference#bean_discovery" />
</hint>
</perform>
</rule>
<rule id="cdi-to-quarkus-00031">
<when>
<or>
<xmlfile in="beans.xml" matches="/b:beans/b:interceptors">
<namespace prefix="b" uri="http://xmlns.jcp.org/xml/ns/javaee" />
</xmlfile>
<xmlfile in="beans.xml" matches="/b:beans/b:interceptors">
<namespace prefix="b" uri="https://jakarta.ee/xml/ns/jakartaee" />
</xmlfile>
</or>
</when>
<perform>
<hint title="Annotate Interceptor classes" effort="1" category-id="mandatory">
<message>
<![CDATA[
`beans.xml` descriptor content is ignored, and therefore interceptor beans must
directly be annotated with `@Interceptor` instead, so a beans.xml configuration like:
```
<interceptors>
<class>com.acme.intercept.TransactionInterceptor</class>
</interceptors>
```
would turn into:
```
@Interceptor
public class TransactionInterceptor { ... }
```
]]>
</message>
<link title="Quarkus - CDI reference - Bean discovery" href="https://quarkus.io/guides/cdi-reference#bean_discovery" />
</hint>
</perform>
</rule>
<rule id="cdi-to-quarkus-00032">
<when>
<or>
<xmlfile in="beans.xml" matches="/b:beans/b:decorators">
<namespace prefix="b" uri="http://xmlns.jcp.org/xml/ns/javaee" />
</xmlfile>
<xmlfile in="beans.xml" matches="/b:beans/b:decorators">
<namespace prefix="b" uri="https://jakarta.ee/xml/ns/jakartaee" />
</xmlfile>
</or>
</when>
<perform>
<hint title="Annotate Decorator classes" effort="1" category-id="mandatory">
<message>
<![CDATA[
`beans.xml` descriptor content is ignored, and therefore decorator beans must
directly be annotated with `@Interceptor` instead, so a beans.xml configuration like:
```
<decorators>
<class>com.acme.decorate.BigAccountDecorator</class>
</decorators>
```
would turn into:
```
@Decorator
public class BigAccountDecorator { ... }
```
]]>
</message>
<link title="Quarkus - CDI reference - Bean discovery" href="https://quarkus.io/guides/cdi-reference#bean_discovery" />
</hint>
</perform>
</rule>
<rule id="cdi-to-quarkus-00033">
<when>
<or>
<xmlfile in="beans.xml" matches="/b:beans/b:stereotypes">
<namespace prefix="b" uri="http://xmlns.jcp.org/xml/ns/javaee" />
</xmlfile>
<xmlfile in="beans.xml" matches="/b:beans/b:stereotypes">
<namespace prefix="b" uri="https://jakarta.ee/xml/ns/jakartaee" />
</xmlfile>
</or>
</when>
<perform>
<!-- TODO: check out how exactly alternatives/stereotypes work -->
<hint title="Annotate Stereotype classes" effort="1" category-id="mandatory">
<message>
<![CDATA[
`beans.xml` descriptor content is ignored, and therefore stereotype beans must
directly be annotated with `@Stereotype` instead, so a beans.xml configuration like:
```
<stereotypes>
<class>com.acme.decorate.BigAccountDecorator</class>
</stereotypes>
```
would turn into:
```
@Decorator
public class BigAccountDecorator { ... }
```
]]>
</message>
<link title="Quarkus - CDI reference - Bean discovery" href="https://quarkus.io/guides/cdi-reference#bean_discovery" />
</hint>
</perform>
</rule>
<rule id="cdi-to-quarkus-00034">
<when>
<or>
<xmlfile in="beans.xml" matches="/b:beans[@bean-discovery-mode = 'all' or @bean-discovery-mode = 'none']">
<namespace prefix="b" uri="http://xmlns.jcp.org/xml/ns/javaee" />
</xmlfile>
<xmlfile in="beans.xml" matches="/b:beans[@bean-discovery-mode = 'all' or @bean-discovery-mode = 'none']">
<namespace prefix="b" uri="https://jakarta.ee/xml/ns/jakartaee" />
</xmlfile>
</or>
</when>
<perform>
<hint title="`beans.xml` discovery mode must be taken into account" effort="1" category-id="optional">
<message>
`beans.xml` descriptor content is ignored by Quarkus. The `bean-discovery-mode` attribute must be
taken into account when migrating to Quarkus in the following manner:
- ANNOTATED: no change in annotations; this is Quarkus' default (only pick up beans with bean-discovery annotations)
- ALL: all classes with bean-defining annotations are picked up, but also any class that meets the requirements
for a managed bean is picked up and given the default `@Dependent` scope (see links below)

Refer to the guide referenced below to check the supported CDI feature in Quarkus.
</message>
<link title="Quarkus - CDI reference - Bean discovery" href="https://quarkus.io/guides/cdi-reference#bean_discovery" />
<link title="JavaEE tutorial: About CDI Managed Beans" href="https://docs.oracle.com/javaee/7/tutorial/cdi-basic004.htm" />
</hint>
</perform>
</rule>
<rule id="cdi-to-quarkus-00040">
Expand All @@ -72,7 +202,7 @@
</when>
<perform>
<hint title="Producer annotation no longer required" effort="1" category-id="potential">
<message>In Quarkus, you can skip the @Produces annotation completely if the producer method is annotated with a scope annotation, a stereotype or a qualifier..
<message>In Quarkus, you can skip the @Produces annotation completely if the producer method is annotated with a scope annotation, a stereotype or a qualifier.
This field could be accessed using a `@Named` getter method instead.
</message>
<link title="Quarkus Simplified Producer Method Declaration" href="https://quarkus.io/guides/cdi-reference#simplified-producer-method-declaration"/>
Expand Down
85 changes: 85 additions & 0 deletions rules/rules-reviewed/quarkus/java-ee/ee-to-quarkus.windup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="ee-to-quarkus"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<metadata>
<description>
This ruleset gives hints to migrate different EE related technologies (ie, EJB) to Quarkus. Applies for both javax and jakarta namespaces.
</description>
<dependencies>
<addon id="org.jboss.windup.rules,windup-rules-javaee,3.0.0.Final" />
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final" />
<addon id="org.jboss.windup.rules,windup-rules-xml,3.0.0.Final" />
</dependencies>
<sourceTechnology id="java-ee" />
<sourceTechnology id="jakarta-ee" />
<targetTechnology id="quarkus" />
</metadata>
<rules>
<rule id="ee-to-quarkus-00000">
<when>
<or>
<javaclass references="javax.ejb.Stateless">
<location>ANNOTATION</location>
</javaclass>
<javaclass references="jakarta.ejb.Stateless">
<location>ANNOTATION</location>
</javaclass>
</or>
</when>
<perform>
<hint title="@Stateless annotation must be replaced" effort="1" category-id="potential">
<message>Stateless EJBs can be converted to a CDI bean by replacing the `@Stateless` annotation with a scope eg `@ApplicationScoped`</message>
<link title="Quarkus CDI reference" href="https://quarkus.io/guides/cdi-reference"/>
</hint>
</perform>
</rule>
<rule id="ee-to-quarkus-00010">
<when>
<or>
<javaclass references="javax.ejb.Stateful">
<location>ANNOTATION</location>
</javaclass>
<javaclass references="jakarta.ejb.Stateful">
<location>ANNOTATION</location>
</javaclass>
</or>
</when>
<perform>
<hint title="@Stateful annotation must be replaced" effort="3" category-id="mandatory">
<message>
Stateful EJBs can be converted to a CDI bean by replacing the `@Stateful` annotation with a bean-defining annotation
that encompasses the appropriate scope (e.g., `@ApplicationScoped`). `@Stateful` EJBs often translate to `@SessionScoped`
beans (a scope which requires activating the `quarkus-undertow` extension), but the appropriate scope may differ based
on your application architecture. Review your application's requirements to determine the appropriate scope.

Note that it is recommended, as a good practice, to keep state external from the service in Quarkus.
</message>
<link title="Quarkus CDI reference" href="https://quarkus.io/guides/cdi-reference"/>
</hint>
</perform>
</rule>
<rule id="ee-to-quarkus-00020">
<when>
<or>
<javaclass references="javax.ejb.{*}">
<location>ANNOTATION</location>
</javaclass>
<javaclass references="jakarta.ejb.{*}">
<location>ANNOTATION</location>
</javaclass>
</or>
</when>
<perform>
<hint title="Method should be marked as @Transactional" effort="3" category-id="mandatory">
<message>
Any EJB method has container-manager transactions by default, with transaction attribute
`REQUIRED` as a default (a transaction is started if one is not already in progress). Methods that were part of
an EJB bean to be migrated to CDI must be annotated with `@Transactional`, or be marked as transactional
in any other way (i.e, by annotating the class).
</message>
<link title="Quarkus CDI reference" href="https://quarkus.io/guides/cdi-reference"/>
</hint>
</perform>
</rule>
</rules>
</ruleset>
Loading
Loading