# J2EE Checks

- About
- Checkstyle
- Documentation
- Release Notes
- Configuration
- Property Types
- Running
- Ant Task
- Command Line
- Available Checks
- Standard Checks
- Javadoc Comments
- Naming Conventions
- Headers
- Imports
- Size Violations
- Whitespace
- Modifiers
- Block Checks
- Coding
- Class Design
- Duplicate Code
- Metrics
- Miscellaneous
- Optional Checks
- J2EE Checks
- EntityBean
- FinalStatic
- LocalHomeInterface
- LocalInterface
- MessageBean
- RemoteHomeInterface
- RemoteInterface
- SessionBean
- ThisParameter
- ThisReturn
- Extending Checkstyle
- Writing checks
- Writing filters
- Writing listeners
- Javadoc
- SourceForge
- Mailing Lists
- Bug Database
- Feature Requests
- Developers
- Project Page
- SVN Repository
- Contributing

- Hosted by:

## EntityBean

### Description

Checks that a direct entity bean, i.e. a class that directly implements javax.ejb.EntityBean, satisfies these class requirements:

- The class is defined as public.
- The class cannot be defined as final.
- It contains a public constructor with no parameters.
- It must not define the finalize method.

Checks that methods of a direct entity bean satisfy these requirements:

- All ejbCreate<METHOD>(...) methods are public, not final, and not static.
- The return type of all ejbCreate<METHOD>(...) methods is not void, because the return type must be the entity bean's primary key type.
- All ejbPostCreate<METHOD>(...) methods are public, not final, and not static.
- The return type of all ejbPostCreate<METHOD>(...) methods is void.
- For each ejbCreate<METHOD>(...) method there is a matching ejbPostCreate<METHOD>(...) method.
- All ejbHome<METHOD>(...) methods are public, and not static.
- The throws clause of all ejbHome<METHOD>(...) methods does not define the java.rmi.RemoteException.

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

- All ejbFind<METHOD>(...) methods are public, not final, and not static.
- The return type of all ejbFind<METHOD>(...) methods is not void, because the return type must be the entity bean's primary key type, or a collection of primary keys.
- There is a ejbFindByPrimaryKey method with one parameter.

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

- The throws clause of all ejbCreate<METHOD>(...) methods defines the javax.ejb.CreateException.
- All ejbSelect<METHOD>(...) methods are public and abstract.
- The throws clause of all ejbSelect<METHOD>(...) methods defines the javax.ejb.FinderException.

### Properties

name | description | type | default value
--- | --- | --- | ---
persistence | type of persistence management | persistence policy | mixed

Reference: Enterprise JavaBeans? Specification,Version 2.0, sections 10.6 and 12.2.

### Example

To configure the check:

    <module name="j2ee.EntityBean"/>

To configure the check to apply the container policy to direct entity beans:

    <module name="j2ee.EntityBean">
        <property name="persistence" value="container"/>
    </module>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

## FinalStatic

### Description

Checks that all static fields are declared final.

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

Reference: Programming restrictions on EJB.

### Example

To configure the check:

    <module name="j2ee.FinalStatic"/>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

## LocalHomeInterface

### Description

Checks that a direct local home interface, i.e. an interface that directly extends javax.ejb.EJBLocalHome, satisfies these requirements:

- The return type of all create<METHOD>(...) methods is not void, because the return type must be the bean's local interface.
- The throws clause of all create<METHOD>(...) methods defines the javax.ejb.CreateException.
- The throws clause of all methods does not define the java.rmi.RemoteException.

Reference: Enterprise JavaBeansTM Specification,Version 2.0, sections 6.4 and 9.6.

### Example

To configure the check:

    <module name="j2ee.LocalHomeInterface"/>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

## LocalInterface

### Description

Checks that a direct local interface, i.e. an interface that directly extends javax.ejb.EJBLocalObject, satisfies these requirements:

- The throws clause of all methods does not define the java.rmi.RemoteException.

Reference: Enterprise JavaBeansTM Specification,Version 2.0, section 9.10.

### Example

To configure the check:

    <module name="j2ee.LocalInterface"/>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

## MessageBean

### Description

Checks that a direct message bean, i.e. a class that directly implements javax.ejb.MessageDrivenBean and javax.jms.MessageListener, satisfies these class requirements:

- The class is defined as public.
- The class cannot be defined as final.
- The class cannot be defined as abstract.
- It contains a public constructor with no parameters.
- It must not define the finalize method.
- It defines an ejbCreate() method this is public, not final, not static, has no parameters, and has return type void.

Reference: Enterprise JavaBeans? Specification,Version 2.0, section 15.7.

### Example

To configure the check:

    <module name="j2ee.MessageBean"/>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

## RemoteHomeInterface

### Description

Checks that a direct remote home interface, i.e. an interface that directly extends javax.ejb.EJBHome, satisfies these requirements:

- The return type of all create<METHOD>(...) methods is not void, because the return type must be the bean's remote interface.
- The throws clause of all create<METHOD>(...) methods defines the javax.ejb.CreateException.
- The throws clause of all methods defines the java.rmi.RemoteException.

Reference: Enterprise JavaBeansTM Specification,Version 2.0, sections 6.3 and 9.5.

### Example

To configure the check:

    <module name="j2ee.RemoteHomeInterface"/>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

## RemoteInterface

### Description

Checks that a direct remote interface, i.e. an interface that directly extends javax.ejb.EJBObject, satisfies these requirements:

- The throws clause of all methods defines the java.rmi.RemoteException.

Reference: Enterprise JavaBeansTM Specification,Version 2.0, section 9.9.

### Example

To configure the check:

    <module name="j2ee.RemoteInterface"/>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

## SessionBean

### Description

Checks that a direct session bean, i.e. a class that directly implements javax.ejb.SessionBean, satisfies these class requirements:

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

Reference: Enterprise JavaBeans? Specification,Version 2.0, section 7.10.

### Example

To configure the check:

    <module name="j2ee.SessionBean"/>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

## ThisParameter

### Description

Checks that this is not a parameter of any method calls or constructors for a bean. Instead, you must use the result of the getEJBObject() available in SessionContext or EntityContext.

Reference: Programming restrictions on EJB.

### Example

To configure the check:

    <module name="j2ee.ThisParameter"/>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

## ThisReturn

### Description

Checks that this is not returned by a bean method. Instead, you must use the result of the getEJBObject() available in SessionContext or EntityContext.

Reference: Programming restrictions on EJB.

### Example

To configure the check:

    <module name="j2ee.ThisReturn"/>

### Package

com.puppycrawl.tools.checkstyle.checks.j2ee

### Parent Module

TreeWalker

Copyright © 2001-2007, Oliver Burn