本文整理匯總了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;
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
}
示例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);
}
示例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());
}
示例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();
}
}
示例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);
}
示例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();
}
示例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);
}
}
}
示例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;
});
}