/** * Register a new function defined with annotations on a java class. * @param func the function class */ public void registerBuiltInFunctions( Class<?> func ) throws KernelException { for ( CallableUserFunction function : compiler.withoutNamingRestrictions().compileFunction( func ) ) { register( function, false ); } }
/** * Register a new function defined with annotations on a java class. * @param func the function class */ public void registerFunction( Class<?> func, boolean overrideCurrentImplementation ) throws KernelException { for ( CallableUserFunction function : compiler.compileFunction( func ) ) { register( function, overrideCurrentImplementation ); } }
/** * Register a new aggregation function defined with annotations on a java class. * @param func the function class */ public void registerAggregationFunction( Class<?> func, boolean overrideCurrentImplementation ) throws KernelException { for ( CallableUserAggregationFunction function : compiler.compileAggregationFunction( func ) ) { register( function, overrideCurrentImplementation ); } }
/** * Register a new internal procedure defined with annotations on a java class. * @param proc the procedure class */ public void registerProcedure( Class<?> proc ) throws KernelException { registerProcedure( proc, false ); }
private Callables loadProcedures( URL jar, ClassLoader loader, Callables target ) throws IOException, KernelException { RawIterator<Class<?>,IOException> classes = listClassesIn( jar, loader ); while ( classes.hasNext() ) { Class<?> next = classes.next(); target.addAllProcedures( compiler.compileProcedure( next, null, false ) ); target.addAllFunctions( compiler.compileFunction( next ) ); target.addAllAggregationFunctions( compiler.compileAggregationFunction( next ) ); } return target; }
/** * Register a new internal procedure defined with annotations on a java class. * @param proc the procedure class * @param overrideCurrentImplementation set to true if procedures within this class should override older procedures with the same name * @param warning the warning the procedure should generate when called */ public void registerProcedure( Class<?> proc, boolean overrideCurrentImplementation, String warning ) throws KernelException { for ( CallableProcedure procedure : compiler.compileProcedure( proc, warning, true ) ) { register( procedure, overrideCurrentImplementation ); } }
/** * Register a new function. This method must not be called concurrently with {@link #procedure(QualifiedName)}. * @param function the function. */ public void register( CallableUserFunction function ) throws ProcedureException { register( function, false ); }
@Before public void setUp() { ComponentRegistry safeComponents = new ComponentRegistry(); ComponentRegistry allComponents = new ComponentRegistry(); safeComponents.register( MyAwesomeAPI.class, ctx -> new MyAwesomeAPI() ); allComponents.register( MyAwesomeAPI.class, ctx -> new MyAwesomeAPI() ); allComponents.register( MyUnsafeAPI.class, ctx -> new MyUnsafeAPI() ); compiler = new ReflectiveProcedureCompiler( new TypeMappers(), safeComponents, allComponents, log, ProcedureConfig.DEFAULT ); }
ReflectiveProcedureCompiler( TypeMappers typeMappers, ComponentRegistry safeComponents, ComponentRegistry allComponents, Log log, ProcedureConfig config ) { this( new MethodSignatureCompiler( typeMappers ), new OutputMappers( typeMappers ), new FieldInjections( safeComponents ), new FieldInjections( allComponents ), log, typeMappers, config, ReflectiveProcedureCompiler::rejectEmptyNamespace ); }
private List<CallableProcedure> compile( Class<?> clazz ) throws KernelException { return new ReflectiveProcedureCompiler( new TypeMappers(), new ComponentRegistry(), new ComponentRegistry(), NullLog.getInstance(), ProcedureConfig.DEFAULT ).compileProcedure( clazz, null, true ); } }
private OutputMapper mapper( Class<?> clazz ) throws ProcedureException { return new OutputMappers( new TypeMappers() ).mapper( clazz ); }
private ComponentRegistry registryWithUnsafeAPI() { ComponentRegistry allComponents = new ComponentRegistry(); allComponents.register( UnsafeAPI.class, ctx -> new UnsafeAPI() ); return allComponents; }
/** * Registers a type and its mapping to Neo4jTypes * * @param javaClass * the class of the native type * @param type * the mapping to Neo4jTypes */ public void registerType( Class<?> javaClass, Neo4jTypes.AnyType type ) { typeMappers.registerType( javaClass, new TypeMappers.DefaultValueConverter( type, javaClass ) ); }
protected void inject( Context ctx, Object object ) throws ProcedureException { for ( FieldInjections.FieldSetter setter : fieldSetters ) { setter.apply( ctx, object ); } }
private List<CallableUserFunction> compile( Class<?> clazz ) throws KernelException { return procedureCompiler.compileFunction( clazz ); } }
public RawIterator<Object[], ProcedureException> callProcedure( Context ctx, QualifiedName name, Object[] input, ResourceTracker resourceTracker ) throws ProcedureException { return registry.callProcedure( ctx, name, input, resourceTracker ); }
/** * Register a new internal procedure defined with annotations on a java class. * @param proc the procedure class * @param overrideCurrentImplementation set to true if procedures within this class should override older procedures with the same name */ public void registerProcedure( Class<?> proc, boolean overrideCurrentImplementation ) throws KernelException { registerProcedure( proc, overrideCurrentImplementation, null ); }
@Override public void registerUserFunction( CallableUserFunction function ) throws ProcedureException { procedures.register( function ); }
/** * Register a new function. This method must not be called concurrently with {@link #procedure(QualifiedName)}. * @param function the function. */ public void register( CallableUserAggregationFunction function ) throws ProcedureException { register( function, false ); }