}
}
}
if (remoteBean instanceof SessionBean) {
SessionBean sessionBean = (SessionBean) remoteBean;
// Anything declared in the xml is also not eligable
List<String> declared = new ArrayList<String>();
declared.addAll(sessionBean.getBusinessLocal());
declared.addAll(sessionBean.getBusinessRemote());
declared.add(sessionBean.getHome());
declared.add(sessionBean.getRemote());
declared.add(sessionBean.getLocalHome());
declared.add(sessionBean.getLocal());
declared.add(sessionBean.getServiceEndpoint());
List<Class<?>> interfaces = new ArrayList<Class<?>>();
for (Class<?> interfce : clazz.getInterfaces()) {
String name = interfce.getName();
if (!name.equals("java.io.Serializable") &&
!name.equals("java.io.Externalizable") &&
!name.startsWith("javax.ejb.") &&
!declared.contains(interfce.getName())) {
interfaces.add(interfce);
}
}
List<Class> remotes = new ArrayList<Class>();
Remote remote = clazz.getAnnotation(Remote.class);
if (remote != null) {
if (remote.value().length == 0) {
if (interfaces.size() != 1) {
validation.fail(ejbName, "ann.remote.noAttributes", join(", ", interfaces));
} else if (clazz.getAnnotation(Local.class) != null) {
validation.fail(ejbName, "ann.remoteLocal.ambiguous", join(", ", interfaces));
} else if (interfaces.get(0).getAnnotation(Local.class) != null) {
validation.fail(ejbName, "ann.remoteLocal.conflict", join(", ", interfaces));
} else {
validateRemoteInterface(interfaces.get(0), validation, ejbName);
remotes.add(interfaces.get(0));
interfaces.remove(0);
}
} else for (Class interfce : remote.value()) {
validateRemoteInterface(interfce, validation, ejbName);
remotes.add(interfce);
interfaces.remove(interfce);
}
}
List<Class> locals = new ArrayList<Class>();
Local local = clazz.getAnnotation(Local.class);
if (local != null) {
if (local.value().length == 0) {
if (interfaces.size() != 1) {
validation.fail(ejbName, "ann.local.noAttributes", join(", ", interfaces));
} else if (clazz.getAnnotation(Remote.class) != null) {
validation.fail(ejbName, "ann.localRemote.ambiguous", join(", ", interfaces));
} else if (interfaces.get(0).getAnnotation(Remote.class) != null) {
validation.fail(ejbName, "ann.localRemote.conflict", join(", ", interfaces));
} else {
validateLocalInterface(interfaces.get(0), validation, ejbName);
locals.add(interfaces.get(0));
interfaces.remove(0);
}
} else for (Class interfce : local.value()) {
validateLocalInterface(interfce, validation, ejbName);
locals.add(interfce);
interfaces.remove(interfce);
}
}
if (sessionBean.getServiceEndpoint() == null) {
WebService webService = clazz.getAnnotation(WebService.class);
if (webService != null) {
String endpointInterfaceName = webService.endpointInterface();
if (!endpointInterfaceName.equals("")){
try {
sessionBean.setServiceEndpoint(endpointInterfaceName);
Class endpointInterface = Class.forName(endpointInterfaceName, false, ejbModule.getClassLoader());
interfaces.remove(endpointInterface);
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Class not found @WebService.endpointInterface: "+endpointInterfaceName, e);
}
} else {
sessionBean.setServiceEndpoint(DeploymentInfo.ServiceEndpoint.class.getName());
}
} else if (clazz.isAnnotationPresent(WebServiceProvider.class)) {
sessionBean.setServiceEndpoint(DeploymentInfo.ServiceEndpoint.class.getName());
}
}
for (Class interfce : copy(interfaces)) {
if (interfce.isAnnotationPresent(Remote.class)) {
remotes.add(interfce);
interfaces.remove(interfce);
} else {
locals.add(interfce);
interfaces.remove(interfce);
}
}
for (Class interfce : remotes) {
sessionBean.addBusinessRemote(interfce.getName());
}
for (Class interfce : locals) {
sessionBean.addBusinessLocal(interfce.getName());
}
}
}
if (bean instanceof MessageDrivenBean) {