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


Java JMException类代码示例

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


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

示例1: registerMBean

import javax.management.JMException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ObjectName registerMBean(Object managedResource, ObjectName objectName)
{
    Object mbean;
    if (isMBean(managedResource.getClass()))
    {
        mbean = managedResource;
    }
    else
    {
        mbean = createAndConfigureMBean(managedResource, managedResource.getClass().getName());
    }
    ObjectName actualObjectName = objectName;
    try
    {
        doRegister(mbean, actualObjectName);
    }
    catch (JMException e)
    {
        throw new RuntimeException(e);
    }
    return actualObjectName;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:DynamicMBeanExporter.java

示例2: register

import javax.management.JMException; //导入依赖的package包/类
/**
 * Registers a new MBean with the platform MBean server. 
 * @param bean the bean being registered
 * @param parent if not null, the new bean will be registered as a child
 * node of this parent.
 */
public void register(ZKMBeanInfo bean, ZKMBeanInfo parent)
    throws JMException
{
    assert bean != null;
    String path = null;
    if (parent != null) {
        path = mapBean2Path.get(parent);
        assert path != null;
    }
    path = makeFullPath(path, parent);
    if(bean.isHidden())
        return;
    ObjectName oname = makeObjectName(path, bean);
    try {
        mBeanServer.registerMBean(bean, oname);
        mapBean2Path.put(bean, path);
        mapName2Bean.put(bean.getName(), bean);
    } catch (JMException e) {
        LOG.warn("Failed to register MBean " + bean.getName());
        throw e;
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:29,代码来源:MBeanRegistry.java

示例3: initializeAndRun

import javax.management.JMException; //导入依赖的package包/类
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }
    //再次解析配置文件(我也是醉了呀,又解析一遍!!!,写这段的人你出来我保证不打你)
    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:19,代码来源:ZooKeeperServerMain.java

示例4: invokeOperation

import javax.management.JMException; //导入依赖的package包/类
/**
 * Routes a method invocation (not a property get/set) to the corresponding
 * operation on the managed resource.
 * @param method the method corresponding to operation on the managed resource.
 * @param args the invocation arguments
 * @return the value returned by the method invocation.
 */
private Object invokeOperation(Method method, Object[] args) throws JMException, IOException {
	MethodCacheKey key = new MethodCacheKey(method.getName(), method.getParameterTypes());
	MBeanOperationInfo info = this.allowedOperations.get(key);
	if (info == null) {
		throw new InvalidInvocationException("Operation '" + method.getName() +
				"' is not exposed on the management interface");
	}
	String[] signature = null;
	synchronized (this.signatureCache) {
		signature = this.signatureCache.get(method);
		if (signature == null) {
			signature = JmxUtils.getMethodSignature(method);
			this.signatureCache.put(method, signature);
		}
	}
	return this.serverToUse.invoke(this.objectName, method.getName(), args, signature);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:MBeanClientInterceptor.java

示例5: registerManagedResource

import javax.management.JMException; //导入依赖的package包/类
@Override
public void registerManagedResource(Object managedResource, ObjectName objectName) throws MBeanExportException {
	Assert.notNull(managedResource, "Managed resource must not be null");
	Assert.notNull(objectName, "ObjectName must not be null");
	try {
		if (isMBean(managedResource.getClass())) {
			doRegister(managedResource, objectName);
		}
		else {
			ModelMBean mbean = createAndConfigureMBean(managedResource, managedResource.getClass().getName());
			doRegister(mbean, objectName);
			injectNotificationPublisherIfNecessary(managedResource, mbean, objectName);
		}
	}
	catch (JMException ex) {
		throw new UnableToRegisterMBeanException(
				"Unable to register MBean [" + managedResource + "] with object name [" + objectName + "]", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:MBeanExporter.java

示例6: adaptMBeanIfPossible

import javax.management.JMException; //导入依赖的package包/类
/**
 * Build an adapted MBean for the given bean instance, if possible.
 * <p>The default implementation builds a JMX 1.2 StandardMBean
 * for the target's MBean/MXBean interface in case of an AOP proxy,
 * delegating the interface's management operations to the proxy.
 * @param bean the original bean instance
 * @return the adapted MBean, or {@code null} if not possible
 */
@SuppressWarnings("unchecked")
protected DynamicMBean adaptMBeanIfPossible(Object bean) throws JMException {
	Class<?> targetClass = AopUtils.getTargetClass(bean);
	if (targetClass != bean.getClass()) {
		Class<?> ifc = JmxUtils.getMXBeanInterface(targetClass);
		if (ifc != null) {
			if (!ifc.isInstance(bean)) {
				throw new NotCompliantMBeanException("Managed bean [" + bean +
						"] has a target class with an MXBean interface but does not expose it in the proxy");
			}
			return new StandardMBean(bean, ((Class<Object>) ifc), true);
		}
		else {
			ifc = JmxUtils.getMBeanInterface(targetClass);
			if (ifc != null) {
				if (!ifc.isInstance(bean)) {
					throw new NotCompliantMBeanException("Managed bean [" + bean +
							"] has a target class with an MBean interface but does not expose it in the proxy");
				}
				return new StandardMBean(bean, ((Class<Object>) ifc));
			}
		}
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:MBeanExporter.java

示例7: testSpiderInfo

import javax.management.JMException; //导入依赖的package包/类
/**
     * 测试爬虫模板
     *
     * @param info
     * @return
     */
    public List<Webpage> testSpiderInfo(SpiderInfo info) throws JMException {
        final ResultItemsCollectorPipeline resultItemsCollectorPipeline = new ResultItemsCollectorPipeline();
        final String uuid = UUID.randomUUID().toString();
        Task task = taskManager.initTask(uuid, info.getDomain(), info.getCallbackURL(), "spiderInfoId=" + info.getId() + "&spiderUUID=" + uuid);
        task.addExtraInfo("spiderInfo", info);
        QueueScheduler queueScheduler = new QueueScheduler();
        MySpider spider = (MySpider) makeSpider(info, task)
                .addPipeline(resultItemsCollectorPipeline)
                .setScheduler(queueScheduler);
        spider.startUrls(info.getStartURL());
        //慎用爬虫监控,可能导致内存泄露
//        spiderMonitor.register(spider);
        spiderMap.put(uuid, spider);
        taskManager.getTaskById(uuid).setState(State.RUNNING);
        spider.run();
        List<Webpage> webpageList = Lists.newLinkedList();
        resultItemsCollectorPipeline.getCollected().forEach(resultItems -> webpageList.add(CommonWebpagePipeline.convertResultItems2Webpage(resultItems)));
        return webpageList;
    }
 
开发者ID:bruceq,项目名称:Gather-Platform,代码行数:26,代码来源:CommonSpider.java

示例8: register

import javax.management.JMException; //导入依赖的package包/类
/**
 * Registers a new MBean with the platform MBean server. 
 * @param bean the bean being registered
 * @param parent if not null, the new bean will be registered as a child
 * node of this parent.
 */
public void register(ZKMBeanInfo bean, ZKMBeanInfo parent)
    throws JMException
{
    assert bean != null;
    String path = null;
    if (parent != null) {
        path = mapBean2Path.get(parent);
        assert path != null;
    }
    path = makeFullPath(path, parent);
    if(bean.isHidden())
        return;
    ObjectName oname = makeObjectName(path, bean);
    try {
        synchronized (LOCK) {
            mBeanServer.registerMBean(bean, oname);
            mapBean2Path.put(bean, path);
        }
    } catch (JMException e) {
        LOG.warn("Failed to register MBean " + bean.getName());
        throw e;
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:30,代码来源:MBeanRegistry.java

示例9: initializeAndRun

import javax.management.JMException; //导入依赖的package包/类
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException, AdminServerException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:19,代码来源:ZooKeeperServerMain.java

示例10: startManager

import javax.management.JMException; //导入依赖的package包/类
public static void startManager() {
  MemberMXBean bean = getManagementService().getMemberMXBean();
  // When the cache is created if jmx-manager is true then we create the manager.
  // So it may already exist when we get here.
  if (!bean.isManagerCreated()) {
    if (!bean.createManager()) {
      fail("Could not create Manager");
    } else if (!bean.isManagerCreated()) {
      fail("Should have been a manager after createManager returned true.");
    }
  }
  ManagerMXBean mngrBean = getManagementService().getManagerMXBean();
  try {
    mngrBean.start();
  } catch (JMException e) {
    fail("Could not start Manager " + e);
  }
  assertTrue(mngrBean.isRunning());
  assertTrue(getManagementService().isManager());
  assertTrue(bean.isManager());
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:CacheManagementDUnitTest.java

示例11: applyConfiguration

import javax.management.JMException; //导入依赖的package包/类
private void applyConfiguration(ScanManagerConfig bean)
    throws IOException, JMException {
    if (bean == null) return;
    if (!sequencer.tryAcquire()) {
        throw new IllegalStateException("Can't acquire lock");
    }
    try {
        unregisterScanners();
        final DirectoryScannerConfig[] scans = bean.getScanList();
        if (scans == null) return;
        for (DirectoryScannerConfig scan : scans) {
            addDirectoryScanner(scan);
        }
        log.setConfig(bean.getInitialResultLogConfig());
    } finally {
        sequencer.release();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:ScanManager.java

示例12: initializeAndRun

import javax.management.JMException; //导入依赖的package包/类
protected void initializeAndRun(String[] args)
    throws ConfigException, IOException
{
    try {
        ManagedUtil.registerLog4jMBeans();
    } catch (JMException e) {
        LOG.warn("Unable to register log4j JMX control", e);
    }

    ServerConfig config = new ServerConfig();
    if (args.length == 1) {
        config.parse(args[0]);
    } else {
        config.parse(args);
    }

    runFromConfig(config);
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:19,代码来源:ZooKeeperServerMain.java

示例13: registerMBean

import javax.management.JMException; //导入依赖的package包/类
@SuppressWarnings({
		"unchecked", "rawtypes"
})
public static String registerMBean(final Object object) throws JMException {
	final ObjectName objectName = generateMBeanName(object.getClass());
	final MBeanServer context = ManagementFactory.getPlatformMBeanServer();
	final String mbeanName = object.getClass().getName() + "MBean";
	for (final Class c : object.getClass().getInterfaces()) {
		if (mbeanName.equals(c.getName())) {
			context.registerMBean(new AnnotatedStandardMBean(object, c), objectName);
			return objectName.getCanonicalName();
		}
	}
	context.registerMBean(object, objectName);
	return objectName.getCanonicalName();
}
 
开发者ID:ggrandes,项目名称:metrics-tomcat,代码行数:17,代码来源:AnnotatedStandardMBean.java

示例14: handlePotentialStuckRepairs

import javax.management.JMException; //导入依赖的package包/类
private void handlePotentialStuckRepairs(LazyInitializer<Set<String>> busyHosts, String hostName)
    throws ConcurrentException {

  if (!busyHosts.get().contains(hostName) && context.storage instanceof IDistributedStorage) {
    try (JmxProxy hostProxy
        = context.jmxConnectionFactory.connect(hostName, context.config.getJmxConnectionTimeoutInSeconds())) {
      // We double check that repair is still running there before actually canceling repairs
      if (hostProxy.isRepairRunning()) {
        LOG.warn(
            "A host ({}) reported that it is involved in a repair, but there is no record "
                + "of any ongoing repair involving the host. Sending command to abort all repairs "
                + "on the host.",
            hostName);
        hostProxy.cancelAllRepairs();
        hostProxy.close();
      }
    } catch (ReaperException | RuntimeException | InterruptedException | JMException e) {
      LOG.debug("failed to cancel repairs on host {}", hostName, e);
    }
  }
}
 
开发者ID:thelastpickle,项目名称:cassandra-reaper,代码行数:22,代码来源:SegmentRunner.java

示例15: startAll

import javax.management.JMException; //导入依赖的package包/类
/**
 * 根据爬虫模板ID批量启动任务
 *
 * @param spiderInfoIdList 爬虫模板ID列表
 * @return 任务id列表
 */
public ResultListBundle<String> startAll(List<String> spiderInfoIdList) {
    return bundleBuilder.listBundle(spiderInfoIdList.toString(), () -> {
        List<String> taskIdList = Lists.newArrayList();
        for (String id : spiderInfoIdList) {
            try {
                SpiderInfo info = spiderInfoService.getById(id).getResult();
                String taskId = commonSpider.start(info);
                taskIdList.add(taskId);
            } catch (JMException e) {
                LOG.error("启动任务ID{}出错,{}", id, e);
            }
        }
        return taskIdList;
    });
}
 
开发者ID:gsh199449,项目名称:spider,代码行数:22,代码来源:CommonsSpiderService.java


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