當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。