Database Reference
In-Depth Information
INSERT INTO appsec.v_application_registry
(application_id, app_user, app_role) VALUES
('OJSADMIN','AVADMIN','APPVER_ADMIN');
The Create App Class Button
When the application developer has included the Login class in his application, modifying the
application ID and the package, he has made the registration of his application in Oracle database much
easier. If he had not gone this route, then we would have to get his application inner class definition
from him, and would have to execute the command CREATE OR REPLACE AND RESOLVE JAVA SOURCE
NAMED . However, since he is following the preferred GUI development path, using Login, we know
enough from his package alone to create a class on the Oracle database to represent his application.
So, when we get to the Register New Application screen, and we see the word “Login” typed in the
Class field, we provide a button to allow easy creation of a representative application inner class on the
database. The code in Listing 12-43 is used to display or hide that button. We use a keyReleased event to
tell when the user has entered a character in the classTextField . If after entering the character, the text
of the field equals “Login,” then we make the button visible. Otherwise, we hide it.
Listing 12-43. Display or Hide the Create App Class Button
private void classTextField_keyReleased(KeyEvent e) {
if (classTextField.getText().equals("Login"))
createTemplateButton.setVisible(true);
else
createTemplateButton.setVisible(false);
}
When the button is visible, it can be selected and it then executes the code in the
createTemplateButton_actionPerformed() method. In that method, we find the code shown in Listing
12-44. To create the template class in the database, we call the p_create_template_class procedure. That
is a new procedure that we are defining in the appsec_admin_pkg package. We pass in the fully qualified
class name; however, we don't read all the user-provided fields to get that. Rather we read the package
name that the user provided and append the string “.Login$InnerRevLvlClass” to the package name.
Listing 12-44. Create a Template Class in Oracle
stmt = (OracleCallableStatement)conn.prepareCall(
"call appsec.appsec_admin_pkg.p_create_template_class ( ?,?,? )");
stmt.registerOutParameter(2, OracleTypes.NUMBER);
stmt.registerOutParameter(3, OracleTypes.VARCHAR);
stmt.setString(1, packageTextField.getText() + ".Login$InnerRevLvlClass") ;
stmt.setInt(2, 0);
stmt.setNull(3, OracleTypes.VARCHAR);
stmt.executeUpdate();
Listing 12-45 shows the code of the new p_create_template_class procedure. The procedure needs
to live on the apver database instance, so the definition is included in the script file
Chapter12/ApverSys.sql . The bulk of this procedure is given to the definition of the Java inner class.
Notice that there are two places in that inner-class definition that we insert the package name: once in
the name of the Java structure and once in the package statement. We do several tests before we decide
 
Search WWH ::




Custom Search