1 25 26 package org.objectweb.jonas_ejb.deployment.api; 27 28 import java.lang.reflect.Method ; 29 import java.util.Iterator ; 30 31 import org.objectweb.jonas_ejb.deployment.xml.AssemblyDescriptor; 32 import org.objectweb.jonas_ejb.deployment.xml.CommonEjb; 33 import org.objectweb.jonas_ejb.deployment.xml.JonasSession; 34 import org.objectweb.jonas_ejb.deployment.xml.Session; 35 import org.objectweb.jonas_ejb.lib.BeanNaming; 36 37 import org.objectweb.jonas_lib.deployment.api.DeploymentDescException; 38 import org.objectweb.jonas_lib.deployment.xml.JLinkedList; 39 40 46 public class SessionStatelessDesc extends SessionDesc { 47 48 51 private static final String SERVICE_ENDPOINT_JNDI_SUFFIX = "_SE"; 52 53 56 private String wrpServiceEndpointName; 57 private String wrpSEHomeName; 58 59 62 private String fullWrpServiceEndpointName; 63 private String fullWrpSEHomeName; 64 65 68 private Class serviceEndpointClass; 69 70 73 private String serviceEndpointJndiName; 74 75 87 public SessionStatelessDesc(ClassLoader classLoader, Session ses, AssemblyDescriptor asd, JonasSession jSes, 88 JLinkedList jMDRList, String filename) throws DeploymentDescException { 89 super(classLoader, ses, asd, jSes, jMDRList, filename); 90 91 String ejbIdentifier = getIdentifier(); 93 if (getServiceEndpointClass() != null) { 94 String packageName = BeanDesc.GENERATED_PREFIX + 95 BeanNaming.getPackageName(getServiceEndpointClass().getName()); 96 wrpServiceEndpointName = new String ("JOnAS" + ejbIdentifier + "ServiceEndpoint"); 97 fullWrpServiceEndpointName = BeanNaming.getClassName(packageName, wrpServiceEndpointName); 98 wrpSEHomeName = new String ("JOnAS" + ejbIdentifier + "SEHome"); 99 fullWrpSEHomeName = BeanNaming.getClassName(packageName, wrpSEHomeName); 100 } 101 102 if (jSes.getJndiEndpointName() != null) { 104 serviceEndpointJndiName = jSes.getJndiEndpointName(); 105 } else { 106 serviceEndpointJndiName = getJndiName() + SERVICE_ENDPOINT_JNDI_SUFFIX; 107 } 108 109 for (Iterator i = getMethodDescIterator(); i.hasNext();) { 111 MethodDesc methd = (MethodDesc) i.next(); 112 if (methd.getMethod().getName().equals("ejbTimeout")) { 113 timerTxAttribute = methd.getTxAttribute(); 114 ejbTimeoutSignature = BeanNaming.getSignature(getEjbName(), methd.getMethod()); 115 } 116 } 117 } 118 119 124 public void check() throws DeploymentDescException { 125 super.check(); 126 if (javax.ejb.SessionSynchronization .class.isAssignableFrom(ejbClass)) { 128 throw new DeploymentDescException(ejbClass.getName() 129 + " should NOT implement javax.ejb.SessionSynchronization"); 130 } 131 } 132 133 143 protected int addEJBMethodDesc(int len) throws DeploymentDescException { 144 145 if (this.serviceEndpointClass != null) { 146 Method [] m = this.serviceEndpointClass.getMethods(); 148 for (int i = 0; i < m.length; i++) { 149 addMethodDesc(m[i], this.serviceEndpointClass); 150 len++; 151 checkRemoteException(m[i], true); 153 } 154 } 155 return len; 156 } 157 158 166 protected void loadExtraClasses(CommonEjb bd, ClassLoader classLoader) throws DeploymentDescException { 167 168 Session ses = (Session) bd; 169 170 if (ses.getServiceEndpoint() != null) { 172 try { 173 serviceEndpointClass = classLoader.loadClass(ses.getServiceEndpoint()); 174 if (!java.rmi.Remote .class.isAssignableFrom(serviceEndpointClass)) { 176 throw new DeploymentDescException("ServiceEndpoint class '" + ses.getServiceEndpoint() 177 + "' doesn't not extends java.rmi.Remote"); 178 } 179 } catch (ClassNotFoundException e) { 180 throw new DeploymentDescException("ServiceEndpoint class not found for bean " + ejbName, e); 181 } 182 } 183 184 } 185 186 196 protected Class getParentClass(String intfType) throws DeploymentDescException { 197 Class pClass = null; 198 if (intfType.equals("Home")) { 199 pClass = javax.ejb.EJBHome .class; 200 } else if (intfType.equals("Remote")) { 201 pClass = javax.ejb.EJBObject .class; 202 } else if (intfType.equals("LocalHome")) { 203 pClass = javax.ejb.EJBLocalHome .class; 204 } else if (intfType.equals("Local")) { 205 pClass = javax.ejb.EJBLocalObject .class; 206 } else if (intfType.equals("ServiceEndpoint")) { 207 pClass = java.rmi.Remote .class; 208 } else { 209 throw new DeploymentDescException(intfType + " is invalid value for method-intf on bean " + ejbName); 210 } 211 return pClass; 212 } 213 214 217 public Class getServiceEndpointClass() { 218 return serviceEndpointClass; 219 } 220 221 private void checkValidServiceEndpointInterface() { 222 } 234 235 238 public String getJndiServiceEndpointName() { 239 return serviceEndpointJndiName; 240 } 241 242 245 public String getFullWrpServiceEndpointName() { 246 return fullWrpServiceEndpointName; 247 } 248 249 252 public String getWrpServiceEndpointName() { 253 return wrpServiceEndpointName; 254 } 255 256 259 public String getFullWrpSEHomeName() { 260 return fullWrpSEHomeName; 261 } 262 263 266 public String getWrpSEHomeName() { 267 return wrpSEHomeName; 268 } 269 } 270 | Popular Tags |