Class SQLDatabaseTypeExtensionPoint
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint<SQLDatabaseType>
-
- org.ametys.core.datasource.dbtype.SQLDatabaseTypeExtensionPoint
-
- All Implemented Interfaces:
LogEnabled
,ExtensionPoint<SQLDatabaseType>
,Disposable
,Initializable
,Component
,Contextualizable
,Serviceable
,ThreadSafe
public class SQLDatabaseTypeExtensionPoint extends AbstractThreadSafeComponentExtensionPoint<SQLDatabaseType>
This class is in charge to load and initialize theSQLDatabaseType
-
-
Field Summary
Fields Modifier and Type Field Description static String
ROLE
Avalon Role-
Fields inherited from class org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint
_cocoonManager, _context, _manager
-
-
Constructor Summary
Constructors Constructor Description SQLDatabaseTypeExtensionPoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
getBlob(String dbType, ResultSet resultSet, int pos)
Get the InputStream to read a blobInputStream
getBlob(String dbType, ResultSet resultSet, String columnName)
Get the InputStream to read a blobMap<String,I18nizableText>
getSQLDatabaseTypes()
Get the SQL database types with their labelvoid
initializeExtensions()
Finalize the initialization of the extensions.
This method is called after alladdExtension()
calls.
This is the last step before the actual startup of the application.String
languageEscapeTableName(String dbType, String tableNameToEscape)
Some db systems requires the table names to be escapedString
languageLimitQuery(String dbType, String queryToLimit, String limit, String offset)
Add a limit/offset element to the given queryvoid
setBlob(String dbType, PreparedStatement statement, int pos, byte[] bytes)
Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can usesetBlob(String, PreparedStatement, int, String)
void
setBlob(String dbType, PreparedStatement statement, int pos, InputStream is, long length)
Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can usesetBlob(String, PreparedStatement, int, String)
void
setBlob(String dbType, PreparedStatement statement, int pos, String blob)
Set an String into a blob-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint
addComponent, addExtension, contextualize, dispose, getExtension, getExtensionsIds, hasExtension, initialize, service
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Constructor Detail
-
SQLDatabaseTypeExtensionPoint
public SQLDatabaseTypeExtensionPoint()
-
-
Method Detail
-
initializeExtensions
public void initializeExtensions() throws Exception
Description copied from interface:ExtensionPoint
Finalize the initialization of the extensions.
This method is called after alladdExtension()
calls.
This is the last step before the actual startup of the application.- Specified by:
initializeExtensions
in interfaceExtensionPoint<SQLDatabaseType>
- Overrides:
initializeExtensions
in classAbstractThreadSafeComponentExtensionPoint<SQLDatabaseType>
- Throws:
Exception
- if something wrong occurs
-
getSQLDatabaseTypes
public Map<String,I18nizableText> getSQLDatabaseTypes()
Get the SQL database types with their label- Returns:
- the SQL database types with their label
-
languageEscapeTableName
public String languageEscapeTableName(String dbType, String tableNameToEscape)
Some db systems requires the table names to be escaped- Parameters:
dbType
- The identifier of the db type usedtableNameToEscape
- The non-null table name- Returns:
- The escaped table name or at least the table name if no escape is required. Or null if the dbtype is unknown.
-
languageLimitQuery
public String languageLimitQuery(String dbType, String queryToLimit, String limit, String offset)
Add a limit/offset element to the given query- Parameters:
dbType
- The identifier of the db type usedqueryToLimit
- The sql query that will be amendedlimit
- The max number of the results to returnoffset
- The initial offset of the results to return- Returns:
- The initial query amended to handle the limit and offset. Or null if the dbtype is unknown.
-
getBlob
public InputStream getBlob(String dbType, ResultSet resultSet, String columnName) throws SQLException
Get the InputStream to read a blob- Parameters:
dbType
- The identifier of the db type usedresultSet
- the result set containing the blob.columnName
- column- Returns:
- an InputStream to read the blob
- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
-
getBlob
public InputStream getBlob(String dbType, ResultSet resultSet, int pos) throws SQLException
Get the InputStream to read a blob- Parameters:
dbType
- The identifier of the db type usedresultSet
- the result set containing the blob.pos
- column position- Returns:
- an InputStream to read the blob
- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
-
setBlob
public void setBlob(String dbType, PreparedStatement statement, int pos, String blob) throws SQLException, UnsupportedEncodingException, IllegalArgumentException
Set an String into a blob- Parameters:
dbType
- The identifier of the db type usedstatement
- The satement where the blob will be setpos
- position in the statementblob
- String representing the blob- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result setUnsupportedEncodingException
- if UTF-8 is not supportedIllegalArgumentException
- if the dbType is not found
-
setBlob
public void setBlob(String dbType, PreparedStatement statement, int pos, byte[] bytes) throws SQLException, IllegalArgumentException
Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can usesetBlob(String, PreparedStatement, int, String)
- Parameters:
dbType
- The identifier of the db type usedstatement
- The satement where the blob will be setpos
- position in the statementbytes
- byte[] representing the blob, in UTF-8- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result setIllegalArgumentException
- if the dbType is not found
-
setBlob
public void setBlob(String dbType, PreparedStatement statement, int pos, InputStream is, long length) throws SQLException, IllegalArgumentException
Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can usesetBlob(String, PreparedStatement, int, String)
- Parameters:
dbType
- The identifier of the db type usedstatement
- The satement where the blob will be setpos
- position in the statementis
- inputStream to put in the bloblength
- length of the stream- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result setIllegalArgumentException
- if the dbType is not found
-
-