- java.lang.Object
-
- org.postgresql.pljava.internal.Session
-
- All Implemented Interfaces:
Session
public class Session extends Object implements Session
An instance of this interface reflects the current session. The attribute store is deprecated. It had interesting transactional behavior until PL/Java 1.2.0, but since then it has behaved as any (non-null-allowing) Map. Anyone needing any sort of attribute store with transactional behavior will need to implement one and use aTransactionListener
to keep it sync'd.- Author:
- Thomas Hallgren
-
-
Method Summary
Modifier and Type Method Description void
addSavepointListener(SavepointListener listener)
Adds the specified listener to the list of listeners that will receive savepoint events.void
addTransactionListener(TransactionListener listener)
Adds the specified listener to the list of listeners that will receive transactional events.void
executeAsOuterUser(Connection conn, String statement)
void
executeAsSessionUser(Connection conn, String statement)
Deprecated, for removal: This API element is subject to removal in a future version.Object
getAttribute(String attributeName)
Deprecated, for removal: This API element is subject to removal in a future version.Session
's attribute store once had a special, and possibly useful, transactional behavior, but since PL/Java 1.2.0 it has lacked that, and offers nothing you don't get with an ordinaryMap
(that forbids nulls).<T extends PooledObject>
ObjectPool<T>getObjectPool(Class<T> cls)
String
getOuterUserName()
Lexicals.Identifier.Simple
getOuterUserSchema()
Return current_schema() as the outer user would see it.String
getSessionUserName()
Deprecated, for removal: This API element is subject to removal in a future version.String
getUserName()
static Charset
implServerCharset()
A static method (not part of the API-exposed Session interface) by which pljava implementation classes can get hold of the server charset without the indirection of getting a Session instance.static Session
provider()
void
removeAttribute(String attributeName)
Deprecated, for removal: This API element is subject to removal in a future version.Session
's attribute store once had a special, and possibly useful, transactional behavior, but since PL/Java 1.2.0 it has lacked that, and offers nothing you don't get with an ordinaryMap
(that forbids nulls).void
removeSavepointListener(SavepointListener listener)
Removes the specified listener from the list of listeners that will receive savepoint events.void
removeTransactionListener(TransactionListener listener)
Removes the specified listener from the list of listeners that will receive transactional events.void
setAttribute(String attributeName, Object value)
Deprecated, for removal: This API element is subject to removal in a future version.Session
's attribute store once had a special, and possibly useful, transactional behavior, but since PL/Java 1.2.0 it has lacked that, and offers nothing you don't get with an ordinaryMap
(that forbids nulls).
-
-
-
Method Detail
-
provider
public static Session provider()
-
implServerCharset
public static Charset implServerCharset()
A static method (not part of the API-exposed Session interface) by which pljava implementation classes can get hold of the server charset without the indirection of getting a Session instance. If there turns out to be demand for client code to obtain it through the API, an interface methodserverCharset
can easily be added later.- Returns:
- The Java Charset corresponding to the server's encoding, or null
if no matching Java charset was found. That can happen if a corresponding
Java charset really does exist but is not successfully found using the
name reported by PostgreSQL. That can be worked around by giving the
right name explicitly as the system property
org.postgresql.server.encoding
inpljava.vmoptions
for the affected database (or cluster-wide, if the same encoding is used).
-
addTransactionListener
public void addTransactionListener(TransactionListener listener)
Adds the specified listener to the list of listeners that will receive transactional events.- Specified by:
addTransactionListener
in interfaceSession
-
addSavepointListener
public void addSavepointListener(SavepointListener listener)
Adds the specified listener to the list of listeners that will receive savepoint events.- Specified by:
addSavepointListener
in interfaceSession
-
getAttribute
@Deprecated(since="1.5.3", forRemoval=true) public Object getAttribute(String attributeName)
Deprecated, for removal: This API element is subject to removal in a future version.Session
's attribute store once had a special, and possibly useful, transactional behavior, but since PL/Java 1.2.0 it has lacked that, and offers nothing you don't get with an ordinaryMap
(that forbids nulls). If some kind of store with transactional behavior is needed, it should be implemented in straight Java and kept in sync by using aTransactionListener
.Get an attribute from the session's attribute store.- Specified by:
getAttribute
in interfaceSession
-
getObjectPool
public <T extends PooledObject> ObjectPool<T> getObjectPool(Class<T> cls)
- Specified by:
getObjectPool
in interfaceSession
-
getUserName
public String getUserName()
- Specified by:
getUserName
in interfaceSession
-
getOuterUserName
public String getOuterUserName()
- Specified by:
getOuterUserName
in interfaceSession
-
getSessionUserName
@Deprecated(since="1.5.0", forRemoval=true) public String getSessionUserName()
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
getSessionUserName
in interfaceSession
-
removeAttribute
@Deprecated(since="1.5.3", forRemoval=true) public void removeAttribute(String attributeName)
Deprecated, for removal: This API element is subject to removal in a future version.Session
's attribute store once had a special, and possibly useful, transactional behavior, but since PL/Java 1.2.0 it has lacked that, and offers nothing you don't get with an ordinaryMap
(that forbids nulls). If some kind of store with transactional behavior is needed, it should be implemented in straight Java and kept in sync by using aTransactionListener
.Remove an attribute from the session's attribute store.- Specified by:
removeAttribute
in interfaceSession
-
setAttribute
@Deprecated(since="1.5.3", forRemoval=true) public void setAttribute(String attributeName, Object value)
Deprecated, for removal: This API element is subject to removal in a future version.Session
's attribute store once had a special, and possibly useful, transactional behavior, but since PL/Java 1.2.0 it has lacked that, and offers nothing you don't get with an ordinaryMap
(that forbids nulls). If some kind of store with transactional behavior is needed, it should be implemented in straight Java and kept in sync by using aTransactionListener
.Set an attribute in the session's attribute store.- Specified by:
setAttribute
in interfaceSession
-
removeTransactionListener
public void removeTransactionListener(TransactionListener listener)
Removes the specified listener from the list of listeners that will receive transactional events.- Specified by:
removeTransactionListener
in interfaceSession
-
removeSavepointListener
public void removeSavepointListener(SavepointListener listener)
Removes the specified listener from the list of listeners that will receive savepoint events.- Specified by:
removeSavepointListener
in interfaceSession
-
executeAsSessionUser
@Deprecated(since="1.5.0", forRemoval=true) public void executeAsSessionUser(Connection conn, String statement) throws SQLException
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
executeAsSessionUser
in interfaceSession
- Throws:
SQLException
-
executeAsOuterUser
public void executeAsOuterUser(Connection conn, String statement) throws SQLException
- Specified by:
executeAsOuterUser
in interfaceSession
- Throws:
SQLException
-
getOuterUserSchema
public Lexicals.Identifier.Simple getOuterUserSchema() throws SQLException
Return current_schema() as the outer user would see it. Currently used only in Commands.java. Not made visible API yet because there has to be a more general way to do this.- Throws:
SQLException
-
-