Search in sources :

Example 1 with WorkManager

use of org.jboss.jca.core.api.workmanager.WorkManager in project wildfly by wildfly.

the class BootstrapContextAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    String name = JcaBootstrapContextDefinition.BootstrapCtxParameters.NAME.getAttribute().resolveModelAttribute(context, model).asString();
    String workmanager = JcaBootstrapContextDefinition.BootstrapCtxParameters.WORKMANAGER.getAttribute().resolveModelAttribute(context, model).asString();
    boolean usingDefaultWm = false;
    CloneableBootstrapContext ctx;
    if (DEFAULT_NAME.equals(workmanager)) {
        usingDefaultWm = true;
        ctx = new NamedBootstrapContext(name);
    } else {
        ctx = new NamedBootstrapContext(name, workmanager);
    }
    ServiceTarget serviceTarget = context.getServiceTarget();
    final BootStrapContextService bootCtxService = new BootStrapContextService(ctx, name, usingDefaultWm);
    serviceTarget.addService(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(name), bootCtxService).addDependency(ConnectorServices.WORKMANAGER_SERVICE.append(workmanager), WorkManager.class, bootCtxService.getWorkManagerValueInjector()).addDependency(TxnServices.JBOSS_TXN_CONTEXT_XA_TERMINATOR, JBossContextXATerminator.class, bootCtxService.getXaTerminatorInjector()).addDependency(TxnServices.JBOSS_TXN_ARJUNA_TRANSACTION_MANAGER, com.arjuna.ats.jbossatx.jta.TransactionManagerService.class, bootCtxService.getTxManagerInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, bootCtxService.getJcaConfigInjector()).setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Also used : BootStrapContextService(org.jboss.as.connector.services.bootstrap.BootStrapContextService) WorkManager(org.jboss.jca.core.api.workmanager.WorkManager) NamedBootstrapContext(org.jboss.as.connector.services.bootstrap.NamedBootstrapContext) ServiceTarget(org.jboss.msc.service.ServiceTarget) CloneableBootstrapContext(org.jboss.jca.core.api.bootstrap.CloneableBootstrapContext)

Example 2 with WorkManager

use of org.jboss.jca.core.api.workmanager.WorkManager in project wildfly by wildfly.

the class WorkManagerStatisticsService method start.

@Override
public void start(StartContext context) throws StartException {
    synchronized (this) {
        WorkManager wm = workManager.getValue();
        wm.setStatisticsEnabled(statsEnabled);
        if (wm.getStatistics() != null) {
            PathElement peLocaldWm = PathElement.pathElement(Constants.STATISTICS_NAME, "local");
            ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peLocaldWm, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
            ManagementResourceRegistration wmSubRegistration = overrideRegistration.registerSubModel(resourceBuilder.build());
            OperationStepHandler metricHandler = new WorkManagerRuntimeAttributeReadHandler(wm, wm.getStatistics(), false);
            for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) {
                wmSubRegistration.registerMetric(metric, metricHandler);
            }
            OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(wm, wm.getStatistics(), false);
            OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(wm, false, Constants.WORKMANAGER_RW_ATTRIBUTES);
            for (SimpleAttributeDefinition attribute : Constants.WORKMANAGER_RW_ATTRIBUTES) {
                wmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler);
            }
            wmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(wm));
        }
    }
}
Also used : ResourceBuilder(org.jboss.as.controller.ResourceBuilder) PathElement(org.jboss.as.controller.PathElement) WorkManagerRuntimeAttributeWriteHandler(org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeWriteHandler) WorkManager(org.jboss.jca.core.api.workmanager.WorkManager) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) StandardResourceDescriptionResolver(org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) WorkManagerRuntimeAttributeReadHandler(org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler) ClearWorkManagerStatisticsHandler(org.jboss.as.connector.dynamicresource.ClearWorkManagerStatisticsHandler)

Aggregations

WorkManager (org.jboss.jca.core.api.workmanager.WorkManager)2 ClearWorkManagerStatisticsHandler (org.jboss.as.connector.dynamicresource.ClearWorkManagerStatisticsHandler)1 BootStrapContextService (org.jboss.as.connector.services.bootstrap.BootStrapContextService)1 NamedBootstrapContext (org.jboss.as.connector.services.bootstrap.NamedBootstrapContext)1 WorkManagerRuntimeAttributeReadHandler (org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeReadHandler)1 WorkManagerRuntimeAttributeWriteHandler (org.jboss.as.connector.subsystems.resourceadapters.WorkManagerRuntimeAttributeWriteHandler)1 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)1 PathElement (org.jboss.as.controller.PathElement)1 ResourceBuilder (org.jboss.as.controller.ResourceBuilder)1 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)1 StandardResourceDescriptionResolver (org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver)1 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)1 CloneableBootstrapContext (org.jboss.jca.core.api.bootstrap.CloneableBootstrapContext)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1