00001
00026 package org.objectweb.jonas_ejb.deployment.api;
00027
00028 import java.lang.reflect.Method;
00029 import java.util.Iterator;
00030
00031 import org.objectweb.jonas_ejb.deployment.xml.AssemblyDescriptor;
00032 import org.objectweb.jonas_ejb.deployment.xml.CommonEjb;
00033 import org.objectweb.jonas_ejb.deployment.xml.JonasSession;
00034 import org.objectweb.jonas_ejb.deployment.xml.Session;
00035 import org.objectweb.jonas_ejb.lib.BeanNaming;
00036
00037 import org.objectweb.jonas_lib.deployment.api.DeploymentDescException;
00038 import org.objectweb.jonas_lib.deployment.xml.JLinkedList;
00039
00046 public class SessionStatelessDesc extends SessionDesc {
00047
00051 private static final String SERVICE_ENDPOINT_JNDI_SUFFIX = "_SE";
00052
00056 private String wrpServiceEndpointName;
00057 private String wrpSEHomeName;
00058
00062 private String fullWrpServiceEndpointName;
00063 private String fullWrpSEHomeName;
00064
00068 private Class serviceEndpointClass;
00069
00073 private String serviceEndpointJndiName;
00074
00087 public SessionStatelessDesc(ClassLoader classLoader, Session ses, AssemblyDescriptor asd, JonasSession jSes,
00088 JLinkedList jMDRList, String filename) throws DeploymentDescException {
00089 super(classLoader, ses, asd, jSes, jMDRList, filename);
00090
00091
00092 String ejbIdentifier = getIdentifier();
00093 if (getServiceEndpointClass() != null) {
00094 String packageName = BeanNaming.getPackageName(getServiceEndpointClass().getName());
00095 wrpServiceEndpointName = new String("JOnAS" + ejbIdentifier + "ServiceEndpoint");
00096 fullWrpServiceEndpointName = BeanNaming.getClassName(packageName, wrpServiceEndpointName);
00097 wrpSEHomeName = new String("JOnAS" + ejbIdentifier + "SEHome");
00098 fullWrpSEHomeName = BeanNaming.getClassName(packageName, wrpSEHomeName);
00099 }
00100
00101
00102 if (jSes.getJndiEndpointName() != null) {
00103 serviceEndpointJndiName = jSes.getJndiEndpointName();
00104 } else {
00105 serviceEndpointJndiName = getJndiName() + SERVICE_ENDPOINT_JNDI_SUFFIX;
00106 }
00107
00108
00109 for (Iterator i = getMethodDescIterator(); i.hasNext();) {
00110 MethodDesc methd = (MethodDesc) i.next();
00111 if (methd.getMethod().getName().equals("ejbTimeout")) {
00112 timerTxAttribute = methd.getTxAttribute();
00113 ejbTimeoutSignature = BeanNaming.getSignature(getEjbName(), methd.getMethod());
00114 }
00115 }
00116 }
00117
00123 public void check() throws DeploymentDescException {
00124 super.check();
00125
00126 if (javax.ejb.SessionSynchronization.class.isAssignableFrom(ejbClass)) {
00127 throw new DeploymentDescException(ejbClass.getName()
00128 + " should NOT implement javax.ejb.SessionSynchronization");
00129 }
00130 }
00131
00142 protected int addEJBMethodDesc(int len) throws DeploymentDescException {
00143
00144 if (this.serviceEndpointClass != null) {
00145
00146 Method[] m = this.serviceEndpointClass.getMethods();
00147 for (int i = 0; i < m.length; i++) {
00148 addMethodDesc(m[i]);
00149 len++;
00150
00151 checkRemoteException(m[i], true);
00152 }
00153 }
00154 return len;
00155 }
00156
00165 protected void loadExtraClasses(CommonEjb bd, ClassLoader classLoader) throws DeploymentDescException {
00166
00167 Session ses = (Session) bd;
00168
00169
00170 if (ses.getServiceEndpoint() != null) {
00171 try {
00172 serviceEndpointClass = classLoader.loadClass(ses.getServiceEndpoint());
00173
00174 if (!java.rmi.Remote.class.isAssignableFrom(serviceEndpointClass)) {
00175 throw new DeploymentDescException("ServiceEndpoint class '" + ses.getServiceEndpoint()
00176 + "' doesn't not extends java.rmi.Remote");
00177 }
00178 } catch (ClassNotFoundException e) {
00179 throw new DeploymentDescException("ServiceEndpoint class not found for bean " + ejbName, e);
00180 }
00181 }
00182
00183 }
00184
00195 protected Class getParentClass(String intfType) throws DeploymentDescException {
00196 Class pClass = null;
00197 if (intfType.equals("Home")) {
00198 pClass = javax.ejb.EJBHome.class;
00199 } else if (intfType.equals("Remote")) {
00200 pClass = javax.ejb.EJBObject.class;
00201 } else if (intfType.equals("LocalHome")) {
00202 pClass = javax.ejb.EJBLocalHome.class;
00203 } else if (intfType.equals("Local")) {
00204 pClass = javax.ejb.EJBLocalObject.class;
00205 } else if (intfType.equals("ServiceEndpoint")) {
00206 pClass = java.rmi.Remote.class;
00207 } else {
00208 throw new DeploymentDescException(intfType + " is invalid value for method-intf on bean " + ejbName);
00209 }
00210 return pClass;
00211 }
00212
00216 public Class getServiceEndpointClass() {
00217 return serviceEndpointClass;
00218 }
00219
00220 private void checkValidServiceEndpointInterface() {
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 }
00233
00237 public String getJndiServiceEndpointName() {
00238 return serviceEndpointJndiName;
00239 }
00240
00244 public String getFullWrpServiceEndpointName() {
00245 return fullWrpServiceEndpointName;
00246 }
00247
00251 public String getWrpServiceEndpointName() {
00252 return wrpServiceEndpointName;
00253 }
00254
00258 public String getFullWrpSEHomeName() {
00259 return fullWrpSEHomeName;
00260 }
00261
00265 public String getWrpSEHomeName() {
00266 return wrpSEHomeName;
00267 }
00268 }