Search in sources :

Example 1 with JBossServiceDependencyListConfig

use of org.jboss.as.service.descriptor.JBossServiceDependencyListConfig in project wildfly by wildfly.

the class ParsedServiceDeploymentProcessor method addDependencyLists.

private void addDependencyLists(final JBossServiceDependencyListConfig[] dependencyListConfigs, final List<ClassReflectionIndex> mBeanClassHierarchy, final MBeanServices mBeanServices) throws DeploymentUnitProcessingException {
    if (dependencyListConfigs != null) {
        final Service<Object> createDestroyService = mBeanServices.getCreateDestroyService();
        for (final JBossServiceDependencyListConfig dependencyListConfig : dependencyListConfigs) {
            final List<ObjectName> dependencyObjectNames = new ArrayList<ObjectName>(dependencyListConfig.getDependencyConfigs().length);
            for (final JBossServiceDependencyConfig dependencyConfig : dependencyListConfig.getDependencyConfigs()) {
                final String dependencyName = dependencyConfig.getDependencyName();
                mBeanServices.addDependency(dependencyName);
                final ObjectName dependencyObjectName = createDependencyObjectName(dependencyName);
                dependencyObjectNames.add(dependencyObjectName);
            }
            final String optionalAttributeName = dependencyListConfig.getOptionalAttributeName();
            if (optionalAttributeName != null) {
                final Injector<Object> injector = getOptionalAttributeInjector(optionalAttributeName, mBeanClassHierarchy, createDestroyService);
                final ImmediateValue<List<ObjectName>> dependencyNamesValue = new ImmediateValue<List<ObjectName>>(dependencyObjectNames);
                mBeanServices.addInjectionValue(injector, dependencyNamesValue);
            }
        }
    }
}
Also used : JBossServiceDependencyListConfig(org.jboss.as.service.descriptor.JBossServiceDependencyListConfig) ArrayList(java.util.ArrayList) JBossServiceDependencyConfig(org.jboss.as.service.descriptor.JBossServiceDependencyConfig) ArrayList(java.util.ArrayList) List(java.util.List) ObjectName(javax.management.ObjectName) ImmediateValue(org.jboss.msc.value.ImmediateValue)

Example 2 with JBossServiceDependencyListConfig

use of org.jboss.as.service.descriptor.JBossServiceDependencyListConfig in project wildfly by wildfly.

the class ParsedServiceDeploymentProcessor method addServices.

private void addServices(final ServiceTarget target, final JBossServiceConfig mBeanConfig, final ClassLoader classLoader, final DeploymentReflectionIndex index, ServiceComponentInstantiator componentInstantiator, final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final String mBeanClassName = mBeanConfig.getCode();
    final List<ClassReflectionIndex> mBeanClassHierarchy = getClassHierarchy(mBeanClassName, index, classLoader);
    final Object mBeanInstance = newInstance(mBeanConfig, mBeanClassHierarchy, classLoader);
    final String mBeanName = mBeanConfig.getName();
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final MBeanServices mBeanServices = new MBeanServices(mBeanName, mBeanInstance, mBeanClassHierarchy, target, componentInstantiator, deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS), classLoader, mbeanServerServiceName);
    final JBossServiceDependencyConfig[] dependencyConfigs = mBeanConfig.getDependencyConfigs();
    addDependencies(dependencyConfigs, mBeanClassHierarchy, mBeanServices, mBeanInstance);
    final JBossServiceDependencyListConfig[] dependencyListConfigs = mBeanConfig.getDependencyConfigLists();
    addDependencyLists(dependencyListConfigs, mBeanClassHierarchy, mBeanServices, mBeanInstance);
    final JBossServiceAttributeConfig[] attributeConfigs = mBeanConfig.getAttributeConfigs();
    addAttributes(attributeConfigs, mBeanClassHierarchy, mBeanServices, classLoader, mBeanInstance);
    // register all mBean related services
    mBeanServices.install();
}
Also used : JBossServiceDependencyListConfig(org.jboss.as.service.descriptor.JBossServiceDependencyListConfig) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) JBossServiceAttributeConfig(org.jboss.as.service.descriptor.JBossServiceAttributeConfig) JBossServiceDependencyConfig(org.jboss.as.service.descriptor.JBossServiceDependencyConfig) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 3 with JBossServiceDependencyListConfig

use of org.jboss.as.service.descriptor.JBossServiceDependencyListConfig in project wildfly by wildfly.

the class ParsedServiceDeploymentProcessor method addDependencyLists.

private void addDependencyLists(final JBossServiceDependencyListConfig[] dependencyListConfigs, final List<ClassReflectionIndex> mBeanClassHierarchy, final MBeanServices mBeanServices, final Object mBeanInstance) throws DeploymentUnitProcessingException {
    if (dependencyListConfigs != null) {
        for (final JBossServiceDependencyListConfig dependencyListConfig : dependencyListConfigs) {
            final List<ObjectName> dependencyObjectNames = new ArrayList<ObjectName>(dependencyListConfig.getDependencyConfigs().length);
            for (final JBossServiceDependencyConfig dependencyConfig : dependencyListConfig.getDependencyConfigs()) {
                final String dependencyName = dependencyConfig.getDependencyName();
                mBeanServices.addDependency(dependencyName);
                final ObjectName dependencyObjectName = createDependencyObjectName(dependencyName);
                dependencyObjectNames.add(dependencyObjectName);
            }
            final String optionalAttributeName = dependencyListConfig.getOptionalAttributeName();
            if (optionalAttributeName != null) {
                final Method setter = ReflectionUtils.getSetter(mBeanClassHierarchy, optionalAttributeName);
                final ObjectSupplier objectSupplier = new ObjectSupplier(dependencyObjectNames);
                mBeanServices.addValue(setter, objectSupplier);
            }
        }
    }
}
Also used : JBossServiceDependencyListConfig(org.jboss.as.service.descriptor.JBossServiceDependencyListConfig) ArrayList(java.util.ArrayList) JBossServiceDependencyConfig(org.jboss.as.service.descriptor.JBossServiceDependencyConfig) Method(java.lang.reflect.Method) ObjectName(javax.management.ObjectName)

Aggregations

JBossServiceDependencyConfig (org.jboss.as.service.descriptor.JBossServiceDependencyConfig)3 JBossServiceDependencyListConfig (org.jboss.as.service.descriptor.JBossServiceDependencyListConfig)3 ArrayList (java.util.ArrayList)2 ObjectName (javax.management.ObjectName)2 Method (java.lang.reflect.Method)1 List (java.util.List)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 ClassReflectionIndex (org.jboss.as.server.deployment.reflect.ClassReflectionIndex)1 JBossServiceAttributeConfig (org.jboss.as.service.descriptor.JBossServiceAttributeConfig)1 ImmediateValue (org.jboss.msc.value.ImmediateValue)1