1 25 26 package org.objectweb.jonas_ejb.deployment.api; 27 28 import org.objectweb.jonas_ejb.container.TraceEjb; 29 import org.objectweb.jonas_ejb.deployment.xml.Session; 30 import org.objectweb.jonas_ejb.deployment.xml.AssemblyDescriptor; 31 import org.objectweb.jonas_ejb.deployment.xml.JonasSession; 32 import org.objectweb.jonas_lib.deployment.api.DeploymentDescException; 33 import org.objectweb.jonas_lib.deployment.xml.JLinkedList; 34 import org.objectweb.util.monolog.api.BasicLevel; 35 36 42 public abstract class SessionDesc extends BeanDesc { 43 44 protected int transactionType; 45 int sessionTimeout = 0; 46 47 51 public SessionDesc(ClassLoader classLoader, Session ses, 52 AssemblyDescriptor asd, JonasSession jSes, JLinkedList jMDRList, 53 String filename) throws DeploymentDescException { 54 55 super(classLoader, ses, jSes, asd, jMDRList, filename); 56 57 if (jSes.getSessionTimeout() != null) { 59 String tstr = jSes.getSessionTimeout(); 60 Integer tval = new Integer (tstr); 61 sessionTimeout = tval.intValue(); 62 } 63 if (jSes.getMinPoolSize() != null) { 65 String tstr = jSes.getMinPoolSize(); 66 Integer tval = new Integer (tstr); 67 poolMin = tval.intValue(); 68 } 69 70 if (jSes.getMaxCacheSize() != null) { 72 String tstr = jSes.getMaxCacheSize(); 73 Integer tval = new Integer (tstr); 74 cacheMax = tval.intValue(); 75 } 76 77 if (ses.getTransactionType().equals("Bean")) { 79 transactionType = BEAN_TRANSACTION_TYPE; 80 } else if (ses.getTransactionType().equals("Container")) { 81 transactionType = CONTAINER_TRANSACTION_TYPE; 82 } else { 83 throw new DeploymentDescException( 84 "Invalid transaction-type content for ejb-name " + ejbName); 85 } 86 } 87 88 91 protected void checkTxAttribute(MethodDesc md) 92 throws DeploymentDescException { 93 java.lang.reflect.Method m = md.getMethod(); 94 if (getTransactionType() == CONTAINER_TRANSACTION_TYPE) { 95 if ((md.getTxAttribute() == MethodDesc.TX_NOT_SET) 98 && javax.ejb.EJBObject .class.isAssignableFrom(m 99 .getDeclaringClass()) 100 && !javax.ejb.EJBObject .class.equals(m.getDeclaringClass())) { 101 logger.log(BasicLevel.WARN, 104 "trans-attribute missing for method " + m.toString() 105 + " in session bean " + getEjbName() 106 + " (set to the default value " 107 + MethodDesc.TX_STR_DEFAULT_VALUE + ")"); 108 md.setTxAttribute(MethodDesc.TX_STR_DEFAULT_VALUE); 109 } 110 if ((md.getTxAttribute() != MethodDesc.TX_NOT_SET) 112 && javax.ejb.EJBHome .class.isAssignableFrom(m 113 .getDeclaringClass()) 114 && ((md.getTxAttributeStatus() == MethodDesc.APPLY_TO_CLASS) 115 || (md.getTxAttributeStatus() == MethodDesc.APPLY_TO_CLASS_METHOD_NAME) || (md 116 .getTxAttributeStatus() == MethodDesc.APPLY_TO_CLASS_METHOD))) { 117 TraceEjb.dd.log(BasicLevel.WARN, 118 "trans-attribute must not be specified for home interface's method " 119 + m.toString() + " in session bean " 120 + getEjbName()); 121 } 122 } else { 123 if (md.getTxAttribute() != MethodDesc.TX_NOT_SET) { 124 throw new DeploymentDescException(md.getTxAttributeName() 125 + " is not a valid trans-attribute for method " 126 + m.toString() + " in session bean " + getEjbName()); 127 } 128 } 129 } 130 131 137 public int getTransactionType() { 138 return transactionType; 139 } 140 141 144 public boolean isBeanManagedTransaction() { 145 return (transactionType == BEAN_TRANSACTION_TYPE); 146 } 147 148 151 public int getSessionTimeout() { 152 return sessionTimeout; 153 } 154 155 161 public void check() throws DeploymentDescException { 162 super.check(); 163 if ((getTransactionType() == BEAN_TRANSACTION_TYPE) 166 && (javax.ejb.SessionSynchronization .class 167 .isAssignableFrom(ejbClass))) { 168 throw new DeploymentDescException( 169 ejbClass.getName() 170 + " should NOT manage transactions and implement javax.ejb.SessionSynchronization"); 171 } 172 } 173 174 179 public String toString() { 180 StringBuffer ret = new StringBuffer (); 181 ret.append(super.toString()); 182 ret.append("\ngetTransactionType()" + TRANS[getTransactionType()]); 183 ret.append("\nsessionTimeout = " + sessionTimeout); 184 return ret.toString(); 185 } 186 187 } 188 189 | Popular Tags |