A bean instance will be moved into the ready state when a client makes a call to one of the
create() methods in the home interface. In the ready state, the bean instance is available to
the client for use. As with session beans, there is instance sharing of entity bean instances.
They can be moved in and out of the pooled state when the application server feels it is
acceptable to share the bean instance with another client. The application server uses the same
processes of passivation and activation that it does when dealing with session beans. Next we
need to talk about persistence. As we have discussed, an entity bean is tied to an entry in a
database. When an instance of an entity bean is used during a transaction, it must be stored to
the database. There are also times when the instance needs to be filled with the information it
represents in the database. The timing of these stores and loads is up to the application server.
For loading and storing the persistent information you must implement the ejbLoad() and
ejbStore() methods. As their names indicate, ejbLoad() loads information from the database
into the bean instance and ejbStore() stores the information back to the database.
For bean-managed beans the ejbStore() and ejbLoad() methods are very important. It is here
that the developer must provide the update and select SQL statements.
For any container-managed bean these methods provide the capability to do any processing of
the data before it is stored or after it is loaded. The application server will call ejbStore()
immediately before it stores the container-managed fields to the database. Consequently, it will
also call ejbLoad() immediately after loading the information into the bean instance again.
We have left these two methods empty because there is no processing required for the Quote
Deploying Your EJB to Your Application Server
The process of deploying your Enterprise JavaBeans is not regulated by any specification, so it
is usually different for each application server. There are, however, some concepts that are the
Packaging the jar File
First is packaging all of your classes and the deployment descriptor in a jar file. As we have
discussed before, all of the beans that are described in the ejb-jar.xml deployment descriptor
will be included within one jar file. Archive all of the class files as well as the ejb-jar.xml
file into a jar file. The ejb-jar.xml file belongs in the meta-inf directory in the archive.
Many existing application servers provide a graphical deployment tool. Each one will appear
differently. One of the major steps that is taken when deploying your jar file to any application
server is to run the EJB compiler over it. In many cases, the application server does this during
the process of using its deployment tool. However, many developers choose to handle this dur-
ing the build process of their beans. The EJB compiler will create all of the necessary client-
and server-side classes required to process the remote-method invocations.