Methods Summary |
---|
public void | createServerInstance(InstanceDefinition instance)Creates the given ServerInstance. InstanceDefinition may not be null.
Gives call to underlying cgi program
to actually create the new instance of iAS. The creation of instance
consists of creation of directory structure as per the definition of
instance.
Note that this method does an expensive Runtime.exec() internally.
/*
* Be very careful with this method. All the paths that are
* required to be put into the various config files for
* an instance have forward slashes regardless of the
* underlying platform.
*/
/* Removing this entire method as it is not applicable to PE */
throw new UnsupportedOperationException("createServerInstance - not in PE");
|
public void | deleteServerInstance(java.lang.String instanceName)A method to delete the server instance with given name or id.
Unlike other methods to create, start and stop the instances, this
method does not depend on other lower level API. The file system folder
where the instance's configuration resides, is deleted.
Running instance should be soped before this call (in ServerController).
On NT the Service needs to be deleted - which is not yet implemented (01/26/02).
/* Removing this entire method as it is not applicable to PE */
throw new UnsupportedOperationException("deleteServerInstance - not in PE");
|
public java.lang.String | getDomainName()Provides the domain name from the domain root
File domainRoot = new File(INSTANCE_CFG_ROOT);
return domainRoot.getName();
|
private int | getFreePort(int defaultPort)This method is a wrapper over the other routine to get the port.
It provides logging support and default ports.
int port = NetUtils.getFreePort();
if (port == 0) {
/* log the stuff */
sLogger.log(Level.SEVERE, "general.free_port_failed");
return defaultPort;
}
else {
Integer portInteger = new Integer(port);
sLogger.log(Level.INFO, "general.free_port", portInteger);
return port;
}
|
public java.lang.String[] | getInstanceNames(boolean countAdmin)The instance names are not registered in any configuration file for iASSE.
Hence this method scans the folder on disk where installation is done, each time
it is called and returns the instance names. Note that all the instances
are denoted by https-id folders in INSTALL_ROOT. This method returns
an array of all ids. Note that admin server itself is NOT returned
as an Instance.
//KE: FIXTHIS. We can get instances from domain.xml only.
return new String[] {"server"};
|
public java.lang.String | getInstanceUser(InstanceEnvironment env)
/*
Need an alternative. PE conf does'nt include init.conf.
Ramakanth 04/23/2003
*/
/*
if (env == null)
{
throw new IllegalArgumentException("env cant be null");
}
InitConfFileBean initConf = new InitConfFileBean();
initConf.readConfig(env.getInitFilePath());
String instanceUser = initConf.get_mag_var("User");
return instanceUser;
*/
return System.getProperty("user.name");
|
public java.lang.String | getMimeTypesTemplateFilePath()Returns the path of the mime.types.template file for this installation.
This templates file is stored in the templates directory.
final String libDirName = "lib";
final String installDirName = "install";
final String templateDirName = "templates";
final String mimeTemplateFileName = "mime.types.template";
String [] fileNames = new String[] {INSTALL_ROOT, libDirName,
installDirName, templateDirName, mimeTemplateFileName};
return ( StringUtils.makeFilePath(fileNames, false) );
|
public int | getNumInstances(boolean countAdmin)Returns the number of instances depending on whether the admin
instance is to be counted.
return ( getInstanceNames(countAdmin).length );
|
public java.lang.String[] | getSecurityTokensForInstance(InstanceDefinition instance)
if (instance == null) {
throw new IllegalArgumentException();
}
String[] command = instance.getGetSecurityTokensCommand();
String[] inputLines = null;
try {
sLogger.log(Level.FINE, "general.gettokens_cmd", command[0]);
ProcessExecutor executor = new ProcessExecutor(command);
return executor.execute(true);
}
catch (ExecException ee) {
throw new RuntimeException(Localizer.getValue(ExceptionType.NO_RECEIVE_TOKENS));
}
catch (Exception e) {
throw new ConfigException(e.getMessage());
}
|
public static com.sun.enterprise.instance.ServerManager | instance()Static Method to get a reference to the singleton.
return SHARED_INSTANCE;
|
public boolean | instanceExists(java.lang.String instanceID)A method to find whether a Server Instance with given name exists
in the install. The instanceID should be the one designated by the user
while creating the instance. An Instance is recognized by the configuration
stored in a folder (on file system) named https- id. (This is
for historical reasons). So, there are as many instances as there are
folders beginning with string https-. No other consideration will be
given. This method always ignores admin server.
//KE: FIXTHIS: We can only tell if an instance exists by looking
//at domain.xml
if (instanceID.equals("server")) {
return true;
}
return false;
|
private boolean | portTakenByHTTP(int port)Method to check whether the given port has clash with the
http ports of other instances. It checks in the server.xml
of various instances for this.
boolean portTaken = true;
String portString = "" + port;
String[] instances = getInstanceNames(true);
/* count admin server also for this purpose */
try {
for (int i = 0 ; i < instances.length ; i++) {
String instanceName = instances[i];
InstanceEnvironment inst =
new InstanceEnvironment(instanceName);
String backURL = inst.getConfigFilePath();
ConfigContext context = ConfigFactory.
createConfigContext(backURL);
Config rootElement = ServerBeansFactory.getConfigBean(context);
HttpService httpService = rootElement.getHttpService();
HttpListener[] httpListeners =
httpService.getHttpListener();
for (int j = 0 ; j < httpListeners.length ; j++) {
String aPort = httpListeners[j].getPort();
aPort = aPort.trim();
sLogger.log(Level.FINE, "port = " + aPort);
if (aPort.equals(portString)) {
sLogger.log(Level.WARNING,
"general.port_occupied", instanceName);
return portTaken;
}
}
}
}
catch (Exception e) {
sLogger.log(Level.WARNING, "general.port_derivation_failed", e);
}
return ( false );
|
private boolean | portTakenByJMS(int port)Checks whether this port is taken by jms provider (imq broker).
boolean portTaken = true;
String portString = "" + port;
String[] instances = getInstanceNames(true);
/* count admin server also for this purpose */
try {
for (int i = 0 ; i < instances.length ; i++) {
String instanceName = instances[i];
InstanceEnvironment inst =
new InstanceEnvironment(instanceName);
String backURL = inst.getConfigFilePath();
ConfigContext context = ConfigFactory.
createConfigContext(backURL);
JmsHost jmsHost = ServerBeansFactory.getJmsHostBean(context);
String aPort = jmsHost.getPort();
aPort = aPort.trim();
sLogger.log(Level.FINE, "port = " + aPort);
if (aPort.equals(portString)) {
sLogger.log(Level.WARNING,
"general.port_occupied", instanceName);
return portTaken;
}
}
}
catch (Exception e) {
sLogger.log(Level.WARNING, "general.port_derivation_failed", e);
}
return ( false );
|
private boolean | portTakenByORB(int port)Checks whether this port is occupied by any of the orb listeners.
boolean portTaken = true;
String portString = "" + port;
String[] instances = getInstanceNames(true);
/* count admin server also for this purpose */
try {
for (int i = 0 ; i < instances.length ; i++) {
String instanceName = instances[i];
InstanceEnvironment inst =
new InstanceEnvironment(instanceName);
String backURL = inst.getConfigFilePath();
ConfigContext context = ConfigFactory.
createConfigContext(backURL);
Config rootElement = ServerBeansFactory.getConfigBean(context);
IiopService iiopService = rootElement.getIiopService();
IiopListener[] iiopListeners = iiopService.getIiopListener();
for (int j = 0 ; j < iiopListeners.length ; j++) {
String aPort = iiopListeners[j].getPort();
aPort = aPort.trim();
sLogger.log(Level.FINE, "port = " + aPort);
if (aPort.equals(portString)) {
sLogger.log(Level.WARNING,
"general.port_occupied", instanceName);
return portTaken;
}
}
}
}
catch (Exception e) {
sLogger.log(Level.WARNING, "general.port_derivation_failed", e);
}
return ( false );
|
public void | restartServerInstance(InstanceDefinition instance)
if (instance == null) {
throw new IllegalArgumentException();
}
String[] restartCommand = instance.getRestartCommand();
try {
sLogger.log(Level.FINE, "general.exec_cmd", restartCommand[0]);
ProcessExecutor executor = new ProcessExecutor(restartCommand);
executor.execute();
}
catch (Exception e) {
throw new ConfigException(e.getMessage());
}
|
public void | startServerInstance(InstanceDefinition instance)Starts the given instance. The argument may not be null.
Gives call to start program inside the proper directory structure of
that instance (e.g. /export/iplanet/ias7/https-test/start).
The createServerInstance call has to succeed for this call to work.
Note that it gives call to an expensive Runtime.exec().
startServerInstance(instance, null);
|
public void | startServerInstance(InstanceDefinition instance, java.lang.String[] passwords)
if (instance == null) {
throw new IllegalArgumentException();
}
String[] startCommand = instance.getStartCommand();
String[] inputLines = null;
if(passwords!=null)
inputLines = passwords;
else
inputLines = new String[]{}; //to provoke stream closing
//startCommand = startCommand + " " + instance.getID() + " " + INSTALL_ROOT;
try {
sLogger.log(Level.FINE, "general.exec_cmd", startCommand[0]);
ProcessExecutor executor = new ProcessExecutor(startCommand, inputLines);
executor.execute();
}
catch (ExecException ee) {
sLogger.log(Level.WARNING, "general.exec_cmd", ee);
throw new RuntimeException(Localizer.getValue(ExceptionType.SERVER_NO_START));
}
catch (Exception e) {
throw new ConfigException(e.getMessage());
}
|
public void | stopServerInstance(InstanceDefinition instance)Stops the given instance. The argument may not be null.
Gives call to stop program inside the proper directory structure of
that instance (e.g. /export/iplanet/ias7/https-test/stop).
The createServerInstance call has to succeed for this call to work.
Note that it gives call to an expensive Runtime.exec().
if (instance == null) {
throw new IllegalArgumentException();
}
String stopCommand[] = instance.getStopCommand();
try {
sLogger.log(Level.FINE, "general.exec_cmd", stopCommand[0]);
ProcessExecutor executor = new ProcessExecutor(stopCommand);
executor.execute();
}
catch (Exception e) {
throw new ConfigException(e.getMessage());
}
|