/** * Create java code to add function copy paste into * GeoSpatialFunctionsAddRemove to upload it * @param st SQL Statement * @param function Function instance * @param packagePrepend For OSGi environment only, use Bundle-SymbolicName:Bundle-Version: */ public static void registerFunction(Statement st,Function function,String packagePrepend) throws SQLException { registerFunction(st,function,packagePrepend,true); }
/** * Register all built-ins function * @param connection JDBC Connection * @param packagePrepend For OSGi environment only, use Bundle-SymbolicName:Bundle-Version: * @throws SQLException */ private static void addSpatialFunctions(Connection connection,String packagePrepend) throws SQLException { Statement st = connection.createStatement(); for(Function function : getBuiltInsFunctions()) { try { registerFunction(st,function,packagePrepend); } catch (SQLException ex) { // Catch to register other functions ex.printStackTrace(System.err); } } }
@Override public Function addingService(ServiceReference<Function> reference) { // Do not register system functions (h2spatial functions) because it should already be done through initialisation. if(reference.getBundle().getBundleId() != context.getBundle().getBundleId()) { Function function = super.addingService(reference); try { Connection connection = dataSource.getConnection(); try { CreateSpatialExtension.registerFunction(connection.createStatement(), function, ""); //bundle.getSymbolicName() + ":" + bundle.getVersion().toString() + ":" } finally { connection.close(); } } catch (SQLException ex) { LOGGER.error(ex.getLocalizedMessage(), ex); } return function; } else { return super.addingService(reference); } }