Static Varialbes In EJB


EJB design: Static Varialbes In EJB

  1. Static Varialbes In EJB (2 messages)

    Can we use static variables in any type of EJB.If so what r the uses of using static variables in EJb.
    If not why cannot we them in EJB?

    Waiting for reply.
  2. Static Varialbes In EJB[ Go to top ]

    Yes, you can use static variables, but they should be read-only (final that is). The reason for this is a *possible* clustering.
  3. Static Varialbes In EJB[ Go to top ]

    It may be simpler to explain this if you give a scenario of why you may want to use non-final static variables.

    Anyway, the EJB spec imposes very rigid limitations on the coding of EJBs. Some make perfect sense (do not start threads), some are almost meaningless IMHO (do not instantiate class loaders). The "do not use statics" is somewhere in the middle. You usually do not need it (and the spec prohibits it), but you might get away with it... That is until your deployer tool starts checking for it.

    Gene Florintsev
    gene at ejbility dot com