EjbDeploymentBuilder ejbDeploymentBuilder = ejbModule.getEjbBuilder();
// add enc
ejbDeploymentBuilder.buildEnc();
Set<GBeanData> gBeanDatas = earContext.getConfiguration().findGBeanDatas(Collections.singleton(new AbstractNameQuery(PersistenceUnitGBean.class.getName())));
LinkResolver<String> linkResolver = new UniqueDefaultLinkResolver<String>();
for (GBeanData gBeanData : gBeanDatas) {
String name = (String) gBeanData.getAttribute("persistenceUnitName");
String rootUrl = (String) gBeanData.getAttribute("persistenceUnitRoot");
if (name.equals("cmp")) continue;
String id = name + " " + rootUrl.hashCode();
linkResolver.add(rootUrl, name, id);
}
EjbJarInfo ejbJarInfo = ejbModule.getEjbJarInfo();
for (EnterpriseBeanInfo beanInfo : ejbJarInfo.enterpriseBeans) {
if (beanInfo instanceof StatefulBeanInfo) {
StatefulBeanInfo statefulBeanInfo = (StatefulBeanInfo) beanInfo;
for (PersistenceContextReferenceInfo refInfo : statefulBeanInfo.jndiEnc.persistenceContextRefs) {
if (refInfo.extended) {
String id = linkResolver.resolveLink(refInfo.persistenceUnitName, ejbJarInfo.moduleId);
refInfo.unitId = id;
}
}
}
}
// Add JSR77 EJBModule GBean
GBeanData ejbModuleGBeanData = new GBeanData(ejbModule.getModuleName(), EjbModuleImplGBean.GBEAN_INFO);
try {
ejbModuleGBeanData.setReferencePattern("J2EEServer", earContext.getServerName());
if (!ejbModule.isStandAlone()) {
ejbModuleGBeanData.setReferencePattern("J2EEApplication", earContext.getModuleName());
}
ejbModuleGBeanData.setAttribute("deploymentDescriptor", ejbModule.getOriginalSpecDD());
ejbModuleGBeanData.setReferencePatterns("EJBCollection",
new ReferencePatterns(new AbstractNameQuery(null,
Collections.singletonMap(NameFactory.EJB_MODULE, ejbModule.getModuleName().getNameProperty(NameFactory.J2EE_NAME)),
EjbDeployment.class.getName())));
ejbModuleGBeanData.setReferencePattern("OpenEjbSystem", new AbstractNameQuery(null, Collections.EMPTY_MAP, OpenEjbSystem.class.getName()));
ejbModuleGBeanData.setAttribute("ejbJarInfo", ejbModule.getEjbJarInfo());
earContext.addGBean(ejbModuleGBeanData);
} catch (Exception e) {
throw new DeploymentException("Unable to initialize EJBModule GBean " + ejbModuleGBeanData.getAbstractName(), e);