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


Java SerializationUtils类代码示例

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


SerializationUtils类属于org.apache.commons.lang包,在下文中一共展示了SerializationUtils类的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: saveSuggestion

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
/**
 * Method to save an event with RabbitMq
 * @param id
 * @return
 * @throws ParseException 
 */
@RequestMapping(value = "/saveSuggestion", method = RequestMethod.POST)
public String saveSuggestion(@RequestParam Map<String, String> body){
	ObjectMapper mapper = new ObjectMapper();
	Suggestion suggestion = null;
	try {
		suggestion = mapper.readValue((String) body.get("suggestion"),Suggestion.class);
	} catch (IOException e1) {
		Log
		.forContext("MemberName", "saveSuggestion")
		.forContext("Service", appName)
		.error(e1," IOException");
	}
	Log
	.forContext("MemberName", "saveSuggestion")
	.forContext("Service", appName)
	.forContext("suggestion", body.get("suggestion"))
	.information("Request : saveSuggestion");
	
	return new RabbitClient(EXCHANGE).rabbitRPCRoutingKeyExchange(SerializationUtils.serialize(suggestion),"saveSuggestion");
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:27,代码来源:WebSuggestionController.java

示例4: updateEvent

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
/**
 * Method to save an event with RabbitMq
 * @return
 */
@RequestMapping(value = "/saveEvent", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public String updateEvent(@RequestParam Map<String, String> body) {
	ObjectMapper mapper = new ObjectMapper();
	Event event = null;
	try {
		event = mapper.readValue(body.get("event"),Event.class);
	} catch (IOException e1) {
		Log
		.forContext("MemberName", "saveEvent")
		.forContext("Service", appName)
		.error(e1," IOException");
	}
	Log
	.forContext("MemberName", "saveEvent")
	.forContext("Service", appName)
	.forContext("event", body.get("event"))
	.information("Request : saveEvent");
	
	new RabbitClient(EXCHANGE).rabbitRPCRoutingKeyExchange(SerializationUtils.serialize(event),"saveEvent");
	return "{\"response\":\"success\"}";

}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:27,代码来源:WebEventController.java

示例5: 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

示例6: findByOwner

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
/**
 * method to find all events by  owner
 * @param owner
 * @return
 * @throws UnsupportedEncodingException
 */
@RabbitListener(queues = "#{findByOwnerQueue.name}")
public String findByOwner(byte[] owner){
	
	Log
	.forContext("MemberName", "findByOwner")
	.forContext("Service", appName)
	.information("RabbitMQ : findByOwner");
	return repository.findByOwner((Person)SerializationUtils.deserialize(owner)).toString();
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:16,代码来源:EventController.java

示例7: getEventsByPerson

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
/**
 * method to find all event of a person
 * @param owner
 * @return
 * @throws JsonProcessingException 
 * @throws UnsupportedEncodingException
 */
@RabbitListener(queues = "#{getEventsByPersonQueue.name}")
public String getEventsByPerson(byte[] person) throws JsonProcessingException{
	List<Event> res;
	Log
	.forContext("MemberName", "getEventsByPerson")
	.forContext("Service", appName)
	.information("RabbitMQ : getEventsByPerson");
	res = repository.getEventsByPerson((Person)SerializationUtils.deserialize(person));
	ObjectMapper mapper = new ObjectMapper();
	return mapper.writeValueAsString(res);
}
 
开发者ID:TraineeSIIp,项目名称:PepSIIrup-2017,代码行数:19,代码来源:EventController.java

示例8: 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

示例9: getVerifications

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
@Override
public Map<String, Verification> getVerifications(Project project, String commit) {
	Environment env = getEnv(project.getId().toString());
	Store store = getStore(env, VERIFICATIONS_STORE);
	return env.computeInTransaction(new TransactionalComputable<Map<String, Verification>>() {
		
		@SuppressWarnings("unchecked")
		@Override
		public Map<String, Verification> compute(Transaction txn) {
			byte[] bytes = getBytes(store.get(txn, new StringByteIterable(commit)));
			if (bytes != null)
				return (Map<String, Verification>) SerializationUtils.deserialize(bytes);
			else
				return new HashMap<>();
		}
		
	});
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:19,代码来源:DefaultVerificationManager.java

示例10: getVerificationNames

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
@Override
public Collection<String> getVerificationNames(Project project) {
	Environment env = getEnv(project.getId().toString());
	Store store = getStore(env, DEFAULT_STORE);
	return env.computeInTransaction(new TransactionalComputable<Collection<String>>() {
		
		@SuppressWarnings("unchecked")
		@Override
		public Collection<String> compute(Transaction txn) {
			byte[] bytes = getBytes(store.get(txn, new StringByteIterable(VERIFICATION_NAMES_KEY)));
			if (bytes != null)
				return ((Map<String, Date>) SerializationUtils.deserialize(bytes)).keySet();
			else
				return null;
		}
		
	});
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:19,代码来源:DefaultVerificationManager.java

示例11: canBeSerialized

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
@Test
public void canBeSerialized() throws Exception {
  long timeout = 2;
  TimeUnit timeUnit = TimeUnit.SECONDS;
  boolean lookingForStuckThread = true;

  SerializableTimeout instance = SerializableTimeout.builder().withTimeout(timeout, timeUnit)
      .withLookingForStuckThread(lookingForStuckThread).build();

  assertThat(readField(Timeout.class, instance, FIELD_TIMEOUT)).isEqualTo(timeout);
  assertThat(readField(Timeout.class, instance, FIELD_TIME_UNIT)).isEqualTo(timeUnit);
  assertThat(readField(Timeout.class, instance, FIELD_LOOK_FOR_STUCK_THREAD))
      .isEqualTo(lookingForStuckThread);

  SerializableTimeout cloned = (SerializableTimeout) SerializationUtils.clone(instance);

  assertThat(readField(Timeout.class, cloned, FIELD_TIMEOUT)).isEqualTo(timeout);
  assertThat(readField(Timeout.class, cloned, FIELD_TIME_UNIT)).isEqualTo(timeUnit);
  assertThat(readField(Timeout.class, cloned, FIELD_LOOK_FOR_STUCK_THREAD))
      .isEqualTo(lookingForStuckThread);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:22,代码来源:SerializableTimeoutTest.java

示例12: 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

示例13: testSerialization

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
private static void testSerialization(final byte[] state, final List<ReplicatedLogEntry> unapplied) {
    long lastIndex = 6;
    long lastTerm = 2;
    long lastAppliedIndex = 5;
    long lastAppliedTerm = 1;
    long electionTerm = 3;
    String electionVotedFor = "member-1";
    ServerConfigurationPayload serverConfig = new ServerConfigurationPayload(Arrays.asList(
            new ServerInfo("1", true), new ServerInfo("2", false)));

    Snapshot expected = Snapshot.create(ByteState.of(state), unapplied, lastIndex, lastTerm, lastAppliedIndex,
            lastAppliedTerm, electionTerm, electionVotedFor, serverConfig);
    Snapshot cloned = (Snapshot) SerializationUtils.clone(expected);

    assertEquals("lastIndex", expected.getLastIndex(), cloned.getLastIndex());
    assertEquals("lastTerm", expected.getLastTerm(), cloned.getLastTerm());
    assertEquals("lastAppliedIndex", expected.getLastAppliedIndex(), cloned.getLastAppliedIndex());
    assertEquals("lastAppliedTerm", expected.getLastAppliedTerm(), cloned.getLastAppliedTerm());
    assertEquals("unAppliedEntries", expected.getUnAppliedEntries(), cloned.getUnAppliedEntries());
    assertEquals("electionTerm", expected.getElectionTerm(), cloned.getElectionTerm());
    assertEquals("electionVotedFor", expected.getElectionVotedFor(), cloned.getElectionVotedFor());
    assertEquals("state", expected.getState(), cloned.getState());
    assertEquals("serverConfig", expected.getServerConfiguration().getServerConfig(),
            cloned.getServerConfiguration().getServerConfig());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:26,代码来源:SnapshotTest.java

示例14: testSerialization

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
@Test
public void testSerialization() {
    byte[] data = new byte[1000];
    for (int i = 0, j = 0; i < data.length; i++) {
        data[i] = (byte)j;
        if (++j >= 255) {
            j = 0;
        }
    }

    ServerConfigurationPayload serverConfig = new ServerConfigurationPayload(Arrays.asList(
            new ServerInfo("leader", true), new ServerInfo("follower", false)));
    InstallSnapshot expected = new InstallSnapshot(3L, "leaderId", 11L, 2L, data, 5, 6,
            Optional.<Integer>of(54321), Optional.of(serverConfig));

    Object serialized = expected.toSerializable(RaftVersions.CURRENT_VERSION);
    assertEquals("Serialized type", InstallSnapshot.class, serialized.getClass());

    InstallSnapshot actual = (InstallSnapshot) SerializationUtils.clone((Serializable) serialized);
    verifyInstallSnapshot(expected, actual);

    expected = new InstallSnapshot(3L, "leaderId", 11L, 2L, data, 5, 6);
    actual = (InstallSnapshot) SerializationUtils.clone((Serializable) expected.toSerializable(
            RaftVersions.CURRENT_VERSION));
    verifyInstallSnapshot(expected, actual);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:27,代码来源:InstallSnapshotTest.java

示例15: testSerialization

import org.apache.commons.lang.SerializationUtils; //导入依赖的package包/类
@Test
public void testSerialization() {
    NormalizedNode<?, ?> data = ImmutableContainerNodeBuilder.create()
            .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
            .withChild(ImmutableNodes.leafNode(TestModel.DESC_QNAME, "foo")).build();

    ReadDataReply expected = new ReadDataReply(data, DataStoreVersions.CURRENT_VERSION);

    Object serialized = expected.toSerializable();
    assertEquals("Serialized type", ReadDataReply.class, serialized.getClass());

    ReadDataReply actual = ReadDataReply.fromSerializable(SerializationUtils.clone(
            (Serializable) serialized));
    assertEquals("getVersion", DataStoreVersions.CURRENT_VERSION, actual.getVersion());
    assertEquals("getNormalizedNode", expected.getNormalizedNode(), actual.getNormalizedNode());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:ReadDataReplyTest.java


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