1 Reply Latest reply on Oct 8, 2013 1:20 PM by James Perkins

    How to check if return type in MessageBundle is subclass of my own Exception in jboss logging tools source code

    Yaguo Zhou Newbie

      Hi:

          I am doing some hack on jboss logging tool recently and i meet some problems.

       

      I've created a root exception class named BaseException for my application .

      public class BaseException extends Exception {

          blabla

      }

      and i also have created a sub exception class named BusinessException which extends BaseException

      public class BusinessException extends BaseException {

          blabla

      }

      and my MessageBundle interface is:

      @MessageBundle(projectCode = "AAA")

      public interface MyProjectMessages {

       

          @Message("This is my error message")

          BusinessException loggingException(@Cause Exception e);

      }

       

      So problem is how can i check if the return type is subclass of my root exception class when org.jboss.logging.processor.generator.model.ImplementationClassModel create the source file? What i want is like:

      org.jboss.logging.processor.generator.model.ImplementationClassModel

       

      .....

       

      if (messageMethod.returnType().isThrowable()) {

           boolean isMyOwnException;

           // here i've tried generateModel().directClass(BaseException.class.getName()).isAssignableFrom(returnField), but got no luck. I guess jboss logging tool generate source file first and then mvn compile, so jboss logging tool can not get my class before it's compiled.

           if (isMyOwnException){

                blabla

           } else {

               blabla

           }

       

      .....

       

      Any ideas?

      Regards