Search in sources :

Example 1 with SequenceConfig

use of org.eclipse.persistence.internal.sessions.factories.model.sequencing.SequenceConfig in project eclipselink by eclipse-ee4j.

the class SessionsFactory method processLoginConfig.

/**
 * INTERNAL:
 * Process the common elements of a Login.
 */
protected void processLoginConfig(LoginConfig loginConfig, DatasourceLogin login) {
    // Platform class
    String platformClassName = loginConfig.getPlatformClass();
    if (platformClassName != null) {
        try {
            @SuppressWarnings({ "unchecked" }) Class<DatasourcePlatform> platformClass = (Class<DatasourcePlatform>) m_classLoader.loadClass(platformClassName);
            if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
                login.usePlatform(AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(platformClass)));
            } else {
                login.usePlatform(PrivilegedAccessHelper.newInstanceFromClass(platformClass));
            }
        } catch (Exception exception) {
            throw SessionLoaderException.failedToLoadTag("platform-class", platformClassName, exception);
        }
    }
    // Table qualifier
    String tableQualifier = loginConfig.getTableQualifier();
    if (tableQualifier != null) {
        login.setTableQualifier(tableQualifier);
    }
    // Username - setUserName checks for null
    login.setUserName(loginConfig.getUsername());
    // Encryption class (must be set before the password)
    // XML Schema default is org.eclipse.persistence.internal.security.JCEEncryptor
    login.setEncryptionClassName(loginConfig.getEncryptionClass());
    // Password is encrypted on the model - setEncryptedPassword checks for null
    login.setEncryptedPassword(loginConfig.getEncryptedPassword());
    // External connection pool - XML Schema default is false
    login.setUsesExternalConnectionPooling(loginConfig.getExternalConnectionPooling());
    // External transaction controller - XML Schema default is false
    login.setUsesExternalTransactionController(loginConfig.getExternalTransactionController());
    // Sequencing - XML Schema default is null
    if (loginConfig.getSequencingConfig() != null) {
        if (loginConfig.getSequencingConfig().getDefaultSequenceConfig() != null) {
            Sequence sequence = buildSequence(loginConfig.getSequencingConfig().getDefaultSequenceConfig());
            login.setDefaultSequence(sequence);
        }
        if ((loginConfig.getSequencingConfig().getSequenceConfigs() != null) && !loginConfig.getSequencingConfig().getSequenceConfigs().isEmpty()) {
            Enumeration<SequenceConfig> eSequenceConfigs = loginConfig.getSequencingConfig().getSequenceConfigs().elements();
            while (eSequenceConfigs.hasMoreElements()) {
                Sequence sequence = buildSequence(eSequenceConfigs.nextElement());
                login.addSequence(sequence);
            }
        }
    }
    // Properties (assumes they are all valid)
    if (loginConfig.getPropertyConfigs() != null) {
        Enumeration<PropertyConfig> e = loginConfig.getPropertyConfigs().elements();
        while (e.hasMoreElements()) {
            PropertyConfig propertyConfig = e.nextElement();
            login.getProperties().put(propertyConfig.getName(), propertyConfig.getValue());
        }
    }
}
Also used : PrivilegedNewInstanceFromClass(org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass) DatasourcePlatform(org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform) PropertyConfig(org.eclipse.persistence.internal.sessions.factories.model.property.PropertyConfig) PrivilegedNewInstanceFromClass(org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass) SequenceConfig(org.eclipse.persistence.internal.sessions.factories.model.sequencing.SequenceConfig) XMLFileSequenceConfig(org.eclipse.persistence.internal.sessions.factories.model.sequencing.XMLFileSequenceConfig) NativeSequenceConfig(org.eclipse.persistence.internal.sessions.factories.model.sequencing.NativeSequenceConfig) DefaultSequenceConfig(org.eclipse.persistence.internal.sessions.factories.model.sequencing.DefaultSequenceConfig) UnaryTableSequenceConfig(org.eclipse.persistence.internal.sessions.factories.model.sequencing.UnaryTableSequenceConfig) TableSequenceConfig(org.eclipse.persistence.internal.sessions.factories.model.sequencing.TableSequenceConfig) Sequence(org.eclipse.persistence.sequencing.Sequence) NativeSequence(org.eclipse.persistence.sequencing.NativeSequence) DefaultSequence(org.eclipse.persistence.sequencing.DefaultSequence) UnaryTableSequence(org.eclipse.persistence.sequencing.UnaryTableSequence) TableSequence(org.eclipse.persistence.sequencing.TableSequence) ValidationException(org.eclipse.persistence.exceptions.ValidationException) PrivilegedActionException(java.security.PrivilegedActionException) SessionLoaderException(org.eclipse.persistence.exceptions.SessionLoaderException)

Aggregations

PrivilegedActionException (java.security.PrivilegedActionException)1 SessionLoaderException (org.eclipse.persistence.exceptions.SessionLoaderException)1 ValidationException (org.eclipse.persistence.exceptions.ValidationException)1 DatasourcePlatform (org.eclipse.persistence.internal.databaseaccess.DatasourcePlatform)1 PrivilegedNewInstanceFromClass (org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass)1 PropertyConfig (org.eclipse.persistence.internal.sessions.factories.model.property.PropertyConfig)1 DefaultSequenceConfig (org.eclipse.persistence.internal.sessions.factories.model.sequencing.DefaultSequenceConfig)1 NativeSequenceConfig (org.eclipse.persistence.internal.sessions.factories.model.sequencing.NativeSequenceConfig)1 SequenceConfig (org.eclipse.persistence.internal.sessions.factories.model.sequencing.SequenceConfig)1 TableSequenceConfig (org.eclipse.persistence.internal.sessions.factories.model.sequencing.TableSequenceConfig)1 UnaryTableSequenceConfig (org.eclipse.persistence.internal.sessions.factories.model.sequencing.UnaryTableSequenceConfig)1 XMLFileSequenceConfig (org.eclipse.persistence.internal.sessions.factories.model.sequencing.XMLFileSequenceConfig)1 DefaultSequence (org.eclipse.persistence.sequencing.DefaultSequence)1 NativeSequence (org.eclipse.persistence.sequencing.NativeSequence)1 Sequence (org.eclipse.persistence.sequencing.Sequence)1 TableSequence (org.eclipse.persistence.sequencing.TableSequence)1 UnaryTableSequence (org.eclipse.persistence.sequencing.UnaryTableSequence)1