Introduction to Enterprise JavaBeans 5

  Bean entities inside and outside of the exchange 

  Now should be to look at javax.ejb.EntityBean interface. 

  Public interface javax.ejb.EntityBean extends EnterpriseBean ( 
  Public void ejbActivate () throws RemoteException; 
  Public void ejbPassivate () throws RemoteException; 
  Public void ejbRemove () throws RemoteException, RemoveException; 
  Public void setEntityContext (EntityContext ctx) throws RemoteException; 
  Public void unsetEntityContext () throws RemoteException; 
  Public void ejbLoad () throws RemoteException; 
  Public void ejbStore () throws RemoteException; 
  ) 

  Activation and passivation process with a similar session bean.    However, not in the affairs of state is no entity bean; its status and the underlying data are always synchronized.    If we, as passive as passive entities session bean bean, when passive when no state entity bean will delete it.    But because the containers anonymous call finder requires the entity bean, containers may not for the passive activities of the entity bean to a private memory pool.    Once deleted from the EJBObject entity bean, the deletion of the identifiers (primary key relevance). 
  When clients call not related to the entity bean EJBObject business methods, the containers can be re-allocated memory pool entity bean. Attention to the memory of the bean pool no logo, can be any EJBObject reuse.    Vessels can be no maintenance of any EJBObject entity bean, unless there is a commercial way through EJBObject was called.    If the entity bean in the affairs and EJBObject required to maintain its relevance. 

  Since the management of persistent 

  Because the bottom of the entity bean representative data, we need the data from the data from the database then put out in the bean.    When the containers the first time, the example of an entity bean and EJBObject association, it began a Service call this bean and the ejbLoad () method.    In this method of development must be removed from the database to provide the correct data and put it in the bean.    When the containers will be submitted to a panel of its first call bean ejbStrore () method.    This method is responsible for the data in the database to write.    We call it self-managing lasting, because the bean methods provided such synchronous code. 
  When ejbLoad () method is completed, bean may inconsistent with the underlying database.    Business methods call triggered EJBObject associated with the distribution of the bean, and then in the implementation of the affairs ejbLoad () must be in the deployment descriptors in the statement.    According to the Method Invocation receiving requests EJBObject and containers with the establishment of a panel context.    EJBObject containers distribution of the bean and bean ejbLoad call () method.    This approach is now operating in a business context.    Services this context transmitted to the database, based on the deployment descriptors in the isolation of the designated level, the Panel locked in the database being accessed data. 
  Services provided context, the data in the database has been locked state to maintain.    When the client or containers submitted to the Panel, the bean containers First Call ejbStore () method, the bean wrote back to the data in the database. 
  Recorded in the corresponding database ejbLoad () and ejbStore () to maintain inter-lock guarantees the bean and database synchronization.    Which can be different commercial Method Invocation.    Moreover, ejbLoad () and ejbStore () a clear distinction between Affairs border affairs can be conducted any business method invocation.    Services by the duration of the deployment descriptors decision may also be decided by the client.    Pay attention to the need to use ejbActivate () and ejbPassivate () approach to the implementation of the database and synchronization. 

  Persistent management of containers 

  If the deployment descriptor statement bean container management of the use of persistent, not ejbLoad () and ejbStore () to access the database.    Vessels will import data from the database to the bean, and then call the bean ejbLoad () method to accomplish receive data from the database. 
  Similarly, the ejbStore bean containers call () method to complete the data in the database to write.    These methods do not actually implement any database operations.    When developers use sophisticated tools to provide management durable containers, such as automatically generated objects can be carried out - the entity relationship mapping bean category, the provisions regulating the packaging manufacturers must provide lasting management entity of the smallest set of requirements. 
  Deployment descriptors bean can be designated a public domain database out to achieve with a simple mapping.    Vessel deployment descriptors used to read out the bean wrote this public domain and the corresponding list from the database or Douchushuju wrote out in public domain.    Vessel Management on the sustainability of the development of EJB, who is a very good service and not object - alluding relations and other complex system, and developers will find it than the management of persistent more efficient. 

  Deployment descriptor 

  EJB development of the distinction between the role of 

  EJB development of the two main role is to bean and bean development, deployment.    There are many attributes developers can not predict, such as the network address database, the use of the database-driven procedure.    Deployment descriptors, as a form of the definition of development, deployment, by the insertion of the correct value.    Fu described the deployment of a standard format, in the development and deployment environment that can be transplanted, or even in different EJB platforms is also portable.    Enterprise bean addition to the behavioral control for the development and deployment of synergies provide a standard single attribute, deployment descriptors should also include how to enforce the bean affairs and security details.    Some chains such as Access Control (ACL), and other attributes, should also be adjusted by the deployment, to ensure that the appropriate users can use bean at runtime. Other attributes, such as information services, it is possible entirely by the developer designated by the developers because of the general create the database access code, and the method should be familiar bean how to run affairs.    Definition of the deployment descriptors deployment descriptors is a standard Java class.    Creates an instance, imported data, and then the serial.    Serial the deployment of this description at a jar on the document and enterprise bean class together and to the deployment environment.    To read the serial deployment of the deployment descriptors, may change some attribute values, and then use the revised deployment descriptors to install enterprise bean. 
  Below is a part of the deployment descriptors content.    It is the deployment of two other descriptors such as ultra-category.    In fact super-category is described at the description of the bean. 

Javax.ejb.deployment.DeploymentDescriptor
  Bean home name 
  Bean class name 
  Home interface class name 
  Remote interface class name 
  Environment properties 
  Control descriptors 
  Access control list 

  DeploymentDescriptor there are two sub-categories: 

  Javax.ejb.deployment.SessionDescriptor 
  State management type 
  Session timeout 

  Javax.ejb.deployment.EntityDescriptor 
  List of ocntainer-managed fields 
  Primary key class name 

  Descriptors for each entity bean and the methods defined affairs and security attributes.    An array of these objects in the DeploymentDescriptor designated. 

  Javax.ejb.deployment.ControlDescriptor 
  Transaction isolation level 
  Method object to which this descriptor applies 
  Run-as mode (for odentity mapping) 
  Run-as identity (for identity mapping) 
  Transaction attribute 

  Deployment of an enterprise bean, the allocation of the corresponding description, and then initialized, serial, and then with the enterprise bean class with a jar Add to the document.    Different vendors in the definition, deployment descriptors may have a different approach.    For example, a vendor may use text, while another vendor may provide graphical tools.    But in the end, the outcome of the deployment descriptors is a standard format, and in the different platforms is portable. 

  EJB Jar document 

  To a packaging enterprise bean, bean class, and serial interface of the deployment descriptors in a jar file.    This document must have a jar file import manifest in a statement the deployment of an enterprise bean descriptors. 
  Name: AccountDD.ser 
  Enterprise-Bean: true 
  As manifest in the enterprise bean is listed in the deployment descriptor, and not bean category.    Apart from the deployment descriptor definition of enterprise bean, but also provide jar document, all the integrity of the document described.    Developers need not concern EJB jar file was created.    Manufacturers should provide a tool to help developers create deployment descriptors, and then all the necessary documents packaged into a jar file. 

  Introduction of an Enterprise JavaBeans 
  Enterprise JavaBeans Introduction 2 
  Introduction to Enterprise JavaBeans 3 
  Introduction to Enterprise JavaBeans 4 
  Introduction to Enterprise JavaBeans 5 
  6 Introduction to Enterprise JavaBeans 
  Introduction to Enterprise JavaBeans 7 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags:

Releated Java Articles

Comments

Leave a Reply