Search in sources :

Example 1 with FailedLoadFunction

use of org.neo4j.kernel.api.procedure.FailedLoadFunction in project neo4j by neo4j.

the class ProcedureCompiler method compileFunction.

private CallableUserFunction compileFunction(Class<?> procDefinition, Method method, QualifiedName procName) throws ProcedureException {
    restrictions.verify(procName);
    List<FieldSignature> inputSignature = inputSignatureDeterminer.signatureFor(method);
    Class<?> returnType = method.getReturnType();
    TypeCheckers.TypeChecker typeChecker = typeCheckers.checkerFor(returnType);
    String description = description(method);
    UserFunction function = method.getAnnotation(UserFunction.class);
    String deprecated = deprecated(method, function::deprecatedBy, "Use of @UserFunction(deprecatedBy) without @Deprecated in " + procName);
    List<FieldSetter> setters = allFieldInjections.setters(procDefinition);
    if (!config.fullAccessFor(procName.toString())) {
        try {
            setters = safeFieldInjections.setters(procDefinition);
        } catch (ComponentInjectionException e) {
            description = describeAndLogLoadFailure(procName);
            UserFunctionSignature signature = new UserFunctionSignature(procName, inputSignature, typeChecker.type(), deprecated, config.rolesFor(procName.toString()), description, null, false);
            return new FailedLoadFunction(signature);
        }
    }
    UserFunctionSignature signature = new UserFunctionSignature(procName, inputSignature, typeChecker.type(), deprecated, config.rolesFor(procName.toString()), description, null, false);
    return ProcedureCompilation.compileFunction(signature, setters, method);
}
Also used : FieldSignature(org.neo4j.internal.kernel.api.procs.FieldSignature) UserFunctionSignature(org.neo4j.internal.kernel.api.procs.UserFunctionSignature) FailedLoadFunction(org.neo4j.kernel.api.procedure.FailedLoadFunction) CallableUserFunction(org.neo4j.kernel.api.procedure.CallableUserFunction) UserFunction(org.neo4j.procedure.UserFunction) ComponentInjectionException(org.neo4j.kernel.api.exceptions.ComponentInjectionException)

Aggregations

FieldSignature (org.neo4j.internal.kernel.api.procs.FieldSignature)1 UserFunctionSignature (org.neo4j.internal.kernel.api.procs.UserFunctionSignature)1 ComponentInjectionException (org.neo4j.kernel.api.exceptions.ComponentInjectionException)1 CallableUserFunction (org.neo4j.kernel.api.procedure.CallableUserFunction)1 FailedLoadFunction (org.neo4j.kernel.api.procedure.FailedLoadFunction)1 UserFunction (org.neo4j.procedure.UserFunction)1