com.alibaba.dubbo.remoting.Codec Java Examples

The following examples show how to use com.alibaba.dubbo.remoting.Codec. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractEndpoint.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
protected static Codec2 getChannelCodec(URL url) {
//        默认codec是telnet
        String codecName = url.getParameter(Constants.CODEC_KEY, "telnet");
        if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
            return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName);
        } else {
            return new CodecAdapter(ExtensionLoader.getExtensionLoader(Codec.class)
                    .getExtension(codecName));
        }
    }
 
Example #2
Source File: CodecAdapter.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public Object decode(Channel channel, ChannelBuffer buffer) throws IOException {
    byte[] bytes = new byte[buffer.readableBytes()];
    int savedReaderIndex = buffer.readerIndex();
    buffer.readBytes(bytes);
    UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream(bytes);
    Object result = codec.decode(channel, is);
    buffer.readerIndex(savedReaderIndex + is.position());
    return result == Codec.NEED_MORE_INPUT ? DecodeResult.NEED_MORE_INPUT : result;
}
 
Example #3
Source File: AbstractEndpoint.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
protected static Codec2 getChannelCodec(URL url) {
    String codecName = url.getParameter(Constants.CODEC_KEY, "telnet");
    if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
        return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName);
    } else {
        return new CodecAdapter(ExtensionLoader.getExtensionLoader(Codec.class)
                                           .getExtension(codecName));
    }
}
 
Example #4
Source File: CodecAdapter.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Object decode(Channel channel, ChannelBuffer buffer) throws IOException {
    byte[] bytes = new byte[buffer.readableBytes()];
    int savedReaderIndex = buffer.readerIndex();
    buffer.readBytes(bytes);
    UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream(bytes);
    Object result = codec.decode(channel, is);
    buffer.readerIndex(savedReaderIndex + is.position());
    return result == Codec.NEED_MORE_INPUT ? DecodeResult.NEED_MORE_INPUT : result;
}
 
Example #5
Source File: Netty4Channel.java    From dubbo-plus with Apache License 2.0 5 votes vote down vote up
protected Codec2 getChannelCodec(URL url) {
    String codecName = url.getParameter(Constants.CODEC_KEY, "telnet");
    if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
        return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName);
    } else {
        return new CodecAdapter(ExtensionLoader.getExtensionLoader(Codec.class)
                .getExtension(codecName));
    }
}
 
Example #6
Source File: AbstractEndpoint.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected static Codec2 getChannelCodec(URL url) {
    String codecName = url.getParameter(Constants.CODEC_KEY, "telnet");
    if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
        return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName);
    } else {
        return new CodecAdapter(ExtensionLoader.getExtensionLoader(Codec.class)
                                           .getExtension(codecName));
    }
}
 
Example #7
Source File: CodecAdapter.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Object decode(Channel channel, ChannelBuffer buffer) throws IOException {
    byte[] bytes = new byte[buffer.readableBytes()];
    int savedReaderIndex = buffer.readerIndex();
    buffer.readBytes(bytes);
    UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream(bytes);
    Object result = codec.decode(channel, is);
    buffer.readerIndex(savedReaderIndex + is.position());
    return result == Codec.NEED_MORE_INPUT ? DecodeResult.NEED_MORE_INPUT : result;
}
 
Example #8
Source File: AbstractEndpoint.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected static Codec2 getChannelCodec(URL url) {
    String codecName = url.getParameter(Constants.CODEC_KEY, "telnet");
    if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
        return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName);
    } else {
        return new CodecAdapter(ExtensionLoader.getExtensionLoader(Codec.class)
                                           .getExtension(codecName));
    }
}
 
Example #9
Source File: CodecAdapter.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public Object decode(Channel channel, ChannelBuffer buffer) throws IOException {
    byte[] bytes = new byte[buffer.readableBytes()];
    int savedReaderIndex = buffer.readerIndex();
    buffer.readBytes(bytes);
    UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream(bytes);
    Object result = codec.decode(channel, is);
    buffer.readerIndex(savedReaderIndex + is.position());
    return result == Codec.NEED_MORE_INPUT ? DecodeResult.NEED_MORE_INPUT : result;
}
 
Example #10
Source File: AbstractEndpoint.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
protected static Codec2 getChannelCodec(URL url) {
    String codecName = url.getParameter(Constants.CODEC_KEY, "telnet");
    if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
        return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName);
    } else {
        return new CodecAdapter(ExtensionLoader.getExtensionLoader(Codec.class)
                                           .getExtension(codecName));
    }
}
 
Example #11
Source File: AbstractEndpoint.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected static Codec2 getChannelCodec(URL url) {
    String codecName = url.getParameter(Constants.CODEC_KEY, "telnet");
    if (ExtensionLoader.getExtensionLoader(Codec2.class).hasExtension(codecName)) {
        return ExtensionLoader.getExtensionLoader(Codec2.class).getExtension(codecName);
    } else {
        return new CodecAdapter(ExtensionLoader.getExtensionLoader(Codec.class)
                                           .getExtension(codecName));
    }
}
 
Example #12
Source File: CodecAdapter.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
public Object decode(Channel channel, ChannelBuffer buffer) throws IOException {
    byte[] bytes = new byte[buffer.readableBytes()];
    int savedReaderIndex = buffer.readerIndex();
    buffer.readBytes(bytes);
    UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream(bytes);
    Object result = codec.decode(channel, is);
    buffer.readerIndex(savedReaderIndex + is.position());
    return result == Codec.NEED_MORE_INPUT ? DecodeResult.NEED_MORE_INPUT : result;
}
 
Example #13
Source File: CodecAdapter.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public Object decode(Channel channel, ChannelBuffer buffer) throws IOException {
    byte[] bytes = new byte[buffer.readableBytes()];
    int savedReaderIndex = buffer.readerIndex();
    buffer.readBytes(bytes);
    UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream(bytes);
    Object result = codec.decode(channel, is);
    buffer.readerIndex(savedReaderIndex + is.position());
    return result == Codec.NEED_MORE_INPUT ? DecodeResult.NEED_MORE_INPUT : result;
}
 
Example #14
Source File: MockedClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setCodec(Codec codec) {
}
 
Example #15
Source File: CodecAdapter.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public CodecAdapter(Codec codec) {
    Assert.notNull(codec, "codec == null");
    this.codec = codec;
}
 
Example #16
Source File: CodecAdapter.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Codec getCodec() {
    return codec;
}
 
Example #17
Source File: ProtocolConfig.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public void setCodec(String codec) {
    if ("dubbo".equals(name)) {
        checkMultiExtension(Codec.class, "codec", codec);
    }
    this.codec = codec;
}
 
Example #18
Source File: ProtocolConfig.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setCodec(String codec) {
    if ("dubbo".equals(name)) {
        checkMultiExtension(Codec.class, "codec", codec);
    }
    this.codec = codec;
}
 
Example #19
Source File: MockedClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Codec getCodec() {
	return null;
}
 
Example #20
Source File: MockedClient.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public void setCodec(Codec codec) {
}
 
Example #21
Source File: CodecAdapter.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public CodecAdapter(Codec codec) {
    Assert.notNull(codec, "codec == null");
    this.codec = codec;
}
 
Example #22
Source File: CodecAdapter.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Codec getCodec() {
    return codec;
}
 
Example #23
Source File: ProtocolConfig.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setCodec(String codec) {
    if ("dubbo".equals(name)) {
        checkMultiExtension(Codec.class, "codec", codec);
    }
    this.codec = codec;
}
 
Example #24
Source File: MockedClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public Codec getCodec() {
	return null;
}
 
Example #25
Source File: MockedClient.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public void setCodec(Codec codec) {
}
 
Example #26
Source File: CodecAdapter.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public Codec getCodec() {
    return codec;
}
 
Example #27
Source File: CodecAdapter.java    From dubbo3 with Apache License 2.0 4 votes vote down vote up
public CodecAdapter(Codec codec) {
    Assert.notNull(codec, "codec == null");
    this.codec = codec;
}
 
Example #28
Source File: MockedClient.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public Codec getCodec() {
	return null;
}
 
Example #29
Source File: ProtocolConfig.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public void setCodec(String codec) {
    if ("dubbo".equals(name)) {
        checkMultiExtension(Codec.class, "codec", codec);
    }
    this.codec = codec;
}
 
Example #30
Source File: CodecAdapter.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public Codec getCodec() {
    return codec;
}