当前位置: 首页>>代码示例>>Java>>正文


Java JMRuntimeException类代码示例

本文整理汇总了Java中javax.management.JMRuntimeException的典型用法代码示例。如果您正苦于以下问题:Java JMRuntimeException类的具体用法?Java JMRuntimeException怎么用?Java JMRuntimeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JMRuntimeException类属于javax.management包,在下文中一共展示了JMRuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processCommand

import javax.management.JMRuntimeException; //导入依赖的package包/类
/**
 * Processes the given command string using the given environment information if it's non-empty.
 * Result returned is in a JSON format.
 * 
 * @param commandString command string to be processed
 * @param env environment information to be used for processing the command
 * @return result of the processing the given command string.
 */
public String processCommand(String commandString, Map<String, String> env) {
  if (commandService == null) {
    throw new JMRuntimeException(
        "Command can not be processed as Command Service did not get initialized. Reason: "
            + commandServiceInitError);
  }

  boolean isGfshRequest = isGfshRequest(env);
  if (isGfshRequest) {
    CommandExecutionContext.setShellRequest();
  }

  Result result = ((MemberCommandService) commandService).processCommand(commandString, env);
  if (!(result instanceof CommandResult)) {// TODO - Abhishek - Shouldn't be needed
    while (result.hasNextLine()) {
      result = ResultBuilder.createInfoResult(result.nextLine());
    }
  }

  if (isGfshRequest) {
    return CommandResponseBuilder.createCommandResponseJson(getMember(), (CommandResult) result);
  } else {
    return ResultBuilder.resultAsString(result);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:34,代码来源:MemberMBeanBridge.java

示例2: getInfo

import javax.management.JMRuntimeException; //导入依赖的package包/类
private ModelNode getInfo(ObjectName objectName) {
    MBeanServerConnection connection = getConnection();
    ModelNode attributes = null;
    ModelNode headers = null;
    Exception exception = null;
    try {
        MBeanInfo mBeanInfo = connection.getMBeanInfo(objectName);
        MBeanAttributeInfo[] attributeInfos = mBeanInfo.getAttributes();
        ModelNode[] data = modelNodeAttributesInfo(attributeInfos, objectName);
        attributes = data[0];
        headers = data[1];
    } catch (Exception e) {
        if (e instanceof JMException || e instanceof JMRuntimeException) {
            exception = e;
        } else {
            throw new RuntimeException(e);
        }
    }
    return modelNodeResult(attributes, exception, headers);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:JmxManagementInterface.java

示例3: getAttribute

import javax.management.JMRuntimeException; //导入依赖的package包/类
private void getAttribute(String userName, JmxManagementInterface jmx) throws Exception {
    boolean successExpected = isReadAllowed(userName);

    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName("java.lang:type=OperatingSystem");
    try {
        Object attribute = connection.getAttribute(domain, "Name");
        assertTrue("Failure was expected", successExpected);
        assertEquals(System.getProperty("os.name"), attribute.toString());
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:AbstractJmxNonCoreMBeansSensitivityTestCase.java

示例4: setAttribute

import javax.management.JMRuntimeException; //导入依赖的package包/类
private void setAttribute(String userName, JmxManagementInterface jmx) throws Exception {
    boolean successExpected = isWriteAllowed(userName);

    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName("java.lang:type=Memory");
    try {
        connection.setAttribute(domain, new Attribute("Verbose", true));
        connection.setAttribute(domain, new Attribute("Verbose", false)); // back to default to not pollute the logs
        assertTrue("Failure was expected", successExpected);
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:AbstractJmxNonCoreMBeansSensitivityTestCase.java

示例5: getAttribute

import javax.management.JMRuntimeException; //导入依赖的package包/类
private void getAttribute(String userName, JmxManagementInterface jmx) throws Exception {
    boolean successExpected = isReadAllowed(userName);
    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName("java.lang:type=OperatingSystem");
    try {
        Object attribute = connection.getAttribute(domain, "Name");
        assertTrue("Failure was expected", successExpected);
        assertEquals(System.getProperty("os.name"), attribute.toString());
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:JmxRBACProviderHostScopedRolesTestCase.java

示例6: checkAddSensitive

import javax.management.JMRuntimeException; //导入依赖的package包/类
private void checkAddSensitive(final StandardRole standardRole, final boolean wildcard, final boolean  executable, final SensitiveTargetAccessConstraintDefinition...sensitivityConstraints) throws Exception {
    PathElement pathElement = wildcard ? ONE : ONE_A;
    ChildResourceDefinition oneChild = new ChildResourceDefinition(pathElement, sensitivityConstraints);
    oneChild.addAttribute("attr1");
    oneChild.addOperation("test", true, false, null);
    rootRegistration.registerSubModel(oneChild);

    AccessAuditContext.doAs(roleToSecurityIdentity(standardRole), null, new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws Exception {
            Assert.assertFalse(server.queryNames(null, null).contains(ONE_A_NAME));
            try {
                String add = wildcard ? "addOne" : "addOneA";
                Object[] params = wildcard ? new String[]{"a", "test"} : new String[]{"test"};
                String[] sig = wildcard ? new String[] {String.class.getName(), String.class.getName()} : new String[] {String.class.getName()};
                server.invoke(ROOT_NAME, add, params, sig);
                Assert.assertTrue(executable);
                Assert.assertTrue(server.queryNames(null, null).contains(ONE_A_NAME));
            } catch (JMRuntimeException e) {
                Assert.assertFalse(executable);
            }

            return null;
        }
    });
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:27,代码来源:JmxFacadeRbacEnabledTestCase.java

示例7: releaseMBeanServer

import javax.management.JMRuntimeException; //导入依赖的package包/类
/**
 * Unregisters all GemFire MBeans and then releases the MBeanServer for garbage collection.
 */
static void releaseMBeanServer() {
  try {
    // unregister all GemFire mbeans...
    Iterator iter = mbeanServer.queryNames(null, null).iterator();
    while (iter.hasNext()) {
      ObjectName name = (ObjectName) iter.next();
      if (name.getDomain().startsWith(DEFAULT_DOMAIN)) {
        unregisterMBean(name);
      }
    }

    // last, release the mbean server...
    MBeanServerFactory.releaseMBeanServer(mbeanServer);
    mbeanServer = null;
  } catch (JMRuntimeException e) {
    logStackTrace(Level.WARN, e);
  }
  /*
   * See #42391. Cleaning up the static maps which might be still holding references to
   * ManagedResources
   */
  synchronized (MBeanUtil.managedResources) {
    MBeanUtil.managedResources.clear();
  }
  synchronized (refreshClients) {
    refreshClients.clear();
  }
  /*
   * See #42391. Cleaning up the static maps which might be still holding references to
   * ManagedResources
   */
  synchronized (MBeanUtil.managedResources) {
    MBeanUtil.managedResources.clear();
  }
  synchronized (refreshClients) {
    refreshClients.clear();
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:42,代码来源:MBeanUtil.java

示例8: updateEvictionPercent

import javax.management.JMRuntimeException; //导入依赖的package包/类
public void updateEvictionPercent(float newValue) {
  try {
    this.gfxdbridge.updateEvictionPercent(newValue);
  } catch (StandardException e) {
    throw new JMRuntimeException(e.getMessage());
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:8,代码来源:GfxdMemberMBean.java

示例9: updateCriticalPercent

import javax.management.JMRuntimeException; //导入依赖的package包/类
public void updateCriticalPercent(float newValue) {
  try {
    this.gfxdbridge.updateCriticalPercent(newValue);
  } catch (StandardException e) {
    throw new JMRuntimeException(e.getMessage());
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:8,代码来源:GfxdMemberMBean.java

示例10: releaseMBeanServer

import javax.management.JMRuntimeException; //导入依赖的package包/类
/**
 * Unregisters all GemFire MBeans and then releases the MBeanServer for
 * garbage collection.
 */
static void releaseMBeanServer() {
  try {
    // unregister all GemFire mbeans...
    Iterator iter = mbeanServer.queryNames(null, null).iterator();
    while (iter.hasNext()) {
      ObjectName name = (ObjectName)iter.next();
      if (name.getDomain().startsWith(DEFAULT_DOMAIN)) {
        unregisterMBean(name);
      }
    }
    
    // last, release the mbean server...
    MBeanServerFactory.releaseMBeanServer(mbeanServer);
    mbeanServer = null;
  } catch (JMRuntimeException e) { 
    logStackTrace(LogWriterImpl.WARNING_LEVEL, e); 
 	} 
 /* See #42391. Cleaning up the static maps which might be still holding  
  * references to ManagedResources */ 
  synchronized (MBeanUtil.managedResources) { 
    MBeanUtil.managedResources.clear(); 
  } 
  synchronized (refreshClients) { 
    refreshClients.clear();
  }
  /* See #42391. Cleaning up the static maps which might be still holding 
   * references to ManagedResources */
  synchronized (MBeanUtil.managedResources) {
    MBeanUtil.managedResources.clear();
  }
  synchronized (refreshClients) {
    refreshClients.clear();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:39,代码来源:MBeanUtil.java

示例11: processCommand

import javax.management.JMRuntimeException; //导入依赖的package包/类
/**
   * Processes the given command string using the given environment information
   * if it's non-empty. Result returned is in a JSON format.
   * 
   * @param commandString
   *          command string to be processed
   * @param env
   *          environment information to be used for processing the command
   * @return result of the processing the given command string.
   */
  public String processCommand(String commandString, Map<String, String> env) {
    if (commandService == null) {
      throw new JMRuntimeException(
          "Command can not be processed as Command Service did not get initialized. Reason: "+commandServiceInitError);
    }
    
    boolean isGfshRequest = isGfshRequest(env);
    if (isGfshRequest) {
      CommandExecutionContext.setShellRequest();
    }
//    System.out.println("isGfshRequest :: "+isGfshRequest);
    
    Result result = ((MemberCommandService)commandService).processCommand(commandString, env);
    if (!(result instanceof CommandResult)) {// TODO - Abhishek - Shouldn't be needed
      while (result.hasNextLine()) {
        result = ResultBuilder.createInfoResult(result.nextLine());
      }
    }
    if (isGfshRequest) {
      String responseJson = CommandResponseBuilder.createCommandResponseJson(getMember(), (CommandResult) result);
  //    System.out.println("responseJson :: "+responseJson);
      return responseJson;
    } else {
      return ResultBuilder.resultAsString(result);
    }
  }
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:37,代码来源:MemberMBeanBridge.java

示例12: doOperation

import javax.management.JMRuntimeException; //导入依赖的package包/类
private void doOperation(boolean successExpected, String operationName, JmxManagementInterface jmx) throws Exception {
    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName("jboss.test:service=testdeployments");
    try {
        connection.invoke(domain, operationName, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY);
        assertTrue("Failure was expected but success happened", successExpected);
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:15,代码来源:AbstractJmxNonCoreMBeansSensitivityTestCase.java

示例13: doOperation

import javax.management.JMRuntimeException; //导入依赖的package包/类
private void doOperation(boolean successExpected, String objectName, String operationName, JmxManagementInterface jmx) throws Exception {
    MBeanServerConnection connection = jmx.getConnection();
    ObjectName domain = new ObjectName(objectName);
    try {
        connection.invoke(domain, operationName, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY);
        assertTrue("Failure was expected but success happened", successExpected);
    } catch (JMRuntimeException e) {
        if (e.getMessage().contains("WFLYJMX0037")) {
            assertFalse("Success was expected but failure happened: " + e, successExpected);
        } else {
            throw e;
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:15,代码来源:JmxRBACProviderHostScopedRolesTestCase.java

示例14: checkReadVaultExpressionReadSensitive

import javax.management.JMRuntimeException; //导入依赖的package包/类
private void checkReadVaultExpressionReadSensitive(final StandardRole standardRole, final boolean readable) throws Exception {
    VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresAccessPermission(false);
    VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresReadPermission(true);
    VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresWritePermission(false);
    try {
        ChildResourceDefinition oneChild = new ChildResourceDefinition(ONE);
        oneChild.addAttribute("attr1");
        oneChild.addOperation("test", true, false, null);
        rootRegistration.registerSubModel(oneChild);
        Resource resourceA = Resource.Factory.create();
        resourceA.getModel().get("attr1").set("test-a");
        rootResource.registerChild(ONE_A, resourceA);
        Resource resourceB = Resource.Factory.create();
        resourceB.getModel().get("attr1").set("${VAULT::AA::bb::cc}");
        rootResource.registerChild(ONE_B, resourceB);

        AccessAuditContext.doAs(roleToSecurityIdentity(standardRole), null, new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws Exception {
                Assert.assertEquals("test-a", server.getAttribute(ONE_A_NAME, "attr1"));
                try {
                    Assert.assertEquals("${VAULT::AA::bb::cc}", server.getAttribute(ONE_B_NAME, "attr1"));
                    Assert.assertTrue(readable);
                } catch (JMRuntimeException e) {
                    Assert.assertFalse(readable);
                }

                return null;
            }
        });
    } finally {
        VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresAccessPermission(null);
        VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresReadPermission(null);
        VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresWritePermission(null);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:37,代码来源:JmxFacadeRbacEnabledTestCase.java

示例15: checkWriteVaultExpressionWriteSensitive

import javax.management.JMRuntimeException; //导入依赖的package包/类
private void checkWriteVaultExpressionWriteSensitive(final StandardRole standardRole, final boolean writable) throws Exception {
    VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresAccessPermission(false);
    VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresReadPermission(true);
    VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresWritePermission(true);
    try {
        ChildResourceDefinition oneChild = new ChildResourceDefinition(ONE);
        oneChild.addAttribute("attr1");
        oneChild.addOperation("test", true, false, null);
        rootRegistration.registerSubModel(oneChild);
        Resource resourceA = Resource.Factory.create();
        resourceA.getModel().get("attr1").set("test-a");
        rootResource.registerChild(ONE_A, resourceA);

        AccessAuditContext.doAs(roleToSecurityIdentity(standardRole), null, new PrivilegedExceptionAction<Void>() {
            @Override
            public Void run() throws Exception {
                try {
                    server.setAttribute(ONE_A_NAME, new Attribute("attr1", "${VAULT::AA::bb::cc}"));
                    Assert.assertTrue(writable);
                } catch (JMRuntimeException e) {
                    Assert.assertFalse(writable);
                }

                return null;
            }
        });
    } finally {
        VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresAccessPermission(null);
        VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresReadPermission(null);
        VaultExpressionSensitivityConfig.INSTANCE.setConfiguredRequiresWritePermission(null);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:33,代码来源:JmxFacadeRbacEnabledTestCase.java


注:本文中的javax.management.JMRuntimeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。