本文整理汇总了Java中javax.management.MBeanParameterInfo.getType方法的典型用法代码示例。如果您正苦于以下问题:Java MBeanParameterInfo.getType方法的具体用法?Java MBeanParameterInfo.getType怎么用?Java MBeanParameterInfo.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.MBeanParameterInfo
的用法示例。
在下文中一共展示了MBeanParameterInfo.getType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeOperationInternal
import javax.management.MBeanParameterInfo; //导入方法依赖的package包/类
/**
* Invokes an operation on an MBean.
* @param onameStr The name of the MBean.
* @param operation The name of the operation to invoke.
* @param parameters An array of Strings containing the parameters to the
* operation. They will be converted to the appropriate
* types to call the reuested operation.
* @return The value returned by the requested operation.
*/
private Object invokeOperationInternal(String onameStr,
String operation,
String[] parameters)
throws OperationsException, MBeanException, ReflectionException {
ObjectName oname=new ObjectName( onameStr );
MBeanOperationInfo methodInfo = registry.getMethodInfo(oname,operation);
MBeanParameterInfo[] signature = methodInfo.getSignature();
String[] signatureTypes = new String[signature.length];
Object[] values = new Object[signature.length];
for (int i = 0; i < signature.length; i++) {
MBeanParameterInfo pi = signature[i];
signatureTypes[i] = pi.getType();
values[i] = registry.convertValue(pi.getType(), parameters[i] );
}
return mBeanServer.invoke(oname,operation,values,signatureTypes);
}
示例2: invokeOperationInternal
import javax.management.MBeanParameterInfo; //导入方法依赖的package包/类
/**
* Invokes an operation on an MBean.
*
* @param onameStr
* The name of the MBean.
* @param operation
* The name of the operation to invoke.
* @param parameters
* An array of Strings containing the parameters to the
* operation. They will be converted to the appropriate types to
* call the requested operation.
* @return The value returned by the requested operation.
*/
private Object invokeOperationInternal(String onameStr, String operation, String[] parameters)
throws OperationsException, MBeanException, ReflectionException {
ObjectName oname = new ObjectName(onameStr);
MBeanOperationInfo methodInfo = registry.getMethodInfo(oname, operation);
MBeanParameterInfo[] signature = methodInfo.getSignature();
String[] signatureTypes = new String[signature.length];
Object[] values = new Object[signature.length];
for (int i = 0; i < signature.length; i++) {
MBeanParameterInfo pi = signature[i];
signatureTypes[i] = pi.getType();
values[i] = registry.convertValue(pi.getType(), parameters[i]);
}
return mBeanServer.invoke(oname, operation, values, signatureTypes);
}
示例3: invokeOperation
import javax.management.MBeanParameterInfo; //导入方法依赖的package包/类
public String invokeOperation(String domain, String bean, String operation, ModelMap model) throws Exception
{
ObjectName oname = new ObjectName(domain + ":" + bean);
MBeanInfo mbeanInfo = server.getMBeanInfo(oname);
MBeanOperationInfo opInfo = Stream.of(mbeanInfo.getOperations()).filter(o -> o.getName().equals(operation)).findFirst().get();
List<Object> params = new ArrayList<Object>();
List<String> signature = new ArrayList<String>();
for(MBeanParameterInfo pInfo : opInfo.getSignature())
{
Object param = model.get(pInfo.getName());
String type = pInfo.getType();
Object oval = TypeConverter.convertObjectValue(type, param.toString());
params.add(oval);
signature.add(type);
}
Object result = server.invoke(oname, operation, params.toArray(), signature.toArray(new String[0]));
return result != null ? result.toString() : null;
}
示例4: addOperation
import javax.management.MBeanParameterInfo; //导入方法依赖的package包/类
public void addOperation(MBeanOperationInfo opInfo)
{
OperationData opData = new OperationData(opInfo.getName());
opData.setDescription(opInfo.getDescription());
opData.setImpact(opInfo.getImpact());
opData.setReturnType(opInfo.getReturnType());
int parametersCount = opInfo.getSignature().length;
if (parametersCount != 0)
{
List<ParameterData> paramList = new ArrayList<ParameterData>();
for (int i = 0; i < parametersCount; i++)
{
MBeanParameterInfo paramInfo = opInfo.getSignature()[i];
ParameterData param = new ParameterData(paramInfo.getName(), paramInfo.getDescription(),
paramInfo.getType());
paramList.add(param);
}
opData.setParameters(paramList);
}
_operationMap.put(opInfo.getName(), opData);
}
示例5: doGet
import javax.management.MBeanParameterInfo; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String beanName = request.getParameter("beanName");
String encparm = URLEncoder.encode(beanName, "UTF-8");
try
{
MBeanServer server = MBeanServerFactory.findMBeanServer(null).get(0);
ObjectName oname = new ObjectName(beanName);
String opName = request.getParameter("opName");
MBeanInfo mbeanInfo = server.getMBeanInfo(oname);
MBeanOperationInfo[] opInfos = mbeanInfo.getOperations();
// Who thought up this API? Geez
MBeanOperationInfo opInfo = null;
for(MBeanOperationInfo i : opInfos)
{
if(i.getName().equals(opName))
{
opInfo = i;
break;
}
}
List<Object> params = new ArrayList<Object>();
List<String> signature = new ArrayList<String>();
int count = 0;
String parm = null;
while((parm = request.getParameter("arg" + count++)) != null)
{
MBeanParameterInfo parmInfo = opInfo.getSignature()[count-1];
String type = parmInfo.getType();
Object oval = TypeConverter.convertObjectValue(type, parm);
params.add(oval);
signature.add(type);
}
Object result = server.invoke(oname, opName, params.toArray(), signature.toArray(new String[0]));
request.setAttribute("result", result);
request.setAttribute("beanName", beanName);
request.setAttribute("opName", opName);
request.setAttribute("opParams", params);
request.setAttribute("beanUrl", "/jmx-console/showBean?beanName=" + encparm);
request.getRequestDispatcher("operationResult.jsp").forward(request, response);
}
catch(Exception e)
{
e.printStackTrace();
response.sendRedirect("/showBean?beanName=" + encparm);
}
}