Package org.glassfish.persistence.common
Class Java2DBProcessorHelper
java.lang.Object
org.glassfish.persistence.common.Java2DBProcessorHelper
- Author:
- pramodg
-
Constructor Summary
ConstructorsConstructorDescriptionJava2DBProcessorHelper(String appName) Creates a new instance of Java2DBProcessorHelper to be used to execute SQL statements only.Java2DBProcessorHelper(org.glassfish.api.deployment.DeploymentContext ctx) Creates a new instance of Java2DBProcessorHelper. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateOrDropTablesInDB(boolean create, String type) Iterate over all "create" or "drop" ddl files and execute them.voidexecuteDDLs(File f, Statement sql) Open a DDL file and execute each line as a SQL statement.booleanexecuteDDLStatement(File fileName, org.glassfish.api.naming.SimpleJndiName resourceName) Get the ddl files eventually executed against the database.booleanexecuteDDLStatement(String fileNamePrefix, org.glassfish.api.naming.SimpleJndiName resourceName) Get the DDL file and execute the statements.getCreateJdbcFileName(String bundleName) Returns createJdbcFileNamebooleangetCreateTables(boolean param) Create tables only on deploy, and only if the CLI options cliCreateTables or cliDropAndCreateTables are not set to false.booleangetCreateTables(String bundleName) Calculate createTables value based on the parameter stored on deploygetDDLFile(String fileName, boolean deploy) Read the ddl file from the disk location.static StringgetDDLNamePrefix(Object info) Returns name prefix for DDL files extracted from the info instance by the Sun-specific code.getDropJdbcFileName(String bundleName) Returns dropJdbcFileNamebooleangetDropTables(boolean param) Drop tables on undeploy and redeploy, if the corresponding CLI options cliDropAndCreateTables (for redeploy) or cliDropTables (for undeploy) are not set to false.booleangetDropTables(String bundleName) Calculate dropTables value based on the parameter stored on deploygetGeneratedLocation(String bundleName) Returns appGeneratedLocation or user defined value if the latter is specifiedgetI18NMessage(String errorCode) Get the localized message for the error code.getI18NMessage(String errorCode, String regName, String fileName, Throwable ex) Get a generic localized message.getJndiName(String bundleName) Returns jndiNamebooleanbooleanvoidinit()Initializes the rest of the settingsvoidlogI18NWarnMessage(String errorCode, String regName, String fileName, Throwable ex) Provide a generic warning message to the user.voidsetCreateJdbcFileName(String createJdbcFileName, String bundleName) Sets createJdbcFileNamevoidsetCreateTablesValue(boolean createTablesValue, String bundleName) Store user defined value for create tables for future reference.voidsetDropJdbcFileName(String dropJdbcFileName, String bundleName) Sets dropJdbcFileNamevoidsetDropTablesValue(boolean dropTablesValue, String bundleName) Store user defined value for drop tables for future reference.voidsetGeneratedLocation(String generatedLocation, String bundleName) Sets the substitute for the internal location of the generated filesvoidsetJndiName(org.glassfish.api.naming.SimpleJndiName jndiName, String bundleName) Sets jndiNamevoidsetProcessorType(String processorType, String bundleName) Sets this processor typestatic voidProvide a warning message to the user.
-
Constructor Details
-
Java2DBProcessorHelper
Creates a new instance of Java2DBProcessorHelper to be used to execute SQL statements only.- Parameters:
appName- the name used for reporting purposes
-
Java2DBProcessorHelper
public Java2DBProcessorHelper(org.glassfish.api.deployment.DeploymentContext ctx) Creates a new instance of Java2DBProcessorHelper. Do not parse all the data until it's requested in the #init() call.- Parameters:
ctx- the deployment context object.
-
-
Method Details
-
init
public void init()Initializes the rest of the settings -
createOrDropTablesInDB
Iterate over all "create" or "drop" ddl files and execute them. Skip processing if the boolean argument is false. -
getDDLFile
Read the ddl file from the disk location.- Parameters:
fileName- the string name of the file.deploy- true if this event results in creating tables.- Returns:
- the jdbc ddl file.
-
executeDDLs
Open a DDL file and execute each line as a SQL statement.- Parameters:
f- the File object to use.sql- the Statement to use for execution.- Throws:
IOException- if there is a problem with reading the file.
-
getDeployedLocation
-
getAppRegisteredName
-
getCreateJdbcFileName
Returns createJdbcFileName -
setCreateJdbcFileName
Sets createJdbcFileName -
getDropJdbcFileName
Returns dropJdbcFileName -
setDropJdbcFileName
Sets dropJdbcFileName -
getJndiName
Returns jndiName -
setJndiName
Sets jndiName -
setProcessorType
Sets this processor type -
getGeneratedLocation
Returns appGeneratedLocation or user defined value if the latter is specified -
setGeneratedLocation
Sets the substitute for the internal location of the generated files -
hasDeployCliOverrides
public boolean hasDeployCliOverrides()- Returns:
- true if cli overrides were set during deploy
-
hasUndeployCliOverrides
public boolean hasUndeployCliOverrides()- Returns:
- true if cli overrides were set during undeploy
-
getCreateTables
public boolean getCreateTables(boolean param) Create tables only on deploy, and only if the CLI options cliCreateTables or cliDropAndCreateTables are not set to false. If those options are not set (null) the value is taken from the boolean parameter provided by the caller.- Returns:
- true if tables are to be created.
-
getDropTables
public boolean getDropTables(boolean param) Drop tables on undeploy and redeploy, if the corresponding CLI options cliDropAndCreateTables (for redeploy) or cliDropTables (for undeploy) are not set to false. If the corresponding option is not set the value is taken from the boolean parameter provided by the caller.- Returns:
- true if the tables have to be dropped.
-
getCreateTables
Calculate createTables value based on the parameter stored on deploy -
setCreateTablesValue
Store user defined value for create tables for future reference. -
getDropTables
Calculate dropTables value based on the parameter stored on deploy -
setDropTablesValue
Store user defined value for drop tables for future reference. -
getDDLNamePrefix
Returns name prefix for DDL files extracted from the info instance by the Sun-specific code.- Parameters:
info- the instance to use for the name generation.- Returns:
- name prefix as String.
-
executeDDLStatement
public boolean executeDDLStatement(File fileName, org.glassfish.api.naming.SimpleJndiName resourceName) Get the ddl files eventually executed against the database. This method deals with both create and drop ddl files.- Parameters:
fileName- the create or drop jdbc ddl file.resourceName- the jdbc resource name that would be used to get a connection to the database.- Returns:
- true if the tables were successfully created/dropped from the database.
-
executeDDLStatement
public boolean executeDDLStatement(String fileNamePrefix, org.glassfish.api.naming.SimpleJndiName resourceName) Get the DDL file and execute the statements.- Parameters:
fileNamePrefix- the common prefix for the DDL file nameresourceName- the jdbc resource name that would be used to get a connection to the database.- Returns:
- true if the statements were successfully in the database.
-
logI18NWarnMessage
Provide a generic warning message to the user. -
getI18NMessage
Get the localized message for the error code.- Parameters:
errorCode-- Returns:
- i18ned message
-
getI18NMessage
Get a generic localized message. -
warnUser
Provide a warning message to the user. The message is appended to any already-existing warning message text.- Parameters:
msg- Message for user.
-