com.jwebmp.plugins.atmosphere.transport.JacksonDecoder Maven / Gradle / Ivy
/*
* Copyright (C) 2017 Marc Magon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.jwebmp.plugins.atmosphere.transport;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jwebmp.core.base.ajax.AjaxResponse;
import com.jwebmp.guicedinjection.GuiceContext;
import com.jwebmp.logger.LogFactory;
import org.atmosphere.config.managed.Decoder;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Decode a String into a {@link AtmosphereWSReceiver}.
*/
public class JacksonDecoder
implements Decoder
{
private static final Logger log = LogFactory.getLog("AtmosphereJacksonDecoder");
@Override
public AjaxResponse decode(String s)
{
try
{
return GuiceContext.inject()
.getInstance(ObjectMapper.class)
.readValue(s, AjaxResponse.class);
}
catch (IOException e)
{
log.log(Level.SEVERE, "Unable to decode message", e);
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy