forked from pgjdbc/pgjdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(1) Support reading config file 'smart-pgjdbc.config' from user's hom…
…e directory; (2) Support reporting query time to QueryRewriter through the HTTP request;
- Loading branch information
Showing
7 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2021, PostgreSQL Global Development Group | ||
* See the LICENSE file in the project root for more information. | ||
*/ | ||
|
||
package org.postgresql.smart; | ||
|
||
import org.postgresql.util.OSUtil; | ||
|
||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
public class ConfigUtil { | ||
|
||
private static final String CONFIG_PATH = OSUtil.getUserConfigRootDirectory() + "/smart-pgjdbc.config"; | ||
private static final String SMARTJDBC_SERVER_URL_DEFAULT = "http://localhost:8000"; | ||
private static final String APP_GUID = "App007"; | ||
|
||
public static Properties readConfigProperties() throws IOException { | ||
File configFile = new File(CONFIG_PATH); | ||
FileReader cofingFileReader = new FileReader(configFile); | ||
Properties properties = new Properties(); | ||
properties.load(cofingFileReader); | ||
return properties; | ||
} | ||
|
||
public static String getSmartJDBCServerUrl() { | ||
try { | ||
Properties properties = readConfigProperties(); | ||
return properties.getProperty("smartjdbc.server.url"); | ||
} catch (IOException e) { | ||
return SMARTJDBC_SERVER_URL_DEFAULT; | ||
} | ||
} | ||
|
||
public static String getAppGuid() { | ||
try { | ||
Properties properties = readConfigProperties(); | ||
return properties.getProperty("app.guid"); | ||
} catch (IOException e) { | ||
return APP_GUID; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters