当前位置: 首页>>代码示例>>Java>>正文


Java SerializationUtils.deserialize方法代码示例

本文整理汇总了Java中org.apache.commons.lang.SerializationUtils.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Java SerializationUtils.deserialize方法的具体用法?Java SerializationUtils.deserialize怎么用?Java SerializationUtils.deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang.SerializationUtils的用法示例。


在下文中一共展示了SerializationUtils.deserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveEvent

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
/**
 * method to save a suggestion in the DB
 * @param data
 * @return
 * @throws JsonProcessingException
 */
@RabbitListener(queues = "#{saveSuggestionQueue.name}")
public String saveEvent(byte[] data){
	String res = "";
	Suggestion s = (Suggestion)SerializationUtils.deserialize(data);

	s = repository.save(s);
	ObjectMapper mapper = new ObjectMapper();
	Log
	.forContext("MemberName", "saveSuggestion")
	.forContext("Service", appName)
	.information("RabbitMQ : saveSuggestion");
	try {
		res =  mapper.writeValueAsString(s);
	} catch (JsonProcessingException e1) {
		Log
		.forContext("MemberName", "saveSuggestion")
		.forContext("Service", appName)
		.error(e1,"JsonProcessingException");
	}
	return res;
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:28,代码来源:SuggestionController.java

示例2: init

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
public void init(int mode, byte[] key, byte[] iv, AlgorithmParameterSpec params) {
  Preconditions.checkNotNull(key);

  this.mode = mode;
  try {
    if (mode == TRANSFORM_MODE)
    {
      reKey = new BBS98ReEncryptionKeySpec(key);
      this.params = params;
    } else {
      Preconditions.checkNotNull(iv);
      BBS98KeySpec keySpec = new BBS98KeySpec(key, "BBS98");
      this.blockSize = 30;
      this.key = (ECKey) SerializationUtils.deserialize(keySpec.getKeyMaterial());
      this.params = this.key.getParameters();
    }
    engine = new WrapperBBS98(this.params, random);
  } catch (InvalidAlgorithmParameterException e) {
    e.printStackTrace();
  }

  this.iv = iv;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:BBS98BCCipher.java

示例3: saveEvent

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
/**
 * method to save an event in the DB
 * @param data
 * @return
 * @throws JsonProcessingException
 */
@RabbitListener(queues = "#{saveEventQueue.name}")
public String saveEvent(byte[] data){
	String res = null;
	Event e = (Event)SerializationUtils.deserialize(data);
	Event event = null;
	if (e.checkEvent()){
		 event = repository.save(e);
	}
	else{
		Log
		.forContext("MemberName", "saveEvent")
		.forContext("Service", appName)
		.error(new IllegalArgumentException(),"IllegalArgumentException");
	}
	ObjectMapper mapper = new ObjectMapper();
	Log
	.forContext("MemberName", "saveEvent")
	.forContext("Service", appName)
	.information("RabbitMQ : saveEvent");
	try {
		res =  mapper.writeValueAsString(event);
	} catch (JsonProcessingException e1) {
		Log
		.forContext("MemberName", "saveEvent")
		.forContext("Service", appName)
		.error(e1,"JsonProcessingException");
	}
	return res;
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:36,代码来源:EventController.java

示例4: addPerson

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
/**
 * Method to add a Person in DataBase, works with RabbitMq
 * @param data
 * @return
 * @throws JsonProcessingException 
 */
@RabbitListener(queues = "#{addPersonQueue.name}")
public String addPerson(byte[] data) throws JsonProcessingException{
	Person p =  (Person) SerializationUtils.deserialize(data);
	if (p.checkPerson()){
		p = repository.save(p);
	}
	else{
		Log
		.forContext("MemberName", "addPerson")
		.forContext("Service", appName)
		.error(new IllegalArgumentException(),"IllegalArgumentException");
	}
	String res = "";
	ObjectMapper mapper = new ObjectMapper();
	Log
	.forContext("MemberName", "addPerson")
	.forContext("Service", appName)
	.information("Request : addPerson");
	try {
		res = mapper.writeValueAsString(p);
	} catch (JsonProcessingException e) {
		Log
		.forContext("MemberName", "addPerson")
		.forContext("Service", appName)
		.error(e,"JsonProcessingException");
	}
	return res;
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:35,代码来源:PersonController.java

示例5: nextRow

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
@Override
public RowDataPacket nextRow() {
    RowDataPacket rp = super.nextRow();
    if (rp == null)
        return null;
    else {
        DGRowPacket newRow = new DGRowPacket(orgFieldCount, sumSize);
        for (int index = 0; index < sumSize; index++) {
            byte[] b = rp.getValue(index);
            if (b != null) {
                Object obj = SerializationUtils.deserialize(b);
                newRow.setSumTran(index, obj, b.length);
            }
        }
        for (int index = sumSize; index < this.fieldCount; index++) {
            newRow.add(rp.getValue(index));
        }
        return newRow;
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:21,代码来源:GroupResultDiskBuffer.java

示例6: getDesiredContainerList

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
private Set<Integer> getDesiredContainerList() {
    log.debug("Fetching the latest container assignment from ZooKeeper.");
    if (hostContainerMapNode.getCurrentData() != null) { //Check if path exists.
        //read data from zk.
        byte[] containerToHostMapSer = hostContainerMapNode.getCurrentData().getData();
        if (containerToHostMapSer != null) {
            @SuppressWarnings("unchecked")
            val controlMapping = (Map<Host, Set<Integer>>) SerializationUtils.deserialize(containerToHostMapSer);
            return controlMapping.entrySet().stream()
                                 .filter(ep -> ep.getKey().equals(this.host))
                                 .map(Map.Entry::getValue)
                                 .findFirst().orElse(Collections.emptySet());
        }
    }

    return null;
}
 
开发者ID:pravega,项目名称:pravega,代码行数:18,代码来源:ZKSegmentContainerMonitor.java

示例7: testSerializeAndDeserialize

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
public void testSerializeAndDeserialize() throws Exception {
    final RowAnnotationFactory annotationFactory = RowAnnotations.getDefaultFactory();
    final RowAnnotation annotation = annotationFactory.createAnnotation();
    final InputColumn<String> col1 = new MockInputColumn<>("foo", String.class);
    final InputColumn<String> col2 = new MockInputColumn<>("bar", String.class);

    annotationFactory.annotate(new MockInputRow().put(col1, "1").put(col2, "2"), 1, annotation);
    annotationFactory.annotate(new MockInputRow().put(col1, "3").put(col2, "4"), 1, annotation);

    final AnnotatedRowsResult result1 = new AnnotatedRowsResult(annotation, annotationFactory, col1);
    performAssertions(result1);

    final AnnotatedRowsResult result2 =
            (AnnotatedRowsResult) SerializationUtils.deserialize(SerializationUtils.serialize(result1));
    performAssertions(result2);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:17,代码来源:AnnotatedRowResultTest.java

示例8: getObject

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
public static Object getObject(String key) {
    Jedis jedis = null;
    byte[] bytes = null;
    try {
        jedis = getJedis();
        bytes = jedis.get((prefix + key).getBytes());
    } catch(Exception e) {
        e.printStackTrace();
    } finally {
        if(jedis != null) {
            jedis.close();
        }
    }

    return bytes != null ? SerializationUtils.deserialize(bytes) : null;
}
 
开发者ID:dipoo,项目名称:arong,代码行数:17,代码来源:RedisUtil.java

示例9: testSerializeAndDeserialize

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
public void testSerializeAndDeserialize() throws Exception {
	RowAnnotationFactory annotationFactory = new InMemoryRowAnnotationFactory();
	RowAnnotation annotation = annotationFactory.createAnnotation();
	InputColumn<String> col1 = new MockInputColumn<String>("foo", String.class);
	InputColumn<String> col2 = new MockInputColumn<String>("bar", String.class);

	annotationFactory.annotate(new MockInputRow().put(col1, "1").put(col2, "2"), 1, annotation);
	annotationFactory.annotate(new MockInputRow().put(col1, "3").put(col2, "4"), 1, annotation);

	AnnotatedRowsResult result1 = new AnnotatedRowsResult(annotation, annotationFactory, col1);
	performAssertions(result1);

	AnnotatedRowsResult result2 = (AnnotatedRowsResult) SerializationUtils.deserialize(SerializationUtils
			.serialize(result1));
	performAssertions(result2);
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:17,代码来源:AnnotatedRowResultTest.java

示例10: testSerializationAndDeserialization

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
public void testSerializationAndDeserialization() throws Exception {
    final NumberResult result1 = new NumberResult(42);

    final AnalyzerResultFuture<NumberResult> future = new AnalyzerResultFuture<>("foo",
            new ImmutableRef<NumberResult>(result1));
    
    future.addListener(new Listener<NumberResult>() {
        @Override
        public void onSuccess(NumberResult result) {
            // do nothing - this is just a non-serializable listener
        }

        @Override
        public void onError(RuntimeException error) {
            // do nothing - this is just a non-serializable listener
        }
    });
    
    final byte[] bytes = SerializationUtils.serialize(future);
    
    final AnalyzerResultFuture<?> copy = (AnalyzerResultFuture<?>) SerializationUtils.deserialize(bytes);
    
    assertEquals("foo", copy.getName());
    assertEquals("42", copy.get().toString());
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:26,代码来源:AnalyzerResultFutureTest.java

示例11: hget

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
@Override
public Object hget(String key, String field) {
    byte[] bytes = jedis.hget(key.getBytes(), field.getBytes());
    if (bytes == null){
        return null;
    } else {
        return SerializationUtils.deserialize(bytes);
    }
}
 
开发者ID:x-hansong,项目名称:RedisHttpSession,代码行数:10,代码来源:SingleRedisConnection.java

示例12: executeCommand

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
@Override
public Command executeCommand(Command command){
	try {
		return (Command)SerializationUtils.deserialize(server.receiveCommand(SerializationUtils.serialize(command)));
	} catch (Exception e){
		return null;
	}
}
 
开发者ID:unsftn,项目名称:bisis-v4,代码行数:9,代码来源:ServiceBroker.java

示例13: lookupByName

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
@Override
public Object lookupByName(String key) {
    // Substitute $ character in key
    key = key.replaceAll("\\$", "/");
    kvClient = consul.keyValueClient();
    Optional<String> result = kvClient.getValueAsString(key);
    if (result.isPresent()) {
        byte[] postDecodedValue = Base64.decodeBase64(result.get());
        return SerializationUtils.deserialize(postDecodedValue);
    }
    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:ConsulRegistry.java

示例14: isWorkflowContentEqual

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
/**
 * API to match the work flow content for equality with same module(s) and their sequence and also same plugin(s) and sequence.
 * 
 * @param userOptions ImportBatchClassUserOptionDTO
 * @param userInputWorkflowName String
 * @return Map<String, Boolean>
 */
@Override
public Map<String, Boolean> isWorkflowContentEqual(ImportBatchClassUserOptionDTO userOptions, String userInputWorkflowName) {
	ImportBatchService imService = this.getSingleBeanOfType(ImportBatchService.class);
	DeploymentService deployService = this.getSingleBeanOfType(DeploymentService.class);
	Map<String, Boolean> results = new HashMap<String, Boolean>();
	boolean isEqual = false;
	boolean isDeployed = deployService.isDeployed(userInputWorkflowName);
	InputStream serializableFileStream = null;
	String serializableFilePath = FileUtils.getFileNameOfTypeFromFolder(userOptions.getZipFileName(), SERIALIZATION_EXT);
	BatchClass importBatchClass = null;
	try {
		serializableFileStream = new FileInputStream(serializableFilePath);
		try {
			// Import Into Database from the serialized file
			importBatchClass = (BatchClass) SerializationUtils.deserialize(serializableFileStream);
		} finally {
			try {
				if (serializableFileStream != null) {
					serializableFileStream.close();
				}
			} catch (IOException ioe) {
				LOGGER.info("Error while closing file input stream.File name:" + serializableFilePath, ioe);
			}
		}
	} catch (Exception e) {
		LOGGER.error("Error while importing" + e, e);
	}
	if (importBatchClass != null) {
		isEqual = imService.isImportWorkflowEqualDeployedWorkflow(importBatchClass, userInputWorkflowName);
	}
	results.put("isEqual", isEqual);
	results.put("isDepoyed", isDeployed);
	return results;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:42,代码来源:BatchClassManagementServiceImpl.java

示例15: testReadObject

import org.apache.commons.lang.SerializationUtils; //导入方法依赖的package包/类
@Test
public void testReadObject() throws NoSuchFieldException, IllegalAccessException {
    AbstractStAXProcessor<?> abstractStAXProcessor = spy(AbstractStAXProcessor.class);

    final Field field = ReflectionTestUtils.getAccessibleField(AbstractStAXProcessor.class, "xmlInputFactory");
    assertThat(field.get(abstractStAXProcessor), is(notNullValue()));

    // Serialise then deserialise the spy and check the XMLInputFactory has been recreated...
    final byte[] serialisedSpy = SerializationUtils.serialize(abstractStAXProcessor);
    abstractStAXProcessor = (AbstractStAXProcessor<?>) SerializationUtils.deserialize(serialisedSpy);
    assertThat(field.get(abstractStAXProcessor), is(notNullValue()));
}
 
开发者ID:hpe-idol,项目名称:java-aci-api-ng,代码行数:13,代码来源:AbstractStAXProcessorTest.java


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