Explain the different Transaction Attributes and Isolation Levels with reference to a scenario. Posted: The Enterprise JavaBeans model supports six different transaction rules: · TX_BEAN_MANAGED. The TX_BEAN_MANAGED setting indicates that the enterprise bean manually manages its own transaction control. EJB supports manual transaction demarcation using the Java Transaction API. This is very tricky and should not be attempted without a really good [...] |
| Posted: [For example, I have a method transfer which transfers funds from one account to another account.] Vague question. Is the Session bean doing the DB work? I’ll assume no. Let’s say AtmEJB is a Session bean with the transfer method. Let’s say AccountEJB is an Entity bean. Step 1: When the client invokes the transfer method you want that [...] |
| How is the passivation of Entity beans Managed? Posted: The passivation of Entity beans is managed by the container. To passivate an instance, the container first invokes the ejbStore() method for synchronizing the database with the bean instance, then the container invokes the ejbPassivate() method. It will then return the bean instance back to the pooled state. (Every bean has an instance pool.) There are [...] |
| Posted: An .ear file is an “Enterprise Archive” file. The file has the same format as a regular .jar file (which is the same as ZIP, incidentally). The .ear file contains everything necessary to deploy an enterprise application on an application server. It contains both the .war (Web Archive) file containing the web component of the [...] |
| What is an EJB primary key? How is it implemented when the database doesn’t have a primary key? Posted: A primary key is an object that uniquely identifies the entity bean. According to the specification, the primary key must be unique for each entity bean within a container. Hence the bean’s primary key usually maps to the PK in the database (provided its persisted to a database). You may need to create a primary key [...] |
| What classes does a client application need to access EJB? Posted: It is worthwhile to note that the client never directly interacts with the bean object but interacts with distributed object stubs or proxies that provide a network connection to the EJB container system. The mechanhism is as follows. 1. The client uses the JNDI context to get a remote reference (stub) to [...] |
| How does EJB support polymorphism? Posted: Because an EJB consists of multiple “parts”, inheritance is achievable in a rather limited fashion (see FAQ answer on inheritance here). There have been noteworthy suggestions on using multiple inheritance of the remote interface to achieve polymorphism, but the problem of how to share method signatures across whole EJBs remains to be addressed. The following [...] |
| Why are beans not allowed to create their own threads? Posted: Enterprise beans exist inside a container at run time. The container is responsible for managing every aspect of the enterprise bean’s life including: transactions, access control, persistence, resource pooling, etc. In order for the container to manage the runtime environment of a bean, it must have complete control over the threads that access and run [...] |
| How should complex find operations be implemented? Posted: In bean-managed persistence (BMP) complex find operations are not difficult to implement, because you have complete control over how a find operation works through the ejbFind methods in the bean class. ejbFind methods in BMP entities can span multiple tables and even different data sources to locate the right entity beans. With container-managed persistence (CMP) its [...] |
| Does the EJB programming model support inheritance? Posted: Inheritance is supported in EJB in a limited fashion. Enterprise beans are made up of several parts including: a remote interface; a home interface, a bean class (implementation); and a deployment descriptor The remote interface, which extends javax.ejb.EJBObject can be a subtype or a super-type of remote interfaces of other beans. This is also true of [...] |
| Posted: Container-managed fields may be specified in the bean’s deployment descriptor. An entity bean, for example, has an XML deployment descriptor containing elements similar to the following: This entity bean models an audio compact disc. MusicCDBean musicstore.MusicCDHome musicstore.MusicCD musicstore.MusicCDBean Container musicstore.MusicCDPK [...] |
| Why would a session bean use bean-managed transactions? Posted: In some situations, it’s necessary for a (stateful) session bean to selectively control which methods participate in transactions, and then take over the bundling of operations that form a logical unit of work. |
| How does a session bean obtain a JTA UserTransaction object? Posted: If it’s necessary to engage in explicit transaction management, a session bean can be designed for bean-managed transactions and obtain a UserTransaction object via the EJBContext using the getUserTransaction() method. (It may also use JNDI directly, but it’s simpler to use this convenience method.) |
| Why would a client application use JTA transactions? Posted: One possible example would be a scenario in which a client needs to employ two (or more) session beans, where each session bean is deployed on a different EJB server and each bean performs operations against external resources (for example, a database) and/or is managing one or more entity beans. In this scenario, the client’s [...] |
| Do JTS implementations support nested transactions? Posted: A JTS transaction manager must support flat transactions; support of nested transactions is optional. If a client begins a transaction, and within that transaction begins another transaction, the latter operation will throw a NotSupportedException if the JTS implementation does not support nested transactions. Keep in mind that even if the JTS implementation supports nested transactions, this [...] |
| How does a client application create a transaction object? Posted: How you gain access to UserTransaction objects varies depending on the type of client. Enterprise JavaBeans provides two types of transaction management: · Container-managed transactions. As the name implies, the EJB container makes the decisions (based on the deployment descriptor’s trans-attribute setting) regarding how to bundle operations into [...] |
| How does passivation work in stateful session beans? Posted: Unlike entity beans and stateless session beans, stateful session bean are usually evicted from memory when they are passivated. This is not true of all vendors but this view serves as good model for understanding the concepts of passivation in session beans. When a stateful bean experiences a lull in use — between client invocations and [...] |
| Are Enterprise JavaBeans and JavaBeans the same thing? Posted: Enterprise JavaBeans and JavaBeans are not the same thing; nor is one an extension of the other. They are both component models, based on Java, and created by Sun Microsystems, but their purpose and packages (base types and interfaces) are completely different. JavaBeans The original JavaBeans specification is based on the java.beans package which is a standard [...] |
| Why an onMessage call in Message-driven bean is always a separate transaction? Posted: EJB 2.0 specification: “An onMessage call is always a separate transaction, because there is never a transaction in progress when the method is called.” When a message arrives, it is passed to the Message Driven Bean through the onMessage() method, that is where the business logic goes. Since there is no [...] |
| Can I develop an Entity Bean without implementing the create() method in the home interface? Posted: As per the specifications, there can be ‘ZERO’ or ‘MORE’ create() methods defined in an Entity Bean. In cases where create() method is not provided, the only way to access the bean is by knowing its primary key, and by acquiring a handle to it by using its corresponding finder method. [...] |
Thursday, October 30, 2008
TECHNICAL QUESTIONS
Subscribe to:
Post Comments (Atom)



No comments:
Post a Comment