public final class ConnectionManager
extends java.lang.Object
Persistence
service object.
A connection in the sense of this class is not a database-level connection,
such as a JDBC connection. Database-level connections are managed by the
Persistence
class transparently. A connection to this class
is a logical construct inherited from converted Progress code. Connecting
and disconnecting from a database at this level does not create or destroy
a JDBC-level connection resource. However, for transient databases at
least, it may affect the loading and unloading of database configurations
at the DatabaseManager
level. That is, the first time any client
context connects to a transient database (i.e., one that is not always
loaded by the server by default), that database's configuration is loaded
temporarily by the server. The last time a client context disconnects
from a transient database, that database's configuration is unloaded.
Connections register a physical database name to a logical database name, which can be different or the same as the physical name. A database may not be connected more than once without first disconnecting. Once disconnected, it may be connected again. Only one physical database may be registered to a given logical name at a time. Methods are provided to connect and disconnect, as well as to query information about connected databases, such as their physical and logical names, how many are connected, their types and restrictions.
Any number of aliases may be assigned to a given logical name. Aliases may only be created for connected databases, though they survive database disconnect. They may be explicitly deleted, however.
Whenever a new record buffer scope is opened, it is registered with its context's connection manager. References from buffers to their backing, physical databases are tracked, to enable the correct processing of database disconnect requests. Disconnects can only occur immediately if all procedures which reference the target database are complete. This translates to a state where no record buffers reference the database. Furthermore, even if no buffers reference a database, it may not be disconnected if the active code point currently is within a transaction. At the end of the transaction, all disconnects which were deferred are processed.
A single instance of this class is created for each client context. The
constructor is not called directly by client code; rather, access is
provided through the static get()
method.
Currently, the Progress semantic of database-level auto connect lists is not supported.
Modifier and Type | Class and Description |
---|---|
private static class |
ConnectionManager.ConnectInfo
Information about a specific database connection (in Progress terms, not JDBC terms).
|
private static class |
ConnectionManager.MetaConnectionsCleaner
Container for DB connections which need their meta tables cleaned up.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.String> |
aliases
Map of active aliases to logical database names
|
private java.util.Map<java.lang.String,ConnectionManager.ConnectInfo> |
connected
Map of logical database names to
ConnectInfo objects |
private java.util.Map<java.lang.String,java.lang.String> |
connectTimeUserid
Stores the userid used at connection time whether the database is connected using
command-line (directory implementation) or programatically using
CONNECT
with -U/-P parameters. |
private static java.util.Map<java.lang.String,java.lang.String> |
dbVersionCache
Cache of database versions, indexed by PDB name
|
private static java.lang.String |
DEFAULT_DBVERSION
Default DBVERSION text
|
private static java.lang.String |
DICTDB
DICTDB alias name
|
private java.util.Map<Database,java.lang.String> |
ldbMap
Map of physical database helper objects to logical database names
|
private static ContextLocal<ConnectionManager> |
local
Context local instance of this class
|
private static java.util.logging.Logger |
LOG
Logger
|
private static ContextLocal<ConnectionManager.MetaConnectionsCleaner> |
metaCleaner
Collect all the DB connections so that they are cleaned up before anything else (as
these are dependent on persistence and other context-local data.
|
private static java.util.Map<java.lang.String,ConnectionListener> |
metaListeners
Map of primary database IDs to
ConnectionListener objects |
private static long |
nextConnectID
Next available connect ID for metadata updates
|
private java.util.Map<Database,java.util.Set<RecordBuffer>> |
pdbReferences
Map of buffer sets currently referencing databases
|
private java.util.Set<Database> |
pendingDisconn
Databases awaiting disconnect (first level)
|
private java.util.Set<Database> |
pendingTxDisconn
Databases awaiting disconnect (second level)
|
private java.util.Map<Database,Session> |
sessions
Map of database info objects to network sessions
|
(package private) boolean |
singleClient
Equivalent of -1 argument in CONNECT statement.
|
private java.util.Map<java.lang.String,java.lang.String> |
userIds
Map with the userids for the currently connected databases.
|
Modifier | Constructor and Description |
---|---|
private |
ConnectionManager()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
static character |
alias(int index)
Retrieve the alias at the specified index in the current context.
|
static character |
alias(NumberType index)
Retrieve the alias at the specified index in the current context.
|
private character |
aliasImpl(int index)
Retrieve the alias at the specified index in the current context.
|
private static void |
assertKnownValue(BaseDataType data,
java.lang.String description)
Assert that
data does not represent the unknown value. |
static boolean |
authenticate(java.lang.String userid,
java.lang.String password,
java.lang.String dbname)
Authenticates the user for specified DB connection.
|
(package private) void |
closeBufferScope(RecordBuffer buffer)
Called by a record buffer to notify that its scope has been closed,
indicating that it no longer has an active reference to its database.
|
static void |
connect(java.lang.Object... args)
Create a logical connection to a database using the specified
parameters.
|
static logical |
connected(character name)
Tests whether a logical connection to a database exists in this context,
given a logical database name or alias.
|
static logical |
connected(java.lang.String name)
Tests whether a logical connection to a database exists in this context,
given a logical database name or alias.
|
private logical |
connectedImpl(character name)
Tests whether a logical connection to a database exists in this context,
given a logical database name or alias.
|
private void |
connectImpl(java.util.List<java.lang.Object> args)
Create a logical connection to a database using the specified
parameters.
|
static void |
createAlias(character alias,
character ldbName)
Create an alias for a logical database name within the current context.
|
static void |
createAlias(character alias,
java.lang.String ldbName)
Create an alias for a logical database name within the current context.
|
static void |
createAlias(java.lang.String alias,
character ldbName)
Create an alias for a logical database name within the current context.
|
static void |
createAlias(java.lang.String alias,
java.lang.String ldbName)
Create an alias for a logical database name within the current context.
|
private void |
createAliasImpl(java.lang.String alias,
java.lang.String ldbName)
Create an alias for a logical database name.
|
static character |
dbName()
Get the name of the connected database in this context.
|
static character |
dbParam(character nameOrAlias)
Implementation of the
DBPARAM() Progress function. |
static character |
dbParam(int index)
Implementation of the
DBPARAM() Progress function. |
static character |
dbParam(NumberType index)
Implementation of the
DBPARAM() Progress function. |
static character |
dbParam(java.lang.String nameOrAlias)
Implementation of the
DBPARAM() Progress function. |
private character |
dbParamImpl(java.lang.String nameOrAlias,
int index)
Implementation of the
DBPARAM() Progress function. |
static character |
dbRestrictions(character name)
Get a description of restrictions for the connected database with the
specified logical name or alias.
|
static character |
dbRestrictions(character name,
character table)
Get a description of restrictions for the connected database with the
specified logical name or alias.
|
static character |
dbRestrictions(character name,
java.lang.String table)
Get a description of restrictions for the connected database with the
specified logical name or alias.
|
static character |
dbRestrictions(int index)
Get a description of restrictions for the connected database at the
specified index.
|
static character |
dbRestrictions(int index,
character table)
Get a description of restrictions for the connected database at the
specified index.
|
static character |
dbRestrictions(int index,
java.lang.String table)
Get a description of restrictions for the connected database at the
specified index.
|
static character |
dbRestrictions(NumberType index)
Get a description of restrictions for the connected database at the
specified index.
|
static character |
dbRestrictions(NumberType index,
character table)
Get a description of restrictions for the connected database at the
specified index.
|
static character |
dbRestrictions(NumberType index,
java.lang.String table)
Get a description of restrictions for the connected database at the
specified index.
|
static character |
dbRestrictions(java.lang.String name)
Get a description of restrictions for the connected database with the
specified logical name or alias.
|
static character |
dbRestrictions(java.lang.String name,
character table)
Get a description of restrictions for the connected database with the
specified logical name or alias.
|
static character |
dbRestrictions(java.lang.String name,
java.lang.String table)
Get a description of restrictions for the connected database with the
specified logical name or alias.
|
static character |
dbType(character name)
Get a brief descriptor of the database type with the specified logical
name or alias.
|
static character |
dbType(int index)
Get a brief descriptor of the database type with the specified
connection index.
|
static character |
dbType(NumberType index)
Get a brief descriptor of the database type with the specified
connection index.
|
static character |
dbType(java.lang.String name)
Get a brief descriptor of the database type with the specified logical
name or alias.
|
static character |
dbVersion(character name)
Get the version number of the target database.
|
static character |
dbVersion(int index)
Get the version number of the target database.
|
static character |
dbVersion(NumberType index)
Get the version number of the target database.
|
static character |
dbVersion(java.lang.String name)
Get the version number of the target database.
|
private character |
dbVersionImpl(java.lang.String name,
int index)
Get the version number of the target database.
|
static void |
deleteAlias(character alias)
Delete the specified alias immediately.
|
static void |
deleteAlias(java.lang.String alias)
Delete the specified alias immediately.
|
private void |
deleteAliasImpl(java.lang.String alias)
Delete the specified alias immediately.
|
static void |
disconnect(character ldbName)
Request a disconnect from a logical database.
|
static void |
disconnect(java.lang.String ldbName)
Request a disconnect from a logical database.
|
private void |
disconnectImmediately(Database database,
boolean sessionCleanup)
Disconnect the specified database by deregistering it with the
DatabaseManager
and terminating the associated network session. |
private void |
disconnectImmediately(java.util.Set<Database> pending,
boolean sessionCleanup)
Disconnect all databases in the specified set by deregistering them with the
DatabaseManager and removing them from the set. |
private void |
disconnectImpl(java.lang.String ldbName)
Request a disconnect from a logical database.
|
(package private) static ConnectionManager |
get()
Retrieve the
ConnectionManager instance for the local context. |
(package private) java.util.Map<java.lang.String,java.lang.String> |
getAliasesByLDB()
Get the currently connected aliases by their logical database name.
|
static int |
getAuthLevel(java.lang.String ldbname)
Check the access level for a database based on metadata of that database.
|
static int |
getConnectedDbCount()
Get the number of databases currently connected in this context.
|
static java.lang.String |
getCurrentUserid(java.lang.String ldbName)
Returns a string representing the user ID used for authentication to a database.
|
private java.lang.String |
getCurrentUseridImpl(java.lang.String ldbName)
Returns the current id used by the user to authenticated to a database
identified by its logical name.
|
(package private) Database |
getDatabase(java.lang.String name)
Get the database information object for the given database name, which
may be a logical name, physical name, or alias.
|
(package private) java.lang.String |
getLDBName(Database database)
Get the logical database name for a connected physical database.
|
(package private) java.lang.String |
getLDBName(java.lang.String name)
Get the logical database name for the given logical database name or
alias.
|
(package private) java.lang.String |
getPDBName(java.lang.String name,
boolean normalize)
Get the physical database name for the given logical database name or
alias.
|
static Persistence |
getPersistence(java.lang.String name)
Get the
Persistence instance associated with the given database
name, which may be a physical or logical name, or an alias. |
static Session |
getSession(Database database)
Retrieve the network session which manages the connection to the remote
server which is authoritative for the specified database.
|
static Session |
getSession(java.lang.String name)
Retrieve the network session which manages the connection to the remote server which is
authoritative for the specified database name, which may be a logical name, physical name,
or alias.
|
(package private) static void |
initializeMeta(Database primaryDB,
Database metaDB)
Initialize a metaschema database by initializing a connection listener and storing it for
later use.
|
private static java.lang.Object |
iterateToIndex(java.util.Collection coll,
int index)
Iterate over the specified collection, returning the element at index
index . |
static character |
ldbName(character name)
Get the logical database name for the connected database with the given
logical name or alias.
|
static character |
ldbName(int index)
Get the logical database name for the connected database at the given
index.
|
static character |
ldbName(NumberType index)
Get the logical database name for the connected database at the given
index.
|
static character |
ldbName(java.lang.Object dmo)
Get the logical database name for the record buffer associated with the
given DMO.
|
static character |
ldbName(java.lang.String name)
Get the logical database name for the connected database with the given
logical name or alias.
|
private character |
ldbNameImpl(java.lang.String name,
int index)
Get the logical name for a database, given an alias (which may be the
logical name itself), or its index among all connected databases in
this context.
|
private java.lang.String |
makeConnection(Database database,
java.lang.String ldbName,
java.lang.String certAlias)
Create a logical connection to the database with the specified physical
name, creating the specified logical name for it.
|
private static character |
normalizeAliasOrLDB(character name)
Normalize an alias or logical database name by right trimming whitespace and lowercasing.
|
private static java.lang.String |
normalizeFilename(java.lang.String name)
Normalize the given filename by extracting the root name (removing the
file path and the filename extension).
|
static integer |
numAliases()
Get the number of aliases currently defined in this context.
|
static integer |
numDBs()
Get the number of databases currently connected in this context.
|
(package private) void |
openBufferScope(RecordBuffer buffer)
Register that a reference from a record buffer to its database has
become active.
|
static character |
pdbName(character name)
Get the physical database name for the connected database with the
given logical name or alias.
|
static character |
pdbName(int index)
Get the physical database name for the connected database at the given
index.
|
static character |
pdbName(NumberType index)
Get the physical database name for the connected database at the given
index.
|
static character |
pdbName(java.lang.String name)
Get the physical database name for the connected database with the
given logical name or alias.
|
private character |
pdbNameImpl(java.lang.String name,
int index)
Get the physical name for a database, given its logical name or alias,
or its index among all connected databases in this context.
|
private void |
putConnected(java.lang.String ldbName,
Database database,
java.lang.String userId)
Update the various housekeeping data structures to reflect a successful connection event,
and update connection metadata if it is in use.
|
private Database |
removeConnected(java.lang.String ldbName)
Update the various housekeeping data structures to reflect a disconnection event, and update
connection metadata if it is in use.
|
static character |
sdbName(character name)
Get the logical database name for the connected database with the given
logical name or alias.
|
static character |
sdbName(int index)
Get the logical database name for the connected database at the given
index.
|
static character |
sdbName(NumberType index)
Get the logical database name for the connected database at the given
index.
|
static character |
sdbName(java.lang.String name)
Get the logical database name for the connected database with the given
logical name or alias.
|
private void |
sessionClosed()
Perform end of session cleanup; disconnects all connected databases
without regard to transaction state or buffer reference status.
|
static void |
setAuthenticatedUserid(java.lang.String ldbName,
java.lang.String userid,
boolean byConnect)
Set the currently authenticated userid for a database.
|
private void |
setConnectUserImpl(java.lang.String ldbName)
Mark the current user for the database as the connection parameter.
|
private void |
setCurrentUseridImpl(java.lang.String ldbName,
java.lang.String newUserId)
Sets the currently authenticated userid for a database.
|
(package private) void |
transactionEnded()
This method is invoked after a master transaction commit/rollback; any
databases awaiting the end of the current transaction to disconnect are
now deregistered with the database manager.
|
private static final java.util.logging.Logger LOG
private static final ContextLocal<ConnectionManager> local
private static final ContextLocal<ConnectionManager.MetaConnectionsCleaner> metaCleaner
private static final java.lang.String DICTDB
private static final java.lang.String DEFAULT_DBVERSION
private static final java.util.Map<java.lang.String,java.lang.String> dbVersionCache
private static long nextConnectID
private static java.util.Map<java.lang.String,ConnectionListener> metaListeners
ConnectionListener
objectsprivate final java.util.Map<java.lang.String,java.lang.String> userIds
connected
map of the databases.private final java.util.Map<java.lang.String,java.lang.String> connectTimeUserid
CONNECT
with -U/-P parameters.
This list is not affected by later SETUSERID
calls.private final java.util.Map<java.lang.String,ConnectionManager.ConnectInfo> connected
ConnectInfo
objectsprivate final java.util.Map<Database,java.lang.String> ldbMap
private final java.util.Set<Database> pendingDisconn
private final java.util.Set<Database> pendingTxDisconn
private final java.util.Map<java.lang.String,java.lang.String> aliases
private final java.util.Map<Database,java.util.Set<RecordBuffer>> pdbReferences
private final java.util.Map<Database,Session> sessions
boolean singleClient
private ConnectionManager()
public static void connect(java.lang.Object... args)
args
- One or more connection parameters. This may take one of several forms:
-db mydb -ld logical_name -H
192.168.1.12 -S 3333
. After -db
,
parameters can be in any order, so long as each is
preceded by the specified option identifier.
ErrorConditionException
- if any parameter is null or represents the unknown value;
if any parameter is neither a text value nor an integral
value;
if there is an error registering the database with the
database manager.public static void disconnect(character ldbName)
ldbName
for disconnect at the appropriate time: once no buffers reference the
database, and at the end of the current transaction (if any).ldbName
- Logical name of the database to disconnect.ErrorConditionException
- if the specified database has not been opened.public static void disconnect(java.lang.String ldbName)
ldbName
for disconnect at the appropriate time: once no buffers reference the
database, and at the end of the current transaction (if any).ldbName
- Logical name of the database to disconnect.ErrorConditionException
- if the specified database has not been opened.public static logical connected(character name)
name
- Logical database name or alias.true
if a logical connection exists; else
false
.public static logical connected(java.lang.String name)
name
- Logical database name or alias.true
if a logical connection exists; else
false
.public static integer numAliases()
public static int getConnectedDbCount()
public static integer numDBs()
public static character dbName()
public static character dbParam(int index)
DBPARAM()
Progress function.
Returns, as a character string, a comma-separated list of the parameters
used to connect to the database.
The sequence number of a database the Progress session is connected to. For example, DBPARAM(1) returns information on the first database the Progress session is connected to, DBPARAM(2) returns information on the second database the Progress session is connected to, etc. If you specify a sequence number that does not correspond to a database the Progress session is connected to, the DBPARAM function returns the unknown value (?).
index
- One-based index of the target database among all databases
currently connected in this context.public static character dbParam(NumberType index)
DBPARAM()
Progress function.
Returns, as a character string, a comma-separated list of the parameters
used to connect to the database.
The sequence number of a database the Progress session is connected to. For example, DBPARAM(1) returns information on the first database the Progress session is connected to, DBPARAM(2) returns information on the second database the Progress session is connected to, etc. If you specify a sequence number that does not correspond to a database the Progress session is connected to, the DBPARAM function returns the unknown value (?).
index
- One-based index of the target database among all databases
currently connected in this context.public static character dbParam(java.lang.String nameOrAlias)
DBPARAM()
Progress function.
Returns, as a character string, a comma-separated list of the parameters
used to connect to the database.
This forms of the DBPARAM()
function require a character
expression as a parameter. If the parameter is an alias or the logical
name of a connected database, then Progress returns the comma-separated
parameter list. Otherwise, it returns the unknown value (?).
nameOrAlias
- The logical-name or alias of a connected databasepublic static character dbParam(character nameOrAlias)
DBPARAM()
Progress function.
Returns, as a character string, a comma-separated list of the parameters
used to connect to the database.
This forms of the DBPARAM()
function require a character
expression as a parameter. If the parameter is an alias or the logical
name of a connected database, then Progress returns the comma-separated
parameter list. Otherwise, it returns the unknown value (?).
nameOrAlias
- The logical-name or alias of a connected databasepublic static character dbType(NumberType index)
index
- One-based index of the target database among all databases
currently connected in this context.index
represents the unknown value or is outside of the range of
connected databases.public static character dbType(int index)
index
- One-based index of the target database among all databases
currently connected in this context.index
represents the unknown value or is outside of the range of
connected databases.public static character dbType(character name)
name
- Logical name or alias of the target database.name
is not a recognized logical name or alias.public static character dbType(java.lang.String name)
name
- Logical name or alias of the target database.name
is not a recognized logical name or alias.public static character dbVersion(NumberType index)
index
- One-based index of the target database among all databases currently connected in
this context.index
represents the unknown value or is outside of the range of
connected databases.public static character dbVersion(int index)
index
- One-based index of the target database among all databases currently connected in
this context.index
is outside of the range of connected databases.public static character dbVersion(character name)
name
- Logical name or alias of the target database.name
represents the unknown value or is not a recognized logical
name or alias.public static character dbVersion(java.lang.String name)
name
- Logical name or alias of the target database.name
is not a recognized logical name or alias.public static character dbRestrictions(NumberType index)
index
- One-based index of the target database among all databases
currently connected in this context.index
represents the unknown value or is outside of the range of
connected databases.public static character dbRestrictions(int index)
index
- One-based index of the target database among all databases
currently connected in this context.index
is
invalid.public static character dbRestrictions(NumberType index, character table)
table
is ignored.index
- One-based index of the target database among all databases
currently connected in this context.table
- Name of a table within the target database. Ignored.index
is
invalid.public static character dbRestrictions(NumberType index, java.lang.String table)
table
is ignored.index
- One-based index of the target database among all databases
currently connected in this context.table
- Name of a table within the target database. Ignored.index
is
invalid.public static character dbRestrictions(int index, character table)
table
is ignored.index
- One-based index of the target database among all databases
currently connected in this context.table
- Name of a table within the target database. Ignored.index
is
invalid.public static character dbRestrictions(int index, java.lang.String table)
table
is ignored.index
- One-based index of the target database among all databases
currently connected in this context.table
- Name of a table within the target database. Ignored.index
is
invalid.public static character dbRestrictions(character name)
name
- Logical name or alias of the target database.name
is not a recognized logical name or alias.public static character dbRestrictions(java.lang.String name)
name
- Logical name or alias of the target database.name
is not a recognized logical name or alias.public static character dbRestrictions(character name, character table)
table
is
ignored.name
- Logical name or alias of the target database.table
- Name of a table within the target database. Ignored.name
is not a recognized logical name or alias.public static character dbRestrictions(character name, java.lang.String table)
table
is
ignored.name
- Logical name or alias of the target database.table
- Name of a table within the target database. Ignored.name
is not a recognized logical name or alias.public static character dbRestrictions(java.lang.String name, character table)
table
is
ignored.name
- Logical name or alias of the target database.table
- Name of a table within the target database. Ignored.name
is not a recognized logical name or alias.public static character dbRestrictions(java.lang.String name, java.lang.String table)
table
is
ignored.name
- Logical name or alias of the target database.table
- Name of a table within the target database. Ignored.name
is not a recognized logical name or alias.public static void createAlias(character alias, character ldbName)
deleteAlias
method, or until the current session ends.alias
- Alias to be created.ldbName
- Logical name of the database to which the alias is assigned.ErrorConditionException
- if silent error mode is disabled and any of the following:
alias
represents the unknown value;
ldbName
represents the unknown value;
ldbName
.
public static void createAlias(java.lang.String alias, character ldbName)
deleteAlias
method, or until the current session ends.alias
- Alias to be created.ldbName
- Logical name of the database to which the alias is assigned.ErrorConditionException
- if silent error mode is disabled and any of the following:
ldbName
represents the unknown value;
ldbName
.
public static void createAlias(character alias, java.lang.String ldbName)
deleteAlias
method, or until the current session ends.alias
- Alias to be created.ldbName
- Logical name of the database to which the alias is assigned.ErrorConditionException
- if silent error mode is disabled and any of the following:
alias
represents the unknown value;
ldbName
.
public static void createAlias(java.lang.String alias, java.lang.String ldbName)
deleteAlias
method, or until the current session ends.alias
- Alias to be created.ldbName
- Logical name of the database to which the alias is assigned.ErrorConditionException
- if silent error mode is disabled and any of the following:
ldbName
.
public static void deleteAlias(character alias)
alias
- Alias to be deleted.public static void deleteAlias(java.lang.String alias)
alias
- Alias to be deleted.public static character alias(NumberType index)
index
- One-based index of the alias (aliases are stored in the order
in which they were created).index
is
invalid.public static character alias(int index)
index
- One-based index of the alias (aliases are stored in the order
in which they were created).index
is
invalid.public static character ldbName(NumberType index)
index
- One-based index of the target database among all databases
currently connected in this context.index
is
invalid.public static character ldbName(int index)
index
- One-based index of the target database among all databases
currently connected in this context.index
is
invalid.public static character ldbName(character name)
name
- Logical name or alias of the target database.name
is
invalid.public static character ldbName(java.lang.String name)
name
- Logical name or alias of the target database.name
is
invalid.public static character ldbName(java.lang.Object dmo)
dmo
- Data model object returned by a previous call to RecordBuffer.define(java.lang.Class<T>, java.lang.String, java.lang.String)
.public static character pdbName(NumberType index)
index
- One-based index of the target database among all databases
currently connected in this context.index
is
invalid.public static character pdbName(int index)
index
- One-based index of the target database among all databases
currently connected in this context.index
is
invalid.public static character pdbName(character name)
name
- Logical name or alias of the target database.name
is
invalid.public static character pdbName(java.lang.String name)
name
- Logical name or alias of the target database.name
is
invalid.public static character sdbName(NumberType index)
The current implementation delegates to ldbName(NumberType)
.
index
- One-based index of the target database among all databases
currently connected in this context.index
is
invalid.public static character sdbName(int index)
The current implementation delegates to ldbName(int)
.
index
- One-based index of the target database among all databases
currently connected in this context.index
is
invalid.public static character sdbName(character name)
The current implementation delegates to ldbName(character)
.
name
- Logical name or alias of the target database.name
is
invalid.public static character sdbName(java.lang.String name)
The current implementation delegates to ldbName(String)
.
name
- Logical name or alias of the target database.name
is
invalid.public static Session getSession(Database database)
database
- Database to which the target session is mapped.null
if there is no current connection.public static Session getSession(java.lang.String name)
name
- Logical name, physical name, or alias for database.null
if there is no current
connection.public static Persistence getPersistence(java.lang.String name)
Persistence
instance associated with the given database
name, which may be a physical or logical name, or an alias.name
- Physical or logical database name, or alias.public static java.lang.String getCurrentUserid(java.lang.String ldbName)
ldbName
- The logical name of the database for which the userid is requested.public static boolean authenticate(java.lang.String userid, java.lang.String password, java.lang.String dbname)
ENCODE
to password string it is compared to existing record from database in case
sensitive, taking into consideration trailing spaces
userid
- The name of the user to set as UserID.password
- The users password.dbname
- Logical database name.true
in case of valid user match false
otherwise.public static int getAuthLevel(java.lang.String ldbname)
SecurityOps.FREE_ACCESS
if
the meta table is not populated and SecurityOps.BLANK_ALLOWED
otherwise.ldbname
- The logical database name to query.public static void setAuthenticatedUserid(java.lang.String ldbName, java.lang.String userid, boolean byConnect)
authenticate()
method.
If byConnect
then the userid is stored and will be reported by
dbparam
function with -U tag.ldbName
- Logical database name.userid
- The name of the user to set as UserID.byConnect
- true
if the authentication was done from a connect (at startup time
or later) or false
if the authentication was done using the
setuserid
function.static void initializeMeta(Database primaryDB, Database metaDB)
Called only at server startup.
primaryDB
- Primary database for which metaschema information is being managed.metaDB
- Metaschema database for the given primary database.static ConnectionManager get()
ConnectionManager
instance for the local context.private static void assertKnownValue(BaseDataType data, java.lang.String description) throws PersistenceException
data
does not represent the unknown value.
If the assertion fails, an exception is thrown.data
- The data value to be checked.description
- A brief description of data
's purpose; this will
be used in an error message if the assertion fails.PersistenceException
- if the assertion fails.private static java.lang.Object iterateToIndex(java.util.Collection coll, int index)
index
.coll
- Collection over which to iterate.index
- The 1-based index of the target element in the
collection.null
if
index
was never reached.private static java.lang.String normalizeFilename(java.lang.String name)
name
- File name.private static character normalizeAliasOrLDB(character name)
name
- Alias or LDB name to be normalized.void transactionEnded()
void openBufferScope(RecordBuffer buffer)
buffer
- Record buffer whose scope has been opened.closeBufferScope(com.goldencode.p2j.persist.RecordBuffer)
,
disconnect(com.goldencode.p2j.util.character)
void closeBufferScope(RecordBuffer buffer)
If all three conditions are met, the database is disconnected immediately, and removed from the first level pending disconnect list. If the first two conditions are met, but the third is not, the database is moved from the first level to the second level disconnect list, where it will await the end of the transaction for disconnect.
buffer
- Record buffer whose scope has been closed.openBufferScope(com.goldencode.p2j.persist.RecordBuffer)
,
disconnect(com.goldencode.p2j.util.character)
java.lang.String getLDBName(java.lang.String name)
name
represents an alias.name
- Logical database name or alias.null
if name
is not recognized.java.lang.String getPDBName(java.lang.String name, boolean normalize)
name
- Logical database name or alias.normalize
- true
to return the normalized name; else
false
to return the unaltered (possibly fully
qualified name), as provided by the caller of the connect(java.lang.Object...)
method.null
if
name
is not recognized.Database getDatabase(java.lang.String name)
name
- Logical name, physical name, or alias for database.name
,
or null
if no such database currently is
connected.java.lang.String getLDBName(Database database)
database
- Physical database helper object.null
.java.util.Map<java.lang.String,java.lang.String> getAliasesByLDB()
private java.lang.String getCurrentUseridImpl(java.lang.String ldbName)
ldbName
- The logical name of the database for which the userid is requested.private void setCurrentUseridImpl(java.lang.String ldbName, java.lang.String newUserId)
MetadataSecurityOps
and only
after checking the user/password combination against the _User meta-table.
Notes:
* The CONNECT statement with -U and -P parameters will have to call SecurityOps to verify
if the user/password combination if correct.
(At this moment the ConnectionManager does not support these parameters, yet).
* The command-line parameters should be investigated.ldbName
- The logical database name for which the userid is set/updated.newUserId
- The newly newUserId for this database context.private void setConnectUserImpl(java.lang.String ldbName)
dbparam
function with -U
tag.ldbName
- The logical database name for which the userid is maked as connection parameter.private void sessionClosed()
DatabaseManager
's transient database reference
counts are not corrupted when client sessions end.private void disconnectImmediately(java.util.Set<Database> pending, boolean sessionCleanup)
DatabaseManager
and removing them from the set. Network sessions associated
with the databases in the set are terminated accordingly. If being called at the end of a
user's session, clean up internal data structures and update _connect metadata as well.pending
- Set of databases to disconnect.sessionCleanup
- true
if this action is being taken as part of cleanup for a session
that is terminating; false
if a normal disconnect.private void disconnectImmediately(Database database, boolean sessionCleanup)
DatabaseManager
and terminating the associated network session.database
- Database to disconnect.sessionCleanup
- true
if this action is being taken as part of cleanup for a session
that is terminating; false
if a normal disconnect.private character ldbNameImpl(java.lang.String name, int index)
name
- Logical database name or alias. May be null
,
but only if index
is non-null
.index
- Index of the database among connected databases. May be
null
, but only if name
is
non-null
. This is a one-based index.name
is not recognized.private character pdbNameImpl(java.lang.String name, int index)
name
- Logical database name or alias. May be null
,
but only if index
is non-null
.index
- One-based index of the database among connected databases.name
is not recognized.private void connectImpl(java.util.List<java.lang.Object> args) throws PersistenceException
args
- A list of one or more connection parameters. This may take one
of several forms:
PersistenceException
- if any parameter is null;
if any parameter is neither a text value nor an integral
value;
if there is an error registering the database with the
database manager.private java.lang.String makeConnection(Database database, java.lang.String ldbName, java.lang.String certAlias) throws PersistenceException
database
- Database information object.ldbName
- Logical database name. If null
, root name of
physical database name will be used.certAlias
- Alias of certificate to be read from trust store to enable
certificate-based, server-to-server authentication. This
should match the server ID of the remote node.null
, but a new logical name will be computed and returned)
and null
otherwise.ErrorConditionException
- if the given database already is connected.PersistenceException
- if there is an error registering the database with the
database manager or establishing a network session with the
remote server.private void disconnectImpl(java.lang.String ldbName) throws PersistenceException
ldbName
for disconnect at the appropriate time: once no buffers reference the
database, and at the end of the current transaction (if any).ldbName
- Logical name of the database to disconnect.PersistenceException
- if the specified database has not been opened.private logical connectedImpl(character name)
name
- Logical database name or alias.true
if a logical connection exists; else
false
.private void createAliasImpl(java.lang.String alias, java.lang.String ldbName) throws PersistenceException
deleteAlias
method, or
until the current session ends.alias
- Alias to be created.ldbName
- Logical name of the database to which the alias is assigned.PersistenceException
- if the alias conflicts with an existing logical database name,
other than ldbName
.ErrorConditionException
- if the target database is not connected, and we are not in
silent error mode.private void deleteAliasImpl(java.lang.String alias)
alias
- Alias to be deleted.private character aliasImpl(int index)
index
- One-based index of the alias (aliases are stored in the order
in which they were created).index
is
invalid.private character dbParamImpl(java.lang.String nameOrAlias, int index)
DBPARAM()
Progress function.
Returns, as a character string, a comma-separated list of the parameters
used to connect to the database.
The method do a lookup on the database's name, or id it is null, the alias will extracted using the index.
Parameters returned by this method generally will not match those
returned by the original 4GL implementation, since we don't support any
others than those handled by ConnectionManager.connect()
.
nameOrAlias
- Logical database name or alias.index
- One-based index of the alias (aliases are stored in the order
in which they were created).private character dbVersionImpl(java.lang.String name, int index)
name
- Logical name or alias of the target database. If null
, then
index
is used instead.index
- One-based index of the target database among all databases currently connected in
this context.index
represents the unknown value or is outside of the range of
connected databases.java.lang.RuntimeException
- if there is an error binding to the directory service to retrieve runtime
configuration information.private void putConnected(java.lang.String ldbName, Database database, java.lang.String userId)
ldbName
- Logical name of connected database.database
- Object describing physical database.userId
- Current user's ID.private Database removeConnected(java.lang.String ldbName)
ldbName
- Logical name of disconnected database.