13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

476Chapter 21Introducti<strong>on</strong> to Enterprise JavaBeansmore urgent tasks (probably beans that are being actively called) to use resourcestied up by otherwise idle beans. Think of this as like memory swap in anoperating system. The bean will save any data and c<strong>on</strong>text informati<strong>on</strong> intosome sort of persistent storage, which may be a database, flat files, XML files,whatever, when it is passivated.C<strong>on</strong>text switching. Since both sessi<strong>on</strong> and entity beans may be calledup<strong>on</strong> to service requests from multiple clients, it is necessary to provide amethod whereby the c<strong>on</strong>tainer can notify the bean which “c<strong>on</strong>text” (whichmay be loosely said to be a client) is active at the moment. In stateless sessi<strong>on</strong>beans this is not necessarily implemented, but in stateful sessi<strong>on</strong> beans and inentity beans this activity must be supported.How is this distinct from passivati<strong>on</strong> and activati<strong>on</strong>? Passivati<strong>on</strong> is thetemporary “swapping out” of a bean to make room for something else. C<strong>on</strong>textswitching is the move of a Bean instance from client to client. Or, to put itanother way, passivati<strong>on</strong> makes room for some other bean to become activeand serve a client. 1 C<strong>on</strong>text switching switches a given bean from clientto client. 221.2.1.2 The EJB C<strong>on</strong>tainerA J2EE applicati<strong>on</strong> server has two c<strong>on</strong>tainers: a Web c<strong>on</strong>tainer and an EJBc<strong>on</strong>tainer. You can also think of these as “servers” in the more classic sense.J2EE calls them c<strong>on</strong>tainers because it emphasizes the idea that you place Javaobjects (applets, servlets, and Enterprise JavaBeans) into the c<strong>on</strong>tainer that canrun them (a browser, a Web c<strong>on</strong>tainer, an EJB c<strong>on</strong>tainer). The J2EE specificati<strong>on</strong>specifies the exact relati<strong>on</strong>ship between these applicati<strong>on</strong> objects and theirc<strong>on</strong>tainer. For EJB’s, the c<strong>on</strong>tainer provides lifecycle c<strong>on</strong>trol, network management,load management, perhaps clustering services, CMP (c<strong>on</strong>tainer-managedpersistence) services, and so <strong>on</strong>. We’ll talk a lot more about c<strong>on</strong>tainer services1. This is a simplificati<strong>on</strong>. A c<strong>on</strong>tainer can passivate a bean to make resources available for anypurpose, not just for another EJB. Beans might be passivated because some process <strong>on</strong> theserver outside the applicati<strong>on</strong> server needs resources. It is entirely dependent <strong>on</strong> how theapplicati<strong>on</strong> server is written. What is said here is c<strong>on</strong>ceptually true, if not actually true ;-)2. Again, saying “client-to-client” is a simplificati<strong>on</strong>. A single client may have multiple threadsinteracting with multiple beans, and a c<strong>on</strong>text switch might be performed to serve differentrequests from a single client. Again: c<strong>on</strong>ceptually true, if not actually true.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!