Search in sources :

Example 1 with PropertyService

use of org.jboss.as.webservices.service.PropertyService in project wildfly by wildfly.

the class PropertyAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    //modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
    if (context.isBooting()) {
        final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
        final String propertyName = address.getElement(address.size() - 1).getValue();
        final PathElement confElem = address.getElement(address.size() - 2);
        final String configType = confElem.getKey();
        final String configName = confElem.getValue();
        final String propertyValue = operation.has(VALUE) ? Attributes.VALUE.resolveModelAttribute(context, operation).asString() : null;
        final PropertyService service = new PropertyService(propertyName, propertyValue);
        final ServiceTarget target = context.getServiceTarget();
        final ServiceName configServiceName = getConfigServiceName(configType, configName);
        if (context.getServiceRegistry(false).getService(configServiceName) == null) {
            throw WSLogger.ROOT_LOGGER.missingConfig(configName);
        }
        final ServiceName propertyServiceName = getPropertyServiceName(configServiceName, propertyName);
        final ServiceBuilder<?> propertyServiceBuilder = target.addService(propertyServiceName, service);
        ServiceController<?> controller = propertyServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    } else {
        context.reloadRequired();
    }
}
Also used : PathElement(org.jboss.as.controller.PathElement) PackageUtils.getPropertyServiceName(org.jboss.as.webservices.dmr.PackageUtils.getPropertyServiceName) PackageUtils.getConfigServiceName(org.jboss.as.webservices.dmr.PackageUtils.getConfigServiceName) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) PropertyService(org.jboss.as.webservices.service.PropertyService)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)1 PathElement (org.jboss.as.controller.PathElement)1 PackageUtils.getConfigServiceName (org.jboss.as.webservices.dmr.PackageUtils.getConfigServiceName)1 PackageUtils.getPropertyServiceName (org.jboss.as.webservices.dmr.PackageUtils.getPropertyServiceName)1 PropertyService (org.jboss.as.webservices.service.PropertyService)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1