public JmxAuditLogHandlerReferenceResourceDefinition(ManagedAuditLogger auditLogger) { //Make a remove reload required. Handlers using more complex formatters in the future will not like being stopped and started at runtime super(PATH_ELEMENT, JMXExtension.getResourceDescriptionResolver("audit-log.handler"), new AuditLogHandlerReferenceAddHandler(auditLogger), new AuditLogHandlerReferenceRemoveHandler(auditLogger)); }
private boolean lookForHandlerForHc(OperationContext context, String name) { final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); for (ResourceEntry entry : root.getChildren(ModelDescriptionConstants.HOST)) { if (entry.getModel().isDefined()) { return lookForHandler(PathAddress.pathAddress(ModelDescriptionConstants.HOST, entry.getName()), root, name); } } return false; }
@Override protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { final PathAddress addr = PathAddress.pathAddress(operation.require(OP_ADDR)); String name = addr.getLastElement().getValue(); boolean found = context.getProcessType().isServer() ? lookForHandlerForServer(context, name) : lookForHandlerForHc(context, name); if (!found) { throw JmxMessages.MESSAGES.noHandlerCalled(name); } resource.getModel().setEmptyObject(); }
private boolean lookForHandlerForServer(OperationContext context, String name) { final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); return lookForHandler(PathAddress.EMPTY_ADDRESS, root, name); }
private boolean lookForHandler(PathAddress rootAddress, Resource root, String name) { PathAddress addr = rootAddress.append( CoreManagementResourceDefinition.PATH_ELEMENT, AccessAuditResourceDefinition.PATH_ELEMENT); PathAddress referenceAddress = addr.append(FILE_HANDLER, name); if (lookForResource(root, referenceAddress)) { return true; } referenceAddress = addr.append(SYSLOG_HANDLER, name); return lookForResource(root, referenceAddress); } private boolean lookForResource(final Resource root, final PathAddress pathAddress) {
private boolean lookForHandler(PathAddress rootAddress, Resource root, String name) { PathAddress addr = rootAddress.append( CoreManagementResourceDefinition.PATH_ELEMENT, AccessAuditResourceDefinition.PATH_ELEMENT); PathAddress referenceAddress = addr.append(FILE_HANDLER, name); if (lookForResource(root, referenceAddress)) { return true; } referenceAddress = addr.append(SYSLOG_HANDLER, name); return lookForResource(root, referenceAddress); } private boolean lookForResource(final Resource root, final PathAddress pathAddress) {
private boolean lookForHandlerForHc(OperationContext context, String name) { final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); for (ResourceEntry entry : root.getChildren(ModelDescriptionConstants.HOST)) { if (entry.getModel().isDefined()) { return lookForHandler(PathAddress.pathAddress(ModelDescriptionConstants.HOST, entry.getName()), root, name); } } return false; }
public JmxAuditLogHandlerReferenceResourceDefinition(ManagedAuditLogger auditLogger) { //Make a remove reload required. Handlers using more complex formatters in the future will not like being stopped and started at runtime super(PATH_ELEMENT, JMXExtension.getResourceDescriptionResolver("audit-log.handler"), new AuditLogHandlerReferenceAddHandler(auditLogger), new AuditLogHandlerReferenceRemoveHandler(auditLogger)); }
private boolean lookForHandlerForServer(OperationContext context, String name) { final Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS); return lookForHandler(PathAddress.EMPTY_ADDRESS, root, name); }
@Override protected void populateModel(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException { final PathAddress addr = PathAddress.pathAddress(operation.require(OP_ADDR)); String name = addr.getLastElement().getValue(); boolean found = context.getProcessType().isServer() ? lookForHandlerForServer(context, name) : lookForHandlerForHc(context, name); if (!found) { throw JmxLogger.ROOT_LOGGER.noHandlerCalled(name); } resource.getModel().setEmptyObject(); }