Class DataSourceConnectionInfo
- java.lang.Object
-
- org.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<E,I>
-
- org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity<DataSourceConnectionInfo,org.silverpeas.core.persistence.datasource.model.identifier.UniqueIntegerIdentifier>
-
- org.silverpeas.components.jdbcconnector.model.DataSourceConnectionInfo
-
- All Implemented Interfaces:
Serializable,org.silverpeas.core.persistence.datasource.model.IdentifiableEntity
@Entity public class DataSourceConnectionInfo extends org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity<DataSourceConnectionInfo,org.silverpeas.core.persistence.datasource.model.identifier.UniqueIntegerIdentifier>
Information about a JDBC connection to a data source. Such information is the name of the data source and the credentials required to access that data source.- Author:
- mmoquillon
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDataSourceConnectionInfo()DataSourceConnectionInfo(String dataSource, String instanceId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)static DataSourceConnectionInfogetById(String id)intgetDataMaxNumber()Gets the maximum number of data to return when requesting the data source.StringgetDataSourceName()Gets the JNDI name of the data source targeted by this connection information.static List<DataSourceConnectionInfo>getFromComponentInstance(String instanceId)StringgetInstanceId()Gets the unique identifier of the component instance this connection info belongs to.StringgetLogin()Gets the user identifier used in the data source authentication.StringgetPassword()Gets the password associated with the login to connect the data source.StringgetSqlRequest()Gets the SQL request used to select data from the connected data source.inthashCode()booleanisDefined()Is this connection information defined?ConnectionopenConnection()Opens a connection to the data source targeted by this connection information.voidremove()Removes this connection information from the persistence context.static voidremoveFromComponentInstance(String instanceId)voidsave()Saves or updates this connection information into the persistence context in order to be able to retrieve it later.voidsetDataMaxNumber(int maxNumber)Sets the maximum number of data to select when requesting the data source.voidsetDataSourceName(String dataSourceName)Sets a new data source by its JNDI name to this connection info.voidsetLoginAndPassword(String login, String password)Sets the login and the password required to open a connection to the targeted data source.voidsetSqlRequest(String sqlRequest)Sets the SQL request to used when requesting the data source.DataSourceConnectionInfowithDataMaxNumber(int maxNumber)Sets the maximum number of data to select when requesting the data source and returns this connection information.DataSourceConnectionInfowithDataSourceName(String dataSourceName)Sets a new data source by its JNDI name to this connection info.DataSourceConnectionInfowithLoginAndPassword(String login, String password)DataSourceConnectionInfowithSqlRequest(String sqlRequest)Sets the SQL request to used when requesting the data source and returns this connection information.-
Methods inherited from class org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity
performBeforePersist, performBeforeRemove, performBeforeUpdate
-
-
-
-
Method Detail
-
getById
public static DataSourceConnectionInfo getById(String id)
-
getFromComponentInstance
public static List<DataSourceConnectionInfo> getFromComponentInstance(String instanceId)
-
removeFromComponentInstance
public static void removeFromComponentInstance(String instanceId)
-
isDefined
public boolean isDefined()
Is this connection information defined? Information about a connection to a data source is defined if both it is related to a ConnecteurJDBC application instance and the name of the data source is defined.- Returns:
-
withSqlRequest
public DataSourceConnectionInfo withSqlRequest(String sqlRequest)
Sets the SQL request to used when requesting the data source and returns this connection information.- Parameters:
sqlRequest- a SQL request.- Returns:
- itself.
-
withDataMaxNumber
public DataSourceConnectionInfo withDataMaxNumber(int maxNumber)
Sets the maximum number of data to select when requesting the data source and returns this connection information.- Parameters:
maxNumber- the maximum number of data to return. 0 means all.- Returns:
- itself.
-
withLoginAndPassword
public DataSourceConnectionInfo withLoginAndPassword(String login, String password)
-
withDataSourceName
public DataSourceConnectionInfo withDataSourceName(String dataSourceName)
Sets a new data source by its JNDI name to this connection info.- Parameters:
dataSourceName- the JNDI name of the data source to connect to.- Returns:
- itself.
-
getDataSourceName
public String getDataSourceName()
Gets the JNDI name of the data source targeted by this connection information.- Returns:
- the JNDI name of the data source.
-
getInstanceId
public String getInstanceId()
Gets the unique identifier of the component instance this connection info belongs to.- Returns:
- the unique identifier of the component instance.
-
getLogin
public String getLogin()
Gets the user identifier used in the data source authentication.- Returns:
- the login.
-
getPassword
public String getPassword()
Gets the password associated with the login to connect the data source.- Returns:
- the password.
-
getSqlRequest
public String getSqlRequest()
Gets the SQL request used to select data from the connected data source.- Returns:
- the SQL request used in this connection information.
-
getDataMaxNumber
public int getDataMaxNumber()
Gets the maximum number of data to return when requesting the data source.- Returns:
- the maximum number of data to consider. 0 means all.
-
setDataSourceName
public void setDataSourceName(String dataSourceName)
Sets a new data source by its JNDI name to this connection info.- Parameters:
dataSourceName- the JNDI name of the data source to connect to.
-
setLoginAndPassword
public void setLoginAndPassword(String login, String password)
Sets the login and the password required to open a connection to the targeted data source.- Parameters:
login- a login.password- the password associated with the login.
-
setSqlRequest
public void setSqlRequest(String sqlRequest)
Sets the SQL request to used when requesting the data source.- Parameters:
sqlRequest- a SQL request.
-
setDataMaxNumber
public void setDataMaxNumber(int maxNumber)
Sets the maximum number of data to select when requesting the data source.- Parameters:
maxNumber- the maximum number of data to return. 0 means all.
-
save
public void save()
Saves or updates this connection information into the persistence context in order to be able to retrieve it later.
-
remove
public void remove()
Removes this connection information from the persistence context.
-
openConnection
public Connection openConnection() throws JdbcConnectorException
Opens a connection to the data source targeted by this connection information.- Returns:
- a connection against the data source referred by this object.
- Throws:
JdbcConnectorException
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classorg.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<DataSourceConnectionInfo,org.silverpeas.core.persistence.datasource.model.identifier.UniqueIntegerIdentifier>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classorg.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<DataSourceConnectionInfo,org.silverpeas.core.persistence.datasource.model.identifier.UniqueIntegerIdentifier>
-
-