Spring, IOC mode and EJB3 call

xiaoxiao2021-03-06  66

Let's take a look at how to call EJB3: public class helloservlet extends genericservlet {private hello_hello;

Public void sethello (hello hello) {_hello = hello;

public void service (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {PrintWriter out = res.getWriter (); out.println (_hello.hello ());}} We then look at the configuration xml: We see what • The Hellobean passed Hellobean to sethello as a parameter, of course, Hellobean

Now he is a Hello interface; in service, directly call _hello.hello (), actually calling Hellobean

Hello () method is implemented. Oh, pass the needs of the Hellobean to the servlet, if our needs have changed,

New Hello2Bean implementation, we only need to modify in the configuration file, this is the IOC mode

The Type2.Spring framework is also type2 IOC mode, such as the Spring profile as follows: So we can use this in the code : public class teacher {

PRIVATE STUDENT;

Public void setstudent (student student) {this.student = student;} // write paper method public void writepaper () {student.writepaper ();}}, if you want to write IOC's papers, find a master of IOC students Write; if you want to write BPEL's papers, find one

Writing BPEL's student writing, places to modify, that is, configuration files.

转载请注明原文地址:https://www.9cbs.com/read-119009.html

New Post(0)