Search in sources :

Example 1 with BeanMetaDataConfig

use of org.jboss.as.pojo.descriptor.BeanMetaDataConfig 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 2 with BeanMetaDataConfig

use of org.jboss.as.pojo.descriptor.BeanMetaDataConfig in project wildfly by wildfly.

the class AbstractPojoPhase method startInternal.

protected void startInternal(StartContext context) throws StartException {
    try {
        executeInstalls();
        // only after describe do we have a bean
        if (getLifecycleState().isAfter(BeanState.DESCRIBED)) {
            addCallbacks(true);
            addCallbacks(false);
            ServiceRegistry registry = context.getController().getServiceContainer();
            InstancesService.addInstance(registry, context.getChildTarget(), getLifecycleState(), getBean());
        }
        // do we have a next phase
        final AbstractPojoPhase nextPhase = createNextPhase();
        if (nextPhase != null) {
            final BeanState state = getLifecycleState();
            final BeanState next = state.next();
            final BeanMetaDataConfig beanConfig = getBeanConfig();
            final ServiceName name = BeanMetaDataConfig.toBeanName(beanConfig.getName(), next);
            final ServiceTarget serviceTarget = context.getChildTarget();
            final ServiceBuilder serviceBuilder = serviceTarget.addService(name, nextPhase);
            registerAliases(serviceBuilder, next);
            final ConfigVisitor visitor = new DefaultConfigVisitor(serviceBuilder, state, getModule(), getIndex(), getBeanInfo());
            beanConfig.visit(visitor);
            nextPhase.setModule(getModule());
            nextPhase.setBeanConfig(getBeanConfig());
            nextPhase.setIndex(getIndex());
            nextPhase.setBeanInfo(getBeanInfo());
            nextPhase.setBean(getBean());
            serviceBuilder.install();
        }
    } catch (Throwable t) {
        throw new StartException(t);
    }
}
Also used : DefaultConfigVisitor(org.jboss.as.pojo.descriptor.DefaultConfigVisitor) ConfigVisitor(org.jboss.as.pojo.descriptor.ConfigVisitor) DefaultConfigVisitor(org.jboss.as.pojo.descriptor.DefaultConfigVisitor) BeanState(org.jboss.as.pojo.BeanState) BeanMetaDataConfig(org.jboss.as.pojo.descriptor.BeanMetaDataConfig) ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) StartException(org.jboss.msc.service.StartException) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ServiceBuilder(org.jboss.msc.service.ServiceBuilder)

Aggregations

BeanMetaDataConfig (org.jboss.as.pojo.descriptor.BeanMetaDataConfig)2 ServiceTarget (org.jboss.msc.service.ServiceTarget)2 BeanState (org.jboss.as.pojo.BeanState)1 ConfigVisitor (org.jboss.as.pojo.descriptor.ConfigVisitor)1 DefaultConfigVisitor (org.jboss.as.pojo.descriptor.DefaultConfigVisitor)1 KernelDeploymentXmlDescriptor (org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 DeploymentReflectionIndex (org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)1 Module (org.jboss.modules.Module)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1 StartException (org.jboss.msc.service.StartException)1