Package org.jboss.jandex

Examples of org.jboss.jandex.MethodInfo


  private void createDefaultCallback(Class callbackTypeClass,
                     DotName callbackTypeName,
                     String callbackClassName,
                     Map<Class<?>, String> callbacksByClass) {
    for ( AnnotationInstance callback : getLocalBindingContext().getIndex().getAnnotations( callbackTypeName ) ) {
      MethodInfo methodInfo = (MethodInfo) callback.target();
      validateMethod( methodInfo, callbackTypeClass, callbacksByClass, true );
      if ( methodInfo.declaringClass().name().toString().equals( callbackClassName ) ) {
        if ( methodInfo.args().length != 1 ) {
          throw new PersistenceException(
              String.format(
                  "Callback method %s must have exactly one argument defined as either Object or %s in ",
                  methodInfo.name(),
                  getEntityName()
              )
          );
        }
        callbacksByClass.put( callbackTypeClass, methodInfo.name() );
      }
    }
  }
View Full Code Here


    List<AnnotationInstance> annotationInstances = annotations.get( callbackTypeName );
    if ( annotationInstances == null ) {
      return;
    }
    for ( AnnotationInstance callbackAnnotation : annotationInstances ) {
      MethodInfo methodInfo = (MethodInfo) callbackAnnotation.target();
      validateMethod( methodInfo, callbackTypeClass, callbacksByClass, isListener );
      callbacksByClass.put( callbackTypeClass, methodInfo.name() );
    }
  }
View Full Code Here

      {
         AnnotationTarget target = instance.target();
         Annotation annotation = null;
         if (target instanceof MethodInfo)
         {
            MethodInfo m = (MethodInfo) target;
            List<String> parameterTypes = new ArrayList<String>(m.args().length);
            for (Type type : m.args())
            {
               parameterTypes.add(type.toString());
            }
            String declaringClass = m.declaringClass().name().toString();
            annotation = new AnnotationImpl(declaringClass, cl, parameterTypes, m.name(), true, false, annotationClass);
         }
         else if (target instanceof FieldInfo)
         {
            FieldInfo f = (FieldInfo) target;
            String declaringClass = f.declaringClass().name().toString();
View Full Code Here

        ArrayList<Annotation> annotations = new ArrayList<Annotation>(instances.size());
        for (AnnotationInstance instance : instances) {
            AnnotationTarget target = instance.target();
            Annotation annotation = null;
            if (target instanceof MethodInfo) {
                MethodInfo m = (MethodInfo) target;
                List<String> parameterTypes = new ArrayList<String>(m.args().length);
                for (Type type : m.args()) {
                    parameterTypes.add(type.toString());
                }
                String declaringClass = m.declaringClass().name().toString();
                annotation = new AnnotationImpl(declaringClass, cl, parameterTypes, m.name(), true, false, annotationClass);
            }
            if (target instanceof FieldInfo) {
                FieldInfo f = (FieldInfo) target;
                String declaringClass = f.declaringClass().name().toString();
                annotation = new AnnotationImpl(declaringClass, cl, null, f.name(), false, true, annotationClass);
View Full Code Here

        }
        return instances;
    }

    private MethodIdentifier getMethodIdentifier(final AnnotationTarget target) {
        final MethodInfo methodInfo = MethodInfo.class.cast(target);
        final String[] args = new String[methodInfo.args().length];
        for (int i = 0; i < methodInfo.args().length; i++) {
            args[i] = methodInfo.args()[i].name().toString();
        }
        return MethodIdentifier.getIdentifier(methodInfo.returnType().name().toString(), methodInfo.name(), args);
    }
View Full Code Here

    private void processLifeCycle(final EEModuleDescription eeModuleDescription, final AnnotationTarget target, final DotName annotationType, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
        if (!(target instanceof MethodInfo)) {
            throw MESSAGES.methodOnlyAnnotation(annotationType);
        }
        final MethodInfo methodInfo = MethodInfo.class.cast(target);
        final ClassInfo classInfo = methodInfo.declaringClass();
        final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());

        final Type[] args = methodInfo.args();
        if (args.length > 1) {
            ROOT_LOGGER.warn(MESSAGES.invalidNumberOfArguments(methodInfo.name(), annotationType, classInfo.name()));
            return;
        } else if (args.length == 1 && !args[0].name().toString().equals(InvocationContext.class.getName())) {
            ROOT_LOGGER.warn(MESSAGES.invalidSignature(methodInfo.name(), annotationType, classInfo.name(), "void methodName(InvocationContext ctx)"));
            return;
        }

        final MethodIdentifier methodIdentifier;
        if (args.length == 0) {
            methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name());
        } else {
            methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name(), InvocationContext.class);
        }
        final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription());
        if (annotationType == POST_CONSTRUCT_ANNOTATION) {
            builder.setPostConstruct(methodIdentifier);
        } else {
View Full Code Here

                final FieldInfo fieldInfo = (FieldInfo) annotationTarget;
                final ClassInfo classInfo = fieldInfo.declaringClass();
                EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
                processFieldResource(phaseContext, fieldInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses);
            } else if (annotationTarget instanceof MethodInfo) {
                final MethodInfo methodInfo = (MethodInfo) annotationTarget;
                ClassInfo classInfo = methodInfo.declaringClass();
                EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
                processMethodResource(phaseContext, methodInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses);
            } else if (annotationTarget instanceof ClassInfo) {
                final ClassInfo classInfo = (ClassInfo) annotationTarget;
                EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
View Full Code Here

    private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException {
        if (!(target instanceof MethodInfo)) {
            throw MESSAGES.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME);
        }
        final MethodInfo methodInfo = MethodInfo.class.cast(target);
        final ClassInfo classInfo = methodInfo.declaringClass();
        final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());

        validateArgumentType(classInfo, methodInfo);
        InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription());
        builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class));
        classDescription.setInterceptorClassDescription(builder.build());
    }
View Full Code Here

                FieldInfo fieldInfo = (FieldInfo) annotationTarget;
                declaringClass = fieldInfo.declaringClass();
                EEModuleClassDescription eeModuleClassDescription = eeModuleDescription.addOrGetLocalClassDescription(declaringClass.name().toString());
                this.processField(deploymentUnit, annotation, fieldInfo, eeModuleClassDescription);
            } else if (annotationTarget instanceof MethodInfo) {
                MethodInfo methodInfo = (MethodInfo) annotationTarget;
                declaringClass = methodInfo.declaringClass();
                EEModuleClassDescription eeModuleClassDescription = eeModuleDescription.addOrGetLocalClassDescription(declaringClass.name().toString());
                this.processMethod(deploymentUnit, annotation, methodInfo, eeModuleClassDescription);
            } else if (annotationTarget instanceof ClassInfo) {
                declaringClass = (ClassInfo) annotationTarget;
                EEModuleClassDescription eeModuleClassDescription = eeModuleDescription.addOrGetLocalClassDescription(declaringClass.name().toString());
View Full Code Here

    private void processPassivation(final EEModuleDescription eeModuleDescription, final AnnotationTarget target, final DotName annotationType, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
        if (!(target instanceof MethodInfo)) {
            throw MESSAGES.methodOnlyAnnotation(annotationType);
        }
        final MethodInfo methodInfo = MethodInfo.class.cast(target);
        final ClassInfo classInfo = methodInfo.declaringClass();
        final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString());

        final Type[] args = methodInfo.args();
        if (args.length > 1) {
            ROOT_LOGGER.warn(MESSAGES.invalidNumberOfArguments(methodInfo.name(), annotationType, classInfo.name()));
            return;
        } else if (args.length == 1 && !args[0].name().toString().equals(InvocationContext.class.getName())) {
            ROOT_LOGGER.warn(MESSAGES.invalidSignature(methodInfo.name(), annotationType, classInfo.name(), "void methodName(InvocationContext ctx)"));
            return;
        }

        final MethodIdentifier methodIdentifier;
        if (args.length == 0) {
            methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name());
        } else {
            methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name(), InvocationContext.class);
        }
        final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription());
        if (annotationType == POST_ACTIVATE) {
            builder.setPostActivate(methodIdentifier);
        } else {
View Full Code Here

TOP

Related Classes of org.jboss.jandex.MethodInfo

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.