Search in sources :

Example 1 with KernelDeploymentXmlDescriptor

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);
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) XMLStreamReader(javax.xml.stream.XMLStreamReader) InputStream(java.io.InputStream) KernelDeploymentXmlDescriptor(org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor) IOException(java.io.IOException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException)

Example 2 with KernelDeploymentXmlDescriptor

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
    }
}
Also used : BeanMetaDataConfig(org.jboss.as.pojo.descriptor.BeanMetaDataConfig) ServiceTarget(org.jboss.msc.service.ServiceTarget) KernelDeploymentXmlDescriptor(org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 3 with KernelDeploymentXmlDescriptor

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;
        }
    }
}
Also used : ModuleLoader(org.jboss.modules.ModuleLoader) PathFilter(org.jboss.modules.filter.PathFilter) ModuleDependency(org.jboss.as.server.deployment.module.ModuleDependency) ModuleSpecification(org.jboss.as.server.deployment.module.ModuleSpecification) KernelDeploymentXmlDescriptor(org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

KernelDeploymentXmlDescriptor (org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 BeanMetaDataConfig (org.jboss.as.pojo.descriptor.BeanMetaDataConfig)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 ModuleDependency (org.jboss.as.server.deployment.module.ModuleDependency)1 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)1 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)1 Module (org.jboss.modules.Module)1 ModuleLoader (org.jboss.modules.ModuleLoader)1 PathFilter (org.jboss.modules.filter.PathFilter)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1