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