Tabnine Logo
ConnectionCustomizer
Code IndexAdd Tabnine to your IDE (free)

How to use
ConnectionCustomizer
in
org.eclipse.persistence.internal.databaseaccess

Best Java code snippets using org.eclipse.persistence.internal.databaseaccess.ConnectionCustomizer (Showing top 20 results out of 315)

origin: com.haulmont.thirdparty/eclipselink

/**
* Clear and remove customizer if its session is the same as the passed one;
* in case prevCustomizer exists set it as a new customizer.
* Called when ClientSession releases write accessor:
* if the customizer was created by the ClientSession it's removed, and
* the previous customizer (that ConnectionPool had set) is brought back;
* otherwise the customizer (created by ConnectionPool) is kept.
* Ignored if there's no customizer. 
*/
public void releaseCustomizer(AbstractSession session) {
  if(customizer != null) {
    if(customizer.getSession() == session) {
      if(customizer.isActive()) {
        customizer.clear();
      }
      if(customizer.getPrevCustomizer() == null) {
        customizer = null;
      } else {
        setCustomizer(customizer.getPrevCustomizer());
      }
    }
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Set customizer, customize the connection if it's available.
 */
protected void setCustomizer(ConnectionCustomizer newCustomizer) {
  this.customizer = newCustomizer;
  if(getDatasourceConnection() != null) {
    customizer.customize();
  }
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * Clone the accessor.
 */
public Object clone() {
  try {
    DatasourceAccessor accessor = (DatasourceAccessor)super.clone();
    if(accessor.customizer != null) {
      accessor.customizer.setAccessor(accessor);
    }
    return accessor;
  } catch (CloneNotSupportedException exception) {
    throw new InternalError("clone not supported");
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Clear customizer if it's active and set it to null.
 * Called by the same object that has created customizer (DatabaseSession, ConnectionPool) when
 * the latter is no longer required, typically before releasing the accessor.
 * Ignored if there's no customizer. 
 */
public void releaseCustomizer() {
  if(customizer != null) {
    if(customizer.isActive()) {
      customizer.clear();
    }
    customizer = null;
  }
}

origin: org.eclipse.persistence/org.eclipse.persistence.core

if(customizer.getSession() == session) {
  return;
  if(customizer.isActive()) {
    customizer.clear();
  newCustomizer = ConnectionCustomizer.createEmptyCustomizer(session);
  newCustomizer.setPrevCustomizer(customizer);
    if(customizer.isActive()) {
      customizer.clear();
    newCustomizer.setPrevCustomizer(customizer);
    setCustomizer(newCustomizer);
origin: com.haulmont.thirdparty/eclipselink

if(customizer.getSession() == session) {
  return;
  if(customizer.isActive()) {
    customizer.clear();
  newCustomizer = ConnectionCustomizer.createEmptyCustomizer(session);
  newCustomizer.setPrevCustomizer(customizer);
    if(customizer.isActive()) {
      customizer.clear();
    newCustomizer.setPrevCustomizer(customizer);
    setCustomizer(newCustomizer);
origin: com.haulmont.thirdparty/eclipselink

/**
 * Clear customizer if it's active and set it to null.
 * Called by the same object that has created customizer (DatabaseSession, ConnectionPool) when
 * the latter is no longer required, typically before releasing the accessor.
 * Ignored if there's no customizer. 
 */
public void releaseCustomizer() {
  if(customizer != null) {
    if(customizer.isActive()) {
      customizer.clear();
    }
    customizer = null;
  }
}

origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
* Clear and remove customizer if its session is the same as the passed one;
* in case prevCustomizer exists set it as a new customizer.
* Called when ClientSession releases write accessor:
* if the customizer was created by the ClientSession it's removed, and
* the previous customizer (that ConnectionPool had set) is brought back;
* otherwise the customizer (created by ConnectionPool) is kept.
* Ignored if there's no customizer. 
*/
public void releaseCustomizer(AbstractSession session) {
  if(customizer != null) {
    if(customizer.getSession() == session) {
      if(customizer.isActive()) {
        customizer.clear();
      }
      if(customizer.getPrevCustomizer() == null) {
        customizer = null;
      } else {
        setCustomizer(customizer.getPrevCustomizer());
      }
    }
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

if(customizer.getSession() == session) {
  return;
  if(customizer.isActive()) {
    customizer.clear();
  newCustomizer = ConnectionCustomizer.createEmptyCustomizer(session);
  newCustomizer.setPrevCustomizer(customizer);
    if(customizer.isActive()) {
      customizer.clear();
    newCustomizer.setPrevCustomizer(customizer);
    setCustomizer(newCustomizer);
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Clear customizer if it's active and set it to null.
 * Called by the same object that has created customizer (DatabaseSession, ConnectionPool) when
 * the latter is no longer required, typically before releasing the accessor.
 * Ignored if there's no customizer.
 */
public void releaseCustomizer() {
  if(customizer != null) {
    if(customizer.isActive()) {
      customizer.clear();
    }
    customizer = null;
  }
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Set customizer, customize the connection if it's available.
 */
protected void setCustomizer(ConnectionCustomizer newCustomizer) {
  this.customizer = newCustomizer;
  if(getDatasourceConnection() != null) {
    customizer.customize();
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Clone the accessor.
 */
public Object clone() {
  try {
    DatasourceAccessor accessor = (DatasourceAccessor)super.clone();
    if(accessor.customizer != null) {
      accessor.customizer.setAccessor(accessor);
    }
    return accessor;
  } catch (CloneNotSupportedException exception) {
    throw new InternalError("clone not supported");
  }
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
* Clear and remove customizer if its session is the same as the passed one;
* in case prevCustomizer exists set it as a new customizer.
* Called when ClientSession releases write accessor:
* if the customizer was created by the ClientSession it's removed, and
* the previous customizer (that ConnectionPool had set) is brought back;
* otherwise the customizer (created by ConnectionPool) is kept.
* Ignored if there's no customizer.
*/
public void releaseCustomizer(AbstractSession session) {
  if(customizer != null) {
    if(customizer.getSession() == session) {
      if(customizer.isActive()) {
        customizer.clear();
      }
      if(customizer.getPrevCustomizer() == null) {
        customizer = null;
      } else {
        setCustomizer(customizer.getPrevCustomizer());
      }
    }
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * Close the accessor's connection.
 * This is used only for external connection pooling
 * when it is intended for the connection to be reconnected in the future.
 */
public void closeConnection() {
  try {
    if (this.datasourceConnection != null) {
      if (isDatasourceConnected()) {
        if(currentSession != null) {
          currentSession.preDisconnectExternalConnection(this);
        }
        if(customizer != null && customizer.isActive()) {
          customizer.clear();
        }
        closeDatasourceConnection();
      }
      this.datasourceConnection = null;
    }
  } catch (DatabaseException exception) {
    // Ignore
    this.datasourceConnection = null;
  } finally {
    currentSession = null;
  }
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * Set customizer, customize the connection if it's available.
 */
protected void setCustomizer(ConnectionCustomizer newCustomizer) {
  this.customizer = newCustomizer;
  if(getDatasourceConnection() != null) {
    customizer.customize();
  }
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Clone the accessor.
 */
public Object clone() {
  try {
    DatasourceAccessor accessor = (DatasourceAccessor)super.clone();
    if(accessor.customizer != null) {
      accessor.customizer.setAccessor(accessor);
    }
    return accessor;
  } catch (CloneNotSupportedException exception) {
    throw new InternalError("clone not supported");
  }
}
origin: com.haulmont.thirdparty/eclipselink

/**
* This method is called by reestablishConnection.
* Nothing needs to be done in case customize is not active (customization hasn't been applied yet). 
* to repair existing customizer after connection became invalid.
* However if connection has been customized then
* if connection is still there and deemed to be valid - clear customization.
* Otherwise (or if clear fails) remove customizer and set its prevCustomizer as a new customizer,
* then re-create customizer using the same session as the original one.
*/
protected void reestablishCustomizer() {
  if(customizer != null && customizer.isActive()) {
    if(isValid()) {
      // the method eats SQLException in case of a failure.   
      customizer.clear();
    } else {
      // It's an invalid connection - don't bother trying to clear customization.
      AbstractSession customizerSession = (AbstractSession)customizer.getSession();
      // need this so that the new customizer has the same prevCustomizer as the old one.
      customizer = customizer.getPrevCustomizer();
      // customizer recreated - it's the same as the original one, but not active.
      createCustomizer(customizerSession);
    }
  }
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Close the accessor's connection.
 * This is used only for external connection pooling
 * when it is intended for the connection to be reconnected in the future.
 */
public void closeConnection() {
  try {
    if (this.datasourceConnection != null) {
      if (isDatasourceConnected()) {
        if(currentSession != null) {
          currentSession.preReleaseConnection(this);
        }
        if(customizer != null && customizer.isActive()) {
          customizer.clear();
        }
        closeDatasourceConnection();
      }
      this.datasourceConnection = null;
    }
  } catch (DatabaseException exception) {
    // Ignore
    this.datasourceConnection = null;
  } finally {
    currentSession = null;
  }
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * Connect to the database.
 * Exceptions are caught and re-thrown as EclipseLink exceptions.
 */
protected void connectInternal(Login login, AbstractSession session) throws DatabaseException {
  try{
    this.datasourceConnection = login.connectToDatasource(this, session);
    this.isConnected = true;
    if(this.customizer != null) {
      customizer.customize();
    }
  }catch (DatabaseException ex){
    //Set the accessor to ensure the retry code has an opportunity to retry.
    ex.setAccessor(this);
    throw ex;
  }
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
* This method is called by reestablishConnection.
* Nothing needs to be done in case customize is not active (customization hasn't been applied yet).
* to repair existing customizer after connection became invalid.
* However if connection has been customized then
* if connection is still there and deemed to be valid - clear customization.
* Otherwise (or if clear fails) remove customizer and set its prevCustomizer as a new customizer,
* then re-create customizer using the same session as the original one.
*/
protected void reestablishCustomizer() {
  if(customizer != null && customizer.isActive()) {
    if(isValid()) {
      // the method eats SQLException in case of a failure.
      customizer.clear();
    } else {
      // It's an invalid connection - don't bother trying to clear customization.
      AbstractSession customizerSession = (AbstractSession)customizer.getSession();
      // need this so that the new customizer has the same prevCustomizer as the old one.
      customizer = customizer.getPrevCustomizer();
      // customizer recreated - it's the same as the original one, but not active.
      createCustomizer(customizerSession);
    }
  }
}
org.eclipse.persistence.internal.databaseaccessConnectionCustomizer

Javadoc

PUBLIC: The base class for connection customization. The extending class must not alter the attributes defined in this class. Consider implementing equals method on the extending class so that the two instances are consider equal if they apply exactly the same customizations. This allows to skip unnecessary work when overriding customizer defined by ServerSession by the one defined by ClientSession: in case the two customizers are equal the old (ServerSession's) customizer is kept. That may save considerable effort in internal connection pooling case: if both ServerSession and ClientSession have exactly the same proxy properties (that happens if ClientSession doesn't have any proxy properties at all and just "inherits" all the properties from its parent ServerSession) then without correct customizer equality check the proxy session opened by ServerSession would have been closed, only to be re-opened again by ClientSession customizer using exactly the same proxy properties (and then the same happens again when ClientSession releases connection).

Most used methods

  • clear
    INTERNAL: Clears customization from connection. Called only if connection is customized (isActive()=
  • createEmptyCustomizer
  • customize
    INTERNAL: Applies customization to connection. Called only if connection is not already customized (
  • getPrevCustomizer
    INTERNAL:
  • getSession
    INTERNAL:
  • isActive
    INTERNAL: Indicated whether the connection is currently customized.
  • setAccessor
    INTERNAL: Used only by DatasourceAccessor.clone method.
  • setPrevCustomizer
    INTERNAL:

Popular in Java

  • Finding current android device location
  • onCreateOptionsMenu (Activity)
  • getResourceAsStream (ClassLoader)
  • getSupportFragmentManager (FragmentActivity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Option (scala)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now