-
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.
Detects Java SE Threads usage (#794)
* Java SE Threads * Adds executor service
- Loading branch information
Showing
5 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
rules/rules-reviewed/technology-usage/javase-technology-usage.windup.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,30 @@ | ||
<?xml version="1.0"?> | ||
<ruleset id="technology-usage-javase" 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"> | ||
<metadata> | ||
<description> | ||
This ruleset provides statistical summaries of the Java SE APIs. | ||
</description> | ||
<dependencies> | ||
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final" /> | ||
</dependencies> | ||
<phase>PostMigrationRulesPhase</phase> | ||
</metadata> | ||
<rules> | ||
<!-- Threads --> | ||
<rule id="javase-technology-usage-01000"> | ||
<when> | ||
<graph-query discriminator="TechnologyTagModel"> | ||
<property name="name">Java Threads</property> | ||
</graph-query> | ||
</when> | ||
<perform> | ||
<technology-identified name="Java Threads"> | ||
<tag name="Execute"/> | ||
<tag name="Processing"/> | ||
<tag name="Java EE"/> | ||
</technology-identified> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> |
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,44 @@ | ||
<?xml version="1.0"?> | ||
<ruleset | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="javase" | ||
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 the Core Java SE APIs. | ||
</description> | ||
<dependencies> | ||
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final"/> | ||
</dependencies> | ||
</metadata> | ||
<rules> | ||
<!-- Threads --> | ||
<rule id="javase-01000"> | ||
<when> | ||
<javaclass references="java.lang.{classes}"/> | ||
</when> | ||
<perform> | ||
<classification title="Threads" category-id="information" effort="0"> | ||
<description>The application uses Thread APIs.</description> | ||
</classification> | ||
<technology-tag level="INFORMATIONAL">Java Threads</technology-tag> | ||
</perform> | ||
<where param="classes"> | ||
<matches pattern="(Thread|ThreadDeath|ThreadGroup|ThreadLocal|Runnable)"/> | ||
</where> | ||
</rule> | ||
<rule id="javase-01100"> | ||
<when> | ||
<javaclass references="java.util.concurrent.{classes}"/> | ||
</when> | ||
<perform> | ||
<classification title="Threads" category-id="information" effort="0"> | ||
<description>The application uses Concurrent Executors APIs.</description> | ||
</classification> | ||
<technology-tag level="INFORMATIONAL">Java Threads</technology-tag> | ||
</perform> | ||
<where param="classes"> | ||
<matches pattern="(ExecutorService|Executors|Executor|ScheduledExecutorService)"/> | ||
</where> | ||
</rule> | ||
</rules> | ||
</ruleset> |
9 changes: 9 additions & 0 deletions
9
rules/rules-reviewed/technology-usage/tests/data/javase/JavaSEExecutor.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,9 @@ | ||
package com.jboss.windup.test; | ||
|
||
import java.util.concurrent.Executor; | ||
|
||
public class Main implements Executor { | ||
public void execute(Runnable r) { | ||
r.run(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
rules/rules-reviewed/technology-usage/tests/data/javase/JavaSEThread.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,15 @@ | ||
package com.jboss.windup.test; | ||
|
||
public class Main extends Thread { | ||
|
||
public static void main(String[] args) { | ||
|
||
Main thread = new Main(); | ||
thread.start(); | ||
System.out.println("The thread inside the main method!!!"); | ||
} | ||
|
||
public void run() { | ||
System.out.println("The thread outside the main method!!"); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
rules/rules-reviewed/technology-usage/tests/javase-technology-usage.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="technology-usage-javase-test" xmlns="http://windup.jboss.org/schema/jboss-ruleset"> | ||
<testDataPath>data/javase/</testDataPath> | ||
<rulePath>../javase.windup.xml</rulePath> | ||
<rulePath>../javase-technology-usage.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="javase-technology-usage-01000-test"> | ||
<when> | ||
<not> | ||
<technology-statistics-exists name="Java Threads" number-found="1"> | ||
<tag name="Execute"/> | ||
<tag name="Processing"/> | ||
<tag name="Java EE"/> | ||
</technology-statistics-exists> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="Java Threads Not Found" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |