BaseProcessorpublic abstract class BaseProcessor extends Object implements com.sun.jdo.spi.persistence.utility.database.DatabaseConstants
Fields Summary |
---|
protected static final com.sun.jdo.spi.persistence.utility.logging.Logger | loggerThe logger | protected static final ResourceBundle | messagesI18N message handler | protected com.sun.enterprise.deployment.Application | application | protected com.sun.enterprise.deployment.backend.DeploymentEventInfo | info | protected com.sun.enterprise.deployment.backend.DeploymentStatus | status | protected boolean | createTrue if this event results in creating new tables. | protected String | cliCreateTables | protected String | cliDropAndCreateTables | protected String | cliDropTables | protected String | appRegisteredNameName with which the application is registered. | protected String | appDeployedLocation | protected String | appGeneratedLocation | protected String | createJdbcFileNameThe string name of the create jdbc ddl file. | protected String | dropJdbcFileNameThe string name of the drop jdbc ddl file. | protected boolean | debug |
Methods Summary |
---|
protected void | cannotConnect(java.lang.String connName, java.lang.Throwable ex)Provide a warning message to the user about inability to connect to the
database. The message is created from the cmpResource's JNDI name and
the exception.
logI18NWarnMessage( "ejb.BaseProcessor.cannotConnect",
connName, null, ex);
| protected static void | closeConn(java.sql.Connection conn)Close the connection that was opened
to the database
if (conn != null) {
try {
conn.close();
} catch(SQLException ex) {
// Ignore.
}
}
| protected void | executeDDLs(java.io.File f, java.sql.Statement sql)Open a DDL file and execute each line as a SQL statement.
BufferedReader reader = null;
StringBuffer warningBuf = new StringBuffer();
try {
reader = new BufferedReader(new FileReader(f));
String s;
while ((s = reader.readLine()) != null) {
try {
if (debug) {
logger.fine("ejb.BaseProcessor.executestatement", s); //NOI18N
}
sql.execute(s);
} catch(SQLException ex) {
String msg = getI18NMessage("ejb.BaseProcessor.sqlexception",
s, null, ex);
logger.warning(msg);
warningBuf.append("\n\t").append(msg); // NOI18N
}
}
} finally {
if (reader != null) {
try {
reader.close();
} catch(IOException ex) {
// Ignore.
}
}
if (warningBuf.length() > 0) {
String warning =
getI18NMessage("ejb.BaseProcessor.tablewarning");
warnUser(warning + warningBuf.toString());
}
}
| protected void | fileIOError(java.lang.String regName, java.lang.Throwable ex)
logI18NWarnMessage("ejb.BaseProcessor.ioexception",
regName, null, ex);
| protected java.io.File | getDDLFile(java.lang.String fileName, boolean create)Read the ddl file from the disk location.
File file = null;
try {
file = new File(fileName);
if (debug) {
logger.fine(
((create)? "ejb.BaseProcessor.createfilename" //NOI18N
: "ejb.BaseProcessor.dropfilename"), //NOI18N
file.getName());
}
} catch (Exception e) {
logI18NWarnMessage(
"Exception caught in BaseProcessor.getDDLFile()",
appRegisteredName, null, e);
}
return file;
| protected java.lang.String | getI18NMessage(java.lang.String errorCode)
return getI18NMessage(
errorCode, null, null, null);
| protected java.lang.String | getI18NMessage(java.lang.String errorCode, java.lang.String regName, java.lang.String fileName, java.lang.Throwable ex)
String msg = null;
if(null != ex)
msg = I18NHelper.getMessage(
messages, errorCode, regName, ex.toString());
else if(null != fileName )
msg = I18NHelper.getMessage(
messages, errorCode, regName, fileName);
else
msg = I18NHelper.getMessage(messages, errorCode);
return msg;
| private void | initializeVariables(com.sun.enterprise.deployment.backend.DeploymentEventInfo info, boolean create, java.lang.String cliCreateTables, java.lang.String cliDropAndCreateTables, java.lang.String cliDropTables)
this.info = info;
this.application = this.info.getApplicationDescriptor();
this.appRegisteredName = this.application.getRegistrationName();
this.status =
this.info.getDeploymentRequest().getCurrentDeploymentStatus();
this.create = create;
this.cliCreateTables = cliCreateTables;
this.cliDropAndCreateTables = cliDropAndCreateTables;
this.cliDropTables = cliDropTables;
| protected void | logI18NInfoMessage(java.lang.String errorCode, java.lang.String regName, java.lang.String fileName, java.lang.Throwable ex)
String msg = getI18NMessage(errorCode,
regName, fileName, ex);
logger.info(msg);
| protected void | logI18NWarnMessage(java.lang.String errorCode, java.lang.String regName, java.lang.String fileName, java.lang.Throwable ex)
String msg = getI18NMessage(errorCode,
regName, fileName, ex);
logger.warning(msg);
warnUser(msg);
| protected abstract void | processApplication()
| protected void | setApplicationLocation()The location where the application has been deployed. This would ideally
be the domains/domain1/applications directory. This information is obtained
from the DeploymentEventListener object that is passed in.
if(null != this.appDeployedLocation)
return;
this.appDeployedLocation =
info.getDeploymentRequest().getDeployedDirectory().getAbsolutePath()
+ File.separator;
| protected void | setGeneratedLocation()The location where files have been generated as part of the application
deployment cycle. This is where we write out the sql/jdbc files used to
create or drop objects from the database. This information is obtained
from the DeploymentEventListener object that is passed in.
if(null != this.appGeneratedLocation)
return;
this.appGeneratedLocation =
info.getStubsDir().getAbsolutePath() + File.separator;
| protected void | warnUser(java.lang.String msg)Provide a warning message to the user. The message is appended to any
already-existing warning message text.
status.setStageStatus(DeploymentStatus.WARNING);
status.setStageStatusMessage(
status.getStageStatusMessage() + "\n" + msg); // NOI18N
|
|