Java Code Examples for org.nustaq.serialization.FSTConfiguration#setClassLoader()

The following examples show how to use org.nustaq.serialization.FSTConfiguration#setClassLoader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JetLinksRedisConfiguration.java    From jetlinks-community with Apache License 2.0 6 votes vote down vote up
@Bean
public ReactiveRedisTemplate<Object, Object> reactiveRedisTemplate(
    ReactiveRedisConnectionFactory reactiveRedisConnectionFactory, ResourceLoader resourceLoader) {

    FstSerializationRedisSerializer serializer = new FstSerializationRedisSerializer(() -> {
        FSTConfiguration configuration = FSTConfiguration.createDefaultConfiguration()
            .setForceSerializable(true);
        configuration.setClassLoader(resourceLoader.getClassLoader());
        return configuration;
    });
    @SuppressWarnings("all")
    RedisSerializationContext<Object, Object> serializationContext = RedisSerializationContext
        .newSerializationContext()
        .key((RedisSerializer)new StringRedisSerializer())
        .value(serializer)
        .hashKey(StringRedisSerializer.UTF_8)
        .hashValue(serializer)
        .build();

    return new ReactiveRedisTemplate<>(reactiveRedisConnectionFactory, serializationContext);
}
 
Example 2
Source File: FstCodec.java    From redisson with Apache License 2.0 5 votes vote down vote up
private static FSTConfiguration copy(ClassLoader classLoader, FstCodec codec) {
    FSTConfiguration def = codec.config.deriveConfiguration();
    def.setClassLoader(classLoader);
    def.setCoderSpecific(codec.config.getCoderSpecific());
    def.setCrossPlatform(codec.config.isCrossPlatform());
    def.setForceClzInit(codec.config.isForceClzInit());
    def.setForceSerializable(codec.config.isForceSerializable());
    def.setInstantiator(codec.config.getInstantiator(null));
    def.setJsonFieldNames(codec.config.getJsonFieldNames());
    def.setLastResortResolver(codec.config.getLastResortResolver());
    def.setName(codec.config.getName());
    def.setPreferSpeed(codec.config.isPreferSpeed());
    def.setStructMode(codec.config.isStructMode());
    def.setShareReferences(codec.config.isShareReferences());
    def.setStreamCoderFactory(codec.config.getStreamCoderFactory());
    def.setVerifier(codec.config.getVerifier());
    
    try {
        Field serializationInfoRegistryField = FSTConfiguration.class.getDeclaredField("serializationInfoRegistry");
        serializationInfoRegistryField.setAccessible(true);
        FSTClazzInfoRegistry registry = (FSTClazzInfoRegistry) serializationInfoRegistryField.get(codec.config);
        serializationInfoRegistryField.set(def, registry);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
    
    return def;
}
 
Example 3
Source File: GridNode.java    From vlingo-lattice with Mozilla Public License 2.0 4 votes vote down vote up
public GridNode(final GridRuntime gridRuntime, final Node localNode) {
  this.gridRuntime = gridRuntime;
  this.localNode = localNode;

  final FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
  // set classloader with available proxy classes
  conf.setClassLoader(gridRuntime.worldClassLoader());

  final HardRefHolder holder = gridRuntime.world().actorFor(HardRefHolder.class,
      Definition.has(ExpiringHardRefHolder.class, ExpiringHardRefHolder::new));

  this.outbound =
          stage().actorFor(
                  GridActorControl.Outbound.class,
                  OutboundGridActorControl.class,
                  new OutboundGridActorControlInstantiator(
                                  localNode.id(),
                                  new FSTEncoder(conf),
                                  correlation::put,
                                  new OutBuffers(holder)));

  this.gridRuntime.setOutbound(outbound);

  final GridActorControl.Inbound inbound =
          stage().actorFor(
                  GridActorControl.Inbound.class,
                  InboundGridActorControl.class,
                  new InboundGridActorControlInstantiator(
                          gridRuntime,
                          correlation::remove));

  this.applicationMessageHandler =
          new GridApplicationMessageHandler(
                  localNode.id(),
                  gridRuntime.hashRing(),
                  inbound,
                  outbound,
                  new FSTDecoder(conf), holder,
                  scheduler());

  this.quorumObservers = new ArrayList<>(3);

  registerQuorumObserver(gridRuntime);
}
 
Example 4
Source File: FstCodec.java    From redisson with Apache License 2.0 4 votes vote down vote up
private static FSTConfiguration createConfig(ClassLoader classLoader) {
    FSTConfiguration def = FSTConfiguration.createDefaultConfiguration();
    def.setClassLoader(classLoader);
    return def;
}