コード例 #1
0
 @Override
 public Object fetch(Namespace namespace, String key) {
   try {
     Object obj =
         jdbcTemplate.queryForObject(
             "select value from " + TABLE_NAME + " where name=? and key=?",
             new Object[] {namespace.toString(), key},
             Object.class);
     return SerializationUtils.deserialize((byte[]) obj);
   } catch (IncorrectResultSizeDataAccessException e) {
     return null;
   }
 }
コード例 #2
0
 @Override
 public Collection<Object> fetchAll(Namespace namespace, String key) {
   List<Map<String, Object>> fetch;
   try {
     fetch =
         jdbcTemplate.queryForList(
             "select value as value from " + TABLE_NAME + " where name=? and key=? ",
             new Object[] {namespace.toString(), key});
   } catch (EmptyResultDataAccessException e) {
     return ImmutableList.of();
   }
   List<Object> result = Lists.newLinkedList();
   for (Map<String, Object> map : fetch) {
     byte[] data = (byte[]) map.get("value");
     Object value = SerializationUtils.deserialize(data);
     result.add(value);
   }
   return result;
 }
コード例 #3
0
 @Override
 public Multimap<String, Object> fetchAll(Namespace namespace) {
   List<Map<String, Object>> fetch;
   try {
     fetch =
         jdbcTemplate.queryForList(
             "select key as key, value as value from " + TABLE_NAME + " where name=? ",
             new Object[] {namespace.toString()});
   } catch (EmptyResultDataAccessException e) {
     return ImmutableMultimap.of();
   }
   Multimap<String, Object> result = ArrayListMultimap.create();
   for (Map<String, Object> map : fetch) {
     String key = (String) map.get("key");
     byte[] data = (byte[]) map.get("value");
     Object value = SerializationUtils.deserialize(data);
     result.put(key, value);
   }
   return result;
 }
コード例 #4
0
 @Override
 public void put(Namespace namespace, String key, Object value) {
   jdbcTemplate.update(
       "insert into " + TABLE_NAME + " (name, key, value) values (?, ?, ?)",
       new Object[] {namespace.toString(), key, SerializationUtils.serialize(value)});
 }
コード例 #5
0
 private Namespace namespace() {
   return Namespace.of(sessionId, taskId, "ValidationCollector", kernelContext.getId().toString());
 }