<?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="weblogic-services-eap7"
    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 contains rules to detect WebLogic specific services code (eg, startup listeners, and access to WebLogic specific service lookup utilities),
            and to assist in the conversion of this code to code that is compatible with JBoss EAP 7+.
        </description>
        <dependencies>
            <addon id="org.jboss.windup.rules,windup-rules-javaee,2.7.0.Final"/>
            <addon id="org.jboss.windup.rules,windup-rules-java,2.7.0.Final"/>
        </dependencies>
        <sourceTechnology id="weblogic"/>
        <targetTechnology id="eap" versionRange="[7,8)"/>
        <tag>weblogic</tag>
    </metadata>

    <rules>
        <rule id="weblogic-services-eap7-01000">
            <when>
                <javaclass references="weblogic.common.T3StartupDef">
                    <location>IMPLEMENTS_TYPE</location>
                </javaclass>
            </when>
            <perform>
                <hint title="WebLogic Startup Service" effort="3" category-id="mandatory">
                    <message>Replace this class with a class using the EJB 3.2 `@Singleton` and `@Startup` annotations.</message>
                    <link href="http://docs.oracle.com/javaee/7/api/javax/ejb/Singleton.html" title="EJB 3.2 Singleton Bean"/>
                    <link href="http://docs.oracle.com/javaee/7/api/javax/ejb/Startup.html" title="EJB 3.2 Startup Bean"/>
                    <tag>startup</tag>
                    <tag>weblogic</tag>
                </hint>
            </perform>
        </rule>
        <rule id="weblogic-services-eap7-02000">
            <when>
                <javaclass references="weblogic.common.T3ServicesDef"/>
            </when>
            <perform>
                <hint title="WebLogic T3ServicesDef usage" effort="3" category-id="mandatory">
                    <message>
                      <![CDATA[
                      `T3ServicesDef` provides access to core services of the container, such as Timers and Logging facilities.

                      Replace the services provided by this with a Singleton EJB (using the `@Singleton` annotation) that provides access to the equivalent services from JBoss EAP.
                      ]]>
                    </message>
                    <link href="https://docs.oracle.com/javaee/7/tutorial/ejb-intro002.htm#GIPIM" title="Java EE Tutorial - @Singleton Session Bean"/>
                    <tag>webservice</tag>
                    <tag>weblogic</tag>
                </hint>
            </perform>
        </rule>
        <rule id="weblogic-services-eap7-03000">
            <when>
               <javaclass references="weblogic.{logger}{*}"/>
            </when>
            <perform>
                <hint title="WebLogic proprietary logging classes" effort="1" category-id="mandatory">
                    <message>
                      <![CDATA[
                      Oracle WebLogic logging classes should be replaced with SLF4J, Log4J, or Java Logging.

                      Please refer to the [JBoss EAP 7 Development guide](https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html-single/development_guide/#logging) for more information on this.
                      ]]>
                    </message>
                    <link href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html-single/development_guide/#logging" title="JBoss EAP 7 Development Guide - Logging"/>
                    <tag>logging</tag>
                    <tag>weblogic</tag>
                </hint>
            </perform>
            <where param="logger">
               <!--This excludes classes starting with N like i18n.logging.NonCatalogLogger-->
                <matches pattern="(i18n.)?logging.[^N]"/>
            </where>
        </rule>
    </rules>
</ruleset>
