Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.fabric.status;
import com.liferay.petra.concurrent.NoticeableFuture;
import com.liferay.petra.process.ProcessCallable;
import com.liferay.petra.process.ProcessException;
import java.io.Serializable;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryUsage;
import java.lang.management.PlatformManagedObject;
import java.lang.management.ThreadInfo;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import javax.management.Attribute;
import javax.management.AttributeNotFoundException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.openmbean.CompositeData;
/**
* @author Shuyang Zhou
*/
public class JMXProxyUtil {
public static T newProxy(
ObjectName objectName, Class interfaceClass,
ProcessCallableExecutor processCallableExecutor) {
ClassLoader classLoader = interfaceClass.getClassLoader();
if (classLoader == null) {
classLoader = ClassLoader.getSystemClassLoader();
}
return (T)Proxy.newProxyInstance(
classLoader, new Class[] {interfaceClass},
new JMXProxyInvocationHandler(objectName, processCallableExecutor));
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Optional {
}
public interface ProcessCallableExecutor {
public NoticeableFuture execute(
ProcessCallable processCallable);
}
protected static Object decode(
Class decodedClass, Serializable serializable) {
if (serializable instanceof CompositeData) {
return decodeCompositeData(
decodedClass, (CompositeData)serializable);
}
if ((serializable instanceof CompositeData[]) &&
decodedClass.isArray()) {
return decodeCompositeDataArray(
decodedClass, (CompositeData[])serializable);
}
if (decodedClass == List.class) {
Class clazz = serializable.getClass();
if (clazz.isArray()) {
return decodeArrayToList(serializable);
}
}
return serializable;
}
protected static Object decodeArrayToList(Object array) {
List