List of usage examples for org.apache.commons.lang SerializationUtils serialize
public static byte[] serialize(Serializable obj)
Serializes an Object
to a byte array for storage/serialization.
From source file:com.sylvanaar.idea.Lua.lang.psi.stubs.elements.LuaStubCompoundIdentifierType.java
@Override public LuaCompoundIdentifierStub createStub(@NotNull LuaCompoundIdentifier psi, StubElement parentStub) { final LuaType luaType = psi.getLuaType(); final byte[] bytes = luaType instanceof LuaPrimitiveType ? null : SerializationUtils.serialize(luaType); final boolean declaration = psi.isCompoundDeclaration() && psi.getScopeIdentifier() instanceof LuaGlobal; return new LuaCompoundIdentifierStubImpl(parentStub, StringRef.fromNullableString(psi.getName()), declaration, bytes, luaType); }
From source file:at.gv.egovernment.moa.id.storage.DBExceptionStoreImpl.java
public String storeException(Throwable e) { String id = Random.nextRandom(); Logger.debug("Store Exception with ID " + id); ExceptionStore dbexception = new ExceptionStore(); dbexception.setExid(id);// www . j ava 2s .c o m byte[] data = SerializationUtils.serialize(e); dbexception.setException(data); dbexception.setTimestamp(new Date()); try { MOASessionDBUtils.saveOrUpdate(dbexception); } catch (MOADatabaseException e1) { Logger.warn("Exception can not be stored in Database.", e); return null; } return id; }
From source file:com.janrain.backplane.server.dao.redis.RedisBackplaneMessageDAO.java
/** * Add message to work queue - any node may add since it is an atomic operation * However, the message ID will be determined later by the message processor * @param message/* w w w .ja v a 2s. co m*/ */ @Override public void persist(BackplaneMessage message) throws BackplaneServerException { Redis.getInstance().rpush(V1_MESSAGE_QUEUE.getBytes(), SerializationUtils.serialize(message)); }
From source file:com.sylvanaar.idea.Lua.lang.psi.stubs.elements.LuaStubModuleDeclarationType.java
@Override public LuaModuleDeclarationStub createStub(@NotNull LuaModuleExpression psi, StubElement parentStub) { log.debug(psi.getText());//from w ww .j a v a2s .c o m final String moduleName = psi.getModuleName(); return new LuaModuleDeclarationStubImpl(parentStub, StringRef.fromNullableString(psi.getName()), StringRef.fromNullableString(moduleName), SerializationUtils.serialize(psi.getLuaType())); }
From source file:mitm.common.sms.hibernate.SMSGatewayDAO.java
protected SMSGatewayEntity addSMS(SMS sms, Date dateCreated) { byte[] serializedData = sms.getData() != null ? SerializationUtils.serialize(sms.getData()) : null; SMSGatewayEntity entity = new SMSGatewayEntity(sms.getPhoneNumber(), sms.getMessage(), serializedData, dateCreated);/*from www .java 2s . c om*/ entity = makePersistent(entity); return entity; }
From source file:edu.duke.cabig.c3pr.domain.scheduler.runtime.job.CCTSNotificationMessageJob.java
public static void main(String[] args) { Vector v = new Vector(); v.add(new CCTSNotification()); System.out.println(v);//from w ww .ja v a2 s. co m byte[] b = SerializationUtils.serialize(v); Vector v2 = (Vector) SerializationUtils.deserialize(b); System.out.println(v2); }
From source file:mitm.application.djigzo.james.EncryptedContainerTest.java
@SuppressWarnings("unchecked") @Test/*from w ww. j av a 2 s . co m*/ public void testNull() throws Exception { EncryptedContainer<String> container = new EncryptedContainer<String>(); container.set(null); byte[] serialized = SerializationUtils.serialize(container); container = (EncryptedContainer<String>) SerializationUtils.deserialize(serialized); assertNull(container.get()); }
From source file:com.zxy.commons.mq.producer.ObjectProducer.java
/** * Producer message/* w w w .j av a 2 s . c o m*/ * * <p> * kafka_producer.propertiesproducer.type? * * @param <T> value class * @param topic topic * @param routerKey key? * @param value value */ public static <T> void producer4Jdk(String topic, String routerKey, Serializable value) { byte[] bytes = SerializationUtils.serialize(value); ObjectProducerBuilder.BUILDER.sendMessage(topic, routerKey, bytes); }
From source file:dfki.sb.rabbitmqjava.RabbitMQObjectStreamClient.java
private MarketData sendMarketData(MarketData marketObject) throws IOException, InterruptedException { MarketData response = null;/*from w ww . ja v a 2s. c o m*/ String corrId = UUID.randomUUID().toString(); BasicProperties props = new BasicProperties.Builder().correlationId(corrId).replyTo(replyQueueName).build(); channel.basicPublish("", requestQueueName, props, SerializationUtils.serialize(marketObject)); while (true) { QueueingConsumer.Delivery delivery = consumer.nextDelivery(); if (delivery.getProperties().getCorrelationId().equals(corrId)) { response = (MarketData) SerializationUtils.deserialize(delivery.getBody()); break; } } return response; }
From source file:br.com.ufjf.labredes.rest.EleitorResource.java
@POST @Path("/votar/{voto}") public String votar(@PathParam("voto") String vote) { byte[] voto_decoded = Base64.getDecoder().decode(vote); SealedObject aux = (SealedObject) SerializationUtils.deserialize(voto_decoded); Voto voto = null;/* ww w .j av a 2 s . c om*/ voto = (Voto) rsa.decrypt(aux, client_aes); Response ans = new Response(); if (voto != null) { eleitorService.votar(voto.getCpf(), voto.getNumero()); ans.Ok("Voto computado"); //3.1 Responde byte[] data = SerializationUtils.serialize(rsa.encrypt(ans, client_aes)); String retorno = Base64.getEncoder().encodeToString(data); return retorno; } else { ans.Error("Erro ao decriptar chave"); //3.1 Responde byte[] data = SerializationUtils.serialize(rsa.encrypt(ans, client_aes)); String retorno = Base64.getEncoder().encodeToString(data); return retorno; } }