public static Merger getMerger(Class returnType) {
Merger result;
// 数组类型
if (returnType.isArray()) {
Class type = returnType.getComponentType();
// 从缓存中获得 Merger 对象
result = mergerCache.get(type);
if (result == null) {
loadMergers();
result = mergerCache.get(type);
}
// 获取不到,使用 ArrayMerger
if (result == null && !type.isPrimitive()) {
result = ArrayMerger.INSTANCE;
}
// 普通类型
} else {
// 从缓存中获得 Merger 对象
result = mergerCache.get(returnType);
if (result == null) {
loadMergers();
result = mergerCache.get(returnType);
}
}
return result;
}
我们再来看一个类ArrayMerger,这个类是数组结果合并的处理类,实现了merge方法
if (others.length == 0) {
return null;
}
int totalLen = 0;
for (int i = 0; i < others.length; i++) {
Object item = others[i];
if (item != null && item.getClass().isArray()) {
totalLen += Array.getLength(item);
} else {
throw new IllegalArgumentException(
new StringBuilder(32).append(i + 1)
.append("th argument is not an array").toString());
}
}
if (totalLen == 0) {
return null;
}
Class> type = others[0].getClass().getComponentType();
Object result = Array.newInstance(type, totalLen);
int index = 0;
for (Object array : others) {
for (int i = 0; i < Array.getLength(array); i++) {
Array.set(result, index++, Array.get(array, i));
}
}
return (Object[]) result;
再来看一个类MapMerger,这个类是Map结果合并的处理类
if (items.length == 0) {
return null;
}
// 创建结果 Map
Map result = new HashMap();
// 合并多个 Map
for (Map, ?> item : items) {
if (item != null) {
result.putAll(item);
}
}
return result;
系统中统计数据,由于调用统计过程,执行时间超过了weblogic设置的时间,提示如下错误:
统计数据出错!
原因:The transaction is no longer active - status: 'Rolling Back. [Reason=weblogic.transaction.internal
Totally five patchs committed to erlang otp, just small patchs.
IMO, erlang really is a interesting programming language, I really like its concurrency feature.
but the functional programming style
两个步骤:
1.用w命令找到要踢出的用户,比如下面:
[root@localhost ~]# w
18:16:55 up 39 days, 8:27, 3 users, load average: 0.03, 0.03, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
package edu.xidian.graph;
class MyStack {
private final int SIZE = 20;
private int[] st;
private int top;
public MyStack() {
st = new int[SIZE];
top = -1;
}
public void push(i