001/* 002 * PermissionsEx 003 * Copyright (C) zml and PermissionsEx contributors 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package ca.stellardrift.permissionsex.impl; 018 019import org.checkerframework.checker.nullness.qual.Nullable; 020import org.slf4j.Logger; 021 022import javax.sql.DataSource; 023import java.nio.file.Path; 024import java.sql.SQLException; 025import java.util.concurrent.Executor; 026 027/** 028 * Methods that are specific to a certain implementation of PermissionsEx (Sponge, Forge, etc) 029 */ 030public interface ImplementationInterface { 031 032 /** 033 * Return the base directory to store any additional configuration files in. 034 * 035 * @return The base directory 036 */ 037 default Path baseDirectory() { 038 return baseDirectory(BaseDirectoryScope.CONFIG); 039 } 040 041 /** 042 * Return the base directory for storing various types of files, depending on the scope 043 * 044 * @param scope The scope to find the base directory for 045 * @return An appropriate path 046 */ 047 Path baseDirectory(BaseDirectoryScope scope); 048 049 /** 050 * Gets the appropriate logger 051 * @return The base logger 052 */ 053 Logger logger(); 054 055 /** 056 * Returns an appropriate data source for the implementation-dependent specifier {@code url}. 057 * 058 * <p>Implementations may allow this url to be an alias to an existing connection definition, 059 * rather than an actual URL.</p> 060 * 061 * @param url The specifier to get a data source for 062 * @return The appropriate data source, or null if not supported 063 * @throws SQLException If a connection to the provided database cannot be established 064 */ 065 @Nullable DataSource dataSourceForUrl(String url) throws SQLException; 066 067 /** 068 * Get an executor to run tasks asynchronously on. 069 * 070 * @return The async executor 071 */ 072 Executor asyncExecutor(); 073 074 /** 075 * Return the version number attached to this implementation of PEX 076 * 077 * @return The currently running version 078 */ 079 String version(); 080 081}