Examples of AnnotationMetaDataProvider


Examples of org.apache.felix.ipojo.manipulator.metadata.AnnotationMetadataProvider

        //1.1 Metadata collection
        byte[] origin = ManipulatorTest.getBytesFromFile(new File("target/test-classes/test/PlentyOfAnnotations.class"));
        MiniStore store = new MiniStore()
                .addClassToStore("test.PlentyOfAnnotations",
                        origin);
        AnnotationMetadataProvider provider = new AnnotationMetadataProvider(store, reporter);
        List<Element> originalMetadata = provider.getMetadatas();
        // 1.2 Manipulation
        Manipulator manipulator = new Manipulator(this.getClass().getClassLoader());
        manipulator.prepare(origin);
        byte[] clazz = manipulator.manipulate(origin);
        Element originalManipulationMetadata = manipulator.getManipulationMetadata();
        // 1.3 Check that the class is valid
        ManipulatedClassLoader classloader = new ManipulatedClassLoader("test.PlentyOfAnnotations", clazz);
        Class cl = classloader.findClass("test.PlentyOfAnnotations");
        Assert.assertNotNull(cl);

        // ---------------

        // Step 2 - Second collection and manipulation
        // We use the output class as entry.
        // 2.1 Metadata collection
        store = new MiniStore().addClassToStore("test.PlentyOfAnnotations", clazz);
        provider = new AnnotationMetadataProvider(store, reporter);
        List<Element> metadataAfterOneManipulation = provider.getMetadatas();
        // 2.2 Manipulation
        manipulator = new Manipulator(this.getClass().getClassLoader());
        manipulator.prepare(clazz);
        byte[] clazz2 = manipulator.manipulate(clazz);
        Element manipulationMetadataAfterSecondManipulation = manipulator.getManipulationMetadata();
        // 2.3 Check that the class is valid
        classloader = new ManipulatedClassLoader("test.PlentyOfAnnotations", clazz);
        cl = classloader.findClass("test.PlentyOfAnnotations");
        Assert.assertNotNull(cl);

        // ---------------

        // Step 3 - Third collection and manipulation
        // We use the output class of 2 as entry.
        // 3.1 Metadata collection
        store = new MiniStore().addClassToStore("test.PlentyOfAnnotations", clazz2);
        provider = new AnnotationMetadataProvider(store, reporter);
        List<Element> metadataAfterTwoManipulation = provider.getMetadatas();
        // 3.2 Manipulation
        manipulator = new Manipulator(this.getClass().getClassLoader());
        manipulator.prepare(clazz2);
        byte[] clazz3 = manipulator.manipulate(clazz2);
        Element manipulationMetadataAfterThirdManipulation = manipulator.getManipulationMetadata();
View Full Code Here

Examples of org.apache.felix.ipojo.manipulator.metadata.AnnotationMetadataProvider

                ResourceMetadataProvider rmp = new ResourceMetadataProvider(resource, reporter);
                rmp.setValidateUsingLocalSchemas(m_useLocalSchemas);
                provider.addMetadataProvider(rmp);
            }
        }
        provider.addMetadataProvider(new AnnotationMetadataProvider(store, reporter));
        return provider;
    }
View Full Code Here

Examples of org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider

    this.instanceInitializer = instanceInitializer;
    this.entityState = EntityState.CONTAINED_IN_ONLY;
    this.beanXClass = xClass;
    this.beanClass = reflectionManager.toClass( xClass );

    MetadataProvider metadataProvider = new AnnotationMetadataProvider( reflectionManager, configContext );
    this.typeMetadata = metadataProvider.getTypeMetadataFor( reflectionManager.toClass( xClass ) );

    optimizationBlackList.addAll( typeMetadata.getOptimizationBlackList() );

    // set the default similarity in case that after processing all classes there is still no similarity set
    if ( typeMetadata.getSimilarity() == null && similarity == null ) {
View Full Code Here

Examples of org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider

    final Map<XClass, Class<?>> classMappings = initializeClassMappings( cfg, cfg.getReflectionManager() );

    //we process the @Indexed classes last, so we first start all IndexManager(s).
    final List<XClass> rootIndexedEntities = new LinkedList<XClass>();
    final org.hibernate.search.engine.metadata.impl.MetadataProvider metadataProvider =
        new AnnotationMetadataProvider( cfg.getReflectionManager(), context );

    for ( Map.Entry<XClass, Class<?>> mapping : classMappings.entrySet() ) {
      XClass mappedXClass = mapping.getKey();
      Class<?> mappedClass = mapping.getValue();

      if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {
        if ( mappedXClass.isAbstract() ) {
          log.abstractClassesCannotInsertDocuments();
          continue;
        }

        rootIndexedEntities.add( mappedXClass );
        indexingHierarchy.addIndexedClass( mappedClass );
      }
      else if ( metadataProvider.containsSearchMetadata( mappedClass ) ) {
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?

        TypeMetadata typeMetadata = metadataProvider.getTypeMetadataFor( mappedClass );
        final DocumentBuilderContainedEntity<?> documentBuilder = new DocumentBuilderContainedEntity(
            mappedXClass, typeMetadata, cfg.getReflectionManager(), optimizationBlackListedTypes, cfg.getInstanceInitializer()
        );
        //TODO enhance that, I don't like to expose EntityState
        if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
          documentBuildersContainedEntities.put( mappedClass, documentBuilder );
        }
      }
      bindFilterDefs( mappedXClass );
      //TODO should analyzer def for classes at their same level???
    }

    IndexManagerHolder indexesFactory = factoryState.getAllIndexesManager();

    // Create all IndexManagers, configure and start them:
    for ( XClass mappedXClass : rootIndexedEntities ) {
      Class mappedClass = classMappings.get( mappedXClass );
      MutableEntityIndexBinding entityIndexBinding = indexesFactory.buildEntityIndexBinding( mappedXClass, mappedClass, cfg, buildContext );

      // interceptor might use non indexed state
      if ( entityIndexBinding.getEntityIndexingInterceptor() != null ) {
        optimizationBlackListedTypes.add( mappedXClass );
      }

      // Create all DocumentBuilderIndexedEntity
      // FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
      // XClass unfortunately is not (yet) genericized: TODO ?
      TypeMetadata typeMetadata = metadataProvider.getTypeMetadataFor( mappedClass );
      final DocumentBuilderIndexedEntity<?> documentBuilder =
          new DocumentBuilderIndexedEntity(
              mappedXClass,
              typeMetadata,
              context,
View Full Code Here

Examples of org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider

    );

    //we process the @Indexed classes last, so we first start all IndexManager(s).
    final List<XClass> rootIndexedEntities = new LinkedList<XClass>();
    final org.hibernate.search.engine.metadata.impl.MetadataProvider metadataProvider =
        new AnnotationMetadataProvider( searchConfiguration.getReflectionManager(), configContext );

    for ( Map.Entry<XClass, Class<?>> mapping : classMappings.entrySet() ) {
      XClass mappedXClass = mapping.getKey();
      Class<?> mappedClass = mapping.getValue();

      if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {
        if ( mappedXClass.isAbstract() ) {
          log.abstractClassesCannotInsertDocuments( mappedXClass.getName() );
          continue;
        }

        rootIndexedEntities.add( mappedXClass );
        indexingHierarchy.addIndexedClass( mappedClass );
      }
      else if ( metadataProvider.containsSearchMetadata( mappedClass ) ) {
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?

        TypeMetadata typeMetadata = metadataProvider.getTypeMetadataFor( mappedClass );
        final DocumentBuilderContainedEntity documentBuilder = new DocumentBuilderContainedEntity(
            mappedXClass,
            typeMetadata,
            searchConfiguration.getReflectionManager(),
            optimizationBlackListedTypes,
            searchConfiguration.getInstanceInitializer()
        );
        //TODO enhance that, I don't like to expose EntityState
        if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
          documentBuildersContainedEntities.put( mappedClass, documentBuilder );
        }
      }
      bindFilterDefs( mappedXClass );
      //TODO should analyzer def for classes at their same level???
    }

    IndexManagerHolder indexesFactory = factoryState.getAllIndexesManager();

    // Create all IndexManagers, configure and start them:
    for ( XClass mappedXClass : rootIndexedEntities ) {
      Class mappedClass = classMappings.get( mappedXClass );
      MutableEntityIndexBinding entityIndexBinding = indexesFactory.buildEntityIndexBinding(
          mappedXClass,
          mappedClass,
          searchConfiguration,
          buildContext
      );

      // interceptor might use non indexed state
      if ( entityIndexBinding.getEntityIndexingInterceptor() != null ) {
        optimizationBlackListedTypes.add( mappedXClass );
      }

      // Create all DocumentBuilderIndexedEntity
      // FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
      // XClass unfortunately is not (yet) genericized: TODO ?
      TypeMetadata typeMetadata = metadataProvider.getTypeMetadataFor( mappedClass );
      final DocumentBuilderIndexedEntity documentBuilder =
          new DocumentBuilderIndexedEntity(
              mappedXClass,
              typeMetadata,
              configContext,
View Full Code Here

Examples of org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider

    final Map<XClass, Class<?>> classMappings = initializeClassMappings( cfg, cfg.getReflectionManager() );

    //we process the @Indexed classes last, so we first start all IndexManager(s).
    final List<XClass> rootIndexedEntities = new LinkedList<XClass>();
    final org.hibernate.search.engine.metadata.impl.MetadataProvider metadataProvider =
        new AnnotationMetadataProvider( cfg.getReflectionManager(), context );

    for ( Map.Entry<XClass, Class<?>> mapping : classMappings.entrySet() ) {

      XClass mappedXClass = mapping.getKey();
      Class<?> mappedClass = mapping.getValue();

      if ( mappedXClass.isAnnotationPresent( Indexed.class ) ) {

        if ( mappedXClass.isAbstract() ) {
          log.abstractClassesCannotInsertDocuments();
          continue;
        }

        rootIndexedEntities.add( mappedXClass );
        indexingHierarchy.addIndexedClass( mappedClass );
      }
      else if ( metadataProvider.containsSearchMetadata( mappedClass ) ) {
        //FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
        //XClass unfortunately is not (yet) genericized: TODO?

        TypeMetadata typeMetadata = metadataProvider.getTypeMetadataFor( mappedClass);
        final DocumentBuilderContainedEntity<?> documentBuilder = new DocumentBuilderContainedEntity(
            mappedXClass, typeMetadata, cfg.getReflectionManager(), optimizationBlackListedTypes, cfg.getInstanceInitializer()
        );
        //TODO enhance that, I don't like to expose EntityState
        if ( documentBuilder.getEntityState() != EntityState.NON_INDEXABLE ) {
          documentBuildersContainedEntities.put( mappedClass, documentBuilder );
        }
      }
      bindFilterDefs( mappedXClass );
      //TODO should analyzer def for classes at their same level???
    }

    IndexManagerHolder indexesFactory = factoryState.getAllIndexesManager();

    // Create all IndexManagers, configure and start them:
    for ( XClass mappedXClass : rootIndexedEntities ) {
      Class mappedClass = classMappings.get( mappedXClass );
      MutableEntityIndexBinding entityIndexBinding = indexesFactory.buildEntityIndexBinding( mappedXClass, mappedClass, cfg, buildContext );

      // interceptor might use non indexed state
      if ( entityIndexBinding.getEntityIndexingInterceptor() != null ) {
        optimizationBlackListedTypes.add( mappedXClass );
      }

      // Create all DocumentBuilderIndexedEntity
      // FIXME DocumentBuilderIndexedEntity needs to be built by a helper method receiving Class<T> to infer T properly
      // XClass unfortunately is not (yet) genericized: TODO ?
      TypeMetadata typeMetadata = metadataProvider.getTypeMetadataFor( mappedClass);
      final DocumentBuilderIndexedEntity<?> documentBuilder =
          new DocumentBuilderIndexedEntity(
              mappedXClass,
              typeMetadata,
              context,
View Full Code Here

Examples of org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider

  }

  private static void tryCreatingDocumentBuilder(XClass mappedXClass, ReflectionManager reflectionManager) {
    SearchConfiguration searchConfiguration = new SearchConfigurationForTest();
    ConfigContext context = new ConfigContext( searchConfiguration, new BuildContextForTest( searchConfiguration ) );
    MetadataProvider metadataProvider = new AnnotationMetadataProvider( reflectionManager, context );
    TypeMetadata typeMetadata = metadataProvider.getTypeMetadataFor( reflectionManager.toClass( mappedXClass ));
    new DocumentBuilderIndexedEntity( mappedXClass,
        typeMetadata,
        context,
        reflectionManager,
        Collections.<XClass>emptySet(),
View Full Code Here

Examples of org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider

    SearchConfiguration searchConfiguration = new SearchConfigurationForTest();
    ConfigContext configContext = new ConfigContext(
        searchConfiguration,
        new BuildContextForTest( searchConfiguration )
    );
    metadataProvider = new AnnotationMetadataProvider( new JavaReflectionManager(), configContext );
  }
View Full Code Here

Examples of org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider

    SearchConfiguration searchConfiguration = new SearchConfigurationForTest();
    ConfigContext configContext = new ConfigContext(
        searchConfiguration,
        new BuildContextForTest( searchConfiguration )
    );
    metadataProvider = new AnnotationMetadataProvider( new JavaReflectionManager(), configContext );
  }
View Full Code Here

Examples of org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider

    SearchConfiguration searchConfiguration = new SearchConfigurationForTest();
    ConfigContext configContext = new ConfigContext(
        searchConfiguration,
        new BuildContextForTest( searchConfiguration )
    );
    metadataProvider = new AnnotationMetadataProvider( new JavaReflectionManager(), configContext );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.