use of org.neo4j.kernel.api.proc.FailedLoadFunction in project neo4j by neo4j.
the class ReflectiveProcedureCompiler method compileFunction.
private CallableUserFunction compileFunction(Class<?> procDefinition, MethodHandle constructor, Method method, QualifiedName procName) throws ProcedureException, IllegalAccessException {
if (procName.namespace() == null || procName.namespace().length == 0) {
throw new ProcedureException(Status.Procedure.ProcedureRegistrationFailed, "It is not allowed to define functions in the root namespace please use a namespace, e.g. `@UserFunction(\"org.example.com.%s\")", procName.name());
}
List<FieldSignature> inputSignature = inputSignatureDeterminer.signatureFor(method);
Class<?> returnType = method.getReturnType();
TypeMappers.NeoValueConverter valueConverter = typeMappers.converterFor(returnType);
MethodHandle procedureMethod = lookup.unreflect(method);
Optional<String> description = description(method);
UserFunction function = method.getAnnotation(UserFunction.class);
Optional<String> deprecated = deprecated(method, function::deprecatedBy, "Use of @UserFunction(deprecatedBy) without @Deprecated in " + procName);
List<FieldInjections.FieldSetter> setters = allFieldInjections.setters(procDefinition);
if (!config.fullAccessFor(procName.toString())) {
try {
setters = safeFieldInjections.setters(procDefinition);
} catch (ComponentInjectionException e) {
description = Optional.of(procName.toString() + " is not available due to having restricted access rights, check configuration.");
log.warn(description.get());
UserFunctionSignature signature = new UserFunctionSignature(procName, inputSignature, valueConverter.type(), deprecated, config.rolesFor(procName.toString()), description);
return new FailedLoadFunction(signature);
}
}
UserFunctionSignature signature = new UserFunctionSignature(procName, inputSignature, valueConverter.type(), deprecated, config.rolesFor(procName.toString()), description);
return new ReflectiveUserFunction(signature, constructor, procedureMethod, valueConverter, setters);
}
Aggregations