public AppModule deploy(AppModule appModule) throws OpenEJBException {
for (EjbModule ejbModule : appModule.getEjbModules()) {
EjbJar ejbJar = ejbModule.getEjbJar();
OpenejbJar openejbJar = ejbModule.getOpenejbJar();
Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
for (EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
String ejbName = bean.getEjbName();
EjbDeployment ejbDeployment = deployments.get(ejbName);
// Clear any <service-ref> references from ejbs
bean.getServiceRef().clear();
if (!(bean instanceof SessionBean)) {
continue;
}
SessionBean sessionBean = (SessionBean) bean;
if (sessionBean.getServiceEndpoint() == null) continue;
sessionBean.setServiceEndpoint(null);
// Now check if the bean has no other interfaces
// if not, then we should just delete it
if (sessionBean.getHome() != null) continue;
if (sessionBean.getLocalHome() != null) continue;
if (sessionBean.getBusinessLocal().size() > 0) continue;
if (sessionBean.getBusinessRemote().size() > 0) continue;
// Ok, delete away...
ejbJar.removeEnterpriseBean(ejbName);
openejbJar.removeEjbDeployment(ejbDeployment);
// As well, let's get rid of any transaction or security attributes
// associated with the bean we just deleted.
AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
if (assemblyDescriptor != null) {