1 26 27 package org.objectweb.sampleCluster2.ejb; 28 29 30 import java.util.ArrayList ; 31 import java.util.Iterator ; 32 33 import javax.ejb.SessionBean ; 34 import javax.ejb.SessionContext ; 35 import javax.ejb.SessionSynchronization ; 36 37 import org.objectweb.jonas.common.JProp; 38 import org.objectweb.jonas.common.Log; 39 40 import org.objectweb.util.monolog.api.BasicLevel; 41 import org.objectweb.util.monolog.api.Logger; 42 43 46 public class MyStatefulSFR implements SessionBean , SessionSynchronization { 47 48 51 private static final long serialVersionUID = 1L; 52 53 56 public void afterBegin() { 57 logger.log(BasicLevel.DEBUG, ""); 58 } 59 60 63 public void beforeCompletion() { 64 logger.log(BasicLevel.DEBUG, ""); 65 } 66 67 71 public void afterCompletion(boolean committed) { 72 logger.log(BasicLevel.DEBUG, ""); 73 } 74 75 79 public void setSessionContext(SessionContext ctx) { 80 if (logger == null) { 81 logger = Log.getLogger("org.objectweb.jonas_tests"); 82 } 83 logger.log(BasicLevel.DEBUG, ""); 84 } 85 86 89 public void ejbRemove() { 90 logger.log(BasicLevel.DEBUG, ""); 91 } 92 93 96 public void ejbCreate() { 97 logger.log(BasicLevel.DEBUG, ""); 98 creatorJonasInstanceName = "unknown"; 99 100 try { 101 JProp jp = JProp.getInstance(); 102 creatorJonasInstanceName = jp.getValue("jonas.name"); 103 } catch (Exception e) { 104 logger.log(BasicLevel.FATAL, e.getMessage()); 105 } 106 107 log = new ArrayList (MAXSIZE); 108 109 logger.log(BasicLevel.DEBUG, "ejbCreate()->" + this.toString()); 110 111 } 112 113 116 public void ejbPassivate() { 117 logger.log(BasicLevel.DEBUG, ""); 118 } 119 120 123 public void ejbActivate() { 124 logger.log(BasicLevel.DEBUG, ""); 125 } 126 127 133 public void log(java.lang.String s) { 134 logger.log(BasicLevel.DEBUG, ""); 135 136 if (log.size() == MAXSIZE) { 137 Iterator iter = log.iterator(); 138 iter.next(); 139 iter.remove(); 140 } 141 142 log.add(s); 143 } 144 145 151 public java.lang.StringBuffer getLogDump() { 152 logger.log(BasicLevel.DEBUG, ""); 153 154 StringBuffer sb = new StringBuffer (); 155 sb.append("JOnAS instance="); 156 sb.append(creatorJonasInstanceName); 157 sb.append(" ; EJB="); 158 sb.append(this.toString()); 159 sb.append("\n"); 160 sb.append("Owner: "); 161 sb.append(callerHTTPSessionId); 162 sb.append("\n"); 163 Iterator iter = log.iterator(); 164 int i = 0; 165 166 sb 167 .append("<table border=1><tr><td>servlet running on</td><td>stateless bean created on</td><td>statless bean total calls</td><td>entity bean created on</td></tr>"); 168 while (iter.hasNext()) { 169 sb.append(iter.next()); 170 } 171 sb.append("</table>"); 172 173 logger.log(BasicLevel.INFO, sb.toString()); 174 return sb; 175 } 176 177 182 public void setHTTPSessionId(java.lang.String s) { 183 logger.log(BasicLevel.DEBUG, ""); 184 callerHTTPSessionId = s; 185 } 186 187 192 public java.lang.String getHTTPSessionId() { 193 logger.log(BasicLevel.DEBUG, ""); 194 return callerHTTPSessionId; 195 } 196 197 200 private String creatorJonasInstanceName = "unknown"; 201 202 205 private static Logger logger = null; 206 207 208 211 private static final int MAXSIZE = 20; 212 213 216 private ArrayList log = null; 217 218 221 private String callerHTTPSessionId = null; 222 223 } 224 225 | Popular Tags |