Package org.hibernate.reflection

Examples of org.hibernate.reflection.XMethod


    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 );
              final String methodName = method.getName();
              if ( ! callbacksMethodNames.contains( methodName ) ) {
                //overriden method, remove the superclass overriden method
                if ( callback == null ) {
View Full Code Here

TOP

Related Classes of org.hibernate.reflection.XMethod

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.