1. What is EJB?
When I first learned the term EJB, I really learned about the 13 specifications of the Java EE, and at that time I was so unfamiliar with the name, without any understanding, just an impression in my mind.
EJB (Enterprisejavabean) Explanation:
One of the reasons why EE technology has won wide attention is EJB. It provides a framework for developing and implementing distributed business logic, which significantly simplifies the development of scalable and highly complex enterprise-class applications . The EJB specification defines when EJB components interact with their containers. Containers are responsible for providing common services, such as directory services, transaction management, security, resource pooling, and fault tolerance.
In general, EJB is the Java component that implements distributed business logic, and "enterprise" means the extensibility, reliability, availability, security, transactional, and distribution of the application. EJB provides customers with a distributed and deployable business logic service , and has a good interface to execute in a container that provides management and control services. and is reusable between application services.
? Insight (concept article) How to understand enterprise-level development
Enterprise applications are the solutions and applications that are created and deployed for business organizations and large enterprises. These large enterprise-level applications are complex in structure, involving a large number of external resources, transaction-intensive, high data volume, many users, there is strong security considerations.
Enterprise-level development is primarily for enterprise application development.
how to understand server clusters
A server cluster means that many servers are clustered together for the same service, which appears to the client as if there is only one server. A cluster can use multiple computers for parallel computing to achieve high computational speed, or it can be backed up with multiple computers, so that any one machine breaks down the entire system or runs normally.
how to understand distributed
Distributed , is that it can be placed on more than one computer , The process of running a series of programs at the same time .
EJB is the one that can implement this mechanism. For example, the Entitybean used in the database, but placed on a processing machine, and used to deal with the general logic of things, such as session Bean, and can be deployed to another machine. Each machine can access and cooperate with each other through Jndi technology, RMI (Remote call technology).
? Insight (piecemeal)
In Java EE, Enterprise Java Beans (EJB) is called Java Business Bean, which is the core code of the kernel, namely the session bean, the entity bean Bean) and the message-driven bean (Messagedriven bean).
conversation Bean (Session Bean)
Session beans can perform operations on business logic, such as registration, database operations, and so on.
What is a session?
That is, the client obtains the EJB object start, and then invokes the EJB's method (which can be multiple times) until the end of the client's life cycle, or the client releases the EJB object, called a session.
As the session terminates, EJB objects can also be destroyed by the EJB container.
Call procedure
Session beans are divided into two types: stateful and stateless session beans.
non-stateful sessions Bean
To develop a stateless session Bean with only the local interface, use the @local comment to declare that the interface is a local interface.
To develop a stateless session Bean with only remote interfaces, use the @remote comment to declare that the interface is a remote interface.
When both the @local and @remote annotations do not exist, the container implements the Bean class interface by default to the Local interface. If the EJB and the client are deployed on the same application server, accessing the EJB using the Local interface is better than the remote interface.
Stateful Sessions Bean
Each stateful bean serves only one user during the lifetime of the Bean instance, and the member variables of the Bean class can maintain data specific to a particular user between different method invocations.
For example: Shopping cart objects, each user should have their own shopping cart, do not want someone to add or take away the goods in your shopping cart, and the status beans just meet your needs.
Entities Bean (Entity Bean)
Before we say this, let's first understand what persistence is.
Persistence of
A data storage technique in which information can be stored for a long time after the program exits.
The Java object is stored using an RDBMS (relational database management system (relational), which is primarily:
JDBC Direct Access database; EJB entity bean; JDO Technology (Java Data Objects); third-party O/R tools, such as Hibernate, others such as Ibatis,castor,toplink.
ORM (Object relational Mapping)
The technique of mapping an object to an RDBMS is called an object-relational mapping. It can realize the mutual transformation of the memory object and the relational data.
The entity bean is a domain model object that implements the O/R mapping and is responsible for mapping table records in the database to an in-memory entity object, in fact creating an entity bean object that is equivalent to a new record, deleting an entity The bean will delete the corresponding record from the database at the same time, and when modifying an entity bean, the container will automatically synchronize the state of the entity bean with the database.
Message-driven bean (Messagedriven Bean)
This is not to do a detailed introduction, in the next study we look again.
2. Summary
Here are just a few shallow initial, in the next study will be in-depth study, please look forward to.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Tour (3)--EJB (initial)