Appendix C. Stateful Session EJB: FTP Client Example

Description

Often it’s necessary for the server to remember information about a specific client in between requests; this is modeled by components that have “conversational state.” For instance, the File Transfer Protocol is “stateful”—the server knows the current working directory used by each client, for example. In this example we’ll model an FTP client using the stateful session bean.

In order to save resources (i.e., RAM), SFSBs may go through a processes called “passivation” whereby an instance/client session is removed from memory and persisted to disk after some timeout. If the client session is needed again, the state may be activated back into use. Here we must explicitly ensure that our state is properly accounted for in this serialization/deserialization process such that passivation is completely transparent to the client.

Get Enterprise JavaBeans 3.1, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.