@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanConstants.OBJECT_NAME.getName().equals(name)) || ThreadResourceDefinition.THREADING_READ_ATTRIBUTES.contains(name) || ThreadResourceDefinition.THREADING_READ_WRITE_ATTRIBUTES.contains(name) || ThreadResourceDefinition.THREADING_METRICS.contains(name)) { storeResult(name, context.getResult()); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException | UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }
@Override protected void executeWriteAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if (PlatformMBeanConstants.THREAD_CONTENTION_MONITORING_ENABLED.equals(name)) { enabledValidator.validate(operation); ManagementFactory.getThreadMXBean().setThreadContentionMonitoringEnabled(operation.require(ModelDescriptionConstants.VALUE).asBoolean()); } else if (PlatformMBeanConstants.THREAD_CPU_TIME_ENABLED.equals(name)) { enabledValidator.validate(operation); ManagementFactory.getThreadMXBean().setThreadCpuTimeEnabled(operation.require(ModelDescriptionConstants.VALUE).asBoolean()); } else if (PlatformMBeanConstants.THREADING_READ_WRITE_ATTRIBUTES.contains(name)) { // Bug throw PlatformMBeanMessages.MESSAGES.badWriteAttributeImpl4(name); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } catch (UnsupportedOperationException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } }
final ModelNode store = result.get(attribute); try { ThreadMXBeanAttributeHandler.storeResult(attribute, store); } catch (SecurityException ignored) { final ModelNode store = result.get(attribute); try { ThreadMXBeanAttributeHandler.storeResult(attribute, store); } catch (SecurityException ignored) { final ModelNode store = result.get(attribute); try { ThreadMXBeanAttributeHandler.storeResult(attribute, store); } catch (SecurityException ignored) { ThreadMXBeanAttributeHandler.storeResult(PlatformMBeanConstants.OBJECT_NAME, store);
threads.registerOperationHandler(GET_THREAD_USER_TIME, ThreadMXBeanUserTimeHandler.INSTANCE, ThreadMXBeanUserTimeHandler.INSTANCE, READ_ONLY_RUNTIME_ONLY_FLAG); threads.registerOperationHandler(DUMP_ALL_THREADS, ThreadMXBeanDumpAllThreadsHandler.INSTANCE, ThreadMXBeanDumpAllThreadsHandler.INSTANCE, READ_ONLY_RUNTIME_ONLY_FLAG); ThreadMXBeanAttributeHandler.INSTANCE.register(threads);
@Override protected void executeWriteAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if (PlatformMBeanConstants.THREAD_CONTENTION_MONITORING_ENABLED.equals(name)) { enabledValidator.validate(operation); context.getServiceRegistry(true); //to trigger auth ManagementFactory.getThreadMXBean().setThreadContentionMonitoringEnabled(operation.require(ModelDescriptionConstants.VALUE).asBoolean()); } else if (PlatformMBeanConstants.THREAD_CPU_TIME_ENABLED.equals(name)) { enabledValidator.validate(operation); context.getServiceRegistry(true); //to trigger auth ManagementFactory.getThreadMXBean().setThreadCpuTimeEnabled(operation.require(ModelDescriptionConstants.VALUE).asBoolean()); } else if (ThreadResourceDefinition.THREADING_READ_WRITE_ATTRIBUTES.contains(name)) { // Bug throw PlatformMBeanLogger.ROOT_LOGGER.badWriteAttributeImpl(name); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException e) { throw new OperationFailedException(e.toString()); } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }
final ModelNode store = result.get(attribute); try { ThreadMXBeanAttributeHandler.storeResult(attribute, store); } catch (SecurityException ignored) { final ModelNode store = result.get(attribute); try { ThreadMXBeanAttributeHandler.storeResult(attribute, store); } catch (SecurityException ignored) { final ModelNode store = result.get(attribute); try { ThreadMXBeanAttributeHandler.storeResult(attribute, store); } catch (SecurityException ignored) { ThreadMXBeanAttributeHandler.storeResult(PlatformMBeanConstants.OBJECT_NAME.getName(), store);
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanConstants.OBJECT_NAME.getName().equals(name)) || ThreadResourceDefinition.THREADING_READ_ATTRIBUTES.contains(name) || ThreadResourceDefinition.THREADING_READ_WRITE_ATTRIBUTES.contains(name) || ThreadResourceDefinition.THREADING_METRICS.contains(name)) { storeResult(name, context.getResult()); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException | UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }
@Override protected void executeWriteAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if (PlatformMBeanConstants.THREAD_CONTENTION_MONITORING_ENABLED.equals(name)) { enabledValidator.validate(operation); context.getServiceRegistry(true); //to trigger auth ManagementFactory.getThreadMXBean().setThreadContentionMonitoringEnabled(operation.require(ModelDescriptionConstants.VALUE).asBoolean()); } else if (PlatformMBeanConstants.THREAD_CPU_TIME_ENABLED.equals(name)) { enabledValidator.validate(operation); context.getServiceRegistry(true); //to trigger auth ManagementFactory.getThreadMXBean().setThreadCpuTimeEnabled(operation.require(ModelDescriptionConstants.VALUE).asBoolean()); } else if (ThreadResourceDefinition.THREADING_READ_WRITE_ATTRIBUTES.contains(name)) { // Bug throw PlatformMBeanLogger.ROOT_LOGGER.badWriteAttributeImpl(name); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException e) { throw new OperationFailedException(e.toString()); } catch (UnsupportedOperationException e) { throw new OperationFailedException(e.toString()); } }
final ModelNode store = result.get(attribute); try { ThreadMXBeanAttributeHandler.storeResult(attribute, store); } catch (SecurityException ignored) { final ModelNode store = result.get(attribute); try { ThreadMXBeanAttributeHandler.storeResult(attribute, store); } catch (SecurityException ignored) { final ModelNode store = result.get(attribute); try { ThreadMXBeanAttributeHandler.storeResult(attribute, store); } catch (SecurityException ignored) { ThreadMXBeanAttributeHandler.storeResult(PlatformMBeanConstants.OBJECT_NAME.getName(), store);
@Override protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException { final String name = operation.require(ModelDescriptionConstants.NAME).asString(); try { if ((PlatformMBeanUtil.JVM_MAJOR_VERSION > 6 && PlatformMBeanConstants.OBJECT_NAME.equals(name)) || PlatformMBeanConstants.THREADING_READ_ATTRIBUTES.contains(name) || PlatformMBeanConstants.THREADING_READ_WRITE_ATTRIBUTES.contains(name) || PlatformMBeanConstants.THREADING_METRICS.contains(name)) { storeResult(name, context.getResult()); } else { // Shouldn't happen; the global handler should reject throw unknownAttribute(operation); } } catch (SecurityException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } catch (UnsupportedOperationException e) { throw new OperationFailedException(new ModelNode().set(e.toString())); } }