public AsyncHandlerResourceDefinition(final boolean includeLegacyAttributes) { super( ASYNC_HANDLER_PATH, AsyncHandler.class, (includeLegacyAttributes ? Logging.join(ATTRIBUTES, LEGACY_ATTRIBUTES) : ATTRIBUTES), QUEUE_LENGTH); }
/** * Resource for a {@link org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler}. * * @author <a href="mailto:[email protected]">James R. Perkins</a> */ class PeriodicSizeRotatingHandlerResourceDefinition extends AbstractFileHandlerDefinition { public static final String PERIODIC_SIZE_ROTATING_FILE_HANDLER = "periodic-size-rotating-file-handler"; static final PathElement PERIODIC_SIZE_ROTATING_HANDLER_PATH = PathElement.pathElement(PERIODIC_SIZE_ROTATING_FILE_HANDLER); static final AttributeDefinition[] ATTRIBUTES = Logging.join( DEFAULT_ATTRIBUTES, AUTOFLUSH, APPEND, MAX_BACKUP_INDEX, ROTATE_SIZE, ROTATE_ON_BOOT, SUFFIX, NAMED_FORMATTER, FILE); public PeriodicSizeRotatingHandlerResourceDefinition( final ResolvePathHandler resolvePathHandler) { super( PERIODIC_SIZE_ROTATING_HANDLER_PATH, false, PeriodicSizeRotatingFileHandler.class, resolvePathHandler, ATTRIBUTES); } @Override protected void registerResourceTransformers( final KnownModelVersion modelVersion, final ResourceTransformationDescriptionBuilder resourceBuilder, final ResourceTransformationDescriptionBuilder loggingProfileBuilder) { switch (modelVersion) { case VERSION_2_0_0: { resourceBuilder.rejectChildResource(PERIODIC_SIZE_ROTATING_HANDLER_PATH); if (loggingProfileBuilder != null) { loggingProfileBuilder.rejectChildResource(PERIODIC_SIZE_ROTATING_HANDLER_PATH); } break; } } } }
/** * @author <a href="mailto:[email protected]">Tomaz Cerar</a> * @author <a href="mailto:[email protected]">James R. Perkins</a> */ class AsyncHandlerResourceDefinition extends AbstractHandlerDefinition { public static final String ADD_SUBHANDLER_OPERATION_NAME = "assign-subhandler"; public static final String REMOVE_SUBHANDLER_OPERATION_NAME = "unassign-subhandler"; public static final String ASYNC_HANDLER = "async-handler"; static final PathElement ASYNC_HANDLER_PATH = PathElement.pathElement(ASYNC_HANDLER); static final SimpleOperationDefinition ADD_HANDLER = new SimpleOperationDefinitionBuilder(ADD_HANDLER_OPERATION_NAME, HANDLER_RESOLVER) .setParameters(CommonAttributes.HANDLER_NAME) .build(); static final SimpleOperationDefinition REMOVE_HANDLER = new SimpleOperationDefinitionBuilder(REMOVE_HANDLER_OPERATION_NAME, HANDLER_RESOLVER) .setParameters(CommonAttributes.HANDLER_NAME) .build(); static final SimpleOperationDefinition LEGACY_ADD_HANDLER = new SimpleOperationDefinitionBuilder(ADD_SUBHANDLER_OPERATION_NAME, HANDLER_RESOLVER) .setDeprecated(ModelVersion.create(1, 2, 0)) .setParameters(CommonAttributes.HANDLER_NAME) .build(); static final SimpleOperationDefinition LEGACY_REMOVE_HANDLER = new SimpleOperationDefinitionBuilder(REMOVE_SUBHANDLER_OPERATION_NAME, HANDLER_RESOLVER) .setDeprecated(ModelVersion.create(1, 2, 0)) .setParameters(CommonAttributes.HANDLER_NAME) .build(); public static final PropertyAttributeDefinition QUEUE_LENGTH = PropertyAttributeDefinition.Builder.of("queue-length", ModelType.INT) .setAllowExpression(true) .setAttributeMarshaller(ElementAttributeMarshaller.VALUE_ATTRIBUTE_MARSHALLER) .setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES) .setPropertyName("queueLength") .setValidator(new IntRangeValidator(1, false)) .build(); public static final PropertyAttributeDefinition OVERFLOW_ACTION = PropertyAttributeDefinition.Builder.of("overflow-action", ModelType.STRING) .setAllowExpression(true) .setAttributeMarshaller( new DefaultAttributeMarshaller() { @Override public void marshallAsElement( final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException { if (isMarshallable(attribute, resourceModel, marshallDefault)) { writer.writeStartElement(attribute.getXmlName()); String content = resourceModel .get(attribute.getName()) .asString() .toLowerCase(Locale.ENGLISH); writer.writeAttribute("value", content); writer.writeEndElement(); } } }) .setDefaultValue(new ModelNode(OverflowAction.BLOCK.name())) .setPropertyName("overflowAction") .setResolver(OverflowActionResolver.INSTANCE) .setValidator(EnumValidator.create(OverflowAction.class, false, false)) .build(); public static final LogHandlerListAttributeDefinition SUBHANDLERS = LogHandlerListAttributeDefinition.Builder.of("subhandlers") .setAllowExpression(false) .setAllowNull(true) .build(); static final AttributeDefinition[] ATTRIBUTES = Logging.join(DEFAULT_ATTRIBUTES, QUEUE_LENGTH, OVERFLOW_ACTION, SUBHANDLERS); public AsyncHandlerResourceDefinition(final boolean includeLegacyAttributes) { super( ASYNC_HANDLER_PATH, AsyncHandler.class, (includeLegacyAttributes ? Logging.join(ATTRIBUTES, LEGACY_ATTRIBUTES) : ATTRIBUTES), QUEUE_LENGTH); } @Override public void registerOperations(final ManagementResourceRegistration registration) { super.registerOperations(registration); registration.registerOperationHandler(LEGACY_ADD_HANDLER, HandlerOperations.ADD_SUBHANDLER); registration.registerOperationHandler( LEGACY_REMOVE_HANDLER, HandlerOperations.REMOVE_SUBHANDLER); registration.registerOperationHandler(ADD_HANDLER, HandlerOperations.ADD_SUBHANDLER); registration.registerOperationHandler(REMOVE_HANDLER, HandlerOperations.REMOVE_SUBHANDLER); } /** * Add the transformers for the async handler. * * @param subsystemBuilder the default subsystem builder * @param loggingProfileBuilder the logging profile builder * @return the builder created for the resource */ static ResourceTransformationDescriptionBuilder addTransformers( final ResourceTransformationDescriptionBuilder subsystemBuilder, final ResourceTransformationDescriptionBuilder loggingProfileBuilder) { // Register the logger resource final ResourceTransformationDescriptionBuilder child = subsystemBuilder .addChildResource(ASYNC_HANDLER_PATH) .getAttributeBuilder() .addRejectCheck( RejectAttributeChecker.SIMPLE_EXPRESSIONS, QUEUE_LENGTH, OVERFLOW_ACTION) .end() .addOperationTransformationOverride(ADD_HANDLER_OPERATION_NAME) .setCustomOperationTransformer(LoggingOperationTransformer.INSTANCE) .end() .addOperationTransformationOverride(REMOVE_HANDLER_OPERATION_NAME) .setCustomOperationTransformer(LoggingOperationTransformer.INSTANCE) .end(); // Reject logging profile resources loggingProfileBuilder.rejectChildResource(ASYNC_HANDLER_PATH); return registerTransformers(child); } }