Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: ability to customize socket factory (e.g. for unix domain sockets)
This adds socketFactory and socketFactoryArg connection parameters that can be used to customize socket factory closes #457
- Loading branch information
Showing
12 changed files
with
282 additions
and
70 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
36 changes: 36 additions & 0 deletions
36
pgjdbc/src/main/java/org/postgresql/core/v2/SocketFactoryFactory.java
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,36 @@ | ||
package org.postgresql.core.v2; | ||
|
||
import org.postgresql.PGProperty; | ||
import org.postgresql.util.GT; | ||
import org.postgresql.util.ObjectFactory; | ||
import org.postgresql.util.PSQLException; | ||
import org.postgresql.util.PSQLState; | ||
|
||
import java.util.Properties; | ||
import javax.net.SocketFactory; | ||
|
||
/** | ||
* Instantiates {@link SocketFactory} based on the {@link PGProperty#SOCKET_FACTORY}. | ||
*/ | ||
public class SocketFactoryFactory { | ||
|
||
/** | ||
* Instantiates {@link SocketFactory} based on the {@link PGProperty#SOCKET_FACTORY} | ||
* @param info connection properties | ||
* @return socket factory | ||
* @throws PSQLException if something goes wrong | ||
*/ | ||
public static SocketFactory getSocketFactory(Properties info) throws PSQLException { | ||
// Socket factory | ||
String socketFactoryClassName = PGProperty.SOCKET_FACTORY.get(info); | ||
if (socketFactoryClassName == null) { | ||
return SocketFactory.getDefault(); | ||
} | ||
try { | ||
return (SocketFactory) ObjectFactory.instantiate(socketFactoryClassName, info, true, PGProperty.SOCKET_FACTORY_ARG.get(info)); | ||
} catch (Exception e) { | ||
throw new PSQLException(GT.tr("The SocketFactory class provided {0} could not be instantiated.", socketFactoryClassName), PSQLState.CONNECTION_FAILURE, e); | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.