private void processEntityBeanMetaData( final DeploymentUnit deploymentUnit, final EntityBeanMetaData entity) throws DeploymentUnitProcessingException { final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit); final String beanName = entity.getName(); final String beanClassName = entity.getEjbClass(); final EntityBeanComponentDescription description = new EntityBeanComponentDescription( beanName, beanClassName, ejbJarDescription, deploymentUnit.getServiceName()); // add it to the ejb jar description ejbJarDescription.getEEModuleDescription().addComponent(description); description.setDescriptorData(entity); description.setPersistenceType(entity.getPersistenceType()); description.setReentrant(entity.isReentrant()); description.setPrimaryKeyType(entity.getPrimKeyClass()); // TODO: validation final String localHome = entity.getLocalHome(); if (localHome != null) { description.addLocalHome(localHome); } final String local = entity.getLocal(); if (local != null) { description.addEjbLocalObjectView(local); } }
private void processSessionBeanMetaData( final DeploymentUnit deploymentUnit, final SessionBeanMetaData sessionBean) throws DeploymentUnitProcessingException { final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit); final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION); final List<ComponentDescription> additionalComponents = deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS); final String beanName = sessionBean.getName(); // the important bit is to skip already processed EJBs via annotations if (ejbJarDescription.hasComponent(beanName)) { final ComponentDescription description = eeModuleDescription.getComponentByName(beanName); if (description instanceof SessionBeanComponentDescription) { ((SessionBeanComponentDescription) description).setDescriptorData(sessionBean); } else { throw new DeploymentUnitProcessingException( "Session bean with name " + beanName + " referenced in ejb-jar.xml could not be created, as existing non session bean component with same name already exists: " + description); } return; } if (appclient) { for (final ComponentDescription component : additionalComponents) { if (component.getComponentName().equals(beanName)) { if (component instanceof SessionBeanComponentDescription) { ((SessionBeanComponentDescription) component).setDescriptorData(sessionBean); } else { throw new DeploymentUnitProcessingException( "Session bean with name " + beanName + " referenced in ejb-jar.xml could not be created, as existing non session bean component with same name already exists: " + component); } return; } } } final SessionType sessionType = sessionBean.getSessionType(); if (sessionType == null) {} if (sessionType == null && sessionBean instanceof GenericBeanMetaData) { // TODO: this is a hack return; } final String beanClassName = sessionBean.getEjbClass(); final SessionBeanComponentDescription sessionBeanDescription; switch (sessionType) { case Stateless: sessionBeanDescription = new StatelessComponentDescription( beanName, beanClassName, ejbJarDescription, deploymentUnit.getServiceName()); break; case Stateful: sessionBeanDescription = new StatefulComponentDescription( beanName, beanClassName, ejbJarDescription, deploymentUnit.getServiceName()); break; case Singleton: sessionBeanDescription = new SingletonComponentDescription( beanName, beanClassName, ejbJarDescription, deploymentUnit.getServiceName()); break; default: throw new IllegalArgumentException("Unknown session bean type: " + sessionType); } if (appclient) { deploymentUnit.addToAttachmentList( Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS, sessionBeanDescription); } else { // Add this component description to module description ejbJarDescription.getEEModuleDescription().addComponent(sessionBeanDescription); } sessionBeanDescription.setDescriptorData(sessionBean); }
private void processSessionBeans( final DeploymentUnit deploymentUnit, final List<AnnotationInstance> sessionBeanAnnotations, final SessionBeanComponentDescription.SessionBeanType annotatedSessionBeanType) { final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit); final ServiceName deploymentUnitServiceName = deploymentUnit.getServiceName(); // process these session bean annotations and create component descriptions out of it for (final AnnotationInstance sessionBeanAnnotation : sessionBeanAnnotations) { final AnnotationTarget target = sessionBeanAnnotation.target(); if (!(target instanceof ClassInfo)) { // Let's just WARN and move on. No need to throw an error logger.warn( sessionBeanAnnotation.name() + " annotation is expected to be applied on class level. " + target + " is not a class"); continue; } final ClassInfo sessionBeanClassInfo = (ClassInfo) target; // skip if it's not a valid class for session bean if (!assertSessionBeanClassValidity(sessionBeanClassInfo)) { continue; } final String ejbName = sessionBeanClassInfo.name().local(); final AnnotationValue nameValue = sessionBeanAnnotation.value("name"); final String beanName = nameValue == null || nameValue.asString().isEmpty() ? ejbName : nameValue.asString(); final EnterpriseBeanMetaData beanMetaData = getEnterpriseBeanMetaData(deploymentUnit, beanName); final SessionBeanComponentDescription.SessionBeanType sessionBeanType; final String beanClassName; if (beanMetaData != null && beanMetaData instanceof SessionBeanMetaData) { sessionBeanType = override( annotatedSessionBeanType, descriptionOf(((SessionBeanMetaData) beanMetaData).getSessionType())); } else { sessionBeanType = annotatedSessionBeanType; } if (beanMetaData != null) { beanClassName = override(sessionBeanClassInfo.name().toString(), beanMetaData.getEjbClass()); } else { beanClassName = sessionBeanClassInfo.name().toString(); } final SessionBeanComponentDescription sessionBeanDescription; switch (sessionBeanType) { case STATELESS: sessionBeanDescription = new StatelessComponentDescription( beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName); break; case STATEFUL: sessionBeanDescription = new StatefulComponentDescription( beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName); break; case SINGLETON: sessionBeanDescription = new SingletonComponentDescription( beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName); break; default: throw new IllegalArgumentException("Unknown session bean type: " + sessionBeanType); } if (appclient) { deploymentUnit.addToAttachmentList( Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS, sessionBeanDescription); } else { // Add this component description to module description ejbJarDescription.getEEModuleDescription().addComponent(sessionBeanDescription); } } EjbDeploymentMarker.mark(deploymentUnit); }