1 22 package org.jboss.test.jca.ejb; 23 24 import java.rmi.MarshalledObject ; 25 import java.rmi.RemoteException ; 26 import java.sql.Connection ; 27 import javax.ejb.EJBException ; 28 import javax.ejb.SessionBean ; 29 import javax.ejb.SessionContext ; 30 import javax.naming.InitialContext ; 31 import javax.sql.DataSource ; 32 33 import org.jboss.logging.Logger; 34 35 46 public class ConnectionFactorySerializationTestSessionBean 47 implements SessionBean 48 { 49 50 private static final long serialVersionUID = 1L; 51 private final Logger log = Logger.getLogger(getClass()); 52 53 59 public void testConnectionFactorySerialization() 60 { 61 try 62 { 63 DataSource ds = (DataSource )new InitialContext ().lookup("java:/DefaultDS"); 64 Connection c = ds.getConnection(); 65 c.close(); 66 MarshalledObject mo = new MarshalledObject (ds); 67 ds = (DataSource )mo.get(); 68 c = ds.getConnection(); 69 c.close(); 70 } 71 catch (Exception e) 72 { 73 log.info("Exception: ", e); 74 throw new EJBException ("Exception: " + e); 75 } } 77 78 public void ejbCreate() 79 { 80 } 81 82 public void ejbActivate() throws RemoteException 83 { 84 } 85 86 public void ejbPassivate() throws RemoteException 87 { 88 } 89 90 public void ejbRemove() throws RemoteException 91 { 92 } 93 94 public void setSessionContext(SessionContext ctx) throws RemoteException 95 { 96 } 97 98 public void unsetSessionContext() throws RemoteException 99 { 100 } 101 102 } 103 104 | Popular Tags |