1 55 package org.lateralnz.panther.wrapper; 56 57 import java.security.Identity ; 58 import java.security.Principal ; 59 import java.util.Properties ; 60 import javax.ejb.EJBHome ; 61 import javax.ejb.EJBLocalHome ; 62 import javax.ejb.EJBLocalObject ; 63 import javax.ejb.EJBObject ; 64 import javax.transaction.Status ; 65 import javax.transaction.TransactionManager ; 66 import javax.transaction.UserTransaction ; 67 68 import org.apache.log4j.Logger; 69 70 import org.lateralnz.common.util.JNDIUtils; 71 72 78 public class SessionContextWrapper implements javax.ejb.SessionContext { 79 private static final Logger log = Logger.getLogger(SessionContextWrapper.class.getName()); 80 private SessionBeanHome sbw; 81 private TransactionManager tm; 82 private UserTransaction ut; 83 84 public SessionContextWrapper(SessionBeanHome sbw) { 85 this.sbw = sbw; 86 try { 87 this.tm = (TransactionManager )JNDIUtils.get("java:/TransactionManager"); 88 } 89 catch (Exception e) { 90 log.error(e); 91 } 92 93 try { 94 this.ut = (UserTransaction )JNDIUtils.get("java:comp/UserTransaction"); 95 } 96 catch (Exception e) { 97 log.error(e); 98 } 99 } 100 101 public Identity getCallerIdentity() { 102 return null; 103 } 104 105 public Principal getCallerPrincipal() { 106 return null; 107 } 108 109 public EJBHome getEJBHome() { 110 return sbw; 111 } 112 113 public EJBLocalHome getEJBLocalHome() { 114 throw new UnsupportedOperationException (); 115 } 116 117 public Properties getEnvironment() { 118 return null; 119 } 120 121 public boolean getRollbackOnly() { 122 try { 123 if (tm == null) { 124 return false; 125 } 126 else { 127 return tm.getStatus() == Status.STATUS_MARKED_ROLLBACK; 128 } 129 } 130 catch (Exception e) { 131 log.error(e); 132 return false; 133 } 134 } 135 136 public UserTransaction getUserTransaction() { 137 return ut; 138 } 139 140 public boolean isCallerInRole(String str) { 141 return false; 142 } 143 144 public boolean isCallerInRole(Identity identity) { 145 return false; 146 } 147 148 public void setRollbackOnly() { 149 try { 150 if (tm != null) { 151 tm.setRollbackOnly(); 152 } 153 } 154 catch (Exception e) { 155 e.printStackTrace(); 156 } 157 } 158 159 public EJBLocalObject getEJBLocalObject() { 160 return null; 161 } 162 163 public EJBObject getEJBObject() { 164 return null; 165 } 166 } | Popular Tags |