1 25 26 29 package org.objectweb.jonas.jtests.tables; 30 31 import java.rmi.RemoteException ; 32 import javax.ejb.CreateException ; 33 import javax.ejb.SessionBean ; 34 import javax.ejb.SessionContext ; 35 import javax.naming.Context ; 36 import javax.naming.InitialContext ; 37 import javax.naming.NamingException ; 38 import javax.sql.DataSource ; 39 40 41 44 public class DBEnvSL implements SessionBean { 45 46 SessionContext ejbContext; 47 48 52 public void setSessionContext(SessionContext ctx) { 53 ejbContext = ctx; 54 } 55 56 public void ejbRemove() { 57 } 58 59 public void ejbCreate() throws CreateException { 60 } 61 62 public void ejbPassivate() { 63 } 64 65 public void ejbActivate() { 66 } 67 68 72 75 public static DataSource getDataSource(String jndiName) throws NamingException { 76 Context initialContext = new InitialContext (); 77 DataSource ds = (DataSource )initialContext.lookup(jndiName); 78 return ds; 79 } 80 81 85 88 public void initTable(String container) throws RemoteException { 89 try { 90 Class.forName("org.objectweb.jonas.jtests.tables."+"T"+container) 91 .getMethod("init", new Class [0]) 92 .invoke(null, new Object [0]); 93 } catch(Exception e) { 94 System.err.println("Could not init table for " + container + ": " + e); 95 throw new RemoteException ("Could not init table for " + container); 96 } 97 } 98 } 99 100 101 | Popular Tags |