public void onKeyValueStoreData( KeyValueStoreData event, IOSubchannel channel) throws JsonDecodeException { if (!event.event().query().equals(storagePath)) { return; } String data = event.data().get(storagePath); if (data != null) { JsonBeanDecoder decoder = JsonBeanDecoder.create(data); @SuppressWarnings({ "unchecked", "PMD.LooseCoupling" }) Class<Map<String, Object>> cls = (Class<Map<String, Object>>) (Class<?>) HashMap.class; persisted = decoder.readObject(cls); } }
public void onKeyValueStoreData( KeyValueStoreData event, IOSubchannel channel) throws JsonDecodeException { if (!event.event().query().equals(storagePath)) { return; } String data = event.data().get(storagePath); if (data != null) { JsonBeanDecoder decoder = JsonBeanDecoder.create(data); @SuppressWarnings({ "unchecked", "PMD.LooseCoupling" }) Class<Map<String, Object>> cls = (Class<Map<String, Object>>) (Class<?>) HashMap.class; persisted = decoder.readObject(cls); } }
/** * Creates a new component with its channel set to the given * channel and the given file. * * @param componentChannel the channel * @param file the file used to store the JSON * @throws JsonDecodeException */ @SuppressWarnings("PMD.ShortVariable") public JsonConfigurationStore(Channel componentChannel, File file, boolean update) throws IOException { super(componentChannel); if (update) { Handler.Evaluator.add(this, "onConfigurationUpdate", channel().defaultCriterion()); } this.file = file; if (!file.exists()) { cache = new HashMap<>(); } try (Reader in = new InputStreamReader( Files.newInputStream(file.toPath()), "utf-8")) { @SuppressWarnings("unchecked") Map<String, Object> confCache = (Map<String, Object>) JsonBeanDecoder.create(in).readObject(); cache = confCache; } catch (JsonDecodeException e) { throw new IOException(e); } }
public void run() { while (true) { JsonBeanDecoder jsonDecoder = JsonBeanDecoder.create(jsonSource); JsonRpc rpc = null; try { rpc = jsonDecoder.readObject(DefaultJsonRpc.class); } catch (JsonDecodeException e) { break;
public void run() { while (true) { JsonBeanDecoder jsonDecoder = JsonBeanDecoder.create(jsonSource); JsonRpc rpc = null; try { rpc = jsonDecoder.readObject(DefaultJsonRpc.class); } catch (JsonDecodeException e) { break;