1 25 26 package org.objectweb.easybeans.deployment.annotations.helper.bean.session; 27 28 import org.objectweb.easybeans.deployment.annotations.impl.JLocal; 29 import org.objectweb.easybeans.deployment.annotations.impl.JRemote; 30 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 31 32 37 public final class SessionBusinessInterfaceFinder { 38 39 42 private SessionBusinessInterfaceFinder() { 43 } 44 45 50 public static void resolve(final ClassAnnotationMetadata sessionBean) { 51 52 JLocal jLocal = sessionBean.getLocalInterfaces(); 53 JRemote jRemote = sessionBean.getRemoteInterfaces(); 54 55 if ((jLocal == null && jRemote == null) || (jLocal == null && jRemote != null && jRemote.getInterfaces().isEmpty()) 57 ||(jRemote == null && jLocal != null && jLocal.getInterfaces().isEmpty())) { 58 59 String [] interfaces = sessionBean.getInterfaces(); 65 int numberItfFound = 0; 66 String itfFound = null; 67 for (String itf : interfaces) { 68 if (!itf.equals(java.io.Serializable .class.getName().replace(".", "/")) 69 && !itf.equals(java.io.Externalizable .class.getName().replace(".", "/")) 70 && !itf.startsWith("javax/ejb")) { 71 itfFound = itf; 72 numberItfFound++; 73 } 74 } 75 76 if (numberItfFound == 0) { 77 throw new IllegalStateException ("No business interface found on class '" + sessionBean.getClassName() + "'."); 78 } 79 80 81 if (numberItfFound > 1) { 82 throw new IllegalStateException ("More than 1 itf on class '" + sessionBean.getClassName() + "'."); 83 } 84 85 94 if (jRemote == null) { 96 JLocal addedJLocal = new JLocal(); 97 addedJLocal.addInterface(itfFound); 98 sessionBean.setLocalInterfaces(addedJLocal); 99 } else { 100 jRemote.addInterface(itfFound); 101 sessionBean.setRemoteInterfaces(jRemote); 102 } 103 104 105 } 106 } 107 } 108 | Popular Tags |