*
* @param args array of arguments indicating command to be executed.
* See class comments for more information
*/
public static void main(String args[]) {
NetworkServerControlImpl server = null;
//
// The following variable lets us preserve the error printing behavior
// seen before we started installing a security manager. Errors can be
// raised as we figure out whether we need to install a security manager
// and during the actual installation of the security manager. We need
// to print out these errors. The old error printing behavior assumed
// that all errors were generated inside NetworkServerControlImpl and
// were reported there.
//
boolean printErrors = true;
try
{
server = new NetworkServerControlImpl();
int command = server.parseArgs( args );
//
// In order to run secure-by-default, we install a security manager
// if one isn't already installed. This feature is described by DERBY-2196.
//
if ( needsSecurityManager( server, command ) )
{
verifySecurityState( server );
installSecurityManager( server );
}
//
// From this point on, NetworkServerControlImpl is responsible for
// printing errors.
//
printErrors = false;
server.executeWork( command );
}
catch (Exception e)
{
//if there was an error, exit(1)
if ((e.getMessage() == null) ||
!e.getMessage().equals(NetworkServerControlImpl.UNEXPECTED_ERR) ||
printErrors
)
{
if (server != null)
server.consoleExceptionPrint(e);
else
e.printStackTrace(); // default output stream is System.out
}
// else, we've already printed a trace, so just exit.
System.exit(1);