1 21 22 package uk.org.primrose.vendor.jboss.ejb; 23 24 import java.rmi.RemoteException ; 25 import javax.ejb.SessionBean ; 26 import javax.ejb.SessionContext ; 27 import javax.naming.Context ; 28 import javax.naming.InitialContext ; 29 import javax.naming.NamingException ; 30 31 35 public class BindBean implements SessionBean { 36 private SessionContext context; 37 38 44 public boolean bindENC(String name, Object value) { 45 System.out.println("[BindBean] Binding JNDI context : " +name +" to : " +value); 46 try { 47 InitialContext ic = new InitialContext (); 48 Context enc = (Context )ic.lookup("java:comp/env"); 49 enc.bind(name, value); 50 } 51 catch(NamingException ne) { 52 System.err.println("[BindBean] Failed to bind JNDI ENC context : " +name +" to : " +value); 53 return false; 54 } 55 return true; 56 } 57 58 64 public boolean bindRoot(String name, Object value) { 65 System.out.println("[BindBean] Binding JNDI Root context : " +name +" to : " +value); 66 try { 67 InitialContext ic = new InitialContext (); 68 ic.bind(name, value); 69 } 70 catch(NamingException ne) { 71 System.err.println("[BindBean] SEVERE ERROR !!! Failed to bind JNDI context : " +name +" to : " +value); 72 ne.printStackTrace(System.err); 73 return false; 74 } 75 return true; 76 } 77 78 81 public void ejbCreate(){} 82 85 public void ejbLoad(){} 86 89 public void ejbRemove(){} 90 93 public void ejbStore(){} 94 97 public void ejbActivate(){} 98 101 public void ejbPassivate(){} 102 103 106 public void setSessionContext(SessionContext context) { 107 this.context = context; 108 } 109 110 113 public void unsetSessionContext() { 114 this.context = null; 115 } 116 } 117 | Popular Tags |