@Override public void removedService(ServiceReference<Function> reference, Function service) { // Do not unregister system functions (h2spatial functions) if(reference.getBundle().getBundleId() != context.getBundle().getBundleId()) { try { Connection connection = dataSource.getConnection(); try { CreateSpatialExtension.unRegisterFunction(connection.createStatement(), service); } finally { connection.close(); } } catch (SQLException ex) { LOGGER.error(ex.getLocalizedMessage(), ex); } super.removedService(reference, service); } } }
/** * Remove spatial type and functions from the current connection. * @param connection Active H2 connection with DROP ALIAS rights */ public static void disposeSpatialExtension(Connection connection) throws SQLException { Statement st = connection.createStatement(); for(Function function : getBuiltInsFunctions()) { unRegisterFunction(st,function); } unRegisterGeometryType(connection); } }