use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class AccessLogAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final PathAddress address = context.getCurrentAddress();
final PathAddress hostAddress = address.getParent();
final PathAddress serverAddress = hostAddress.getParent();
final String worker = AccessLogDefinition.WORKER.resolveModelAttribute(context, model).asString();
final String pattern = AccessLogDefinition.PATTERN.resolveModelAttribute(context, model).asString();
final String directory = AccessLogDefinition.DIRECTORY.resolveModelAttribute(context, model).asString();
final String filePrefix = AccessLogDefinition.PREFIX.resolveModelAttribute(context, model).asString();
final String fileSuffix = AccessLogDefinition.SUFFIX.resolveModelAttribute(context, model).asString();
final boolean useServerLog = AccessLogDefinition.USE_SERVER_LOG.resolveModelAttribute(context, model).asBoolean();
final boolean rotate = AccessLogDefinition.ROTATE.resolveModelAttribute(context, model).asBoolean();
final boolean extended = AccessLogDefinition.EXTENDED.resolveModelAttribute(context, model).asBoolean();
final ModelNode relativeToNode = AccessLogDefinition.RELATIVE_TO.resolveModelAttribute(context, model);
final String relativeTo = relativeToNode.isDefined() ? relativeToNode.asString() : null;
Predicate predicate = null;
ModelNode predicateNode = AccessLogDefinition.PREDICATE.resolveModelAttribute(context, model);
if (predicateNode.isDefined()) {
predicate = Predicates.parse(predicateNode.asString(), getClass().getClassLoader());
}
final AccessLogService service;
if (useServerLog) {
service = new AccessLogService(pattern, extended, predicate);
} else {
service = new AccessLogService(pattern, directory, relativeTo, filePrefix, fileSuffix, rotate, extended, predicate);
}
final String serverName = serverAddress.getLastElement().getValue();
final String hostName = hostAddress.getLastElement().getValue();
final ServiceName serviceName = UndertowService.accessLogServiceName(serverName, hostName);
final ServiceBuilder<AccessLogService> builder = context.getServiceTarget().addService(serviceName, service).addDependency(IOServices.WORKER.append(worker), XnioWorker.class, service.getWorker()).addDependency(PathManagerService.SERVICE_NAME, PathManager.class, service.getPathManager()).addDependency(UndertowService.virtualHostName(serverName, hostName), Host.class, service.getHost());
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class AccessLogRemove method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) {
final PathAddress hostAddress = context.getCurrentAddress().getParent();
final PathAddress serverAddress = hostAddress.getParent();
final String hostName = hostAddress.getLastElement().getValue();
final String serverName = serverAddress.getLastElement().getValue();
final ServiceName serviceName = UndertowService.accessLogServiceName(serverName, hostName);
context.removeService(serviceName);
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class BufferCacheAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
final String name = address.getLastElement().getValue();
int bufferSize = BufferCacheDefinition.BUFFER_SIZE.resolveModelAttribute(context, model).asInt();
int buffersPerRegions = BufferCacheDefinition.BUFFERS_PER_REGION.resolveModelAttribute(context, model).asInt();
int maxRegions = BufferCacheDefinition.MAX_REGIONS.resolveModelAttribute(context, model).asInt();
final BufferCacheService service = new BufferCacheService(bufferSize, buffersPerRegions, maxRegions);
final ServiceTarget target = context.getServiceTarget();
target.addService(BufferCacheService.SERVICE_NAME.append(name), service).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class FilterDefinitions method registerChildren.
@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
super.registerChildren(resourceRegistration);
PathElement targetPe = RequestLimitHandler.INSTANCE.getPathElement();
AliasEntry aliasEntry = new AliasEntry(resourceRegistration.getSubModel(PathAddress.pathAddress(targetPe))) {
@Override
public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) {
PathElement pe = aliasAddress.getLastElement();
return aliasAddress.getParent().append(PathElement.pathElement(targetPe.getKey(), pe.getValue()));
}
};
resourceRegistration.registerAlias(PathElement.pathElement("connection-limit"), aliasEntry);
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class EndpointConfigAdd 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 name = address.getLastElement().getValue();
//get the server config object from the ServerConfigService (service installed but not started yet, but the object is fine for our needs here)
final ServerConfig serverConfig = ASHelper.getMSCService(WSServices.CONFIG_SERVICE, ServerConfig.class, context);
if (serverConfig == null) {
throw WSLogger.ROOT_LOGGER.serviceNotAvailable(WSServices.CONFIG_SERVICE.getCanonicalName());
}
final ServiceName serviceName = getEndpointConfigServiceName(name);
final ConfigService endpointConfigService = new ConfigService(serverConfig, name, false);
final ServiceTarget target = context.getServiceTarget();
final ServiceBuilder<?> serviceBuilder = target.addService(serviceName, endpointConfigService);
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PROPERTY)) {
//get a new injector instance each time
serviceBuilder.addDependency(sn, PropertyService.class, endpointConfigService.getPropertiesInjector());
}
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PRE_HANDLER_CHAIN)) {
//get a new injector instance each time
serviceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, endpointConfigService.getPreHandlerChainsInjector());
}
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.POST_HANDLER_CHAIN)) {
//get a new injector instance each time
serviceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, endpointConfigService.getPostHandlerChainsInjector());
}
serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
} else {
context.reloadRequired();
}
}
Aggregations