diff --git a/src/com/wentch/redkale/convert/Factory.java b/src/com/wentch/redkale/convert/Factory.java index 7b1dc19b8..bf480d674 100644 --- a/src/com/wentch/redkale/convert/Factory.java +++ b/src/com/wentch/redkale/convert/Factory.java @@ -80,7 +80,7 @@ public abstract class Factory { this.register(java.util.Date.class, DateSimpledCoder.instance); this.register(BigInteger.class, BigIntegerSimpledCoder.instance); this.register(InetAddress.class, InetAddressSimpledCoder.instance); - this.register(TwoLong.class, TwoLongSimpledCoder.instance); + this.register(DLong.class, DLongSimpledCoder.instance); this.register(Class.class, TypeSimpledCoder.instance); this.register(InetSocketAddress.class, InetSocketAddressSimpledCoder.instance); this.register(InetSocketAddress.class, InetSocketAddressSimpledCoder.instance); diff --git a/src/com/wentch/redkale/convert/ext/TwoLongSimpledCoder.java b/src/com/wentch/redkale/convert/ext/DLongSimpledCoder.java similarity index 60% rename from src/com/wentch/redkale/convert/ext/TwoLongSimpledCoder.java rename to src/com/wentch/redkale/convert/ext/DLongSimpledCoder.java index 50fdfc505..b6fce842a 100644 --- a/src/com/wentch/redkale/convert/ext/TwoLongSimpledCoder.java +++ b/src/com/wentch/redkale/convert/ext/DLongSimpledCoder.java @@ -8,7 +8,7 @@ package com.wentch.redkale.convert.ext; import com.wentch.redkale.convert.Reader; import com.wentch.redkale.convert.Writer; import com.wentch.redkale.convert.SimpledCoder; -import com.wentch.redkale.util.TwoLong; +import com.wentch.redkale.util.DLong; /** * @@ -16,12 +16,12 @@ import com.wentch.redkale.util.TwoLong; * @param * @param */ -public final class TwoLongSimpledCoder extends SimpledCoder { +public final class DLongSimpledCoder extends SimpledCoder { - public static final TwoLongSimpledCoder instance = new TwoLongSimpledCoder(); + public static final DLongSimpledCoder instance = new DLongSimpledCoder(); @Override - public void convertTo(final W out, final TwoLong value) { + public void convertTo(final W out, final DLong value) { if (value == null) { out.writeNull(); } else { @@ -30,11 +30,11 @@ public final class TwoLongSimpledCoder exten } @Override - public TwoLong convertFrom(R in) { + public DLong convertFrom(R in) { String str = in.readString(); if (str == null) return null; int pos = str.indexOf('_'); - return new TwoLong(Long.parseLong(str.substring(0, pos)), Long.parseLong(str.substring(pos + 1))); + return new DLong(Long.parseLong(str.substring(0, pos)), Long.parseLong(str.substring(pos + 1))); } } diff --git a/src/com/wentch/redkale/net/sncp/Sncp.java b/src/com/wentch/redkale/net/sncp/Sncp.java index a9b944767..07cca6c69 100644 --- a/src/com/wentch/redkale/net/sncp/Sncp.java +++ b/src/com/wentch/redkale/net/sncp/Sncp.java @@ -46,8 +46,8 @@ public abstract class Sncp { return (rs < Integer.MAX_VALUE) ? rs | 0xF00000000L : rs; } - public static TwoLong hash(final java.lang.reflect.Method method) { - if (method == null) return new TwoLong(-1L, -1L); + public static DLong hash(final java.lang.reflect.Method method) { + if (method == null) return new DLong(-1L, -1L); long rs1 = hash(method.getName()); if (rs1 < Integer.MAX_VALUE) { rs1 |= (method.getParameterCount() + 0L) << 32; @@ -58,7 +58,7 @@ public abstract class Sncp { rs2 |= (method.getParameterCount() + 0L) << 32; } rs2 = (rs2 < Integer.MAX_VALUE) ? rs2 | 0xF00000000L : rs2; - return new TwoLong(rs1, rs2); + return new DLong(rs1, rs2); } private static String wrapName(final java.lang.reflect.Method method) { diff --git a/src/com/wentch/redkale/net/sncp/SncpClient.java b/src/com/wentch/redkale/net/sncp/SncpClient.java index 7434823a6..5088d5abb 100644 --- a/src/com/wentch/redkale/net/sncp/SncpClient.java +++ b/src/com/wentch/redkale/net/sncp/SncpClient.java @@ -28,7 +28,7 @@ public final class SncpClient { protected static final class SncpAction { - protected final TwoLong actionid; + protected final DLong actionid; protected final Method method; @@ -38,7 +38,7 @@ public final class SncpClient { protected final boolean async; - public SncpAction(Method method, TwoLong actionid) { + public SncpAction(Method method, DLong actionid) { this.actionid = actionid; Type rt = method.getGenericReturnType(); if (rt instanceof TypeVariable) { @@ -69,7 +69,7 @@ public final class SncpClient { this.serviceid = Sncp.hash(serviceClass); final List methodens = new ArrayList<>(); //------------------------------------------------------------------------------ - Set actionids = new HashSet<>(); + Set actionids = new HashSet<>(); for (java.lang.reflect.Method method : serviceClass.getDeclaredMethods()) { if (method.isSynthetic()) continue; final int mod = method.getModifiers(); @@ -116,7 +116,7 @@ public final class SncpClient { return convert.convertFrom(actions[index].resultTypes, send(convert, transport, index, params)); } - private void fillHeader(ByteBuffer buffer, long seqid, TwoLong actionid, int frameCount, int frameIndex, int bodyLength) { + private void fillHeader(ByteBuffer buffer, long seqid, DLong actionid, int frameCount, int frameIndex, int bodyLength) { //---------------------head---------------------------------- buffer.putLong(seqid); //序列号 buffer.putChar((char) HEADER_SIZE); //header长度 @@ -140,7 +140,7 @@ public final class SncpClient { } final SncpAction action = actions[index]; final long seqid = System.nanoTime(); - final TwoLong actionid = action.actionid; + final DLong actionid = action.actionid; final ByteBuffer buffer = transport.pollBuffer(); final AsyncConnection conn = transport.pollConnection(); final int readto = conn.getReadTimeoutSecond(); diff --git a/src/com/wentch/redkale/net/sncp/SncpDynServlet.java b/src/com/wentch/redkale/net/sncp/SncpDynServlet.java index 0c7c0e984..fc5b2dd66 100644 --- a/src/com/wentch/redkale/net/sncp/SncpDynServlet.java +++ b/src/com/wentch/redkale/net/sncp/SncpDynServlet.java @@ -30,14 +30,14 @@ public class SncpDynServlet extends SncpServlet { private final long serviceid; - private final HashMap actions = new HashMap<>(); + private final HashMap actions = new HashMap<>(); public SncpDynServlet(final BsonConvert convert, final String serviceName, final Service service, final AnyValue conf) { this.conf = conf; final Class serviceClass = service.getClass(); this.nameid = Sncp.hash(serviceName); this.serviceid = Sncp.hash(serviceClass); - Set actionids = new HashSet<>(); + Set actionids = new HashSet<>(); for (java.lang.reflect.Method method : serviceClass.getMethods()) { if (method.isSynthetic()) continue; if (Modifier.isStatic(method.getModifiers())) continue; @@ -48,7 +48,7 @@ public class SncpDynServlet extends SncpServlet { if (method.getName().equals("init") || method.getName().equals("destroy")) continue; Method onMethod = getOnMethod(serviceClass, method); if (onMethod != null) method = onMethod; - final TwoLong actionid = Sncp.hash(method); + final DLong actionid = Sncp.hash(method); SncpServletAction action = SncpServletAction.create(service, actionid, method); action.convert = convert; if (actionids.contains(actionid)) { @@ -132,7 +132,7 @@ public class SncpDynServlet extends SncpServlet { * @return */ @SuppressWarnings("unchecked") - public static SncpServletAction create(final Service service, final TwoLong actionid, final Method method) { + public static SncpServletAction create(final Service service, final DLong actionid, final Method method) { final Class serviceClass = service.getClass(); final String supDynName = SncpServletAction.class.getName().replace('.', '/'); final String serviceName = serviceClass.getName().replace('.', '/'); diff --git a/src/com/wentch/redkale/net/sncp/SncpRequest.java b/src/com/wentch/redkale/net/sncp/SncpRequest.java index 2aaacb9d5..00e173284 100644 --- a/src/com/wentch/redkale/net/sncp/SncpRequest.java +++ b/src/com/wentch/redkale/net/sncp/SncpRequest.java @@ -31,7 +31,7 @@ public final class SncpRequest extends Request { private long serviceid; - private TwoLong actionid; + private DLong actionid; private int bodylength; @@ -60,7 +60,7 @@ public final class SncpRequest extends Request { } this.serviceid = buffer.getLong(); this.nameid = buffer.getLong(); - this.actionid = new TwoLong(buffer.getLong(), buffer.getLong()); + this.actionid = new DLong(buffer.getLong(), buffer.getLong()); this.framecount = buffer.get(); this.frameindex = buffer.get(); if (buffer.getInt() != 0) { @@ -158,7 +158,7 @@ public final class SncpRequest extends Request { return nameid; } - public TwoLong getActionid() { + public DLong getActionid() { return actionid; } diff --git a/src/com/wentch/redkale/net/sncp/SncpResponse.java b/src/com/wentch/redkale/net/sncp/SncpResponse.java index 95fee505c..93b4f2a68 100644 --- a/src/com/wentch/redkale/net/sncp/SncpResponse.java +++ b/src/com/wentch/redkale/net/sncp/SncpResponse.java @@ -66,7 +66,7 @@ public final class SncpResponse extends Response { buffer.putChar((char) SncpRequest.HEADER_SIZE); buffer.putLong(request.getServiceid()); buffer.putLong(request.getNameid()); - TwoLong actionid = request.getActionid(); + DLong actionid = request.getActionid(); buffer.putLong(actionid.getFirst()); buffer.putLong(actionid.getSecond()); buffer.put((byte) frameCount); // frame count diff --git a/src/com/wentch/redkale/util/TwoLong.java b/src/com/wentch/redkale/util/DLong.java similarity index 81% rename from src/com/wentch/redkale/util/TwoLong.java rename to src/com/wentch/redkale/util/DLong.java index b989d711b..56ad110b9 100644 --- a/src/com/wentch/redkale/util/TwoLong.java +++ b/src/com/wentch/redkale/util/DLong.java @@ -9,13 +9,13 @@ package com.wentch.redkale.util; * * @author zhangjx */ -public final class TwoLong extends Number implements Comparable { +public final class DLong extends Number implements Comparable { - private long first; + private final long first; - private long second; + private final long second; - public TwoLong(long one, long two) { + public DLong(long one, long two) { this.first = one; this.second = two; } @@ -41,7 +41,7 @@ public final class TwoLong extends Number implements Comparable { public boolean equals(Object obj) { if (obj == null) return false; if (getClass() != obj.getClass()) return false; - final TwoLong other = (TwoLong) obj; + final DLong other = (DLong) obj; return (this.first == other.first && this.second == other.second); } @@ -71,7 +71,7 @@ public final class TwoLong extends Number implements Comparable { } @Override - public int compareTo(TwoLong o) { + public int compareTo(DLong o) { return (int) (first == o.first ? (second - o.second) : (first - o.first)); }