Java Code Examples for org.jboss.jandex.MethodInfo#declaringClass()

The following examples show how to use org.jboss.jandex.MethodInfo#declaringClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodValidatedAnnotationsTransformer.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private boolean requiresValidation(MethodInfo method) {
    if (method.annotations().isEmpty()) {
        // This method has no annotations of its own: look for inherited annotations
        ClassInfo clazz = method.declaringClass();
        String methodName = method.name().toString();
        for (Map.Entry<DotName, Set<String>> validatedMethod : inheritedAnnotationsToBeValidated.entrySet()) {
            if (clazz.interfaceNames().contains(validatedMethod.getKey())
                    && validatedMethod.getValue().contains(methodName)) {
                return true;
            }
        }
        return false;
    }

    for (DotName consideredAnnotation : consideredAnnotations) {
        if (method.hasAnnotation(consideredAnnotation)) {
            return true;
        }
    }

    return false;
}
 
Example 2
Source File: SpringSecurityProcessorUtil.java    From quarkus with Apache License 2.0 6 votes vote down vote up
static ClassInfo getClassInfoFromBeanName(String beanName, IndexView index, Map<String, DotName> springBeansNameToDotName,
        Map<String, ClassInfo> springBeansNameToClassInfo,
        String expression, MethodInfo methodInfo) {
    ClassInfo beanClassInfo = springBeansNameToClassInfo.get(beanName);
    if (beanClassInfo == null) {
        DotName beanClassDotName = springBeansNameToDotName.get(beanName);
        if (beanClassDotName == null) {
            throw new IllegalArgumentException("Could not find bean named '" + beanName
                    + "' found in expression" + expression + "' in the @PreAuthorize annotation on method "
                    + methodInfo.name() + " of class " + methodInfo.declaringClass()
                    + " in the set of the application beans");
        }
        beanClassInfo = index.getClassByName(beanClassDotName);
        if (beanClassInfo == null) {
            throw new IllegalStateException("Unable to locate class " + beanClassDotName + " in the index");
        }
        springBeansNameToClassInfo.put(beanName, beanClassInfo);
    }
    return beanClassInfo;
}
 
Example 3
Source File: SpringSecurityProcessorUtil.java    From quarkus with Apache License 2.0 6 votes vote down vote up
static int getParameterIndex(MethodInfo methodInfo, String parameterName, String expression) {
    int parametersCount = methodInfo.parameters().size();
    int matchingParameterIndex = -1;
    for (int i = 0; i < parametersCount; i++) {
        if (parameterName.equals(methodInfo.parameterName(i))) {
            matchingParameterIndex = i;
            break;
        }
    }

    if (matchingParameterIndex == -1) {
        throw new IllegalArgumentException(
                "Expression: '" + expression + "' in the @PreAuthorize annotation on method '" + methodInfo.name()
                        + "' of class '" + methodInfo.declaringClass() + "' references parameter " + parameterName
                        + " that the method does not declare");
    }
    return matchingParameterIndex;
}
 
Example 4
Source File: ResteasyServerCommonProcessor.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private static void scanMethodParameters(DotName annotationType,
        BuildProducer<ReflectiveHierarchyBuildItem> reflectiveHierarchy, IndexView index) {
    Collection<AnnotationInstance> instances = index.getAnnotations(annotationType);
    for (AnnotationInstance instance : instances) {
        if (instance.target().kind() != Kind.METHOD) {
            continue;
        }

        MethodInfo method = instance.target().asMethod();
        String source = method.declaringClass() + "[" + method + "]";

        reflectiveHierarchy.produce(new ReflectiveHierarchyBuildItem(method.returnType(), index,
                ResteasyDotNames.IGNORE_FOR_REFLECTION_PREDICATE, source));

        for (short i = 0; i < method.parameters().size(); i++) {
            Type parameterType = method.parameters().get(i);
            if (!hasAnnotation(method, i, ResteasyDotNames.CONTEXT)) {
                reflectiveHierarchy.produce(new ReflectiveHierarchyBuildItem(parameterType, index,
                        ResteasyDotNames.IGNORE_FOR_REFLECTION_PREDICATE, source));
            }
        }
    }
}
 
Example 5
Source File: HibernateValidatorProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private static void contributeMethodsWithInheritedValidation(Map<DotName, Set<String>> inheritedAnnotationsToBeValidated,
        IndexView indexView, MethodInfo method) {
    ClassInfo clazz = method.declaringClass();
    if (Modifier.isInterface(clazz.flags())) {
        // Remember annotated interface methods that must be validated
        inheritedAnnotationsToBeValidated.computeIfAbsent(clazz.name(), k -> new HashSet<String>())
                .add(method.name().toString());
    }
}
 
Example 6
Source File: StockMethodsAdder.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private FieldInfo getIdField(AnnotationTarget idAnnotationTarget) {
    if (idAnnotationTarget instanceof FieldInfo) {
        return idAnnotationTarget.asField();
    }

    MethodInfo methodInfo = idAnnotationTarget.asMethod();
    String propertyName = JavaBeanUtil.getPropertyNameFromGetter(methodInfo.name());
    ClassInfo entityClass = methodInfo.declaringClass();
    FieldInfo field = entityClass.field(propertyName);
    if (field == null) {
        throw new IllegalArgumentException("Entity " + entityClass + " does not appear to have a field backing method"
                + methodInfo.name() + " which is annotated with @Id");
    }
    return field;
}
 
Example 7
Source File: BeanMethodInvocationGenerator.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private MethodInfo determineMatchingBeanMethod(String methodName, int methodParametersSize, ClassInfo beanClassInfo,
        MethodInfo securedMethodInfo, String expression, String beanName) {
    MethodInfo matchingBeanClassMethod = null;
    for (MethodInfo candidateMethod : beanClassInfo.methods()) {
        if (candidateMethod.name().equals(methodName) &&
                Modifier.isPublic(candidateMethod.flags()) &&
                DotNames.PRIMITIVE_BOOLEAN.equals(candidateMethod.returnType().name()) &&
                candidateMethod.parameters().size() == methodParametersSize) {
            if (matchingBeanClassMethod == null) {
                matchingBeanClassMethod = candidateMethod;
            } else {
                throw new IllegalArgumentException(
                        "Could not match a unique method name '" + methodName + "' for bean named " + beanName
                                + " with class " + beanClassInfo.name() + " Offending expression is " +
                                expression + " of @PreAuthorize on method '" + methodName + "' of class "
                                + securedMethodInfo.declaringClass());
            }
        }
    }
    if (matchingBeanClassMethod == null) {
        throw new IllegalArgumentException(
                "Could not find a public, boolean returning method named '" + methodName + "' for bean named " + beanName
                        + " with class " + beanClassInfo.name() + " Offending expression is " +
                        expression + " of @PreAuthorize on method '" + methodName + "' of class "
                        + securedMethodInfo.declaringClass());
    }
    return matchingBeanClassMethod;
}
 
Example 8
Source File: StringPropertyAccessorData.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Called with data parsed from a Spring expression like #person.name that is places inside a Spring security annotation on
 * a method
 */
static StringPropertyAccessorData from(MethodInfo methodInfo, int matchingParameterIndex, String propertyName,
        IndexView index, String expression) {
    Type matchingParameterType = methodInfo.parameters().get(matchingParameterIndex);
    ClassInfo matchingParameterClassInfo = index.getClassByName(matchingParameterType.name());
    if (matchingParameterClassInfo == null) {
        throw new IllegalArgumentException(
                "Expression: '" + expression + "' in the @PreAuthorize annotation on method '" + methodInfo.name()
                        + "' of class '" + methodInfo.declaringClass() + "' references class "
                        + matchingParameterType.name() + " which could not be in Jandex");
    }
    FieldInfo matchingParameterFieldInfo = matchingParameterClassInfo.field(propertyName);
    if (matchingParameterFieldInfo == null) {
        throw new IllegalArgumentException(
                "Expression: '" + expression + "' in the @PreAuthorize annotation on method '" + methodInfo.name()
                        + "' of class '" + methodInfo.declaringClass() + "' references unknown property '"
                        + propertyName + "' of class " + matchingParameterClassInfo);
    }
    if (!DotNames.STRING.equals(matchingParameterFieldInfo.type().name())) {
        throw new IllegalArgumentException(
                "Expression: '" + expression + "' in the @PreAuthorize annotation on method '" + methodInfo.name()
                        + "' of class '" + methodInfo.declaringClass() + "' references property '"
                        + propertyName + "' which is not a string");
    }

    return new StringPropertyAccessorData(matchingParameterClassInfo, matchingParameterFieldInfo);
}
 
Example 9
Source File: HasRoleValueUtil.java    From quarkus with Apache License 2.0 5 votes vote down vote up
static HasRoleValueProducer getHasRoleValueProducer(String hasRoleValue, MethodInfo methodInfo, IndexView index,
        Map<String, DotName> springBeansNameToDotName,
        Map<String, ClassInfo> springBeansNameToClassInfo, Set<String> beansReferencedInPreAuthorized) {
    if (hasRoleValue.startsWith("'") && hasRoleValue.endsWith("'")) {
        return new StaticHasRoleValueProducer(hasRoleValue.replace("'", ""));
    } else if (hasRoleValue.startsWith("@")) {
        Matcher beanFieldMatcher = BEAN_FIELD_PATTERN.matcher(hasRoleValue);
        if (!beanFieldMatcher.find()) {
            throw SpringSecurityProcessorUtil.createGenericMalformedException(methodInfo, hasRoleValue);
        }

        String beanName = beanFieldMatcher.group(1);
        ClassInfo beanClassInfo = SpringSecurityProcessorUtil.getClassInfoFromBeanName(beanName, index,
                springBeansNameToDotName, springBeansNameToClassInfo, hasRoleValue, methodInfo);

        String fieldName = beanFieldMatcher.group(2);
        FieldInfo fieldInfo = beanClassInfo.field(fieldName);
        if ((fieldInfo == null) || !Modifier.isPublic(fieldInfo.flags())
                || !DotNames.STRING.equals(fieldInfo.type().name())) {
            throw new IllegalArgumentException("Bean named '" + beanName + "' found in expression '" + hasRoleValue
                    + "' in the @PreAuthorize annotation on method " + methodInfo.name() + " of class "
                    + methodInfo.declaringClass() + " does not have a public field named '" + fieldName
                    + "' of type String");
        }

        beansReferencedInPreAuthorized.add(fieldInfo.declaringClass().name().toString());

        return new FromBeanHasRoleValueProducer(beanName, fieldInfo);
    } else {
        throw SpringSecurityProcessorUtil.createGenericMalformedException(methodInfo, hasRoleValue);
    }
}
 
Example 10
Source File: TypeUtil.java    From serianalyzer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param i
 * @return
 * @throws SerianalyzerException
 */
static String makeSignature ( MethodInfo i, boolean fix ) throws SerianalyzerException {

    StringBuilder sb = new StringBuilder();
    sb.append('(');
    ClassInfo declaringImpl = i.declaringClass();
    if ( fix && "<init>".equals(i.name()) && declaringImpl.nestingType() == NestingType.INNER ) { //$NON-NLS-1$
        // there seems to be some sort of bug, missing the the outer instance parameter in the constructor
        if ( !Modifier.isStatic(declaringImpl.flags()) ) {
            org.jboss.jandex.Type enclosingClass = org.jboss.jandex.Type.create(declaringImpl.enclosingClass(), Kind.CLASS);
            org.jboss.jandex.Type firstArg = i.parameters().size() > 0 ? i.parameters().get(0) : null;
            if ( firstArg instanceof TypeVariable ) {
                firstArg = firstArg.asTypeVariable().bounds().get(0);
            }
            if ( firstArg == null || !firstArg.equals(enclosingClass) ) {
                sb.append(toString(enclosingClass));
            }
        }
    }

    for ( org.jboss.jandex.Type p : i.parameters() ) {
        sb.append(toString(p));
    }
    sb.append(')');
    sb.append(toString(i.returnType()));
    return sb.toString();
}
 
Example 11
Source File: ParameterProcessor.java    From smallrye-open-api with Apache License 2.0 4 votes vote down vote up
/**
 * Process parameter annotations for the given class and method.This method operates
 * in two phases. First, class-level parameters are processed and saved in the
 * {@link ResourceParameters}. Second, method-level parameters are processed. Form parameters
 * are only applicable to the method-level in this component.
 *
 * @param context the AnnotationScannerContext
 * @param resourceClass the class info
 * @param resourceMethod the JAX-RS resource method, annotated with one of the
 *        JAX-RS HTTP annotations
 * @param reader callback method for a function producing {@link Parameter} from a
 *        {@link org.eclipse.microprofile.openapi.annotations.parameters.Parameter}
 * @param extensions scanner extensions
 * @return scanned parameters and modified path contained in a {@link ResourceParameters}
 *         object
 */
public static ResourceParameters process(AnnotationScannerContext context,
        ClassInfo resourceClass,
        MethodInfo resourceMethod,
        Function<AnnotationInstance, Parameter> reader,
        List<AnnotationScannerExtension> extensions) {
    ResourceParameters parameters = new ResourceParameters();
    ParameterProcessor processor = new ParameterProcessor(context, reader, extensions);

    ClassInfo resourceMethodClass = resourceMethod.declaringClass();

    /*
     * Phase I - Read class fields, constructors, "setter" methods not annotated with JAX-RS
     * HTTP method. Check both the class declaring the method as well as the resource
     * class, if different.
     */
    processor.readParametersInherited(resourceMethodClass, null, false);

    if (!resourceClass.equals(resourceMethodClass)) {
        /*
         * The resource class may be a subclass/implementor of the resource method class. Scanning
         * the resource class after the method's class allows for parameter details to be overridden
         * by annotations in the subclass.
         */
        processor.readParameters(resourceClass, null, true);
    }

    parameters.setPathItemParameters(processor.getParameters(resourceMethod));

    // Clear Path-level parameters discovered and allows for processing operation-level parameters
    processor.reset();

    // Phase II - Read method argument @Parameter and JAX-RS *Param annotations
    resourceMethod.annotations()
            .stream()
            .filter(a -> !a.target().equals(resourceMethod))
            // TODO: Replace 'forEach' below with ".forEach(processor::readAnnotatedType);" once @Parameters no longer need to be supported on method arguments
            .forEach(annotation -> {
                /*
                 * This condition exists to support @Parameters wrapper annotation
                 * on method parameters until (if?) the MP-OAI TCK is changed.
                 */
                if (openApiParameterAnnotations.contains(annotation.name())) {
                    processor.readParameterAnnotation(annotation);
                } else {
                    processor.readAnnotatedType(annotation);
                }
            });

    // Phase III - Read method @Parameter(s) annotations
    resourceMethod.annotations()
            .stream()
            .filter(a -> a.target().equals(resourceMethod))
            .filter(a -> openApiParameterAnnotations.contains(a.name()))
            .forEach(processor::readParameterAnnotation);

    parameters.setOperationParameters(processor.getParameters(resourceMethod));

    /*
     * Working list of all parameters.
     */
    List<Parameter> allParameters = parameters.getAllParameters();
    /*
     * Generate the path using the provided resource class, which may differ from the method's declaring
     * class - e.g. for inheritance.
     */
    parameters.setPathItemPath(processor.generatePath(resourceClass, allParameters));
    parameters.setOperationPath(processor.generatePath(resourceMethod, allParameters));

    // Re-sort (names of matrix parameters may have changed)
    parameters.sort();

    parameters.setFormBodyContent(processor.getFormBodyContent());

    return parameters;
}
 
Example 12
Source File: BeanGenerator.java    From quarkus with Apache License 2.0 4 votes vote down vote up
Collection<Resource> generateProducerMethodBean(BeanInfo bean, MethodInfo producerMethod) {

        ClassInfo declaringClass = producerMethod.declaringClass();
        String declaringClassBase;
        if (declaringClass.enclosingClass() != null) {
            declaringClassBase = DotNames.simpleName(declaringClass.enclosingClass()) + UNDERSCORE
                    + DotNames.simpleName(declaringClass);
        } else {
            declaringClassBase = DotNames.simpleName(declaringClass);
        }

        Type providerType = bean.getProviderType();
        StringBuilder sigBuilder = new StringBuilder();
        sigBuilder.append(producerMethod.name())
                .append(UNDERSCORE)
                .append(producerMethod.returnType().name().toString());

        for (Type i : producerMethod.parameters()) {
            sigBuilder.append(i.name().toString());
        }

        String baseName = declaringClassBase + PRODUCER_METHOD_SUFFIX + UNDERSCORE + producerMethod.name() + UNDERSCORE
                + Hashes.sha1(sigBuilder.toString());
        String providerTypeName = providerType.name().toString();
        String targetPackage = DotNames.packageName(declaringClass.name());
        String generatedName = generatedNameFromTarget(targetPackage, baseName, BEAN_SUFFIX);
        beanToGeneratedName.put(bean, generatedName);
        if (existingClasses.contains(generatedName)) {
            return Collections.emptyList();
        }

        boolean isApplicationClass = applicationClassPredicate.test(declaringClass.name());
        ResourceClassOutput classOutput = new ResourceClassOutput(isApplicationClass,
                name -> name.equals(generatedName) ? SpecialType.BEAN : null, generateSources);

        // Foo_Bean implements InjectableBean<T>
        ClassCreator beanCreator = ClassCreator.builder().classOutput(classOutput).className(generatedName)
                .interfaces(InjectableBean.class, Supplier.class).build();

        // Fields
        FieldCreator beanTypes = beanCreator.getFieldCreator(FIELD_NAME_BEAN_TYPES, Set.class)
                .setModifiers(ACC_PRIVATE | ACC_FINAL);
        FieldCreator qualifiers = null;
        if (!bean.getQualifiers().isEmpty() && !bean.hasDefaultQualifiers()) {
            qualifiers = beanCreator.getFieldCreator(FIELD_NAME_QUALIFIERS, Set.class).setModifiers(ACC_PRIVATE | ACC_FINAL);
        }
        if (bean.getScope().isNormal()) {
            // For normal scopes a client proxy is generated too
            initializeProxy(bean, baseName, beanCreator);
        }
        FieldCreator stereotypes = null;
        if (!bean.getStereotypes().isEmpty()) {
            stereotypes = beanCreator.getFieldCreator(FIELD_NAME_STEREOTYPES, Set.class).setModifiers(ACC_PRIVATE | ACC_FINAL);
        }

        Map<InjectionPointInfo, String> injectionPointToProviderField = new HashMap<>();
        // Producer methods are not intercepted
        initMaps(bean, injectionPointToProviderField, null);

        createProviderFields(beanCreator, bean, injectionPointToProviderField, Collections.emptyMap());
        createConstructor(classOutput, beanCreator, bean, baseName, injectionPointToProviderField, Collections.emptyMap(),
                annotationLiterals, reflectionRegistration);

        implementGetIdentifier(bean, beanCreator);
        implementSupplierGet(beanCreator);
        if (!bean.hasDefaultDestroy()) {
            implementDestroy(bean, beanCreator, providerTypeName, injectionPointToProviderField, reflectionRegistration,
                    isApplicationClass, baseName);
        }
        implementCreate(classOutput, beanCreator, bean, providerTypeName, baseName, injectionPointToProviderField,
                Collections.emptyMap(),
                reflectionRegistration, targetPackage, isApplicationClass);
        implementGet(bean, beanCreator, providerTypeName, baseName);

        implementGetTypes(beanCreator, beanTypes.getFieldDescriptor());
        if (!BuiltinScope.isDefault(bean.getScope())) {
            implementGetScope(bean, beanCreator);
        }
        if (qualifiers != null) {
            implementGetQualifiers(bean, beanCreator, qualifiers.getFieldDescriptor());
        }
        if (bean.isAlternative()) {
            implementGetAlternativePriority(bean, beanCreator);
        }
        implementGetDeclaringBean(beanCreator);
        if (stereotypes != null) {
            implementGetStereotypes(bean, beanCreator, stereotypes.getFieldDescriptor());
        }
        implementGetBeanClass(bean, beanCreator);
        implementGetName(bean, beanCreator);
        if (bean.isDefaultBean()) {
            implementIsDefaultBean(bean, beanCreator);
        }
        implementGetKind(beanCreator, InjectableBean.Kind.PRODUCER_METHOD);

        beanCreator.close();
        return classOutput.getResources();
    }
 
Example 13
Source File: InterceptorInfo.java    From quarkus with Apache License 2.0 4 votes vote down vote up
/**
 *
 * @param target
 * @param beanDeployment
 * @param bindings
 * @param injections
 */
InterceptorInfo(AnnotationTarget target, BeanDeployment beanDeployment, Set<AnnotationInstance> bindings,
        List<Injection> injections, int priority) {
    super(target, beanDeployment, BuiltinScope.DEPENDENT.getInfo(),
            Collections.singleton(Type.create(target.asClass().name(), Kind.CLASS)), new HashSet<>(), injections,
            null, null, null, Collections.emptyList(), null, false);
    this.bindings = bindings;
    this.priority = priority;
    MethodInfo aroundInvoke = null;
    MethodInfo aroundConstruct = null;
    MethodInfo postConstruct = null;
    MethodInfo preDestroy = null;
    for (MethodInfo method : target.asClass().methods()) {
        if (aroundInvoke == null && method.hasAnnotation(DotNames.AROUND_INVOKE)) {
            aroundInvoke = method;
        } else if (method.hasAnnotation(DotNames.AROUND_CONSTRUCT)) {
            // validate compliance with rules for AroundConstruct methods
            if (!method.parameters().equals(Collections.singletonList(
                    Type.create(DotName.createSimple("javax.interceptor.InvocationContext"), Type.Kind.CLASS)))) {
                throw new IllegalStateException(
                        "@AroundConstruct must have exactly one argument of type javax.interceptor.InvocationContext, but method "
                                + method.asMethod() + " declared by " + method.declaringClass()
                                + " violates this.");
            }
            if (!method.returnType().kind().equals(Type.Kind.VOID) &&
                    !method.returnType().name().equals(DotNames.OBJECT)) {
                throw new IllegalStateException("Return type of @AroundConstruct method must be Object or void, but method "
                        + method.asMethod() + " declared by " + method.declaringClass()
                        + " violates this.");
            }
            aroundConstruct = method;
        } else if (postConstruct == null && method.hasAnnotation(DotNames.POST_CONSTRUCT)) {
            postConstruct = method;
        } else if (preDestroy == null && method.hasAnnotation(DotNames.PRE_DESTROY)) {
            preDestroy = method;
        }
    }
    this.aroundInvoke = aroundInvoke;
    this.aroundConstruct = aroundConstruct;
    this.postConstruct = postConstruct;
    this.preDestroy = preDestroy;
    if (aroundConstruct == null && aroundInvoke == null && preDestroy == null && postConstruct == null) {
        LOGGER.warnf("%s declares no around-invoke method nor a lifecycle callback!", this);
    }
}
 
Example 14
Source File: ExtensionMethodGenerator.java    From quarkus with Apache License 2.0 4 votes vote down vote up
public void generate(MethodInfo method, String matchName, Integer priority) {

        // Validate the method first
        validate(method);
        ClassInfo declaringClass = method.declaringClass();
        AnnotationInstance extensionAnnotation = method.annotation(TEMPLATE_EXTENSION);

        if (matchName == null && extensionAnnotation != null) {
            // No explicit name defined, try annotation
            AnnotationValue matchNameValue = extensionAnnotation.value(MATCH_NAME);
            if (matchNameValue != null) {
                matchName = matchNameValue.asString();
            }
        }
        if (matchName == null || matchName.equals(TemplateExtension.METHOD_NAME)) {
            matchName = method.name();
        }
        List<Type> parameters = method.parameters();
        if (matchName.equals(TemplateExtension.ANY)) {
            // Special constant used - the second parameter must be a string
            if (parameters.size() < 2 || !parameters.get(1).name().equals(STRING)) {
                throw new IllegalStateException(
                        "Template extension method matching multiple names must declare at least two parameters and the second parameter must be string: "
                                + method);
            }
        }

        if (priority == null && extensionAnnotation != null) {
            // No explicit priority set, try annotation
            AnnotationValue priorityValue = extensionAnnotation.value(PRIORITY);
            if (priorityValue != null) {
                priority = priorityValue.asInt();
            }
        }
        if (priority == null) {
            priority = TemplateExtension.DEFAULT_PRIORITY;
        }

        String baseName;
        if (declaringClass.enclosingClass() != null) {
            baseName = simpleName(declaringClass.enclosingClass()) + ValueResolverGenerator.NESTED_SEPARATOR
                    + simpleName(declaringClass);
        } else {
            baseName = simpleName(declaringClass);
        }
        String targetPackage = packageName(declaringClass.name());

        String suffix = SUFFIX + "_" + method.name() + "_" + sha1(parameters.toString());
        String generatedName = generatedNameFromTarget(targetPackage, baseName, suffix);
        generatedTypes.add(generatedName.replace('/', '.'));

        ClassCreator valueResolver = ClassCreator.builder().classOutput(classOutput).className(generatedName)
                .interfaces(ValueResolver.class).build();

        implementGetPriority(valueResolver, priority);
        implementAppliesTo(valueResolver, method, matchName);
        implementResolve(valueResolver, declaringClass, method, matchName);

        valueResolver.close();
    }
 
Example 15
Source File: SpringSecurityProcessorUtil.java    From quarkus with Apache License 2.0 4 votes vote down vote up
static IllegalArgumentException createGenericMalformedException(MethodInfo methodInfo, String expression) {
    return new IllegalArgumentException(
            "Expression: '" + expression + "' in the @PreAuthorize annotation on method '" + methodInfo.name()
                    + "' of class '" + methodInfo.declaringClass() + "' is malformed");
}
 
Example 16
Source File: QuarkusMediatorConfigurationUtil.java    From quarkus with Apache License 2.0 4 votes vote down vote up
private static String fullMethodName(MethodInfo methodInfo) {
    return methodInfo.declaringClass() + "#" + methodInfo.name();
}