use of org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor in project wildfly by wildfly.
the class KernelDeploymentParsingProcessor method parseDescriptor.
/**
* Parse -jboss-beans.xml file.
*
* @param unit the deployment unit
* @param beansXmlFile the beans xml file
* @throws DeploymentUnitProcessingException
* for any error
*/
protected void parseDescriptor(DeploymentUnit unit, VirtualFile beansXmlFile) throws DeploymentUnitProcessingException {
if (beansXmlFile == null || beansXmlFile.exists() == false)
return;
InputStream xmlStream = null;
try {
xmlStream = beansXmlFile.openStream();
final XMLStreamReader reader = inputFactory.createXMLStreamReader(xmlStream);
final ParseResult<KernelDeploymentXmlDescriptor> result = new ParseResult<KernelDeploymentXmlDescriptor>();
xmlMapper.parseDocument(result, reader);
final KernelDeploymentXmlDescriptor xmlDescriptor = result.getResult();
if (xmlDescriptor != null)
unit.addToAttachmentList(KernelDeploymentXmlDescriptor.ATTACHMENT_KEY, xmlDescriptor);
else
throw PojoLogger.ROOT_LOGGER.failedToParse(beansXmlFile);
} catch (DeploymentUnitProcessingException e) {
throw e;
} catch (Exception e) {
throw PojoLogger.ROOT_LOGGER.parsingException(beansXmlFile, e);
} finally {
VFSUtils.safeClose(xmlStream);
}
}
use of org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor in project wildfly by wildfly.
the class ParsedKernelDeploymentProcessor method deploy.
/**
* Process a deployment for KernelDeployment configuration.
* Will install a {@code POJO} for each configured bean.
*
* @param phaseContext the deployment unit context
* @throws DeploymentUnitProcessingException
*
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
final List<KernelDeploymentXmlDescriptor> kdXmlDescriptors = unit.getAttachment(KernelDeploymentXmlDescriptor.ATTACHMENT_KEY);
if (kdXmlDescriptors == null || kdXmlDescriptors.isEmpty())
return;
final Module module = unit.getAttachment(Attachments.MODULE);
if (module == null)
throw PojoLogger.ROOT_LOGGER.noModuleFound(unit);
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
final DeploymentReflectionIndex index = unit.getAttachment(Attachments.REFLECTION_INDEX);
if (index == null)
throw PojoLogger.ROOT_LOGGER.missingReflectionIndex(unit);
for (KernelDeploymentXmlDescriptor kdXmlDescriptor : kdXmlDescriptors) {
final List<BeanMetaDataConfig> beanConfigs = kdXmlDescriptor.getBeans();
for (final BeanMetaDataConfig beanConfig : beanConfigs) {
describeBean(module, serviceTarget, index, beanConfig);
}
// TODO -- KD::classloader, KD::aliases
}
}
use of org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor in project wildfly by wildfly.
the class KernelDeploymentModuleProcessor method deploy.
/**
* Add POJO module if we have any bean factories.
*
* @param phaseContext the deployment unit context
* @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
*/
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit unit = phaseContext.getDeploymentUnit();
final List<KernelDeploymentXmlDescriptor> kdXmlDescriptors = unit.getAttachment(KernelDeploymentXmlDescriptor.ATTACHMENT_KEY);
if (kdXmlDescriptors == null || kdXmlDescriptors.isEmpty())
return;
for (KernelDeploymentXmlDescriptor kdxd : kdXmlDescriptors) {
if (kdxd.getBeanFactoriesCount() > 0) {
final ModuleSpecification moduleSpecification = unit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
ModuleDependency dependency = new ModuleDependency(moduleLoader, POJO_MODULE, false, false, false, false);
PathFilter filter = PathFilters.isChildOf(BaseBeanFactory.class.getPackage().getName());
dependency.addImportFilter(filter, true);
dependency.addImportFilter(PathFilters.rejectAll(), false);
moduleSpecification.addSystemDependency(dependency);
return;
}
}
}
Aggregations