<commit_before><?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="environment-dependent-calls"
    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 generic rules that should match when migrating from different server
            to JBoss EAP 6+.
        </description>
        <dependencies>
            <addon id="org.jboss.windup.rules,windup-rules-javaee,2.3.0.Final" />
            <addon id="org.jboss.windup.rules,windup-rules-java,2.3.0.Final" />
        </dependencies>
        <targetTechnology id="eap" versionRange="[6,8)" />
        <targetTechnology id="java-ee" versionRange="[6,)" />
    </metadata>
    <rules>
        <rule id="environment-dependent-calls-01000">
            <when>
                <javaclass references="java.lang.Class.forName({*}">
                    <location>METHOD_CALL</location>
                </javaclass>
            </when>
            <perform>
                 <hint title="Dynamic class instantiation" effort="0" category-id="optional">
                     <message>
                       <![CDATA[
                       The class is dynamically loaded within application. During the migration, multiple classes that are provided on classpath by a different server may not be present anymore.

                       Please review the class-loading mechanisms and ensure that the dynamically loaded class is available in JBoss EAP.
                       ]]>
                     </message>
                     <link title="Class Loading and Modules in JBoss EAP 7" href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html-single/development_guide/#class_loading_and_modules"/>
                     <link title="Class Loading and Modules in JBoss EAP 6" href="https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html-single/Development_Guide/index.html#chap-Class_Loading_and_Modules"/>
                     <link title="Article about Classloading in JBoss EAP 6" href="https://access.redhat.com/solutions/361343" />
                     <tag>classloader</tag>
                 </hint>
            </perform>
        </rule>
        <rule id="environment-dependent-calls-02000">
            <when>
                <javaclass references="javax.naming.Context.lookup{*}" as="default">
                    <location>METHOD_CALL</location>
                </javaclass>
            </when>
            <perform>
                <iteration>
                    <hint title="Call of JNDI lookup" effort="1" category-id="mandatory">
                        <message>
                           <![CDATA[
                           This method lookups an object using a JNDI String. During the migration process, some entity JNDI bindings may change.
                           Ensure that the JNDI Name does not need to change for JBoss.

                           *For Example:*

                           ```java
                           (ConnectionFactory)initialContext.lookup("weblogic.jms.ConnectionFactory");
                           ```

                           *should become:*

                           ```java
                           (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
                           ```
                           ]]>
                        </message>
                        <link title="JBoss JNDI Reference" href="https://docs.jboss.org/author/display/AS71/JNDI+Reference" />
                        <tag>jndi</tag>
                    </hint>
                </iteration>
            </perform>
        </rule>
        <rule id="environment-dependent-calls-03000">
            <when>
                <javaclass references="javax.naming.InitialContext(java.util.Hashtable{*}" as="default">
                    <location>CONSTRUCTOR_CALL</location>
                </javaclass>
            </when>
            <perform>
                <iteration>
                    <hint title="Proprietary InitialContext initialization" effort="1" category-id="mandatory">
                    <message>
                      <![CDATA[
                      In JBoss EAP, the `InitialContext` should be instantiated with no arguments. Once an instance is constructed, look up the service using portable JNDI lookup syntax. Ensure also that in case system properties for `InitialContext` are provided, they do not need to be changed for the JBoss.

                      ```java
                      InitialContext context = new InitialContext();
                      Service service = (Service) context.lookup( "java:app/service/" + ServiceImpl.class.getSimpleName() );
                      ```
                      ]]>
                    </message>
                    <link href="https://access.redhat.com/articles/1496973" title="Migrate Applications From Other Platforms to Use Portable JNDI Syntax in Red Hat JBoss Enterprise Application Platform" />
                    <tag>jndi</tag>
                    </hint>
                </iteration>
            </perform>
        </rule>
        <rule id="environment-dependent-calls-03500">
            <when>
                <file filename="jndi.properties" as="default"/>
            </when>
            <perform>
                <iteration>
                    <classification issue-display-mode="all" title="JNDI properties file" category-id="mandatory" effort="1">
                        <description>
                          <![CDATA[
                          The JNDI automatically reads the application resource files from all components in the applications' classpaths.
                          The JNDI then makes the properties from these files available to the service providers.

                          Please ensure the property values listed in this file are available to JBoss.
                          ]]>
                        </description>
                        <tag>webservice</tag>
                    </classification>
                </iteration>
            </perform>
        </rule>
        <rule id="environment-dependent-calls-04000">
        <!--could also check JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES in the provided hash map-->
            <when>
                <javaclass references="javax.management.{suffix}{*}" as="default">
                    <location>CONSTRUCTOR_CALL</location>
                </javaclass>
            </when>
            <perform>
                <iteration>
                    <hint title="JMX MBean object name (javax.management.{suffix})" effort="1" category-id="mandatory">
                        <message>
                          <![CDATA[
                          After migration, some of the JMX beans provided by the previous server may not be present anymore.
                          Ensure that the `javax.management.{suffix}` does not need to change for JBoss.
                          ]]>
                        </message>
                        <tag>jmx</tag>
                    </hint>
                </iteration>
            </perform>
            <where param="suffix">
                <matches pattern="(ObjectName)" />
            </where>
        </rule>
        <rule id="environment-dependent-calls-04001">
            <!--could also check JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES in the provided hash map-->
            <when>
                <javaclass references="javax.management.{suffix}{*}" as="default">
                    <location>CONSTRUCTOR_CALL</location>
                </javaclass>
            </when>
            <perform>
                <iteration>
                    <hint title="JMX API connector server address (javax.management.{suffix})" effort="1" category-id="mandatory">
                        <message>
                            <![CDATA[
                          After migration, some of the JMX beans provided by the previous server may not be present anymore.
                          Ensure that the `javax.management.{suffix}` does not need to change for JBoss.
                          ]]>
                        </message>
                        <tag>jmx</tag><commit_msg>WINDUPRULE-324 Rewording of a Rule to reference EAP (#291)<commit_after><?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="environment-dependent-calls"
    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 generic rules that should match when migrating from different server
            to JBoss EAP 6+.
        </description>
        <dependencies>
            <addon id="org.jboss.windup.rules,windup-rules-javaee,2.3.0.Final" />
            <addon id="org.jboss.windup.rules,windup-rules-java,2.3.0.Final" />
        </dependencies>
        <targetTechnology id="eap" versionRange="[6,8)" />
        <targetTechnology id="java-ee" versionRange="[6,)" />
    </metadata>
    <rules>
        <rule id="environment-dependent-calls-01000">
            <when>
                <javaclass references="java.lang.Class.forName({*}">
                    <location>METHOD_CALL</location>
                </javaclass>
            </when>
            <perform>
                 <hint title="Dynamic class instantiation" effort="0" category-id="optional">
                     <message>
                       <![CDATA[
                       The class is dynamically loaded within application. During the migration, multiple classes that are provided on classpath by a different server may not be present anymore.

                       Please review the class-loading mechanisms and ensure that the dynamically loaded class is available in JBoss EAP.
                       ]]>
                     </message>
                     <link title="Class Loading and Modules in JBoss EAP 7" href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html-single/development_guide/#class_loading_and_modules"/>
                     <link title="Class Loading and Modules in JBoss EAP 6" href="https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html-single/Development_Guide/index.html#chap-Class_Loading_and_Modules"/>
                     <link title="Article about Classloading in JBoss EAP 6" href="https://access.redhat.com/solutions/361343" />
                     <tag>classloader</tag>
                 </hint>
            </perform>
        </rule>
        <rule id="environment-dependent-calls-02000">
            <when>
                <javaclass references="javax.naming.Context.lookup{*}" as="default">
                    <location>METHOD_CALL</location>
                </javaclass>
            </when>
            <perform>
                <iteration>
                    <hint title="Call of JNDI lookup" effort="1" category-id="mandatory">
                        <message>
                           <![CDATA[
                           This method lookups an object using a JNDI String. During the migration process, some entity JNDI bindings may change.
                           Ensure that the JNDI Name does not need to change for JBoss.

                           *For Example:*

                           ```java
                           (ConnectionFactory)initialContext.lookup("weblogic.jms.ConnectionFactory");
                           ```

                           *should become:*

                           ```java
                           (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
                           ```
                           ]]>
                        </message>
                        <link title="JBoss JNDI Reference" href="https://docs.jboss.org/author/display/AS71/JNDI+Reference" />
                        <tag>jndi</tag>
                    </hint>
                </iteration>
            </perform>
        </rule>
        <rule id="environment-dependent-calls-03000">
            <when>
                <javaclass references="javax.naming.InitialContext(java.util.Hashtable{*}" as="default">
                    <location>CONSTRUCTOR_CALL</location>
                </javaclass>
            </when>
            <perform>
                <iteration>
                    <hint title="Proprietary InitialContext initialization" effort="1" category-id="mandatory">
                    <message>
                      <![CDATA[
                      In JBoss EAP, the `InitialContext` should be instantiated with no arguments. Once an instance is constructed, look up the service using portable JNDI lookup syntax. Ensure also that in case system properties for `InitialContext` are provided, they do not need to be changed for the JBoss.

                      ```java
                      InitialContext context = new InitialContext();
                      Service service = (Service) context.lookup( "java:app/service/" + ServiceImpl.class.getSimpleName() );
                      ```
                      ]]>
                    </message>
                    <link href="https://access.redhat.com/articles/1496973" title="Migrate Applications From Other Platforms to Use Portable JNDI Syntax in Red Hat JBoss Enterprise Application Platform" />
                    <tag>jndi</tag>
                    </hint>
                </iteration>
            </perform>
        </rule>
        <rule id="environment-dependent-calls-03500">
            <when>
                <file filename="jndi.properties" as="default"/>
            </when>
            <perform>
                <iteration>
                    <classification issue-display-mode="all" title="JNDI properties file" category-id="mandatory" effort="1">
                        <description>
                          <![CDATA[
                          The JNDI automatically reads the application resource files from all components in the applications' classpaths.
                          The JNDI then makes the properties from these files available to the service providers.

                          Please ensure the property values listed in this file are available to JBoss.
                          ]]>
                        </description>
                        <tag>webservice</tag>
                    </classification>
                </iteration>
            </perform>
        </rule>
        <rule id="environment-dependent-calls-04000">
        <!--could also check JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES in the provided hash map-->
            <when>
                <javaclass references="javax.management.{suffix}{*}" as="default">
                    <location>CONSTRUCTOR_CALL</location>
                </javaclass>
            </when>
            <perform>
                <iteration>
                    <hint title="JMX MBean object name (javax.management.{suffix})" effort="1" category-id="mandatory">
                        <message>
                          <![CDATA[
                          After migration, some of the JMX beans provided by the previous server may not be present anymore.
                          Ensure that the `javax.management.{suffix}` does not need to change for EAP.
                          ]]>
                        </message>
                        <tag>jmx</tag>
                    </hint>
                </iteration>
            </perform>
            <where param="suffix">
                <matches pattern="(ObjectName)" />
            </where>
        </rule>
        <rule id="environment-dependent-calls-04001">
            <!--could also check JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES in the provided hash map-->
            <when>
                <javaclass references="javax.management.{suffix}{*}" as="default">
                    <location>CONSTRUCTOR_CALL</location>
                </javaclass>
            </when>
            <perform>
                <iteration>
                    <hint title="JMX API connector server address (javax.management.{suffix})" effort="1" category-id="mandatory">
                        <message>
                            <![CDATA[
                          After migration, some of the JMX beans provided by the previous server may not be present anymore.
                          Ensure that the `javax.management.{suffix}` does not need to change for JBoss.
                          ]]>
                        </message>
                        <tag>jmx</tag>
{'fraction_non_alphanumeric': 0.10088108331855006, 'fraction_numerical': 0.009224764945893206, 'mean_word_length': 1.4958677685950412, 'pattern_counts': {'":': 0, '<': 259, '<?xml version=': 2, '>': 259, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2769464', 'n_tokens_mistral': 4313, 'n_tokens_neox': 4009, 'n_words': 1013}