Package org.infinispan.protostream

Examples of org.infinispan.protostream.SerializationContext


   private void initSerializationContext() {
      if (!isSerializationContextInitialized) {
         isSerializationContextInitialized = true;
         try {
            SerializationContext serCtx = SerializationContextHolder.getSerializationContext();
            MarshallerRegistration.registerMarshallers(serCtx);
         } catch (IOException e) {
            throw new CacheException("Failed to initialise serialization context", e);
         } catch (Descriptors.DescriptorValidationException e) {
            throw new CacheException("Failed to initialise serialization context", e);
View Full Code Here


         throw new CacheException("An exception has occurred during query execution", e);
      }
   }

   private byte[] executeQuery(AdvancedCache<byte[], byte[]> cache, byte[] query) throws IOException {
      final SerializationContext serCtx = SerializationContextHolder.getSerializationContext();

      QueryRequest request = ProtobufUtil.fromByteArray(serCtx, query, 0, query.length, QueryRequest.class);

      EntityNamesResolver entityNamesResolver = new EntityNamesResolver() {
         @Override
         public Class<?> getClassFromName(String entityName) {
            try {
               //todo [anistor] this just checks if the type is known
               serCtx.getMessageDescriptor(entityName);
            } catch (Exception e) {
               return null;
            }
            return ProtobufValueWrapper.class;
         }
View Full Code Here

      decodeAndIndex(valueWrapper.getBinary(), document, luceneOptions);
   }

   private void decodeAndIndex(byte[] bytes, Document document, LuceneOptions luceneOptions) {
      //todo [anistor] the SerializationContext should somehow be injected here rather than getting it from a static holder
      SerializationContext serCtx = SerializationContextHolder.getSerializationContext();
      Descriptors.Descriptor wrapperDescriptor = serCtx.getMessageDescriptor(WrappedMessage.PROTOBUF_TYPE_NAME);
      try {
         new ProtobufParser().parse(new WrappedMessageTagHandler(document, luceneOptions, serCtx), wrapperDescriptor, bytes);
      } catch (IOException e) {
         throw new CacheException(e);
      }
View Full Code Here

      QueryRequest queryRequest = new QueryRequest();
      queryRequest.setJpqlString(remoteQuery.getJpqlString());
      queryRequest.setStartOffset(remoteQuery.getStartOffset());
      queryRequest.setMaxResults(remoteQuery.getMaxResults());

      SerializationContext serCtx = remoteQuery.getSerializationContext();
      byte[] requestBytes;
      try {
         requestBytes = ProtobufUtil.toByteArray(serCtx, queryRequest);
      } catch (IOException e) {
         throw new CacheException(e)//todo [anistor] need better exception handling
View Full Code Here

         throw new CacheException("An exception has occurred during query execution", e);
      }
   }

   private byte[] executeQuery(AdvancedCache<byte[], byte[]> cache, byte[] query) throws IOException {
      final SerializationContext serCtx = ProtobufMetadataManager.getSerializationContext(cache.getCacheManager());

      QueryRequest request = ProtobufUtil.fromByteArray(serCtx, query, 0, query.length, QueryRequest.class);

      SearchManager searchManager = Search.getSearchManager(cache);
      Query luceneQuery;
      List<String> projections;
      Class targetEntity;
      Descriptors.Descriptor messageDescriptor;

      QueryParser queryParser = new QueryParser();
      if (cache.getCacheConfiguration().compatibility().enabled()) {
         final QueryInterceptor queryInterceptor = ComponentRegistryUtils.getQueryInterceptor(cache);
         EntityNamesResolver entityNamesResolver = new EntityNamesResolver() {
            @Override
            public Class<?> getClassFromName(String entityName) {
               MessageMarshaller messageMarshaller = (MessageMarshaller) serCtx.getMarshaller(entityName);
               Class clazz = messageMarshaller.getJavaClass();
               Boolean isIndexed = queryInterceptor.getKnownClasses().get(clazz);
               return isIndexed != null && isIndexed ? clazz : null;
            }
         };

         LuceneProcessingChain processingChain = new LuceneProcessingChain((SearchFactoryIntegrator) searchManager.getSearchFactory(), entityNamesResolver, null);
         LuceneQueryParsingResult parsingResult = queryParser.parseQuery(request.getJpqlString(), processingChain);

         MessageMarshaller messageMarshaller = (MessageMarshaller) serCtx.getMarshaller(parsingResult.getTargetEntity());
         messageDescriptor = serCtx.getMessageDescriptor(messageMarshaller.getTypeName());
         targetEntity = parsingResult.getTargetEntity();
         projections = parsingResult.getProjections();
         luceneQuery = parsingResult.getQuery();
      } else {
         EntityNamesResolver entityNamesResolver = new EntityNamesResolver() {
            @Override
            public Class<?> getClassFromName(String entityName) {
               try {
                  //todo [anistor] this just checks if the type is known
                  serCtx.getMessageDescriptor(entityName);
               } catch (Exception e) {
                  return null;
               }
               return ProtobufValueWrapper.class;
            }
View Full Code Here

      decodeAndIndex(valueWrapper.getBinary(), document, luceneOptions);
   }

   private void decodeAndIndex(byte[] bytes, Document document, LuceneOptions luceneOptions) {
      SerializationContext serCtx = ProtobufMetadataManager.getSerializationContext(cache.getCacheManager());
      Descriptors.Descriptor wrapperDescriptor = serCtx.getMessageDescriptor(WrappedMessage.PROTOBUF_TYPE_NAME);
      try {
         new ProtobufParser().parse(new WrappedMessageTagHandler(document, luceneOptions, serCtx), wrapperDescriptor, bytes);
      } catch (IOException e) {
         throw new CacheException(e);
      }
View Full Code Here

   public static final String NULL_TOKEN = "_null_";

   @Override
   public byte[] query(AdvancedCache<byte[], byte[]> cache, byte[] query) {
      try {
         SerializationContext serCtx = ProtobufMetadataManager.getSerializationContextInternal(cache.getCacheManager());
         QueryRequest request = ProtobufUtil.fromByteArray(serCtx, query, 0, query.length, QueryRequest.class);

         QueryResponse response;
         if (cache.getCacheConfiguration().indexing().index().isEnabled()) {
            response = executeQuery(cache, serCtx, request);
View Full Code Here

public class LifecycleManager extends AbstractModuleLifecycle {

   private static final Log log = LogFactory.getLog(LifecycleManager.class, Log.class);

   private void initProtobufMetadataManager(DefaultCacheManager cacheManager, GlobalComponentRegistry gcr) {
      SerializationContext serCtx = ProtobufUtil.newSerializationContext(new org.infinispan.protostream.ConfigurationBuilder().build());
      try {
         MarshallerRegistration.registerMarshallers(serCtx);
      } catch (IOException  | DescriptorParserException e) {
         throw new CacheException("Failed to initialise serialization context", e);
      }
View Full Code Here

    * Registers the remote value wrapper interceptor in the cache before it gets started.
    */
   @Override
   public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) {
      EmbeddedCacheManager cacheManager = cr.getGlobalComponentRegistry().getComponent(EmbeddedCacheManager.class);
      SerializationContext serializationContext = ProtobufMetadataManager.getSerializationContext(cacheManager);
      cr.registerComponent(new ProtobufMatcher(serializationContext), ProtobufMatcher.class);

      if (cfg.compatibility().enabled()) {
         cr.registerComponent(new CompatibilityReflectionMatcher(serializationContext), CompatibilityReflectionMatcher.class);
      }
View Full Code Here

   public static final String NULL_TOKEN = "_null_";

   @Override
   public byte[] query(AdvancedCache<byte[], byte[]> cache, byte[] query) {
      try {
         SerializationContext serCtx = ProtobufMetadataManager.getSerializationContext(cache.getCacheManager());
         QueryRequest request = ProtobufUtil.fromByteArray(serCtx, query, 0, query.length, QueryRequest.class);

         QueryResponse response;
         if (cache.getCacheConfiguration().indexing().index().isEnabled()) {
            response = executeQuery(cache, serCtx, request);
View Full Code Here

TOP

Related Classes of org.infinispan.protostream.SerializationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.