Enterprise JavaBeans - Execution

Execution

EJBs are deployed in an EJB container, typically but not necessarily, within an application server. The specification describes how an EJB interacts with its container and how client code interacts with the container/EJB combination. The EJB classes used by applications are included in the javax.ejb package. (The javax.ejb.spi package is a service provider interface used only by EJB container implementations.)

Clients of EJB beans do not instantiate those beans directly via Java's new operator, but instead have to obtain a reference via the EJB container. This reference is then not a reference to the implementation bean itself, but to a proxy, which either dynamically implements the local or remote business interface that the client requested or dynamically implements a sub-type of the actual bean. The proxy can then be directly cast to the interface or bean. A client is said to have a 'view' on the EJB, and the local interface, remote interface and bean type itself respectively correspond with the local view, remote view and no-interface view.

This proxy is needed in order to give the EJB container the opportunity to transparently provide cross-cutting (AOP-like) services to a bean like transactions, security, interceptions, injections, remoting, etc.

E.g. a client invokes a method on a proxy, which will then first start a transaction with the help of the EJB container and then call the actual bean method. When the actual bean method returns, the proxy ends the transaction (i.e. by committing it or doing a rollback) and transfers control back to the client.

Read more about this topic:  Enterprise JavaBeans

Famous quotes containing the word execution:

    I herewith commission you to carry out all preparations with regard to ... a total solution of the Jewish question in those territories of Europe which are under German influence.... I furthermore charge you to submit to me as soon as possible a draft showing the ... measures already taken for the execution of the intended final solution of the Jewish question.
    Hermann Goering (1893–1946)

    Union of Religious Sentiments begets a surprising confidence and Ecclesiastical Establishments tend to great ignorance and corruption, all of which facilitate the Execution of Mischievous Projects.
    James Madison (1751–1836)

    I will soon be going out to shape all the singing tomorrows.
    Gabriel Péri, French Communist leader. Letter, July 1942, written shortly before his execution by the Germans. Quoted in New York Times (April 11, 1943)