First page Back Continue Last page Graphics
Continuation of Notes...
Notes:
public class LegacyAppSessionBean implements SessionBean {
private SessionContext _ctxt;
private String _strIPAddr;
private int _iPort;
private transient Socket _socket;
//================================================
// Private helper methods
//================================================
private void connect(String strIPAddr, int iPort)
throws UnknownHostException, IOException {
// Socket c'tor throws UnknownHostException, IOException
_socket = new Socket(_strIPAddr, _iPort);
}
private void disconnect() throws IOException {
_socket.close(); // Close connection before sleeping
_socket = null;
}
//================================================
// ejbCreate() method
//================================================
public void ejbCreate(String strIPAddr, int iPort )
throws CreateException {
try {
// connect() throws UnknownHostException, IOException
connect(strIPAddr, iPort);
_strIPAddr = strIPAddr;
_iPort = iPort;
}
catch(Exception e) {
// Tell container there's a problem
throw new CreateException(e.toString());
}
}
// Continued...