Appendix C. Stateful Session EJB: FTP Client Example
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.
Online Companion Information
Wiki article: http://community.jboss.org/docs/DOC-15568
Following is a full listing of all source code used in this runnable example.
package org.jboss.ejb3.examples.ch06.filetransfer; import java.io.IOException; import java.io.Serializable; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.ejb.PostActivate; import javax.ejb.PrePassivate; import javax.ejb.Remote; import ...