|
1. What is clustering? What are the different algorithms used for clustering? Answer: Clustering is grouping machines together to transparantly provide enterprise services.The client does not now the difference between approaching one server or approaching a cluster of servers.Clusters provide two benefits: scalability and high availability.Further information can be found in the JavaWorld article J2EE Clustering. 2. What is the advantage of using Entity bean for database operations, over directly using JDBC API to do database operations? When would I use one over the other? Answer: Entity Beans actually represents the data in a database.It is not that Entity Beans replaces JDBC API.There are two types of Entity Beans Container Managed and Bean Mananged.In Container Managed Entity Bean - Whenever the instance of the bean is created the container automatically retrieves the data from the DB/Persistance storage and assigns to the object variables in bean for user to manipulate or use them.For this the developer needs to map the fields in the database to the variables in deployment descriptor files (which varies for each vendor).In the Bean Managed Entity Bean - The developer has to specifically make connection, retrive values, assign them to the objects in the ejbLoad() which will be called by the container when it instatiates a bean object.Similarly in the ejbStore() the container saves the object values back the the persistance storage.ejbLoad and ejbStore are callback methods and can be only invoked by the container.Apart from this, when you use Entity beans you dont need to worry about database transaction handling, database connection pooling etc.which are taken care by the ejb container.But in case of JDBC you have to explicitly do the above features.what suresh told is exactly perfect.ofcourse, this comes under the database transations, but i want to add this.the great thing about the entity beans of container managed, whenever the connection is failed during the transaction processing, the database consistancy is mantained automatically.the container writes the data stored at persistant storage of the entity beans to the database again to provide the database consistancy.where as in jdbc api, we, developers has to do manually.
3. Can I invoke Runtime.gc() in an EJB? Answer: You shouldn't.What will happen depends on the implementation, but the call will most likely be ignored.You should leave system level management like garbage collection for the container to deal with.After all, that's part of the benefit of using EJBs, you don't have to manage resources yourself.
4. What is EJB QL? Answer: EJB QL is a Query Language provided for navigation across a network of enterprise beans and dependent objects defined by means of container managed persistence.EJB QL is introduced in the EJB 2.0 specification.The EJB QL query language defines finder methods for entity beans with container managed persistenceand is portable across containers and persistence managers.EJB QL is used for queries of two types of finder methods: Finder methods that are defined in the home interface of an entity bean and which return entity objects.Select methods, which are not exposed to the client, but which are used by the Bean Provider to select persistent values that are maintained by the Persistence Manager or to select entity objects that are related to the entity bean on which the query is defined.
5. What is Horizontal Scaling? Answer: When Clones of an application server are defined on multiple physical m/c, it is called Horizontal Scaling.The objective is to use more than one less powerful m/c more efficiently.
6. What is a Clone? Answer: The copies of a server group are called Clones.But unlike a Server Group Clones are associated with a node and are real server process running in that node.
7. Can you control when passivation occurs? Answer: The developer, according to the specification, cannot directly control when passivation occurs.Although for Stateful Session Beans, the container cannot passivate an instance that is inside a transaction.So using transactions can be a a strategy to control passivation.The ejbPassivate() method is called during passivation, so the developer has control over what to do during this exercise and can implement the require optimized logic.Some EJB containers, such as BEA WebLogic, provide the ability to tune the container to minimize passivation calls.Taken from the WebLogic 6.0 DTD -"The passivation-strategy can be either "default" or "transaction".With the default setting the container will attempt to keep a working set of beans in the cache.With the "transaction" setting, the container will passivate the bean after every transaction (or method call for a non-transactional invocation). 8. Can Entity Beans have no create() methods? Answer: Yes.In some cases the data is inserted NOT using Java application. 9. What is in-memory replication? Answer: The process by which the contents in the memory of one physical machine are replicated in all the machine in the cluster is called in-memory replication. Difference Between Abstraction and Encapsulation - Abstraction is removing some distinctions between objects, so as to show their commonalities.Encapsulation is hiding the details of the implementation of an object so that there are no external dependencies on the particular implementation. 10. How can I call one EJB from inside of another EJB? Answer: EJBs can be clients of other EJBs.It just works.Use JNDI to locate the Home Interface of the other bean, then acquire an instance reference, and so forth.
|