當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。