All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.plugins.checkstyle.rules.config_j2ee.xml Maven / Gradle / Ivy

Go to download

This plug-in generates the trend report for Checkstyle, an open source static code analysis program.

There is a newer version: 3.12
Show newest version
<?xml version="1.0" encoding="ISO-8859-1"?>

<document>

  <properties>
    <title>J2EE Checks</title>
    <author>Checkstyle Development Team</author>
  </properties>

  <body>
    <section name="EntityBean">
      <subsection name="Description">
        <p>
          Checks that a direct entity bean, i.e. a class that directly
          implements <span class="code">javax.ejb.EntityBean</span>,
          satisfies these class requirements:
        </p>

        <ul>
          <li>
            The class is defined as <span class="code">public</span>.
          </li>
          <li>
            The class cannot be defined as <span class="code">final</span>.
          </li>
          <li>
            It contains a <span class="code">public</span> constructor with no
            parameters.
          </li>
          <li>
            It must not define the <span class="code">finalize</span> method.
          </li>
        </ul>

        <p>
          Checks that methods of a direct entity bean satisfy these
          requirements:
        </p>

        <ul>
          <li>
            All <span class="code">ejbCreate&lt;METHOD&gt;(...)</span> methods
            are <span class="code">public</span>, not <span
            class="code">final</span>, and not <span
            class="code">static</span>.
          </li>
          <li>
            The return type of all <span
            class="code">ejbCreate&lt;METHOD&gt;(...)</span> methods is not
            <span class="code">void</span>, because the return type must be
            the entity bean's primary key type.
          </li>
          <li>
            All <span class="code">ejbPostCreate&lt;METHOD&gt;(...)</span>
            methods are <span class="code">public</span>, not <span
            class="code">final</span>, and not <span
            class="code">static</span>.
          </li>
          <li>
            The return type of all <span
            class="code">ejbPostCreate&lt;METHOD&gt;(...)</span> methods is
            <span class="code">void</span>.
          </li>
          <li>
            For each <span class="code">ejbCreate&lt;METHOD&gt;(...)</span>
            method there is a matching <span
            class="code">ejbPostCreate&lt;METHOD&gt;(...)</span> method.
          </li>
          <li>
            All <span class="code">ejbHome&lt;METHOD&gt;(...)</span> methods
            are <span class="code">public</span>, and not <span
            class="code">static</span>.
          </li>
          <li>
            The throws clause of all <span
            class="code">ejbHome&lt;METHOD&gt;(...)</span> methods does not
            define the <span class="code">java.rmi.RemoteException</span>.
          </li>
        </ul>

        <p>
          When the check is configured to check direct entity beans as having
          bean-managed persistence, checks that methods satisfy these
          additional requirements:
        </p>

        <ul>
          <li>
            All <span class="code">ejbFind&lt;METHOD&gt;(...)</span> methods
            are <span class="code">public</span>, not <span
            class="code">final</span>, and not <span
            class="code">static</span>.
          </li>
          <li>
            The return type of all <span
            class="code">ejbFind&lt;METHOD&gt;(...)</span> methods is not
            <span class="code">void</span>, because the return type must be
            the entity bean's primary key type, or a collection of primary
            keys.
          </li>
          <li>
            There is a <span class="code">ejbFindByPrimaryKey</span> method
            with one parameter.
          </li>
        </ul>

        <p>
          When the check is configured to check direct entity beans as having
          container-managed persistence, checks that methods satisfy these
          additional requirements:
        </p>

        <ul>
          <li>
            The throws clause of all <span
            class="code">ejbCreate&lt;METHOD&gt;(...)</span> methods defines
            the <span class="code">javax.ejb.CreateException</span>.
          </li>
          <li>
            All <span class="code">ejbSelect&lt;METHOD&gt;(...)</span> methods
            are <span class="code">public</span> and <span
            class="code">abstract</span>.
          </li>
          <li>
            The throws clause of all <span
            class="code">ejbSelect&lt;METHOD&gt;(...)</span> methods defines
            the <span class="code">javax.ejb.FinderException</span>.
          </li>
        </ul>
      </subsection>

      <subsection name="Properties">
        <table>
          <tr>
            <th>name</th>
            <th>description</th>
            <th>type</th>
            <th>default value</th>
          </tr>
          <tr>
            <td>persistence</td>
            <td>type of persistence management</td>
            <td>
              <a href="property_types.html#persistence">persistence policy</a>
            </td>
            <td><span class="default">mixed</span></td>
          </tr>
        </table>

        <p>
          Reference: Enterprise JavaBeans&#x2122; Specification,Version 2.0,
          sections 10.6 and 12.2.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.EntityBean&quot;/&gt;
        </source>

        <p>
          To configure the check to apply the <span
          class="code">container</span> policy to direct entity beans:
        </p>
        <source>
&lt;module name=&quot;j2ee.EntityBean&quot;&gt;
    &lt;property name=&quot;persistence&quot; value=&quot;container&quot;/&gt;
&lt;/module&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="FinalStatic">
      <subsection name="Description">
        <p>
          Checks that all static fields are declared final.
        </p>

        <p>
          Rational: This check ensures consistent runtime semantics so that
          EJB containers have the flexibility to distribute instances across
          multiple JVMs.
        </p>

        <p>
          Reference: <a
          href="http://www.javaworld.com/javaworld/jw-08-2000/jw-0825-ejbrestrict.html">Programming
          restrictions on EJB</a>.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.FinalStatic&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="LocalHomeInterface">
      <subsection name="Description">
        <p>
          Checks that a direct local home interface, i.e. an interface that
          directly extends <span class="code">javax.ejb.EJBLocalHome</span>,
          satisfies these requirements:
        </p>

        <ul>
          <li>
            The return type of all <span
            class="code">create&lt;METHOD&gt;(...)</span> methods is not <span
            class="code">void</span>, because the return type must be the
            bean's local interface.
          </li>
          <li>
            The throws clause of all <span
            class="code">create&lt;METHOD&gt;(...)</span> methods defines the
            <span class="code">javax.ejb.CreateException</span>.
          </li>
          <li>
            The throws clause of all methods does not define the <span
            class="code">java.rmi.RemoteException</span>.
          </li>
        </ul>

        <p>
          Reference: Enterprise JavaBeansTM Specification,Version 2.0,
          sections 6.4 and 9.6.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.LocalHomeInterface&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="LocalInterface">
      <subsection name="Description">
        <p>
          Checks that a direct local interface, i.e. an interface that
          directly extends <span class="code">javax.ejb.EJBLocalObject</span>,
          satisfies these requirements:
        </p>

        <ul>
          <li>
            The throws clause of all methods does not define the <span
            class="code">java.rmi.RemoteException</span>.
          </li>
        </ul>

        <p>
          Reference: Enterprise JavaBeansTM Specification,Version 2.0, section
          9.10.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.LocalInterface&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="MessageBean">
      <subsection name="Description">
        <p>
          Checks that a direct message bean, i.e. a class that directly
          implements <span class="code">javax.ejb.MessageDrivenBean</span> and
          <span class="code">javax.jms.MessageListener</span>, satisfies these
          class requirements:
        </p>

        <ul>
          <li>
            The class is defined as <span class="code">public</span>.
          </li>
          <li>
            The class cannot be defined as <span class="code">final</span>.
          </li>
          <li>
            The class cannot be defined as <span class="code">abstract</span>.
          </li>
          <li>
            It contains a <span class="code">public</span> constructor with no
            parameters.
          </li>
          <li>
            It must not define the <span class="code">finalize</span> method.
          </li>
          <li>
            It defines an <span class="code">ejbCreate()</span> method this is
            <span class="code">public</span>, not <span
            class="code">final</span>, not <span class="code">static</span>,
            has no parameters, and has return type <span
            class="code">void</span>.
          </li>
        </ul>

        <p>
          Reference: Enterprise JavaBeans&#x2122; Specification,Version 2.0,
          section 15.7.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.MessageBean&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="RemoteHomeInterface">
      <subsection name="Description">
        <p>
          Checks that a direct remote home interface, i.e. an interface that
          directly extends <span class="code">javax.ejb.EJBHome</span>,
          satisfies these requirements:
        </p>

        <ul>
          <li>
            The return type of all <span
            class="code">create&lt;METHOD&gt;(...)</span> methods is not <span
            class="code">void</span>, because the return type must be the
            bean's remote interface.
          </li>
          <li>
            The throws clause of all <span
            class="code">create&lt;METHOD&gt;(...)</span> methods defines the
            <span class="code">javax.ejb.CreateException</span>.
          </li>
          <li>
            The throws clause of all methods defines the <span
            class="code">java.rmi.RemoteException</span>.
          </li>
        </ul>

        <p>
          Reference: Enterprise JavaBeansTM Specification,Version 2.0,
          sections 6.3 and 9.5.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.RemoteHomeInterface&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="RemoteInterface">
      <subsection name="Description">
        <p>
          Checks that a direct remote interface, i.e. an interface that
          directly extends <span class="code">javax.ejb.EJBObject</span>,
          satisfies these requirements:
        </p>

        <ul>
          <li>
            The throws clause of all methods defines the <span
            class="code">java.rmi.RemoteException</span>.
          </li>
        </ul>

        <p>
          Reference: Enterprise JavaBeansTM Specification,Version 2.0, section
          9.9.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.RemoteInterface&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="SessionBean">
      <subsection name="Description">
        <p>
          Checks that a direct session bean, i.e. a class that directly
          implements <span class="code">javax.ejb.SessionBean</span>,
          satisfies these class requirements:
        </p>

        <ul>
          <li>
            The class is defined as <span class="code">public</span>.
          </li>
          <li>
            The class cannot be defined as <span class="code">final</span>.
          </li>
          <li>
            The class cannot be defined as <span class="code">abstract</span>.
          </li>
          <li>
            It contains a <span class="code">public</span> constructor with no
            parameters.
          </li>
          <li>
            It must not define the <span class="code">finalize</span> method.
          </li>
          <li>
            It defines an <span class="code">ejbCreate&lt;METHOD&gt;()</span>
            method this is <span class="code">public</span>, not <span
            class="code">final</span>, not <span class="code">static</span>,
            and has return type <span class="code">void</span>.
          </li>
        </ul>

        <p>
          Reference: Enterprise JavaBeans&#x2122; Specification,Version 2.0,
          section 7.10.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.SessionBean&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="ThisParameter">
      <subsection name="Description">
        <p>
          Checks that <span class="code">this</span> is not a parameter of any
          method calls or constructors for a bean.  Instead, you must use the
          result of the <span class="code">getEJBObject()</span> available in
          <span class="code">SessionContext</span> or <span
          class="code">EntityContext</span>.
        </p>

        <p>
          Reference: <a
          href="http://www.javaworld.com/javaworld/jw-08-2000/jw-0825-ejbrestrict.html">Programming
          restrictions on EJB</a>.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.ThisParameter&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>

    <section name="ThisReturn">
      <subsection name="Description">
        <p>
          Checks that <span class="code">this</span> is not returned by a bean
          method.  Instead, you must use the result of the <span
          class="code">getEJBObject()</span> available in <span
          class="code">SessionContext</span> or <span
          class="code">EntityContext</span>.
        </p>

        <p>
          Reference: <a
          href="http://www.javaworld.com/javaworld/jw-08-2000/jw-0825-ejbrestrict.html">Programming
          restrictions on EJB</a>.
        </p>
      </subsection>

      <subsection name="Example">
        <p>
          To configure the check:
        </p>
        <source>
&lt;module name=&quot;j2ee.ThisReturn&quot;/&gt;
        </source>
      </subsection>

      <subsection name="Package">
        <p>
          com.puppycrawl.tools.checkstyle.checks.j2ee
        </p>
      </subsection>

      <subsection name="Parent Module">
        <p>
          <a href="config.html#treewalker">TreeWalker</a>
        </p>
      </subsection>
    </section>
  </body>
</document>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy