Examples of XClass


Examples of org.hibernate.annotations.common.reflection.XClass

      return EMPTY;
    }
  }

  private void updateContainedInMaxDepth(XMember memberWithContainedIn, PropertiesMetadata propertiesMetadata, String accessType) {
    XClass memberReturnedType = memberWithContainedIn.getElementClass();
    String mappedBy = mappedBy( memberWithContainedIn );
    List<XProperty> returnedTypeProperties = memberReturnedType.getDeclaredProperties( accessType );
    for ( XProperty property : returnedTypeProperties ) {
      if ( isCorrespondingIndexedEmbedded( mappedBy, property ) ) {
          updateDepthProperties( memberWithContainedIn, propertiesMetadata, memberReturnedType, property );
          break;
        }
View Full Code Here

Examples of org.hibernate.annotations.common.reflection.XClass

        potentialLevel = Integer.MAX_VALUE;
      }
      maxLevel = potentialLevel > maxLevel ? maxLevel : potentialLevel;
      level++;

      XClass elementClass;
      if ( void.class == embeddedAnn.targetElement() ) {
        elementClass = member.getElementClass();
      }
      else {
        elementClass = reflectionManager.toXClass( embeddedAnn.targetElement() );
      }

      if ( maxLevel == Integer.MAX_VALUE //infinite
          && processedClasses.contains( elementClass ) ) {
        throw new SearchException(
            "Circular reference. Duplicate use of "
                + elementClass.getName()
                + " in root entity " + beanXClass.getName()
                + "#" + buildEmbeddedPrefix( prefix, embeddedAnn, member )
        );
      }
View Full Code Here

Examples of org.hibernate.annotations.common.reflection.XClass

      Spatial spatialAnn = member.getAnnotation( org.hibernate.search.annotations.Spatial.class );
      bridge = buildSpatialBridge( spatialAnn, member );
    }
    else {
      //find in built-ins
      XClass returnType = member.getType();
      bridge = builtInBridges.get( returnType.getName() );
      if ( bridge == null && returnType.isEnum() ) {
        //we return one enum type bridge instance per property as it is customized per ReturnType
        @SuppressWarnings("unchecked")
        final EnumBridge enumBridge = new EnumBridge();
        populateReturnType( reflectionManager.toClass( member.getType() ), EnumBridge.class, enumBridge );
        bridge = new TwoWayString2FieldBridgeAdaptor( enumBridge );
View Full Code Here

Examples of org.hibernate.annotations.common.reflection.XClass

    else if ( numericField != null ) {
      bridge = numericBridges.get( member.getType().getName() );
    }
    else {
      //find in built-ins
      XClass returnType = member.getType();
      bridge = builtInBridges.get( returnType.getName() );
      if ( bridge == null && returnType.isEnum() ) {
        //we return one enum type bridge instance per property as it is customized per ReturnType
        @SuppressWarnings("unchecked")
        final EnumBridge enumBridge = new EnumBridge();
        populateReturnType( reflectionManager.toClass( member.getType() ), EnumBridge.class, enumBridge );
        bridge = new TwoWayString2FieldBridgeAdaptor( enumBridge );
View Full Code Here

Examples of org.hibernate.annotations.common.reflection.XClass

    return idAnnotation;
  }

  private ProvidedId findProvidedId(XClass clazz, ReflectionManager reflectionManager) {
    ProvidedId id = null;
    XClass currentClass = clazz;
    while ( id == null && ( !reflectionManager.equals( currentClass, Object.class ) ) ) {
      id = currentClass.getAnnotation( ProvidedId.class );
      currentClass = currentClass.getSuperclass();
    }
    return id;
  }
View Full Code Here

Examples of org.hibernate.annotations.common.reflection.XClass

    while ( iter.hasNext() ) {
      Class<?> mappedClass = iter.next();
      if ( mappedClass == null ) {
        continue;
      }
      @SuppressWarnings("unchecked")
      XClass mappedXClass = reflectionManager.toXClass( mappedClass );
      if ( mappedXClass == null ) {
        continue;
      }

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

        if ( mappedXClass.isAbstract() ) {
          log.warn( "Abstract classes can never insert index documents. Remove @Indexed." );
          continue;
        }

        DirectoryProviderFactory.DirectoryProviders providers = factory.createDirectoryProviders(
View Full Code Here

Examples of org.hibernate.annotations.common.reflection.XClass

    /*
    * Iterate the class hierarchy top down. This allows to override the default analyzer for the properties if the class holds one
    */
    for ( int index = hierarchy.size() - 1; index >= 0; index-- ) {
      XClass currentClass = hierarchy.get( index );

      initializeClassLevelAnnotations( currentClass, propertiesMetadata, isRoot, prefix, context );

      // rejecting non properties (ie regular methods) because the object is loaded from Hibernate,
      // so indexing a non property does not make sense
      List<XProperty> methods = currentClass.getDeclaredProperties( XClass.ACCESS_PROPERTY );
      for ( XProperty method : methods ) {
        initializeMemberLevelAnnotations(
            method, propertiesMetadata, isRoot, prefix, processedClasses, context
        );
      }

      List<XProperty> fields = currentClass.getDeclaredProperties( XClass.ACCESS_FIELD );
      for ( XProperty field : fields ) {
        initializeMemberLevelAnnotations(
            field, propertiesMetadata, isRoot, prefix, processedClasses, context
        );
      }
View Full Code Here

Examples of org.hibernate.annotations.common.reflection.XClass

        potentialLevel = Integer.MAX_VALUE;
      }
      maxLevel = potentialLevel > maxLevel ? maxLevel : potentialLevel;
      level++;

      XClass elementClass;
      if ( void.class == embeddedAnn.targetElement() ) {
        elementClass = member.getElementClass();
      }
      else {
        elementClass = reflectionManager.toXClass( embeddedAnn.targetElement() );
      }
      if ( maxLevel == Integer.MAX_VALUE //infinite
          && processedClasses.contains( elementClass ) ) {
        throw new SearchException(
            "Circular reference. Duplicate use of "
                + elementClass.getName()
                + " in root entity " + beanXClass.getName()
                + "#" + buildEmbeddedPrefix( prefix, embeddedAnn, member )
        );
      }
      if ( level <= maxLevel ) {
View Full Code Here

Examples of org.hibernate.annotations.common.reflection.XClass

  }

  public static InheritanceState getInheritanceStateOfSuperEntity(
      XClass clazz, Map<XClass, InheritanceState> states
  ) {
    XClass superclass = clazz;
    do {
      superclass = superclass.getSuperclass();
      InheritanceState currentState = states.get( superclass );
      if ( currentState != null && !currentState.isEmbeddableSuperclass() ) {
        return currentState;
      }
    }
    while ( superclass != null && !Object.class.getName().equals( superclass.getName() ) );
    return null;
  }
View Full Code Here

Examples of org.hibernate.reflection.XClass

  public static Callback[] resolveCallback(XClass beanClass, Class annotation, ReflectionManager reflectionManager) {
    List<Callback> callbacks = new ArrayList<Callback>();
    List<String> callbacksMethodNames = new ArrayList<String>(); //used to track overriden methods
    List<Class> orderedListeners = new ArrayList<Class>();
    XClass currentClazz = beanClass;
    boolean stopListeners = false;
    boolean stopDefaultListeners = false;
    do {
      Callback callback = null;
      List<XMethod> methods = currentClazz.getDeclaredMethods();
      final int size = methods.size();
      for ( int i = 0; i < size ; i++ ) {
        final XMethod xMethod = methods.get( i );
        if ( xMethod.isAnnotationPresent( annotation ) ) {
          Method method = reflectionManager.toMethod( xMethod );
          final String methodName = method.getName();
          if ( ! callbacksMethodNames.contains( methodName ) ) {
            //overriden method, remove the superclass overriden method
            if ( callback == null ) {
              callback = new BeanCallback( method );
              Class returnType = method.getReturnType();
              Class[] args = method.getParameterTypes();
              if ( returnType != Void.TYPE || args.length != 0 ) {
                throw new RuntimeException(
                    "Callback methods annotated on the bean class must return void and take no arguments: " + annotation
                        .getName() + " - " + xMethod
                );
              }
              if ( ! method.isAccessible() ) {
                method.setAccessible( true );
              }
              callbacks.add( 0, callback ); //superclass first
              callbacksMethodNames.add( 0, methodName );
            }
            else {
              throw new PersistenceException(
                  "You can only annotate one callback method with "
                      + annotation.getName() + " in bean class: " + beanClass.getName()
              );
            }
          }
        }
      }
      if ( !stopListeners ) {
        getListeners( currentClazz, orderedListeners );
        stopListeners = currentClazz.isAnnotationPresent( ExcludeSuperclassListeners.class );
        stopDefaultListeners = currentClazz.isAnnotationPresent( ExcludeDefaultListeners.class );
      }

      do {
        currentClazz = currentClazz.getSuperclass();
      }
      while ( currentClazz != null
          && ! ( currentClazz.isAnnotationPresent( Entity.class )
          || currentClazz.isAnnotationPresent( MappedSuperclass.class ) )
          );
    }
    while ( currentClazz != null );

    //handle default listeners
    if ( ! stopDefaultListeners ) {
      List<Class> defaultListeners = (List<Class>) reflectionManager.getDefaults().get( EntityListeners.class );

      if ( defaultListeners != null ) {
        int defaultListenerSize = defaultListeners.size();
        for ( int i = defaultListenerSize - 1; i >= 0 ; i-- ) {
          orderedListeners.add( defaultListeners.get( i ) );
        }
      }
    }

    for ( Class listener : orderedListeners ) {
      Callback callback = null;
      if ( listener != null ) {
        XClass xListener = reflectionManager.toXClass( listener );
        callbacksMethodNames = new ArrayList<String>();
        do {
          List<XMethod> methods = xListener.getDeclaredMethods();
          final int size = methods.size();
          for ( int i = 0; i < size ; i++ ) {
            final XMethod xMethod = methods.get( i );
            if ( xMethod.isAnnotationPresent( annotation ) ) {
              final Method method = reflectionManager.toMethod( xMethod );
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.