Introduction to Entity Beans 129 (Web server extensions) Unfortunately this is

Introduction to Entity Beans 129 Unfortunately this is not a scalable way to build an application server. Creation and destruction of objects is expensive, especially if client requests come frequently. How can we save on this overhead? One thing to remember is that an entity bean class describes the fields and rules for your entity bean, but it does not dictate any specific data. For example, an entity bean class may specify that all bank accounts have the following fields: The name of the bank account owner An account ID An available balance That bean class can then represent any distinct instance of database data, such as a particular bank account record. The class itself, though, is not specific to any particular bank account. To save precious time-instantiating objects, entity bean instances are therefore recyclable objects and may be pooled depending on your container s policy. The container may pool and reuse entity bean instances to represent different instances of the same type of data in an underlying storage. For example, a container could use a bank account entity bean instance to represent different bank account records. When you re done using an entity bean instance, that instance may be assigned to handle a different client s request and may represent different data. The container performs this by dynamically assigning the entity bean instance to different client-specific EJB objects. Not only does this save the container from unnecessarily instantiating bean instances, but this scheme also saves on the total amount of resources held by the system. We show this in Figure 6.4. Instance pooling is an interesting optimization that containers may provide, and it is not at all unique to entity beans. However, complications arise when reassigning entity bean instances to different EJB objects. When your entity bean is assigned to a particular EJB object, it may be holding resources such as socket connections. But when it s in the pool, it may not need that socket. Thus, to allow the bean to release and acquire resources, your entity bean class must implement two callback methods: ejbActivate() is the callback that your container will invoke on your bean instance when transitioning your bean out of a generic instance pool. This process is called activation, and it indicates that the container is associating your bean with a specific EJB object and a specific primary key. Your bean s ejbActivate() method should acquire resources, such as sockets, that your bean needs when assigned to a particular EJB object.
If you are looking quality, fast, secure and reliable web hosting with PHP service at an affordable price, check php5 hosting services.

Leave a Reply