-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WINDUPRULE-920] Jakarta Faces rule (#894)
* [WINDUPRULE-920] Jakarta Faces rule * [WINDUPRULE-920] Make rule potential * [WINDUPRULE-920] Add iterable-filter
- Loading branch information
Showing
4 changed files
with
85 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="jakarta-faces" | ||
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 provides analysis of Java EE applications that need to change certain Jakarta Faces usages when migrating to EAP 8. | ||
</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" /> | ||
</dependencies> | ||
<sourceTechnology id="eap" versionRange="[6,8)" /> | ||
<targetTechnology id="eap" versionRange="[8,9)" /> | ||
<tag>JakartaEE</tag> | ||
<tag>eap8</tag> | ||
</metadata> | ||
<rules> | ||
<rule id="jakarta-faces-00001"> | ||
<when> | ||
<and> | ||
<javaclass references="jakarta.faces.context.FacesContext"> | ||
<location>FIELD_DECLARATION</location> | ||
<annotation-type pattern="jakarta.inject.Inject"/> | ||
</javaclass> | ||
<javaclass references="jakarta.faces.context.FacesContext"> | ||
<location>RETURN_TYPE</location> | ||
</javaclass> | ||
</and> | ||
</when> | ||
<perform> | ||
<hint title="Producer for creating FacesContext must be removed" effort="1" category-id="potential"> | ||
<message>The @Producer for instantiating `FacesContext` is not necessary anymore, as CDI injection for `FacesContext` works out of the box.</message> | ||
<link href="https://access.redhat.com/solutions/6982900" title="WELD-001409: Ambiguous dependencies for type FacesContext with qualifiers @Default when migrating to EAP 8"/> | ||
</hint> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> |
11 changes: 11 additions & 0 deletions
11
rules/rules-reviewed/eap8/eap7/tests/data/jakarta-faces/JSFBean.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,11 @@ | ||
import jakarta.inject.Inject; | ||
import jakarta.faces.context.FacesContext; | ||
import jakarta.enterprise.inject.Model; | ||
|
||
@Model | ||
public class JSFBean { | ||
|
||
@Inject | ||
FacesContext ctx; | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
rules/rules-reviewed/eap8/eap7/tests/data/jakarta-faces/Producer.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,11 @@ | ||
import jakarta.faces.context.FacesContext; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.enterprise.context.RequestScoped; | ||
|
||
public class Producer { | ||
@Produces | ||
@RequestScoped | ||
public FacesContext produceFacesContext() { | ||
return FacesContext.getCurrentInstance(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
rules/rules-reviewed/eap8/eap7/tests/jakarta-faces.windup.test.xml
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,24 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="jakarta-faces-tests" | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" | ||
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"> | ||
<testDataPath>data/jakarta-faces</testDataPath> | ||
<rulePath>../jakarta-faces.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="jakarta-faces-00001-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="2"> | ||
<hint-exists message="The @Producer for instantiating `FacesContext` is not necessary anymore, as CDI injection for `FacesContext` works out of the box."/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[jakarta-faces-00001] The hint was not found!"/> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |