Accessing the Initialization Files
The RPL command $PROFILE or the Java API interface de.rochade.serveradmin.ServerAdmin allows you to access initialization files. Using this command, you can read, write, and delete settings of the initialization file. For a detailed description of the command, see the ASG-Rochade Programmer’s Guide Volume 1 or the Java API documentation.
In principle, you can edit initialization files manually with an editor. If you do this, however, be sure not to change the format of the initialization files in any way.
Reading Settings and Sections
This section describes how to use Metability and the Rochade APIs to read settings and sections from the initialization file.
To read the contents of the server initialization file in Metability
- Open the Administration perspective.
- In the Administration tree, right-click the node for the server connection for which you want to display the initialization file (for example, Admin connection), then select Server Configuration from the context menu.
The content of the server initialization file displays in the Editor frame:
Using the Rochade APIs to Read Settings from the Initialization File
This sample code shows how to use the Rochade APIs to read the content of a setting DB1 from an initialization file section CLIENT-1 and writes it to a variable argdb (or ARGDB):
Method | Sample Code |
---|---|
Java API |
String argdb = srvadm.getProfileString("CLIENT-1", "DB1"); |
RPL |
$PROFILE GET CLIENT-1 DB1 ARGDB |
SRAP |
ResultSet details = ResultSetFactory.getResultSet("name, attribute", "String, String", null); details.add(); details.updateString("name", "CLIENT-1"); details.updateString("attribute", "DB1");
ResultSet what = ResultSetFactory.getResultSet("attribute, mode, details", "String, String, ResultSet", null); what.add(); what.updateString("attribute", "profileSection"); what.updateString("mode", ServerAdmin.OperationMode.GET); what.updateResultSet("details", details);
ResultSet rs = srvadm.adminOperation(what); rs.absolute(1); rs = rs.getResultSet("details"); rs.absolute(1); String argdb = rs.getString("sValue"); |
In SRAP, you also can fill ResultSets using the insert method. For example:
details.insert(details.findColumns("name, attribute"), new
String[]{"CLIENT-1", "DB1"});
You can also list all of the settings contained in a specific section. The sample code in this table lists all settings of the section CLIENT-1:
Method | Sample Code |
---|---|
Java API |
String settings = srvadm.listProfileSection("CLIENT-1", true); |
RPL |
$PROFILE LIST CLIENT-1 |
SRAP |
ResultSet what = ResultSetFactory.getResultSet("attribute, mode, details", "String, String, ResultSet", null); what.add(); what.updateString("attribute", "profileSection"); what.updateString("mode", ServerAdmin.OperationMode.GET); what.updateResultSet("details", ResultSetSupport.wrapupString("name", "CLIENT-1"));
ResultSet rs = srvadm.adminOperation(what); rs.absolute(1); rs = rs.getResultSet("details"); rs.absolute(1); rs = rs.getResultSet("details"); for(int i=1; i<=rs.getRowCount(); i++) { rs.absolute(i); String settings = rs.getString("attribute"); System.out.println(settings); } |
Then you can continue processing this list using commands/methods of your choice.
Accessing Reserved Settings and Sections
This sample code shows how to use the Rochade APIs to read the content of the environment variable PATH and writes it to a variable argpath (or ARGPATH):
Method | Sample Code |
---|---|
Java API |
String argpath = srvadm.getProfileString("$ENVIRONMENT", "PATH"); |
RPL |
$PROFILE GET $ENVIRONMENT PATH ARGPATH |
SRAP |
ResultSet details = ResultSetFactory.getResultSet("name, attribute", "String, String", null); details.add(); details.updateString("name", "$ENVIRONMENT"); details.updateString("attribute", "PATH");
ResultSet what = ResultSetFactory.getResultSet("attribute, mode, details", "String, String, ResultSet", null); what.add(); what.updateString("attribute", "profileSection"); what.updateString("mode", ServerAdmin.OperationMode.GET); what.updateResultSet("details", details);
ResultSet rs = srvadm.adminOperation(what); rs.absolute(1); rs = rs.getResultSet("details"); rs.absolute(1); String argpath = rs.getString("sValue"); |
The sample code in this table adds the String ;C:\ASG\ROCHADE to the environment variable PATH:
Method | Sample Code |
---|---|
Java API |
argpath = argpath + ";C:\\ASG\\ROCHADE"; srvadm.setProfileString("$ENVIRONMENT", "PATH", argpath); |
RPL |
$STR ARGSEMI X; 2 1 $CONCAT ARGPATH :ARGPATH :ARGSEMI C:\ASG\ROCHADE $PROFILE SET $ENVIRONMENT PATH :ARGPATH |
SRAP |
argpath = argpath + ";C:\\ASG\\ROCHADE";
ResultSet details = ResultSetFactory.getResultSet("name, attribute, sValue", "String, String, String", null); details.add(); details.updateString("name", "$ENVIRONMENT"); details.updateString("attribute", "PATH"); details.updateString("sValue", argpath);
ResultSet what = ResultSetFactory.getResultSet("attribute, mode, details", "String, String, ResultSet", null); what.add(); what.updateString("attribute", "profileSection"); what.updateString("mode", ServerAdmin.OperationMode.SET); what.updateResultSet("details", details);
ResultSet rs = srvadm.adminOperation(what); |
Writing Settings and Sections
The sample code in this table stores the string UPDATE_AUTOPILOT and the current date in the variable argupd (or ARGUPD), and then writes the content of the variable to the setting $ROUPD in the section CLIENT-1:
Method | Sample Code |
---|---|
Java API |
Date date = new Date(); String argupd = "UPDATE_AUTOPILOT" + date; srvadm.setProfileString("CLIENT-1", "$ROUPD", argupd); |
RPL |
$CONCAT ARGUPD UPDATE_AUTOPILOT / :$DATE $PROFILE SET CLIENT-1 $ROUPD :ARGUPD |
SRAP |
Date date = new Date(); String argupd = "UPDATE_AUTOPILOT" + date;
ResultSet details = ResultSetFactory.getResultSet("name, attribute, sValue", "String, String, String", null); details.add(); details.updateString("name", "CLIENT-1"); details.updateString("attribute", "$ROUPD"); details.updateString("sValue", argupd);
ResultSet what = ResultSetFactory.getResultSet("attribute, mode, details", "String, String, ResultSet", null); what.add(); what.updateString("attribute", "profileSection"); |
|
what.updateString("mode", ServerAdmin.OperationMode.SET); what.updateResultSet("details", details);
ResultSet rs = srvadm.adminOperation(what); |
If CLIENT-1 or $ROUPD do not exist in the server initialization file, they are created. The Metability Server Administration also automatically creates and updates the required settings and sections in the server initialization file.
Deleting Settings and Sections
The sample code in this table deletes the setting $ROUPD from the section CLIENT-1 (for example, to remove obsolete update information after reinstalling a component):
Method | Sample Code |
---|---|
Java API |
srvadm.delProfileString("CLIENT-1", "$ROUPD"); |
RPL |
$PROFILE DEL CLIENT-1 $ROUPD |
SRAP |
ResultSet details = ResultSetFactory.getResultSet("name, attribute", "String, String", null); details.add(); details.updateString("name", "CLIENT-1"); details.updateString("attribute", "$ROUPD");
ResultSet what = ResultSetFactory.getResultSet("attribute, mode, details", "String, String, ResultSet", null); what.add(); what.updateString("attribute", "profileSection"); what.updateString("mode", ServerAdmin.OperationMode.REMOVE); what.updateResultSet("details", details);
ResultSet rs = srvadm.adminOperation(what); |
The sample code in this table deletes the section PrivProg from the initialization file:
Method | Sample Code |
---|---|
Java API |
srvadm.delProfileSection("PrivProg"); |
RPL |
$PROFILE DELS @PrivProg |
SRAP |
ResultSet details = ResultSetFactory.getResultSet("name", "String", null); details.add(); details.updateString("name", "PrivProg");
ResultSet what = ResultSetFactory.getResultSet("attribute, mode, details", "String, String, ResultSet", null); what.add(); what.updateString("attribute", "profileSection"); what.updateString("mode", ServerAdmin.OperationMode.REMOVE); what.updateResultSet("details", details);
ResultSet rs = srvadm.adminOperation(what); |