• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MessagePackFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.msgpack.jackson.dataformat.MessagePackFactory的典型用法代码示例。如果您正苦于以下问题:Java MessagePackFactory类的具体用法?Java MessagePackFactory怎么用?Java MessagePackFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MessagePackFactory类属于org.msgpack.jackson.dataformat包,在下文中一共展示了MessagePackFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: WampClient

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
public WampClient(DataFormat dataFormat) {
	this.isBinary = dataFormat != DataFormat.JSON;
	this.result = new CompletableFutureWebSocketHandler();
	this.headers = new WebSocketHttpHeaders();

	switch (dataFormat) {
	case CBOR:
		this.jsonFactory = new ObjectMapper(new CBORFactory()).getFactory();
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.CBOR_PROTOCOL);
		break;
	case MSGPACK:
		this.jsonFactory = new ObjectMapper(new MessagePackFactory()).getFactory();
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.MSGPACK_PROTOCOL);
		break;
	case JSON:
		this.jsonFactory = new MappingJsonFactory(new ObjectMapper());
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.JSON_PROTOCOL);
		break;
	case SMILE:
		this.jsonFactory = new ObjectMapper(new SmileFactory()).getFactory();
		this.headers.setSecWebSocketProtocol(WampSubProtocolHandler.SMILE_PROTOCOL);
		break;
	default:
		this.jsonFactory = null;
	}

}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:28,代码来源:WampClient.java


示例2: requestBodyConverter

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
@Test
public void requestBodyConverter()
        throws IOException, InterruptedException
{
    ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());

    Pojo requestPojo = new Pojo(42, (float) Math.PI, "Hello");
    Pojo responsePojo = new Pojo(99, 1.23f, "World");
    server.enqueue(new MockResponse().setBody(
            new Buffer().write(objectMapper.writeValueAsBytes(responsePojo))));

    Response<Pojo> response = service.postPojo(requestPojo).execute();
    assertThat(response.body(), is(responsePojo));

    RecordedRequest recordedRequest = server.takeRequest();
    Pojo recordedPojo = objectMapper.readValue(recordedRequest.getBody().readByteArray(), Pojo.class);
    assertThat(recordedPojo, is(requestPojo));
}
 
开发者ID:komamitsu,项目名称:retrofit-converter-msgpack,代码行数:19,代码来源:MessagePackConverterFactoryTest.java


示例3: toJson

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
@Override
public ServiceResponse<String> toJson(byte bytes[]) {

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    try {
        // read message pack
        ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
        JsonNode node = objectMapper.readTree(bytes);

        // write json
        JsonFactory jsonFactory = new JsonFactory();
        JsonGenerator jsonGenerator = jsonFactory.createGenerator(bos);

        objectMapper.writeTree(jsonGenerator, node);
    } catch (IOException | NullPointerException e) {
        LOGGER.error("Exception converting message pack to JSON", e);
        return ServiceResponseBuilder.<String>error().build();
    }

    return ServiceResponseBuilder.<String>ok().withResult(new String(bos.toByteArray())).build();

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:24,代码来源:MessagePackJsonConverter.java


示例4: fromJson

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
@Override
public ServiceResponse<byte[]> fromJson(String json) {

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    try {
        // read json
        ObjectMapper objectMapper = new ObjectMapper(new JsonFactory());
        JsonNode node = objectMapper.readTree(json);

        // write message pack
        MessagePackFactory messagePackFactory = new MessagePackFactory();
        JsonGenerator jsonGenerator = messagePackFactory.createGenerator(bos);

        objectMapper.writeTree(jsonGenerator, node);
    } catch (IOException e) {
        LOGGER.error("Exception converting message pack to JSON", e);
        return ServiceResponseBuilder.<byte[]>error().build();
    }

    return ServiceResponseBuilder.<byte[]>ok().withResult(bos.toByteArray()).build();

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:24,代码来源:MessagePackJsonConverter.java


示例5: Buffer

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
protected Buffer(final Config config)
{
    this.config = config;
    if (config.getFileBackupDir() != null) {
        fileBackup = new FileBackup(new File(config.getFileBackupDir()), this, config.getFileBackupPrefix());
    }
    else {
        fileBackup = null;
    }

    objectMapper = new ObjectMapper(new MessagePackFactory());
    List<Module> jacksonModules = config.getJacksonModules();
    for (Module module : jacksonModules) {
        objectMapper.registerModule(module);
    }
}
 
开发者ID:komamitsu,项目名称:fluency,代码行数:17,代码来源:Buffer.java


示例6: CompletableFutureWebSocketHandler

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
public CompletableFutureWebSocketHandler(int expectedNoOfResults) {
	this.jsonFactory = new MappingJsonFactory(new ObjectMapper());
	this.msgpackFactory = new ObjectMapper(new MessagePackFactory()).getFactory();
	this.cborFactory = new ObjectMapper(new CBORFactory()).getFactory();
	this.smileFactory = new ObjectMapper(new SmileFactory()).getFactory();
	this.timeout = getTimeoutValue();
	this.welcomeMessageFuture = new CompletableFuture<>();
	this.reset(expectedNoOfResults);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:10,代码来源:CompletableFutureWebSocketHandler.java


示例7: MsgPackJackson

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
public MsgPackJackson() {
	super(new ObjectMapper(new MessagePackFactory()));

	// Install MongoDB / BSON serializers
	// (Using JSON serializers)
	tryToAddSerializers("io.datatree.dom.adapters.JsonJacksonBsonSerializers", mapper);
}
 
开发者ID:berkesa,项目名称:datatree-adapters,代码行数:8,代码来源:MsgPackJackson.java


示例8: create

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions") // Guarding public API nullability.
public static MessagePackConverterFactory create(ObjectMapper mapper)
{
    if (mapper == null) {
        throw new IllegalArgumentException("'mapper' is null");
    }

    if (!(mapper.getFactory() instanceof MessagePackFactory)) {
        throw new IllegalArgumentException("'mapper' doesn't have MessagePackFactory");
    }

    return new MessagePackConverterFactory(mapper);
}
 
开发者ID:komamitsu,项目名称:retrofit-converter-msgpack,代码行数:14,代码来源:MessagePackConverterFactory.java


示例9: serialize

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
@Test
public void serialize()
        throws JsonProcessingException
{
    long now = System.currentTimeMillis();
    EventTime eventTime = EventTime.fromEpoch((int) (now / 1000), 999999999);
    ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
    byte[] bytes = objectMapper.writeValueAsBytes(eventTime);
    ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
    assertThat(byteBuffer.get(), is((byte) 0xD7));
    assertThat(byteBuffer.get(), is((byte) 0x00));
    assertThat(byteBuffer.getInt(), is((int) (now / 1000)));
    assertThat(byteBuffer.getInt(), is(999999999));
}
 
开发者ID:komamitsu,项目名称:fluency,代码行数:15,代码来源:EventTimeTest.java


示例10: messagePack

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
@Test
public void messagePack() throws IOException {
    ObjectMapper mapper = new ObjectMapper( new MessagePackFactory() );
    User user = mockUser();
    byte[] bytes = mapper.writeValueAsBytes( user );
    logger.debug( new String( bytes ) );
    mapper.readValue( bytes, User.class );
}
 
开发者ID:turbospaces,项目名称:protoc,代码行数:9,代码来源:JsonSerializationTest.java


示例11: MsgPackJacksonCodec

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
public MsgPackJacksonCodec() {
    super(new ObjectMapper(new MessagePackFactory()));
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:4,代码来源:MsgPackJacksonCodec.java


示例12: updateFromADFile

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
public void updateFromADFile(int attempt) {
    error = false;
    if (attempt > 2) {
        failCheckCount++;
        if (failCheckCount > 5) {

            KRFAM.log(codeName + " > Failed to read A.D > Abort");
            KRFAM.Toast("Failed to access '" + codeName + "' A.D.\nDid you allow KRFAM root access?");
            return;
        }
        KRFAM.delayAction(new Runnable() {
            @Override
            public void run() {
                updateFromADFile();
            }
        }, 200*failCheckCount);
        error = true;
        return;
    }
    if (installed == true) {
        if (adFile.exists()) {
            try {
                boolean flag1 = false;

                InputStream is = new FileInputStream(SaveFile);
                LittleEndianDataInputStream binaryReader = new LittleEndianDataInputStream(is);

                int num1 = binaryReader.readInt();
                int num2 = num1 & 0x7F;
                KRFAM.log("Save data Version: " + ((num1 & 65280) >> 8));
                int b = (binaryReader.readByte() & 0xff);
                int count1 = b - num2;

                byte[] iv = new byte[count1];
                KRFAM.log("IV Length: " + count1);
                binaryReader.read(iv, 0, count1);
                for (int index = 0; index < iv.length; ++index) iv[index] -= (byte) (96 + (int) (byte) index);
                String _iv = new String(iv);
                KRFAM.log("IV: " + _iv);
                int count2 = binaryReader.readInt();
                byte[] numArray = new byte[count2];
                binaryReader.read(numArray, 0, count2);

                if (!flag1)
                {
                    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
                    SecretKeySpec skeySpec = new SecretKeySpec(this.EncryptKey.getBytes(), "AES");
                    cipher.init(Cipher.DECRYPT_MODE, skeySpec, new IvParameterSpec(iv));
                    byte[] decrypted = cipher.doFinal(numArray);


                    ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
                    SaveData value = objectMapper.readValue(decrypted, SaveData.class);
                    accessToken = value.m_AccessToken;
                    uuid = value.m_UUID;
                    myCode = value.m_MyCode;
                    KRFAM.log("at: " + value.m_AccessToken);
                    KRFAM.log("uu: " + value.m_UUID);
                    KRFAM.log("mc: " + value.m_MyCode);
                }
                KRFAM.log(codeName + " > Updated from A.D File");
                failCheckCount = 0;
            } catch (Exception ex) {
                KRFAM.log(ex);
                KRFAM.log(codeName + " > Failed to Read A.D File - Attempting Fix");
                KRFAM.forcePermission(adFile);
                KRFAM.forcePermission(adFile.getParentFile());
                updateFromADFile(attempt + 1);
            }
        } else {
            KRFAM.log(codeName + " > No A.D File exists");
            uuid = "";
            accessToken = "";
            myCode = "";
        }
    } else {
        uuid = "";
        accessToken = "";
    }
}
 
开发者ID:iebb,项目名称:Kasumi,代码行数:81,代码来源:Server.java


示例13: writeToGameEngineActivity

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
public boolean writeToGameEngineActivity(int attempt, String user, String pass, String code) {
    if (attempt > 5) {
        KRFAM.Toast("Failed to write to '" + codeName + "' A.D File.\nHave you allowed KRFAM to have root access?");
        return false;
    }
    if (installed == true) {

        SaveData value = new SaveData();
        value.m_UUID = user;
        value.m_AccessToken = pass;
        value.m_MyCode = code;
        value.m_ConfirmedVer = 0;

        String _iv = createPassword();
        byte[] iv = _iv.getBytes();

        KRFAM.log("iv " + _iv);
        try {


            MessagePack.PackerConfig config = new MessagePack.PackerConfig().withStr8FormatSupport(false);
            ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory(config));
            byte[] bytes = objectMapper.writeValueAsBytes(value);

            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
            SecretKeySpec skeySpec = new SecretKeySpec(this.EncryptKey.getBytes(), "AES");
            cipher.init(Cipher.ENCRYPT_MODE, skeySpec, new IvParameterSpec(iv));
            byte[] encrypted = cipher.doFinal(bytes);

            OutputStream is = new FileOutputStream(SaveFile);
            LittleEndianDataOutputStream binaryWriter = new LittleEndianDataOutputStream(is);

            int num1 = new Random().nextInt();

            byte num2 = (byte) (num1 & 127);
            int num3 = (int) ((long) num1 & 4294902015L) | 65280 & 19 << 8; // 19 denotes 171101
            /* 16 - 20: _170404,  _170713,  _171101,  _latest, */

            binaryWriter.writeInt(num3);

            for (int index = 0; index < iv.length; ++index) iv[index] += (byte) (96 + (int) (byte) index);

            binaryWriter.writeByte((byte) ((int) iv.length + (int) num2));
            binaryWriter.write(iv);

            binaryWriter.writeInt(encrypted.length);
            binaryWriter.write(encrypted);

        }  catch (Exception ex) {
            KRFAM.log(ex);
            KRFAM.log(codeName + " > Failed to Write A.D File");
            KRFAM.forcePermission(adFile);
            KRFAM.forcePermission(adFile.getParentFile());
        }

        KRFAM.log("saved uu " + uuid);
        KRFAM.log("saved at " + accessToken);

        updateFromADFile();
        if (uuid.equals(user) && accessToken.equals(pass)) {
            return true;
        } else {
            KRFAM.forcePermission(adFile);
            KRFAM.forcePermission(adFile.getParentFile());
            return writeToGameEngineActivity(attempt + 1, user, pass, code);
        }
    } else {
        KRFAM.Toast(codeName + " not installed");
        return false;
    }
}
 
开发者ID:iebb,项目名称:Kasumi,代码行数:72,代码来源:Server.java


示例14: msgpackJsonFactory

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
@Bean
public JsonFactory msgpackJsonFactory() {
	return new ObjectMapper(new MessagePackFactory()).getFactory();
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:5,代码来源:WampConfiguration.java


示例15: createMinimalObjectMapper

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
private static ObjectMapper createMinimalObjectMapper() {
  ObjectMapper mapper = new ObjectMapper(new MessagePackFactory());
  mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
  return mapper;
}
 
开发者ID:chonton,项目名称:apm-client,代码行数:6,代码来源:MsgPackProvider.java


示例16: MessagePackSerialization

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
/**
 * Constructor for the {@link MessagePackSerialization} class. Generates {@link ObjectMapper}
 * and sets to include non-null.
 */
public MessagePackSerialization() {
	objectMapper = new ObjectMapper(new MessagePackFactory());
	objectMapper.setSerializationInclusion(Include.NON_NULL);
}
 
开发者ID:rcsb,项目名称:mmtf-java,代码行数:9,代码来源:MessagePackSerialization.java


示例17: get

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
@Override
public ObjectMapper get() {
    ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
    objectMapper.registerSubtypes(Command.class);
    return objectMapper;
}
 
开发者ID:aalmiray,项目名称:javatrove,代码行数:7,代码来源:ObjectMapperProvider.java


示例18: MessagePackParser

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
public MessagePackParser(SecorConfig config) {
    super(config);
    mMessagePackObjectMapper = new ObjectMapper(new MessagePackFactory());
    mTypeReference = new TypeReference<HashMap<String, Object>>(){};
}
 
开发者ID:pinterest,项目名称:secor,代码行数:6,代码来源:MessagePackParser.java


示例19: setUp

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    mConfig = Mockito.mock(SecorConfig.class);
    Mockito.when(mConfig.getMessageTimestampName()).thenReturn("ts");
    Mockito.when(mConfig.getTimeZone()).thenReturn(TimeZone.getTimeZone("UTC"));
    Mockito.when(TimestampedMessageParser.usingDateFormat(mConfig)).thenReturn("yyyy-MM-dd");
    Mockito.when(TimestampedMessageParser.usingHourFormat(mConfig)).thenReturn("HH");
    Mockito.when(TimestampedMessageParser.usingMinuteFormat(mConfig)).thenReturn("mm");
    Mockito.when(TimestampedMessageParser.usingDatePrefix(mConfig)).thenReturn("dt=");
    Mockito.when(TimestampedMessageParser.usingHourPrefix(mConfig)).thenReturn("hr=");
    Mockito.when(TimestampedMessageParser.usingMinutePrefix(mConfig)).thenReturn("min=");

    mMessagePackParser = new MessagePackParser(mConfig);
    mObjectMapper = new ObjectMapper(new MessagePackFactory());

    timestamp = System.currentTimeMillis();

    HashMap<String, Object> mapWithSecondTimestamp = new HashMap<String, Object>();
    mapWithSecondTimestamp.put("ts", 1405970352);
    mMessageWithSecondsTimestamp = new Message("test", 0, 0, null,
            mObjectMapper.writeValueAsBytes(mapWithSecondTimestamp), timestamp);

    HashMap<String, Object> mapWithMillisTimestamp = new HashMap<String, Object>();
    mapWithMillisTimestamp.put("ts", 1405970352123l);
    mapWithMillisTimestamp.put("isActive", true);
    mapWithMillisTimestamp.put("email", "[email protected]");
    mapWithMillisTimestamp.put("age", 27);
    mMessageWithMillisTimestamp = new Message("test", 0, 0, null,
            mObjectMapper.writeValueAsBytes(mapWithMillisTimestamp), timestamp);


    HashMap<String, Object> mapWithMillisFloatTimestamp = new HashMap<String, Object>();
    mapWithMillisFloatTimestamp.put("ts", 1405970352123.0);
    mapWithMillisFloatTimestamp.put("isActive", false);
    mapWithMillisFloatTimestamp.put("email", "[email protected]");
    mapWithMillisFloatTimestamp.put("age", 35);
    mMessageWithMillisFloatTimestamp = new Message("test", 0, 0, null,
            mObjectMapper.writeValueAsBytes(mapWithMillisFloatTimestamp), timestamp);

    HashMap<String, Object> mapWithMillisStringTimestamp = new HashMap<String, Object>();
    mapWithMillisStringTimestamp.put("ts", "1405970352123");
    mapWithMillisStringTimestamp.put("isActive", null);
    mapWithMillisStringTimestamp.put("email", "[email protected]");
    mapWithMillisStringTimestamp.put("age", 67);
    mMessageWithMillisStringTimestamp = new Message("test", 0, 0, null,
            mObjectMapper.writeValueAsBytes(mapWithMillisStringTimestamp), timestamp);
}
 
开发者ID:pinterest,项目名称:secor,代码行数:48,代码来源:MessagePackParserTest.java


示例20: msgPack

import org.msgpack.jackson.dataformat.MessagePackFactory; //导入依赖的package包/类
private static void msgPack(Object src) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
    objectMapper.writeValue(out, src);

    byte[] bytes = out.toByteArray();

    System.out.println("MsgPack : " + src.toString() + " : " + bytes.length);
}
 
开发者ID:jjenkov,项目名称:iap-tools-java-benchmarks,代码行数:11,代码来源:Main.java



注:本文中的org.msgpack.jackson.dataformat.MessagePackFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SSLSessionBindingListener类代码示例发布时间:2022-05-21
下一篇:
Java TObjectDoubleIterator类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap