Search in sources :

Example 1 with Serializer

use of com.tangosol.io.Serializer in project coherence-spring by coherence-community.

the class GrpcSessionConfigurationBean method getConfiguration.

@Override
public Optional<SessionConfiguration> getConfiguration() {
    if (this.getType() != SessionType.GRPC) {
        // TODO
        return Optional.empty();
    }
    GrpcSessionConfiguration.Builder builder;
    if (this.channelName == null || this.channelName.trim().isEmpty()) {
        // TODO builder = GrpcSessionConfiguration.builder(GrpcSessionConfiguration.DEFAULT_HOST);
        builder = GrpcSessionConfiguration.builder();
    } else {
        try {
            final Channel bean = BeanFactoryAnnotationUtils.qualifiedBeanOfType(this.ctx.getBeanFactory(), Channel.class, this.channelName);
            builder = GrpcSessionConfiguration.builder(bean);
        } catch (NoSuchBeanDefinitionException ex) {
            builder = GrpcSessionConfiguration.builder(this.channelName);
        }
    }
    builder = builder.named(getName()).withScopeName(getScopeName()).withTracing(this.tracingEnabled).withPriority(getPriority());
    if (this.serializer != null && this.serializer.trim().isEmpty()) {
        try {
            final Serializer bean = BeanFactoryAnnotationUtils.qualifiedBeanOfType(this.ctx.getBeanFactory(), Serializer.class, this.serializer);
            builder.withSerializer(bean, this.serializer);
        } catch (NoSuchBeanDefinitionException ex) {
            builder.withSerializerFormat(this.serializer);
        }
    }
    return Optional.of(builder.build());
}
Also used : GrpcSessionConfiguration(com.oracle.coherence.client.GrpcSessionConfiguration) Channel(io.grpc.Channel) NoSuchBeanDefinitionException(org.springframework.beans.factory.NoSuchBeanDefinitionException) Serializer(com.tangosol.io.Serializer)

Example 2 with Serializer

use of com.tangosol.io.Serializer in project micronaut-coherence by micronaut-projects.

the class ExtractorFactoriesTest method setup.

@BeforeEach
void setup() {
    phoneNumber = new PhoneNumber(44, "04242424242");
    person = new Person("Arthur", "Dent", LocalDate.of(1978, 3, 8), phoneNumber);
    binaryKey = ExternalizableHelper.toBinary("AD", pofContext);
    binaryPerson = ExternalizableHelper.toBinary(person, pofContext);
    BackingMapContext ctx = mock(BackingMapContext.class);
    Map<ValueExtractor, MapIndex> index = new HashMap<>();
    when(ctx.getIndexMap()).thenReturn(index);
    entry = new BackingMapBinaryEntry(binaryKey, binaryPerson, binaryPerson, null) {

        @Override
        public Object getKey() {
            return "AD";
        }

        @Override
        public Object getValue() {
            return person;
        }

        @Override
        public BackingMapContext getBackingMapContext() {
            return ctx;
        }

        @Override
        public Serializer getSerializer() {
            return pofContext;
        }
    };
}
Also used : BackingMapContext(com.tangosol.net.BackingMapContext) BackingMapBinaryEntry(com.tangosol.net.cache.BackingMapBinaryEntry) HashMap(java.util.HashMap) PhoneNumber(data.PhoneNumber) Person(data.Person) Serializer(com.tangosol.io.Serializer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with Serializer

use of com.tangosol.io.Serializer in project coherence-spring by coherence-community.

the class ExtractorConfigurationTests method setup.

@BeforeEach
void setup() {
    this.phoneNumber = new PhoneNumber(44, "04242424242");
    this.person = new Person("Arthur", "Dent", LocalDate.of(1978, 3, 8), this.phoneNumber);
    this.binaryKey = ExternalizableHelper.toBinary("AD", this.pofContext);
    this.binaryPerson = ExternalizableHelper.toBinary(this.person, this.pofContext);
    BackingMapContext ctx = mock(BackingMapContext.class);
    Map<ValueExtractor, MapIndex> index = new HashMap<>();
    when(ctx.getIndexMap()).thenReturn(index);
    this.entry = new BackingMapBinaryEntry(this.binaryKey, this.binaryPerson, this.binaryPerson, null) {

        @Override
        public Object getKey() {
            return "AD";
        }

        @Override
        public Object getValue() {
            return ExtractorConfigurationTests.this.person;
        }

        @Override
        public BackingMapContext getBackingMapContext() {
            return ctx;
        }

        @Override
        public Serializer getSerializer() {
            return ExtractorConfigurationTests.this.pofContext;
        }
    };
}
Also used : BackingMapContext(com.tangosol.net.BackingMapContext) BackingMapBinaryEntry(com.tangosol.net.cache.BackingMapBinaryEntry) HashMap(java.util.HashMap) PhoneNumber(data.PhoneNumber) ValueExtractor(com.tangosol.util.ValueExtractor) MapIndex(com.tangosol.util.MapIndex) Person(data.Person) Serializer(com.tangosol.io.Serializer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with Serializer

use of com.tangosol.io.Serializer in project coherence-spring by coherence-community.

the class SerializerConfigurationTests method shouldGetPofSerializer.

@Test
void shouldGetPofSerializer() {
    final Serializer serializer = BeanFactoryAnnotationUtils.qualifiedBeanOfType(this.context.getBeanFactory(), Serializer.class, "pof");
    assertThat(serializer).isNotNull();
    assertThat(serializer).isInstanceOf(ConfigurablePofContext.class);
}
Also used : DefaultSerializer(com.tangosol.io.DefaultSerializer) Serializer(com.tangosol.io.Serializer) Test(org.junit.jupiter.api.Test)

Example 5 with Serializer

use of com.tangosol.io.Serializer in project coherence-spring by coherence-community.

the class SerializerConfigurationTests method shouldGetJavaSerializer.

@Test
void shouldGetJavaSerializer() {
    final Serializer serializer = BeanFactoryAnnotationUtils.qualifiedBeanOfType(this.context.getBeanFactory(), Serializer.class, "java");
    assertThat(serializer).isNotNull();
    assertThat(serializer).isInstanceOf(DefaultSerializer.class);
}
Also used : DefaultSerializer(com.tangosol.io.DefaultSerializer) Serializer(com.tangosol.io.Serializer) Test(org.junit.jupiter.api.Test)

Aggregations

Serializer (com.tangosol.io.Serializer)8 Test (org.junit.jupiter.api.Test)5 DefaultSerializer (com.tangosol.io.DefaultSerializer)4 BackingMapContext (com.tangosol.net.BackingMapContext)2 BackingMapBinaryEntry (com.tangosol.net.cache.BackingMapBinaryEntry)2 Binary (com.tangosol.util.Binary)2 Person (data.Person)2 PhoneNumber (data.PhoneNumber)2 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)2 HashMap (java.util.HashMap)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 GrpcSessionConfiguration (com.oracle.coherence.client.GrpcSessionConfiguration)1 Publisher (com.tangosol.net.topic.Publisher)1 MapIndex (com.tangosol.util.MapIndex)1 ValueExtractor (com.tangosol.util.ValueExtractor)1 Channel (io.grpc.Channel)1 NoSuchBeanDefinitionException (org.springframework.beans.factory.NoSuchBeanDefinitionException)1