In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How does Spring support the implementation of EJB? in view of this question, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
In traditional J2EE applications, enterprise JavaBeans (EJB) forms the basis of the application architecture. Although Spring provides simplified versions of many of the services provided by EJB, such as declarable transaction management and object persistence, many applications will continue to build using EJB for some time. Fortunately, you can use Spring in EJB-based solutions. This article is an excerpt from Pro Spring. The authors of Pro Spring, Rob Harrop and Jan Machacek, focus on how to simplify the creation of EJB in Spring, and how Spring provides a simple, friendly way to access EJB resources.
With the development of Spring, developers now have a lightweight replacement for EJB for the first time. With Spring, you can take advantage of many of the features provided by EJB, such as declarable transaction management, object pooling, and simple ORM (object role modeling). That is to say, we expect EJB to continue to be used in application development for the foreseeable future. Although we do not consider the reasons for using or not using EJB in this book, from our excellent experience with Spring, we recommend that you use Spring instead of EJB as much as possible.
Spring supports EJB
Spring supports that EJB can be roughly divided into two categories: access and implementation. The access support classes in Spring allow you to easily access EJB resources. In this section, we examine how Spring extends the basic JNDI (Java name directory interface) support framework's access to EJB and uses AOP (aspect-oriented programming) support to provide proxy-based access to EJB resources.
Spring provides abstract base classes to support the implementation of EJB, which makes it easier to create stateless EJB, stateful EJB, and message-driven EJB. The premise of the use of these three categories is not to reduce the burden of creating EJB, but to make it easier for you to access Spring-managed resources from within bean, and more importantly, it helps to separate business logic from the EJB implementation and write it into EJB's POJO (plain old Java object) object. Here, don't worry about these vague statements, we will use two examples to discuss them in detail in the next chapter.
We are going to build a simple Web application that uses two EJB services. * stateless session bean implements EchoService business logic interface and provides simple response capability. The second is stateful session bean, which implements the CounterService business logic interface and provides stateful counting services.
These are simple examples, but they help demonstrate the recommended solution for compiling EJB components in Spring and the differences between the different components of Spring that support EJB. Apart from discussing the various deployment descriptors in the example, we do not study EJB in more detail. However, we will take an in-depth look at Spring's implementation of EJB support in a variety of components and how this implementation affects applications. In particular, we examine how Spring locates EJB in ApplicationContext and how to use the JNDI infrastructure to locate JNDI resources.
You may notice that the Spring we mentioned supports three types of EJB, but we only implement two types of EJB, stateless and stateful. The support classes for message-driven bean use patterns similar to those used for stateless and stateful session bean.
Building EJB components in Spring
Spring provides three abstract classes as the base classes of the EJB bean class: AbstractStatelessSessionBean,AbstractStatefulSessionBean and AbstractMessageDrivenBean. When using Spring to build EJB, you must provide all the different interfaces and home classes, but when implementing the bean class, you need to inherit from the appropriate Spring base class. The base class provided by Spring allows EJB components to access Spring's ApplicationContext, and thus allows these components to access resources managed by Spring.
Before moving on to the detailed discussion of using Spring to build EchoService and CounterService bean, we will look at how Spring locates EJB components in ApplicationContext and the recommended compilation EJB solution when using Spring.
This is the answer to the question about how Spring supports the implementation of EJB. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.