|
1. Mention some tools to cluster Web Servers? Answer: Web Servers can be clustered using Edge Server or DNS. 2. Is there any default cache management system with Entity beans ? In other words whether a cache of the data in database will be maintained in EJB ? Answer: Caching data from a database inside the Application Server are what Entity EJB's are used for.The ejbLoad() and ejbStore() methods are used to synchronize the Entity Bean state with the persistent storage(database).Transactions also play an important role in this scenario.If data is removed from the database, via an external application - your Entity Bean can still be "alive" the EJB container.When the transaction commits, ejbStore() is called and the row will not be found, and the transaction rolled back. 3. How is persistence implemented in enterprise beans? Answer: Persistence in EJB is taken care of in two ways, depending on how you implement your beans: container managed persistence (CMP) or bean managed persistence (BMP) For CMP, the EJB container which your beans run under takes care of the persistence of the fields you have declared to be persisted with the database - this declaration is in the deployment descriptor.So, anytime you modify a field in a CMP bean, as soon as the method you have executed is finished, the new data is persisted to the database by the container.For BMP, the EJB bean developer is responsible for defining the persistence routines in the proper places in the bean, for instance, the ejbCreate(), ejbStore(), ejbRemove() methods would be developed by the bean developer to make calls to the database.The container is responsible, in BMP, to call the appropriate method on the bean.So, if the bean is being looked up, when the create() method is called on the Home interface, then the container is responsible for calling the ejbCreate() method in the bean, which should have functionality inside for going to the database and looking up the data. 4. What is a Message Driven Bean, what functions does a message driven bean have and how do they work in collaboration with JMS? Answer: Message driven beans are the latest addition to the family of component bean types defined by the EJB specification.The original bean types include session beans, which contain business logic and maintain a state associated with client sessions, and entity beans, which map objects to persistent data.Message driven beans will provide asynchrony to EJB based applications by acting as JMS message consumers.A message bean is associated with a JMS topic or queue and receives JMS messages sent by EJB clients or other beans.Unlike entity beans and session beans, message beans do not have home or remote interfaces.Instead, message driven beans are instantiated by the container as required.Like stateless session beans, message beans maintain no client-specific state, allowing the container to optimally manage a pool of message-bean instances.Clients send JMS messages to message beans in exactly the same manner as they would send messages to any other JMS destination.This similarity is a fundamental design goal of the JMS capabilities of the new specification.To receive JMS messages, message driven beans implement the javax.jms.MessageListener interface, which defines a single "onMessage()" method.When a message arrives, the container ensures that a message bean corresponding to the message topic/queue exists (instantiating it if necessary), and calls its onMessage method passing the client's message as the single argument.The message bean's implementation of this method contains the business logic required to process the message.Note that session beans and entity beans are not allowed to function as message beans. 5. Can a Session Bean be defined without ejbCreate() method? Answer: The ejbCreate() methods is part of the bean's lifecycle, so, the compiler will not return an error because there is no ejbCreate() method.However, the J2EE spec is explicit: the home interface of a Stateless Session Bean must have a single create() method with no arguments, while the session bean class must contain exactly one ejbCreate() method, also without arguments.Stateful Session Beans can have arguments (more than one create method) stateful beans can contain multiple ejbCreate() as long as they match with the home interface definition.You need a reference to your EJBObject to startwith.For that Sun insists on putting a method for creating that reference (create method in the home interface).The EJBObject does matter here.Not the actual bean. 6. I am developing a BMP Entity bean.I have noticed that whenever the create method is invoked, the ejbLoad() and the ejbStore() methods are also invoked.I feel that once my database insert is done, having to do a select and update SQL queries is major overhead.is this behavior typical of all EJB containers? Is there any way to suppress these invocations? Answer: This is the default behaviour for EJB.The specification states that ejbLoad() will be called before every transaction and ejbStore() after every transaction.Each Vendor has optimizations, which are proprietary for this scenario. 7. What is the need of Remote and Home interfaces.Why can't there be one? Answer: In a few words, I would say that the main reason is because there is a clear division of roles and responsabilities between the two interfaces.The home interface is your way to communicate with the container, that is who is responsable of creating, locating even removing one or more beans.The remote interface is your link to the bean, that will allow you to remotely access to all its methods and members.As you can see there are two distinct elements (the container and the beans) and you need two different interfaces for accessing to both of them. 8. The EJB specification says that we cannot use Bean Managed Transaction in Entity Beans.Why? Answer: The short, practical answer is… because it makes your entity beans useless as a reusable component.Also, transaction management is best left to the application server - that's what they're there for.It's all about atomic operations on your data.If an operation updates more than one entity then you want the whole thing to succeed or the whole thing to fail, nothing in between.If you put commits in the entity beans then it's very difficult to rollback if an error occurs at some point late in the operation. 9. How EJB Invocation happens? Answer: The steps for EJB Invocation are: - Retrieve Home Object reference from Naming Service via JNDI.
- Return Home Object reference to the client.
- Create me a new EJB Object through Home Object interface.
- Create EJB Object from the Ejb Objects.
- Return EJB Object reference to the client.
- Invoke business method using EJB Object reference.
- Delegate request to Bean (Enterprise Bean).
10. What is Vertical Scaling? Answer: When multiple server clones of an application server are defined on the same physical m/c, it is called Vertical Scaling.The objective is to use the processing power of that m/c more efficiently.
|