InstanceDefinitionpublic class InstanceDefinition extends Object A class that defines the Server Instance so that it can be created.
Identifies all the required attributes of an (iAS) Instance.
Depends upon the value of Install Root ie. "com.sun.aas.instanceRoot" |
Fields Summary |
---|
public static final int | DEFAULT_PORT | public static final int | DEFAULT_JMS_PORT | public static final String | DEFAULT_JMS_USER | public static final String | DEFAULT_JMS_PW | public static final String | SPACE | public static final String | WINDOWS_BIN_EXT | public static final String | BIN_DIR_NAME | public static final String | LIB_DIR_NAME | private String | mJavaHome | private String | mImqHome | private String | mServerName | private int | mHttpPort | private String | mIdentifier | private String | mMailHost | private String | mUser | private String | mDocRoot | private String | mPortString | private int | mJMSPort | private String | mJMSPortString | private String | mJMSUser | private String | mJMSPasswd | public static final String | UNIX_START_COMMAND_NAME | public static final String | UNIX_STOP_COMMAND_NAME | public static final String | UNIX_GETTOKENS_COMMAND_NAME | public static final String | UNIX_RESTART_COMMAND_NAME | public static final String | WIN_START_COMMAND_NAME | public static final String | WIN_STOP_COMMAND_NAME | public static final String | WIN_GETTOKENS_COMMAND_NAME | public final String | JMS_NODE_PATH |
Constructors Summary |
---|
public InstanceDefinition(String serverName, int httpPort, String identifier, String mailHost, String user, String docRoot, int jmsPort, String jmsUser, String jmsPasswd)Creates new InstanceDefinition.
initialize(serverName, httpPort, identifier, mailHost, user, docRoot,
jmsPort, jmsUser, jmsPasswd);
| public InstanceDefinition(String id, int port)Creates new InstanceDefinition with the given parameters.
if (id == null || port <= 0)
throw new IllegalArgumentException(Localizer.getValue(ExceptionType.ILLEGAL_PORT));
String serverName = createLocalHostName();
String mailHost = createLocalHostName();
String user = System.getProperty("user.name");
String docRoot = ServerManager.INSTANCE_CFG_ROOT
+ "/" + ServerManager.DOC_DIR_NAME;
initialize(serverName, port, id, mailHost, user, docRoot,
DEFAULT_JMS_PORT, DEFAULT_JMS_USER, DEFAULT_JMS_PW);
|
Methods Summary |
---|
private java.lang.String | createLocalHostName()
try {
return InetAddress.getLocalHost().getHostName();
}
catch(UnknownHostException ue) {
return "localhost";
}
| public java.lang.String | getAdminJavaHome()
ConfigContext configContext;
InstanceEnvironment instanceEnvironment =
new InstanceEnvironment(ServerManager.ADMINSERVER_ID);
String fileUrl = instanceEnvironment.getConfigFilePath();
configContext = ConfigFactory.createConfigContext(fileUrl);
ConfigBean configbean = ConfigBeansFactory.getConfigBeanByXPath(
configContext, ServerXPathHelper.XPATH_JAVACONFIG);
mJavaHome = configbean.getAttributeValue(ServerTags.JAVA_HOME);
return mJavaHome;
| private java.lang.String[] | getCompleteNonWindowsStartCommand()
String[] names = new String[] {
System.getProperty(Constants.IAS_ROOT), /* upto domain */
BIN_DIR_NAME, /* "bin" */
UNIX_START_COMMAND_NAME /* "startserv" */
};
String programName = StringUtils.makeFilePath(names, false);
return ( new String[]{programName} );
| private java.lang.String[] | getCompleteWindowsStartCommand()Returns the windows start command. Note that it is
[install-root]/bin/startsec.exe.
String[] names = new String[] {
System.getProperty(Constants.INSTALL_ROOT), /* install-root */
BIN_DIR_NAME, /* "bin" */
WIN_START_COMMAND_NAME /* "startsec.exe" */
};
String programName = StringUtils.makeFilePath(names, false);
/* startsec requires server-id as the first(only) parameter */
return ( new String[] {
programName, /* path to strtsec */
mIdentifier, /* "server-id" */
System.getProperty(Constants.IAS_ROOT), /* path to domain root */
} );
| public java.lang.String | getDocRoot()
return ( mDocRoot );
| public java.lang.String[] | getGetSecurityTokensCommand()Returns the complete path of the gettokens
command for getting security tokens of this instance.
It returns the array of Strings which form the complete
command line.
String[] command = null;
String onlyCommand = null;
if (OS.isWindows()) {
onlyCommand = getWindowsSecTokensCommand();
}
else {
onlyCommand = getNonWindowsSecTokensCommand();
}
command = new String[] {
onlyCommand, /* path of gettokens */
mIdentifier, /* "instance-id": param1 */
System.getProperty(Constants.IAS_ROOT), /* path to domain root */
};
return ( command );
| public java.lang.String | getID()
return mIdentifier;
| private java.lang.String | getNonWindowsSecTokensCommand()
String[] names = new String[] {
System.getProperty(Constants.INSTALL_ROOT), /* install-root */
LIB_DIR_NAME, /* "lib" */
UNIX_GETTOKENS_COMMAND_NAME /* "gettokens" */
};
return ( StringUtils.makeFilePath(names, false) );
| public int | getPort()
return mHttpPort;
| public java.lang.String[] | getRestartCommand()Returns the complete path of the restart
script for restarting this instance. Note that it returns the
platform-specific string that could be exec'ed.
if (OS.isWindows()) {
throw new UnsupportedOperationException(Localizer.getValue(ExceptionType.ILLEGAL_RESTART));
}
String[] restartCommand = new String[1];
String[] names = new String[] {
System.getProperty(Constants.IAS_ROOT), /* upto a domain */
BIN_DIR_NAME, /* "bin" */
UNIX_RESTART_COMMAND_NAME /* "restartserv" */
};
restartCommand[0] = StringUtils.makeFilePath(names, false);
return ( restartCommand );
| public java.lang.String | getServerName()
return mServerName;
| public java.lang.String[] | getStartCommand()Returns the complete path of the start
command for starting this instance. Note that it returns the
platform-specific string that could be exec'ed.
String[] startCommand = null;
/* Note that for windows, the startup executable is stored
at the install-root - one per installation. startsec.exe
just takes the instance name as the only parameter.
*/
if (OS.isWindows()) {
startCommand = getCompleteWindowsStartCommand();
}
else {
/* Note that for non-windows platforms, the startup executable is stored
at the instance directory - one per instance. startserv
script does not take any parameter.
*/
startCommand = getCompleteNonWindowsStartCommand();
}
return ( startCommand );
| public java.lang.String[] | getStopCommand()Returns the complete path of the stop
command for stopping this instance. Note that it returns the
platform-specific string that could be exec'ed.
String[] stopCommand = new String[1];
String command = null;
if (OS.isWindows()) {
command = WIN_STOP_COMMAND_NAME;
}
else {
command = UNIX_STOP_COMMAND_NAME;
}
String[] names = new String[] {
System.getProperty(Constants.IAS_ROOT), /*upto a domain */
BIN_DIR_NAME, /* "bin" */
command /* "stopserv" or "stopserv.bat"*/
};
stopCommand[0] = StringUtils.makeFilePath(names, false);
return ( stopCommand );
| public java.lang.String | getUser()Getter for the instance-user instance variable.
return mUser;
| private java.lang.String | getWindowsSecTokensCommand()
String[] names = new String[] {
System.getProperty(Constants.INSTALL_ROOT), /* install-root */
BIN_DIR_NAME, /* "bin" */
WIN_GETTOKENS_COMMAND_NAME /* "gettokens.exe" */
};
return ( StringUtils.makeFilePath(names, false) );
| private void | initialize(java.lang.String serverName, int httpPort, java.lang.String identifier, java.lang.String mailHost, java.lang.String user, java.lang.String docRoot, int jmsPort, java.lang.String jmsUser, java.lang.String jmsPasswd)
if (serverName == null|| identifier == null||
mailHost == null|| user == null||
user == null|| docRoot == null||
jmsUser == null|| jmsPasswd == null ) {
throw new IllegalArgumentException();
}
if (httpPort <= 0 || jmsPort <= 0) {
throw new IllegalArgumentException();
}
mServerName = serverName;
mHttpPort = httpPort;
mIdentifier = identifier;
mMailHost = mailHost;
mUser = user;
mDocRoot = docRoot;
mPortString = "" + mHttpPort;
mJMSPort = jmsPort;
mJMSPortString = jmsPort +"";
mJMSUser = jmsUser;
mJMSPasswd = jmsPasswd;
| public void | setUser(java.lang.String user)Sets the user (owner) of the instance.
if ((user != null) && (user.length() > 0))
{
mUser = user;
}
| public java.lang.String | toString()Overridden definition of toString for this Instance Definition.
Shows the ServerName, Port, Identifier, MailHostName, User and
Doc Root for the instance.
StringBuffer sb = new StringBuffer();
sb.append(mServerName);
sb.append(SPACE + mPortString);
sb.append(SPACE + mIdentifier);
sb.append(SPACE + mMailHost);
sb.append(SPACE + mUser);
sb.append(SPACE + mDocRoot);
return ( sb.toString() );
|
|