本文整理汇总了Java中org.ofbiz.base.metrics.MetricsFactory类的典型用法代码示例。如果您正苦于以下问题:Java MetricsFactory类的具体用法?Java MetricsFactory怎么用?Java MetricsFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetricsFactory类属于org.ofbiz.base.metrics包,在下文中一共展示了MetricsFactory类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Event
import org.ofbiz.base.metrics.MetricsFactory; //导入依赖的package包/类
public Event(Element eventElement) {
this.type = eventElement.getAttribute("type");
this.path = eventElement.getAttribute("path");
this.invoke = eventElement.getAttribute("invoke");
this.globalTransaction = !"false".equals(eventElement.getAttribute("global-transaction"));
// Get metrics.
Element metricsElement = UtilXml.firstChildElement(eventElement, "metric");
if (metricsElement != null) {
this.metrics = MetricsFactory.getInstance(metricsElement);
}
// SCIPIO: new attribs
String transStr = eventElement.getAttribute("transaction");
if ("true".equals(transStr)) {
transaction = Boolean.TRUE;
} else if ("false".equals(transStr)) {
transaction = Boolean.FALSE;
} else {
transaction = null;
}
this.abortTransaction = eventElement.getAttribute("abort-transaction");
}
示例2: RequestMap
import org.ofbiz.base.metrics.MetricsFactory; //导入依赖的package包/类
public RequestMap(Element requestMapElement) {
// Get the URI info
this.uri = requestMapElement.getAttribute("uri");
this.edit = !"false".equals(requestMapElement.getAttribute("edit"));
this.trackServerHit = !"false".equals(requestMapElement.getAttribute("track-serverhit"));
this.trackVisit = !"false".equals(requestMapElement.getAttribute("track-visit"));
// Check for security
Element securityElement = UtilXml.firstChildElement(requestMapElement, "security");
if (securityElement != null) {
this.securityHttps = "true".equals(securityElement.getAttribute("https"));
this.securityAuth = "true".equals(securityElement.getAttribute("auth"));
this.securityCert = "true".equals(securityElement.getAttribute("cert"));
this.securityExternalView = !"false".equals(securityElement.getAttribute("external-view"));
this.securityDirectRequest = !"false".equals(securityElement.getAttribute("direct-request"));
}
// Check for event
Element eventElement = UtilXml.firstChildElement(requestMapElement, "event");
if (eventElement != null) {
this.event = new Event(eventElement);
}
// Check for description
this.description = UtilXml.childElementValue(requestMapElement, "description");
// Get the response(s)
for (Element responseElement : UtilXml.childElementList(requestMapElement, "response")) {
RequestResponse response = new RequestResponse(responseElement);
requestResponseMap.put(response.name, response);
}
// Get metrics.
Element metricsElement = UtilXml.firstChildElement(requestMapElement, "metric");
if (metricsElement != null) {
this.metrics = MetricsFactory.getInstance(metricsElement);
}
}
示例3: getAllMetrics
import org.ofbiz.base.metrics.MetricsFactory; //导入依赖的package包/类
public static Map<String, Object> getAllMetrics(DispatchContext dctx, Map<String, ?> context) {
List<Map<String, Object>> metricsMapList = new LinkedList<Map<String, Object>>();
Collection<Metrics> metricsList = MetricsFactory.getMetrics();
for (Metrics metrics : metricsList) {
Map<String, Object> metricsMap = new LinkedHashMap<String, Object>();
metricsMap.put("name", metrics.getName());
metricsMap.put("serviceRate", metrics.getServiceRate());
metricsMap.put("threshold", metrics.getThreshold());
metricsMap.put("totalEvents", metrics.getTotalEvents());
metricsMapList.add(metricsMap);
}
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("metricsList", metricsMapList);
return result;
}
示例4: resetMetric
import org.ofbiz.base.metrics.MetricsFactory; //导入依赖的package包/类
public static Map<String, Object> resetMetric(DispatchContext dctx, Map<String, ?> context) {
String originalName = (String) context.get("name");
String name = UtilCodec.getDecoder("url").decode(originalName);
if (name == null) {
return ServiceUtil.returnError("Exception thrown while decoding metric name \"" + originalName + "\"");
}
Metrics metric = MetricsFactory.getMetric(name);
if (metric != null) {
metric.reset();
return ServiceUtil.returnSuccess();
}
return ServiceUtil.returnError("Metric \"" + name + "\" not found.");
}
示例5: RequestMap
import org.ofbiz.base.metrics.MetricsFactory; //导入依赖的package包/类
public RequestMap(Element requestMapElement) {
// Get the URI info
this.uri = requestMapElement.getAttribute("uri");
this.edit = !"false".equals(requestMapElement.getAttribute("edit"));
this.trackServerHit = !"false".equals(requestMapElement.getAttribute("track-serverhit"));
this.trackVisit = !"false".equals(requestMapElement.getAttribute("track-visit"));
// Check for security
Element securityElement = UtilXml.firstChildElement(requestMapElement, "security");
if (securityElement != null) {
this.securityHttps = "true".equals(securityElement.getAttribute("https"));
this.securityAuth = "true".equals(securityElement.getAttribute("auth"));
this.securityCert = "true".equals(securityElement.getAttribute("cert"));
this.securityExternalView = !"false".equals(securityElement.getAttribute("external-view"));
this.securityDirectRequest = !"false".equals(securityElement.getAttribute("direct-request"));
}
// Check for event
Element eventElement = UtilXml.firstChildElement(requestMapElement, "event");
if (eventElement != null) {
this.event = new Event(eventElement);
}
// Check for description
this.description = UtilXml.childElementValue(requestMapElement, "description");
// Get the response(s)
for (Element responseElement: UtilXml.childElementList(requestMapElement, "response")) {
RequestResponse response = new RequestResponse(responseElement);
requestResponseMap.put(response.name, response);
}
// Get metrics.
Element metricsElement = UtilXml.firstChildElement(requestMapElement, "metric");
if (metricsElement != null) {
this.metrics = MetricsFactory.getInstance(metricsElement);
}
}
示例6: Event
import org.ofbiz.base.metrics.MetricsFactory; //导入依赖的package包/类
public Event(Element eventElement) {
this.type = eventElement.getAttribute("type");
this.path = eventElement.getAttribute("path");
this.invoke = eventElement.getAttribute("invoke");
this.globalTransaction = !"false".equals(eventElement.getAttribute("global-transaction"));
// Get metrics.
Element metricsElement = UtilXml.firstChildElement(eventElement, "metric");
if (metricsElement != null) {
this.metrics = MetricsFactory.getInstance(metricsElement);
}
}
示例7: getAllMetrics
import org.ofbiz.base.metrics.MetricsFactory; //导入依赖的package包/类
public static Map<String, Object> getAllMetrics(DispatchContext dctx, Map<String, ?> context) {
List<Map<String, Object>> metricsMapList = FastList.newInstance();
Collection<Metrics> metricsList = MetricsFactory.getMetrics();
for (Metrics metrics : metricsList) {
Map<String, Object> metricsMap = FastMap.newInstance();
metricsMap.put("name", metrics.getName());
metricsMap.put("serviceRate", metrics.getServiceRate());
metricsMap.put("threshold", metrics.getThreshold());
metricsMap.put("totalEvents", metrics.getTotalEvents());
metricsMapList.add(metricsMap);
}
Map<String, Object> result = ServiceUtil.returnSuccess();
result.put("metricsList", metricsMapList);
return result;
}
示例8: resetMetric
import org.ofbiz.base.metrics.MetricsFactory; //导入依赖的package包/类
public static Map<String, Object> resetMetric(DispatchContext dctx, Map<String, ?> context) {
String name = (String) context.get("name");
try {
name = StringUtil.defaultWebEncoder.decodeFromURL(name);
} catch (EncodingException e) {
return ServiceUtil.returnError("Exception thrown while decoding metric name \"" + name + "\"");
}
Metrics metric = MetricsFactory.getMetric(name);
if (metric != null) {
metric.reset();
return ServiceUtil.returnSuccess();
}
return ServiceUtil.returnError("Metric \"" + name + "\" not found.");
}