Top Description Inners Fields Constructors Methods
org.eclipse.persistence.sessions.server

public Class ConnectionPolicy

extends Object
implements Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable
Imports
java.io.Serializable, java.util.HashMap, .Map, org.eclipse.persistence.config.ExclusiveConnectionMode, org.eclipse.persistence.internal.helper.Helper, org.eclipse.persistence.internal.localization.ToStringLocalization, org.eclipse.persistence.sessions.Login

Purpose: Used to specify how a client session's should be allocated.

Description: The ConnectionPolicy is used to indicate how a client session will interact with the internal or external JDBC connection pool/data source. The default ConnectionPolicy is held on the ServerSession but this can be overridden for any specific client session when it is acquired.

See Also
ServerSession#getDefaultConnectionPolicy(), ServerSession#acquireClientSession(ConnectionPolicy), ServerSession#acquireClientSession(ConnectionPolicy, Map), ClientSession#getConnectionPolicy()

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ConnectionPolicy.ExclusiveMode

Default value Transactional causes creation of ClientSession, the other two values - ExclusiveIsolatedClientSession.

Field Summary

Modifier and TypeField and Description
protected ConnectionPolicy.ExclusiveMode
exclusiveMode

This attribute is used by the ServerSession to determine if a client session with an exclusive connection should be built and how the exclusive connection should be used.

protected boolean
isLazy

Determines if the write/exclusive connection is acquired only when first requested (lazy, this is the default) or immediately when the client session is acquired.

protected Login
login

The login information used to create a JDBC connection or acquire one from an external pool/data-source.

protected String
poolName

Name of the pool to be used.

protected Map<K, V>
properties

This attribute will provide a mechanism by which customers will be able to pass connection information to events to enable further customization.

Constructor Summary

AccessConstructor and Description
public
ConnectionPolicy()

PUBLIC: A connection policy is used to define how the client session connection should be acquired.

public
ConnectionPolicy(String poolName)

PUBLIC: A connection policy is used to define how the client session connection should be acquired.

public
ConnectionPolicy(Login login)

PUBLIC: A connection policy is used to define how the client session connection should be acquired.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

INTERNAL: Clone the query
public void
dontUseLazyConnection()

PUBLIC: A lazy connection only acquires a physical connection when a transaction is started and releases the connection when the transaction completes.

public ConnectionPolicy.ExclusiveMode
getExclusiveMode()

PUBLIC: Returns exclusive mode.

public Login
getLogin()

PUBLIC: Return the login to use for this connection.

public String
getPoolName()

PUBLIC: Return the pool name or null if not part of a pool.

public Map<K, V>
getProperties()

ADVANCED: This method will return the collection of custom properties set on the Connection policy.

public Object
getProperty(Object object)

PUBLIC: Returns the property associated with the corresponding key.

public boolean
hasLogin()

PUBLIC: Return if a login is used, only one of login and pool can be used.

public boolean
hasProperties()

PUBLIC: Returns true if properties are available on the Connection Policy

public boolean
isExclusive()

PUBLIC: Indicates whether ExclusiveIsolatedClientSession should be created.

public boolean
isExclusiveAlways()

PUBLIC: Indicates whether exclusiveMode is Always.

public boolean
isExclusiveIsolated()

PUBLIC: Indicates whether exclusiveMode is Isolated.

public boolean
isLazy()

PUBLIC: Return if a lazy connection should be used, a lazy connection only acquire a physical connection when a transaction is started and releases the connection when the transaction completes.

public boolean
isPooled()

INTERNAL: Return if part of a connection pool.

public boolean
isUserDefinedConnection()

INTERNAL: Return if part of a connection pool.

public Object
removeProperty(Object key)

PUBLIC: This method is used to remove a custom property from the Connection Policy.

public void
setExclusiveMode(ConnectionPolicy.ExclusiveMode exclusiveMode)

PUBLIC: Sets exclusive mode, if null is passed sets the default value.

public void
setIsLazy(boolean isLazy)

PUBLIC: Set if a lazy connection should be used, a lazy connection only acquire a physical connection when a transaction is started and releases the connection when the transaction completes.

public void
setLogin(Login login)

PUBLIC: Set the login to use for this connection.

public void
setPoolName(String poolName)

PUBLIC: Set the pool name or null if not part of a pool.

public void
setProperty(Object key, Object property)

PUBLIC: Use this method to set custom properties on the Connection Policy.

public String
toString()

Overrides java.lang.Object.toString.

INTERNAL: return a string representation of this ConnectionPolicy
public void
useLazyConnection()

PUBLIC: A lazy connection only acquires a physical connection when a transaction is started and releases the connection when the transaction completes.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

exclusiveModeback to summary
protected ConnectionPolicy.ExclusiveMode exclusiveMode

This attribute is used by the ServerSession to determine if a client session with an exclusive connection should be built and how the exclusive connection should be used.

isLazyback to summary
protected boolean isLazy

Determines if the write/exclusive connection is acquired only when first requested (lazy, this is the default) or immediately when the client session is acquired. After write/exclusive connection is acquired if isLazy is true and exclusiveMode is Transactional then it's held until transaction is committed or rolled back, otherwise until the client session is released.

loginback to summary
protected Login login

The login information used to create a JDBC connection or acquire one from an external pool/data-source. Typically this is constant within a single persistence unit but in some advanced usages users can customize connections for each client session.

poolNameback to summary
protected String poolName

Name of the pool to be used. If neither pool name nor login provided then default pool will be used. If no pool name is provided but there's a login then the login is used to create connection which the ClientSession will use.

propertiesback to summary
protected Map<K, V> properties

This attribute will provide a mechanism by which customers will be able to pass connection information to events to enable further customization.

Constructor Detail

ConnectionPolicyback to summary
public ConnectionPolicy()

PUBLIC: A connection policy is used to define how the client session connection should be acquired.

ConnectionPolicyback to summary
public ConnectionPolicy(String poolName)

PUBLIC: A connection policy is used to define how the client session connection should be acquired.

ConnectionPolicyback to summary
public ConnectionPolicy(Login login)

PUBLIC: A connection policy is used to define how the client session connection should be acquired.

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

INTERNAL: Clone the query

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
dontUseLazyConnectionback to summary
public void dontUseLazyConnection()

PUBLIC: A lazy connection only acquires a physical connection when a transaction is started and releases the connection when the transaction completes.

getExclusiveModeback to summary
public ConnectionPolicy.ExclusiveMode getExclusiveMode()

PUBLIC: Returns exclusive mode.

getLoginback to summary
public Login getLogin()

PUBLIC: Return the login to use for this connection. Client sessions support using a separate user login for database modification.

getPoolNameback to summary
public String getPoolName()

PUBLIC: Return the pool name or null if not part of a pool.

getPropertiesback to summary
public Map<K, V> getProperties()

ADVANCED: This method will return the collection of custom properties set on the Connection policy. Note that this will cause the lazy initialization of the HashMap.

getPropertyback to summary
public Object getProperty(Object object)

PUBLIC: Returns the property associated with the corresponding key. These properties will be available to connection events.

hasLoginback to summary
public boolean hasLogin()

PUBLIC: Return if a login is used, only one of login and pool can be used.

hasPropertiesback to summary
public boolean hasProperties()

PUBLIC: Returns true if properties are available on the Connection Policy

isExclusiveback to summary
public boolean isExclusive()

PUBLIC: Indicates whether ExclusiveIsolatedClientSession should be created.

isExclusiveAlwaysback to summary
public boolean isExclusiveAlways()

PUBLIC: Indicates whether exclusiveMode is Always.

isExclusiveIsolatedback to summary
public boolean isExclusiveIsolated()

PUBLIC: Indicates whether exclusiveMode is Isolated.

isLazyback to summary
public boolean isLazy()

PUBLIC: Return if a lazy connection should be used, a lazy connection only acquire a physical connection when a transaction is started and releases the connection when the transaction completes.

isPooledback to summary
public boolean isPooled()

INTERNAL: Return if part of a connection pool.

isUserDefinedConnectionback to summary
public boolean isUserDefinedConnection()

INTERNAL: Return if part of a connection pool.

removePropertyback to summary
public Object removeProperty(Object key)

PUBLIC: This method is used to remove a custom property from the Connection Policy. This method will return the propery removed. If it was not found then null will be returned.

setExclusiveModeback to summary
public void setExclusiveMode(ConnectionPolicy.ExclusiveMode exclusiveMode)

PUBLIC: Sets exclusive mode, if null is passed sets the default value.

setIsLazyback to summary
public void setIsLazy(boolean isLazy)

PUBLIC: Set if a lazy connection should be used, a lazy connection only acquire a physical connection when a transaction is started and releases the connection when the transaction completes.

setLoginback to summary
public void setLogin(Login login)

PUBLIC: Set the login to use for this connection. Client sessions support using a separate user login for database modification. Pooled connections must use the pool's login and cannot define their own.

setPoolNameback to summary
public void setPoolName(String poolName)

PUBLIC: Set the pool name or null if not part of a pool.

setPropertyback to summary
public void setProperty(Object key, Object property)

PUBLIC: Use this method to set custom properties on the Connection Policy. These properties will be available from within connection events but have no effect on the connection directly.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

INTERNAL: return a string representation of this ConnectionPolicy

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
useLazyConnectionback to summary
public void useLazyConnection()

PUBLIC: A lazy connection only acquires a physical connection when a transaction is started and releases the connection when the transaction completes.

org.eclipse.persistence.sessions.server back to summary

public final Enum ConnectionPolicy.ExclusiveMode

extends Enum<ConnectionPolicy.ExclusiveMode>
Class Inheritance

Default value Transactional causes creation of ClientSession, the other two values - ExclusiveIsolatedClientSession. ExclusiveMode values correspond to ExclusiveConnectionMode values, the latter class has extensive comments explaining the differences between the values.
See Also
ExclusiveConnectionMode

Field Summary

Modifier and TypeField and Description
public static final ConnectionPolicy.ExclusiveMode
public static final ConnectionPolicy.ExclusiveMode
public static final ConnectionPolicy.ExclusiveMode

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ConnectionPolicy.ExclusiveMode
public static ConnectionPolicy.ExclusiveMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

Alwaysback to summary
public static final ConnectionPolicy.ExclusiveMode Always
Isolatedback to summary
public static final ConnectionPolicy.ExclusiveMode Isolated
Transactionalback to summary
public static final ConnectionPolicy.ExclusiveMode Transactional

Constructor Detail

ExclusiveModeback to summary
private ExclusiveMode()

Method Detail

valueOfback to summary
public static ConnectionPolicy.ExclusiveMode valueOf(String name)
valuesback to summary
public static ConnectionPolicy.ExclusiveMode[] values()