org.redisson.config.Config.getCodec()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中org.redisson.config.Config.getCodec()方法的一些代码示例,展示了Config.getCodec()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.getCodec()方法的具体详情如下:
包路径:org.redisson.config.Config
类名称:Config
方法名:getCodec

Config.getCodec介绍

暂无

代码示例

代码示例来源:origin: redisson/redisson

@Override
public <T extends Codec, K extends RObject> T getCodec(RObjectField anno, Class<?> cls, Class<K> rObjectClass, String fieldName, Config config) {
  try {
    if (!ClassUtils.getDeclaredField(cls, fieldName).isAnnotationPresent(anno.getClass())) {
      throw new IllegalArgumentException("Annotation RObjectField does not present on field " + fieldName + " of type [" + cls.getCanonicalName() + "]");
    }
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
  if (rObjectClass.isInterface()) {
    throw new IllegalArgumentException("Cannot lookup an interface class of RObject [" + rObjectClass.getCanonicalName() + "]. Concrete class only.");
  }
  
  Class<?> codecClass;
  if (anno.codec() == RObjectField.DEFAULT.class) {
    codecClass = config.getCodec().getClass();
  } else {
    codecClass = anno.codec();
  }
  
  return this.<T>getCodec((Class<T>) codecClass);
}

代码示例来源:origin: redisson/redisson

public RMap<String, Object> getMap(String sessionId) {
  String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":";
  String name = keyPrefix + separator + "redisson:tomcat_session:" + sessionId;
  return redisson.getMap(name, new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
}

代码示例来源:origin: redisson/redisson

@Override
public <T extends Codec, K extends RObject> T getCodec(RObjectField anno, Class<?> cls, Class<K> rObjectClass, String fieldName, Config config) {
  try {
    if (!ClassUtils.getDeclaredField(cls, fieldName).isAnnotationPresent(anno.getClass())) {
      throw new IllegalArgumentException("Annotation RObjectField does not present on field " + fieldName + " of type [" + cls.getCanonicalName() + "]");
    }
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
  if (rObjectClass.isInterface()) {
    throw new IllegalArgumentException("Cannot lookup an interface class of RObject [" + rObjectClass.getCanonicalName() + "]. Concrete class only.");
  }
  
  Class<?> codecClass;
  if (anno.codec() == RObjectField.DEFAULT.class) {
    codecClass = config.getCodec().getClass();
  } else {
    codecClass = anno.codec();
  }
  
  return this.<T>getCodec((Class<T>) codecClass);
}

代码示例来源:origin: redisson/redisson

private void enableRedissonReferenceSupport(Config config) {
  Codec codec = config.getCodec();
  objectBuilder = new RedissonObjectBuilder(config);
  ReferenceCodecProvider codecProvider = objectBuilder.getReferenceCodecProvider();
  codecProvider.registerCodec((Class<Codec>) codec.getClass(), codec);
}

代码示例来源:origin: redisson/redisson

public RMap<String, Object> getMap(String sessionId) {
  String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":";
  String name = keyPrefix + separator + "redisson:tomcat_session:" + sessionId;
  return redisson.getMap(name, new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
}

代码示例来源:origin: redisson/redisson

public RMap<String, Object> getMap(String sessionId) {
  String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":";
  String name = keyPrefix + separator + "redisson:tomcat_session:" + sessionId;
  return redisson.getMap(name, new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
}

代码示例来源:origin: redisson/redisson

private void enableRedissonReferenceSupport(Config config) {
  Codec codec = config.getCodec();
  objectBuilder = new RedissonObjectBuilder(config);
  ReferenceCodecProvider codecProvider = objectBuilder.getReferenceCodecProvider();
  codecProvider.registerCodec((Class<Codec>) codec.getClass(), codec);
}

代码示例来源:origin: redisson/redisson

public RMap<String, Object> getMap(String sessionId) {
  String separator = keyPrefix == null || keyPrefix.isEmpty() ? "" : ":";
  String name = keyPrefix + separator + "redisson:tomcat_session:" + sessionId;
  return redisson.getMap(name, new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
}

代码示例来源:origin: redisson/redisson

@Override
public <T extends Codec> T getCodec(REntity anno, Class<?> cls, Config config) {
  if (!ClassUtils.isAnnotationPresent(cls, anno.annotationType())) {
    throw new IllegalArgumentException("Annotation REntity does not present on type [" + cls.getCanonicalName() + "]");
  }
  
  Class<?> codecClass;
  if (anno.codec() == REntity.DEFAULT.class) {
    codecClass = config.getCodec().getClass();
  } else {
    codecClass = anno.codec();
  }
  return this.getCodec((Class<T>) codecClass);
}

代码示例来源:origin: redisson/redisson

@Override
public <T extends Codec> T getCodec(REntity anno, Class<?> cls, Config config) {
  if (!ClassUtils.isAnnotationPresent(cls, anno.annotationType())) {
    throw new IllegalArgumentException("Annotation REntity does not present on type [" + cls.getCanonicalName() + "]");
  }
  
  Class<?> codecClass;
  if (anno.codec() == REntity.DEFAULT.class) {
    codecClass = config.getCodec().getClass();
  } else {
    codecClass = anno.codec();
  }
  return this.getCodec((Class<T>) codecClass);
}

代码示例来源:origin: redisson/redisson

protected RedissonClient buildClient() throws LifecycleException {
  Config config = null;
  try {
    config = Config.fromJSON(new File(configPath), getClass().getClassLoader());
  } catch (IOException e) {
    // trying next format
    try {
      config = Config.fromYAML(new File(configPath), getClass().getClassLoader());
    } catch (IOException e1) {
      log.error("Can't parse json config " + configPath, e);
      throw new LifecycleException("Can't parse yaml config " + configPath, e1);
    }
  }
  
  try {
    try {
    Config c = new Config(config);
    Codec codec = c.getCodec().getClass().getConstructor(ClassLoader.class)
            .newInstance(Thread.currentThread().getContextClassLoader());
    config.setCodec(codec);
    } catch (Exception e) {
      throw new IllegalStateException("Unable to initialize codec with ClassLoader parameter", e);
    }
    
    return Redisson.create(config);
  } catch (Exception e) {
    throw new LifecycleException(e);
  }
}

代码示例来源:origin: redisson/redisson

public RedissonSession(String keyPrefix, String sessionId) {
  this.delegate = new MapSession(sessionId);
  map = redisson.getMap(keyPrefix + sessionId, new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
  principalName = resolvePrincipal(delegate);
}

代码示例来源:origin: redisson/redisson

public RedissonSession(String keyPrefix, String sessionId) {
  this.delegate = new MapSession(sessionId);
  map = redisson.getMap(keyPrefix + sessionId, new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
  principalName = resolvePrincipal(delegate);
}

代码示例来源:origin: redisson/redisson

public RedissonSession(String keyPrefix) {
  this.delegate = new MapSession();
  map = redisson.getMap(keyPrefix + delegate.getId(), new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
  principalName = resolvePrincipal(delegate);
  Map<String, Object> newMap = new HashMap<String, Object>(3);
  newMap.put("session:creationTime", delegate.getCreationTime());
  newMap.put("session:lastAccessedTime", delegate.getLastAccessedTime());
  newMap.put("session:maxInactiveInterval", delegate.getMaxInactiveIntervalInSeconds());
  map.putAll(newMap);
  updateExpiration();
  
  String channelName = getEventsChannelName(delegate.getId());
  RTopic topic = redisson.getTopic(channelName, StringCodec.INSTANCE);
  topic.publish(delegate.getId());
}

代码示例来源:origin: redisson/redisson

public RedissonSession(String keyPrefix) {
  this.delegate = new MapSession();
  map = redisson.getMap(keyPrefix + delegate.getId(), new CompositeCodec(StringCodec.INSTANCE, redisson.getConfig().getCodec()));
  principalName = resolvePrincipal(delegate);
  Map<String, Object> newMap = new HashMap<String, Object>(3);
  newMap.put("session:creationTime", delegate.getCreationTime());
  newMap.put("session:lastAccessedTime", delegate.getLastAccessedTime());
  newMap.put("session:maxInactiveInterval", delegate.getMaxInactiveIntervalInSeconds());
  map.putAll(newMap);
  updateExpiration();
  
  String channelName = getEventsChannelName(delegate.getId());
  RTopic topic = redisson.getTopic(channelName, StringCodec.INSTANCE);
  topic.publish(delegate.getId());
}

代码示例来源:origin: redisson/redisson

public JCache(JCacheManager cacheManager, Redisson redisson, String name, JCacheConfiguration<K, V> config, boolean hasOwnRedisson) {
  super(redisson.getConfig().getCodec(), redisson.getCommandExecutor(), name);
  
  this.hasOwnRedisson = hasOwnRedisson;
  this.redisson = redisson;
  
  Factory<CacheLoader<K, V>> cacheLoaderFactory = config.getCacheLoaderFactory();
  if (cacheLoaderFactory != null) {
    cacheLoader = cacheLoaderFactory.create();
  }
  Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory = config.getCacheWriterFactory();
  if (config.getCacheWriterFactory() != null) {
    cacheWriter = (CacheWriter<K, V>) cacheWriterFactory.create();
  }
  
  this.cacheManager = cacheManager;
  this.config = config;
  
  redisson.getEvictionScheduler().scheduleJCache(getName(), getTimeoutSetName(), getExpiredChannelName());
  
  for (CacheEntryListenerConfiguration<K, V> listenerConfig : config.getCacheEntryListenerConfigurations()) {
    registerCacheEntryListener(listenerConfig, false);
  }
}

代码示例来源:origin: redisson/redisson

public JCache(JCacheManager cacheManager, Redisson redisson, String name, JCacheConfiguration<K, V> config, boolean hasOwnRedisson) {
  super(redisson.getConfig().getCodec(), redisson.getCommandExecutor(), name);
  
  this.hasOwnRedisson = hasOwnRedisson;
  this.redisson = redisson;
  
  Factory<CacheLoader<K, V>> cacheLoaderFactory = config.getCacheLoaderFactory();
  if (cacheLoaderFactory != null) {
    cacheLoader = cacheLoaderFactory.create();
  }
  Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory = config.getCacheWriterFactory();
  if (config.getCacheWriterFactory() != null) {
    cacheWriter = (CacheWriter<K, V>) cacheWriterFactory.create();
  }
  
  this.cacheManager = cacheManager;
  this.config = config;
  
  redisson.getEvictionScheduler().scheduleJCache(getName(), getTimeoutSetName(), getExpiredChannelName());
  
  for (CacheEntryListenerConfiguration<K, V> listenerConfig : config.getCacheEntryListenerConfigurations()) {
    registerCacheEntryListener(listenerConfig, false);
  }
}

代码示例来源:origin: redisson/redisson

this.codec = cfg.getCodec();
this.shutdownPromise = new RedissonPromise<Boolean>();
this.commandExecutor = new CommandSyncService(this);

代码示例来源:origin: redisson/redisson

public Config(Config oldConf) {
  setExecutor(oldConf.getExecutor());
  if (oldConf.getCodec() == null) {
  setNettyThreads(oldConf.getNettyThreads());
  setThreads(oldConf.getThreads());
  setCodec(oldConf.getCodec());
  setReferenceEnabled(oldConf.isReferenceEnabled());
  setEventLoopGroup(oldConf.getEventLoopGroup());

代码示例来源:origin: redisson/redisson

public Config(Config oldConf) {
  setExecutor(oldConf.getExecutor());
  if (oldConf.getCodec() == null) {
  setNettyThreads(oldConf.getNettyThreads());
  setThreads(oldConf.getThreads());
  setCodec(oldConf.getCodec());
  setReferenceEnabled(oldConf.isReferenceEnabled());
  setEventLoopGroup(oldConf.getEventLoopGroup());

相关文章

微信公众号

最新文章

更多