One of EJB’s obvious design goals was to provide an environment thatcan scale up to meet the demands of enterprise applications. I’mcurious, however, about the other end of the scalability spectrum aswell. I would like to write an application that can scale up to meetenterprise demands, but can also be easily used by a single individualworking on a non-networked laptop computer. If I build myapplication with EJB, will I alienate this user base?
You will not necessarily alienate non-networkedindividuals by using EJB, but you will have to package the EJBcomponents and runtime environment for the individual. Therefore,EJBs that mediate access to multi-gigabyte databases are a no-go. Aquick analogy is the use of CORBA on the desktop in the same role ofCOM as is done by the GNOME desktop environment for Linux. Distributedobjects just give you a simpler way of performing interprocesscommunication and it’s ok for that communication to happen on the samemachine.
However, your caution is well-justified. EJB is designed forrelatively coarse-grained components involved in transaction-orienteddistributed applications. This involves modeling database entitiesand business rules as objects. The typical EJB deployment environmentis in three-tier systems. The first tier usually contains a relatively thinclient. The second tier contains EJB components that validate inputs,enforce business rules, and mediate access to databases. The thirdtier contains the actual databases that drive the application. Butthree-tier systems need not be deployed across a network. They can bedeployed on a laptop. By doing so, you gain the advantage of nothaving to rearchitect your network application for the desktop.
An important thing you lose by using EJB is the ability toproduce a lightweight application for the low-end. The key is to usethe approach where appropriate. It is easy to imagine a salesdatabase query system implemented with EJB. Salespeople may need toreplicate a subset of the enterprise data to their laptops for usewhen they go out in the field. There would be no reason to redesignthe distributed application when it could run unchanged in the singleuser environment. However, it would probably impose a largerfootprint than a reimplemented system because of the need to bundlethe EJB server.