programming restrictions in the EJB container


EJB design: programming restrictions in the EJB container

  1. programming restrictions in the EJB container (2 messages)

    Hi everybody
    one of my greatest concern using eib
    is relatd to the programming restrictions listed in the EJB spec. (they say to not use static variable , thread creation and synchronization , use of the singleton pattern and so on). Despite of this
    restrictions I see around a lot of example and also J2EE application running in production environments not compliant to those restrictions without experiencing any sort of problems . So I am in a big confusion in trying to figure out who is saying the true!!!
    thanks a lot in advance for your help
  2. You have to distinguish between what is in the standard, and what actually works in the real world. They are not always the same. In general, it is best to follow the standard, because this will be a (relatively) stable subset of functionality. Therefore, it will be less likely that you will need to change your code if you need to switch or upgrade J2EE servers.

    Sometimes, though, you need functionality outside the scope of the standard, and are forced to break the rules. Many of these changes will end up being server-specific. Sometimes, if you have a deep understanding of the way EJBs work, it is possible to break the rules in a way that is likely to work on most servers. So ... sometimes it is OK to break the rules in the specification, but if you do, be sure you know what you are doing and to test your changes carefully in the environment where you are planning on using them.
  3. This question comes up a lot from the spec. What happens is people read the restrictions without understanding the comments underneath each restriction that explain why this restriction exists. I often think this whole section need to be re-written.

    For instance the reason you have restrictions on static variables in EJBs is because the container is alllowed to use what class loader it likes to load the EJB. Therefore as long as you understand and work within it this then yes you can use a static variable.