本文整理汇总了Java中org.apache.xmlrpc.XmlRpcRequest.getParameterCount方法的典型用法代码示例。如果您正苦于以下问题:Java XmlRpcRequest.getParameterCount方法的具体用法?Java XmlRpcRequest.getParameterCount怎么用?Java XmlRpcRequest.getParameterCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xmlrpc.XmlRpcRequest
的用法示例。
在下文中一共展示了XmlRpcRequest.getParameterCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeRequest
import org.apache.xmlrpc.XmlRpcRequest; //导入方法依赖的package包/类
public void writeRequest(XmlRpcStreamConfig config, XmlRpcRequest request) throws SAXException {
handler.startDocument();
boolean extensions = config.isEnabledForExtensions();
if (extensions) {
handler.startPrefixMapping("ex", org.apache.xmlrpc.serializer.XmlRpcWriter.EXTENSIONS_URI);
}
handler.startElement("", "methodCall", "methodCall", ZERO_ATTRIBUTES);
handler.startElement("", "methodName", "methodName", ZERO_ATTRIBUTES);
String s = request.getMethodName();
handler.characters(s.toCharArray(), 0, s.length());
handler.endElement("", "methodName", "methodName");
handler.startElement("", "params", "params", ZERO_ATTRIBUTES);
int num = request.getParameterCount();
for (int i = 0; i < num; i++) {
handler.startElement("", "param", "param", ZERO_ATTRIBUTES);
writeValue(request.getParameter(i));
handler.endElement("", "param", "param");
}
handler.endElement("", "params", "params");
handler.endElement("", "methodCall", "methodCall");
if (extensions) {
handler.endPrefixMapping("ex");
}
handler.endDocument();
}
示例2: getContext
import org.apache.xmlrpc.XmlRpcRequest; //导入方法依赖的package包/类
protected Map<String, Object> getContext(XmlRpcRequest xmlRpcReq, String serviceName) throws XmlRpcException {
ModelService model;
try {
model = dispatcher.getDispatchContext().getModelService(serviceName);
} catch (GenericServiceException e) {
throw new XmlRpcException(e.getMessage(), e);
}
// context placeholder
Map<String, Object> context = new HashMap<String, Object>();
if (model != null) {
int parameterCount = xmlRpcReq.getParameterCount();
// more than one parameter; use list notation based on service def order
if (parameterCount > 1) {
int x = 0;
for (String name: model.getParameterNames("IN", true, true)) {
context.put(name, xmlRpcReq.getParameter(x));
x++;
if (x == parameterCount) {
break;
}
}
// only one parameter; if its a map use it as the context; otherwise make sure the service takes one param
} else if (parameterCount == 1) {
Object param = xmlRpcReq.getParameter(0);
if (param instanceof Map<?, ?>) {
context = checkMap(param, String.class, Object.class);
} else {
if (model.getDefinedInCount() == 1) {
String paramName = model.getInParamNames().iterator().next();
context.put(paramName, xmlRpcReq.getParameter(0));
} else {
throw new XmlRpcException("More than one parameter defined on service; cannot call via RPC with parameter list");
}
}
}
// do map value conversions
context = model.makeValid(context, ModelService.IN_PARAM);
}
return context;
}
示例3: getContext
import org.apache.xmlrpc.XmlRpcRequest; //导入方法依赖的package包/类
protected Map<String, Object> getContext(XmlRpcRequest xmlRpcReq, String serviceName) throws XmlRpcException {
ModelService model;
try {
model = dispatcher.getDispatchContext().getModelService(serviceName);
} catch (GenericServiceException e) {
throw new XmlRpcException(e.getMessage(), e);
}
// context placeholder
Map<String, Object> context = FastMap.newInstance();
if (model != null) {
int parameterCount = xmlRpcReq.getParameterCount();
// more than one parameter; use list notation based on service def order
if (parameterCount > 1) {
int x = 0;
for (String name: model.getParameterNames("IN", true, true)) {
context.put(name, xmlRpcReq.getParameter(x));
x++;
if (x == parameterCount) {
break;
}
}
// only one parameter; if its a map use it as the context; otherwise make sure the service takes one param
} else if (parameterCount == 1) {
Object param = xmlRpcReq.getParameter(0);
if (param instanceof Map<?, ?>) {
context = checkMap(param, String.class, Object.class);
} else {
if (model.getDefinedInCount() == 1) {
String paramName = model.getInParamNames().iterator().next();
context.put(paramName, xmlRpcReq.getParameter(0));
} else {
throw new XmlRpcException("More than one parameter defined on service; cannot call via RPC with parameter list");
}
}
}
// do map value conversions
context = model.makeValid(context, ModelService.IN_PARAM);
}
return context;
}