Package org.jboss.as.controller

Examples of org.jboss.as.controller.ResourceBuilder


    SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, BPM_PLATFORM_SUBSYSTEM_MAJOR_VERSION, BPM_PLATFORM_SUBSYSTEM_MINOR_VERSION);
    subsystem.registerXMLElementWriter(parser);

    // build resource definitions

    ResourceBuilder processEnginesResource = ResourceBuilder.Factory.create(PROCESS_ENGINES_PATH, getResourceDescriptionResolver(ModelConstants.PROCESS_ENGINES))
      .setAddOperation(ProcessEngineAdd.INSTANCE)
      .setRemoveOperation(ProcessEngineRemove.INSTANCE);

    ResourceBuilder jobAcquisitionResource = ResourceBuilder.Factory.create(JOB_ACQUISTIONS_PATH, getResourceDescriptionResolver(ModelConstants.JOB_ACQUISITIONS))
        .setAddOperation(JobAcquisitionAdd.INSTANCE)
        .setRemoveOperation(JobAcquisitionRemove.INSTANCE);

    ResourceBuilder jobExecutorResource = ResourceBuilder.Factory.create(JOB_EXECUTOR_PATH, getResourceDescriptionResolver(ModelConstants.JOB_EXECUTOR))
      .setAddOperation(JobExecutorAdd.INSTANCE)
      .setRemoveOperation(JobExecutorRemove.INSTANCE)
      .pushChild(jobAcquisitionResource).pop();

    ResourceDefinition subsystemResource = ResourceBuilder.Factory.createSubsystemRoot(SUBSYSTEM_PATH, getResourceDescriptionResolver(SUBSYSTEM_NAME), BpmPlatformSubsystemAdd.INSTANCE, BpmPlatformSubsystemRemove.INSTANCE)
View Full Code Here


                                    }

                                    ManagementResourceRegistration subRegistration;
                                    try {
                                        ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(pe,
                                                new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
                                        subRegistration = overrideRegistration.registerSubModel(resourceBuilder.build());

                                        } catch (IllegalArgumentException iae) {
                                        subRegistration = overrideRegistration.getSubModel(PathAddress.pathAddress(pe));
                                    }
                                    Resource subsystemResource;

                                    if (!deploymentResource.hasChild(pe)) {
                                        subsystemResource = new IronJacamarResource.IronJacamarRuntimeResource();
                                        deploymentResource.registerChild(pe, subsystemResource);
                                    } else {
                                        subsystemResource = deploymentResource.getChild(pe);
                                    }

                                    ManagementResourceRegistration statsRegistration;
                                    try {
                                        ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peStats,
                                                new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));

                                        statsRegistration = subRegistration.registerSubModel(resourceBuilder.build());
                                    } catch (IllegalArgumentException iae) {
                                        statsRegistration = subRegistration.getSubModel(PathAddress.pathAddress(peStats));
                                    }
                                    Resource statisticsResource;

                                    if (!subsystemResource.hasChild(peStats)) {
                                        statisticsResource = new IronJacamarResource.IronJacamarRuntimeResource();
                                        subsystemResource.registerChild(peStats, statisticsResource);
                                    } else {
                                        statisticsResource = subsystemResource.getChild(peStats);
                                    }

                                    ManagementResourceRegistration raRegistration;
                                    try {
                                        ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peRa,
                                                new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));

                                        raRegistration = statsRegistration.registerSubModel(resourceBuilder.build());
                                    } catch (IllegalArgumentException iae) {
                                        raRegistration = statsRegistration.getSubModel(PathAddress.pathAddress(peRa));
                                    }
                                    Resource raResource;

                                    if (!statisticsResource.hasChild(peRa)) {
                                        raResource = new IronJacamarResource.IronJacamarRuntimeResource();
                                        statisticsResource.registerChild(peRa, raResource);
                                    } else {
                                        raResource = statisticsResource.getChild(peRa);
                                    }
                                    if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getResourceAdapter() != null && deploymentMD.getConnector().getResourceAdapter().getStatistics() != null) {
                                        StatisticsPlugin raStats = deploymentMD.getConnector().getResourceAdapter().getStatistics();
                                        raStats.setEnabled(false);
                                        PoolMetrics.ParametrizedPoolMetricsHandler handler = new PoolMetrics.ParametrizedPoolMetricsHandler(raStats);
                                        for (AttributeDefinition attribute : StatisticsResourceDefinition.getAttributesFromPlugin(raStats)){
                                            raRegistration.registerMetric(attribute, handler);
                                        }
                                        //adding enable/disable for pool stats
                                        OperationStepHandler readHandler = new PoolStatisticsRuntimeAttributeReadHandler(raStats);
                                        OperationStepHandler writeHandler = new PoolStatisticsRuntimeAttributeWriteHandler(raStats);
                                        raRegistration.registerReadWriteAttribute(org.jboss.as.connector.subsystems.common.pool.Constants.POOL_STATISTICS_ENABLED, readHandler, writeHandler);

                                    }
                                    if (poolStats.getNames().size() != 0 && raRegistration.getSubModel(PathAddress.pathAddress(peCD)) == null) {
                                        ManagementResourceRegistration cdSubRegistration = raRegistration.registerSubModel(new StatisticsResourceDefinition(peCD, CommonAttributes.RESOURCE_NAME, poolStats));
                                        final Resource cdResource = new IronJacamarResource.IronJacamarRuntimeResource();

                                        if (!raResource.hasChild(peCD))
                                            raResource.registerChild(peCD, cdResource);
                                    }

                                    if (wm.getStatistics() != null) {
                                        if (wm instanceof DistributedWorkManager && ((DistributedWorkManager)wm).getDistributedStatistics() != null && raRegistration.getSubModel(PathAddress.pathAddress(peDistributedWm)) == null) {
                                            ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peDistributedWm,
                                                    new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));

                                            ManagementResourceRegistration dwmSubRegistration = raRegistration.registerSubModel(resourceBuilder.build());
                                            final Resource dwmResource = new IronJacamarResource.IronJacamarRuntimeResource();

                                            if (!raResource.hasChild(peDistributedWm))
                                                raResource.registerChild(peDistributedWm, dwmResource);

                                            OperationStepHandler metricsHandler = new WorkManagerRuntimeAttributeReadHandler(wm, ((DistributedWorkManager)wm).getDistributedStatistics(), false);
                                            for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) {
                                                dwmSubRegistration.registerMetric(metric, metricsHandler);
                                            }

                                            OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(wm, ((DistributedWorkManager)wm).getDistributedStatistics(), true);
                                            OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(wm, true, Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES);
                                            for (SimpleAttributeDefinition attribute : Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES) {
                                                dwmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler);
                                            }

                                            dwmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(wm));
                                        }
                                        if (raRegistration.getSubModel(PathAddress.pathAddress(peWm)) == null) {
                                            ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peWm,
                                                    new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));

                                            ManagementResourceRegistration wmSubRegistration = raRegistration.registerSubModel(resourceBuilder.build());
                                            final Resource wmResource = new IronJacamarResource.IronJacamarRuntimeResource();

                                            if (!raResource.hasChild(peWm))
                                                raResource.registerChild(peWm, wmResource);
View Full Code Here

        final boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();
        final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
                MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
        subsystem.registerXMLElementWriter(WSSubsystemWriter.getInstance());
        // ws subsystem
        ResourceBuilder propertyResource = ResourceBuilder.Factory.create(PROPERTY_PATH, getResourceDescriptionResolver(Constants.PROPERTY))
                .setAddOperation(PropertyAdd.INSTANCE)
                .setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE)
                .addReadWriteAttribute(Attributes.VALUE, null, new ReloadRequiredWriteAttributeHandler(Attributes.VALUE));


        ResourceBuilder handlerBuilder = ResourceBuilder.Factory.create(HANDLER_PATH, getResourceDescriptionResolver(HANDLER))
                .setAddOperation(HandlerAdd.INSTANCE)
                .setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE)
                .addReadWriteAttribute(Attributes.CLASS, null, new ReloadRequiredWriteAttributeHandler(Attributes.CLASS));

        ResourceBuilder preHandler = ResourceBuilder.Factory.create(PRE_HANDLER_CHAIN_PATH, getResourceDescriptionResolver(Constants.PRE_HANDLER_CHAIN))
                .setAddOperation(HandlerChainAdd.INSTANCE)
                .setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE)
                .addReadWriteAttribute(Attributes.PROTOCOL_BINDINGS, null, new ReloadRequiredWriteAttributeHandler(Attributes.PROTOCOL_BINDINGS))
                .pushChild(handlerBuilder).pop();

        ResourceBuilder postHandler = ResourceBuilder.Factory.create(POST_HANDLER_CHAIN_PATH, getResourceDescriptionResolver(Constants.POST_HANDLER_CHAIN))
                .setAddOperation(HandlerChainAdd.INSTANCE)
                .setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE)
                .addReadWriteAttribute(Attributes.PROTOCOL_BINDINGS, null, new ReloadRequiredWriteAttributeHandler(Attributes.PROTOCOL_BINDINGS))
                .pushChild(handlerBuilder).pop();
View Full Code Here

        try {
            Class<? extends Protocol> protocolClass = Protocol.class.getClassLoader().loadClass(className).asSubclass(Protocol.class);

            SimpleResourceDescriptionResolver resolver = new SimpleResourceDescriptionResolver(protocolName, protocolClass.getSimpleName());
            ResourceBuilder builder = ResourceBuilder.Factory.create(ProtocolResourceDefinition.pathElement(protocolName), resolver);
            ProtocolMetricsHandler handler = new ProtocolMetricsHandler();

            for (Map.Entry<String, Attribute> entry: handler.findProtocolAttributes(protocolClass).entrySet()) {
                String name = entry.getKey();
                Attribute attribute = entry.getValue();
                FieldType type = FieldType.valueOf(attribute.getType());
                resolver.addDescription(name, attribute.getDescription());
                builder.addMetric(new SimpleAttributeDefinitionBuilder(name, type.getModelType()).setStorageRuntime().build(), handler);
            }

            return builder.build();
        } catch (ClassNotFoundException e) {
            throw JGroupsLogger.ROOT_LOGGER.unableToLoadProtocolClass(className);
        }
    }
View Full Code Here

        final boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();
        final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, MANAGEMENT_API_MAJOR_VERSION,
                MANAGEMENT_API_MINOR_VERSION, MANAGEMENT_API_MICRO_VERSION);
        subsystem.registerXMLElementWriter(WSSubsystemWriter.getInstance());
        // ws subsystem
        ResourceBuilder propertyResource = ResourceBuilder.Factory.create(PROPERTY_PATH, getResourceDescriptionResolver(Constants.PROPERTY))
                .setAddOperation(PropertyAdd.INSTANCE)
                .setRemoveOperation(PropertyRemove.INSTANCE)
                .addReadWriteAttribute(Attributes.VALUE, null, new ReloadRequiredWriteAttributeHandler(Attributes.VALUE));


        ResourceBuilder handlerBuilder = ResourceBuilder.Factory.create(HANDLER_PATH, getResourceDescriptionResolver("handler"))
                .setAddOperation(HandlerAdd.INSTANCE)
                .setRemoveOperation(HandlerRemove.INSTANCE)
                .addReadWriteAttribute(Attributes.CLASS, null, new ReloadRequiredWriteAttributeHandler(Attributes.CLASS));

        ResourceBuilder preHandler = ResourceBuilder.Factory.create(PRE_HANDLER_CHAIN_PATH, getResourceDescriptionResolver(Constants.PRE_HANDLER_CHAIN))
                .setAddOperation(HandlerChainAdd.INSTANCE)
                .setRemoveOperation(HandlerChainRemove.INSTANCE)
                .addReadWriteAttribute(Attributes.PROTOCOL_BINDINGS, null, new ReloadRequiredWriteAttributeHandler(Attributes.PROTOCOL_BINDINGS))
                .pushChild(handlerBuilder).pop();

        ResourceBuilder postHandler = ResourceBuilder.Factory.create(POST_HANDLER_CHAIN_PATH, getResourceDescriptionResolver(Constants.POST_HANDLER_CHAIN))
                .setAddOperation(HandlerChainAdd.INSTANCE)
                .setRemoveOperation(HandlerChainRemove.INSTANCE)
                .addReadWriteAttribute(Attributes.PROTOCOL_BINDINGS, null, new ReloadRequiredWriteAttributeHandler(Attributes.PROTOCOL_BINDINGS))
                .pushChild(handlerBuilder).pop();
View Full Code Here

TOP

Related Classes of org.jboss.as.controller.ResourceBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.