Methods Summary |
---|
public boolean | applyConfigChanges()Copies the file from backup directory to the real config directory
so that the configuration is stored on disk. There is no guarantee of
any transactional support. In case of admin server instance only
server.xml file is edited in the backup directory, so this method only
copies server.xml. (The other conf files for admin instance are edited
directly in live configuration area). As there is no dynamic
reconfiguration for admin server, the admin instance always requires
restart for new settings to take affect.
try {
InstanceEnvironment ie = new InstanceEnvironment(
ServerManager.ADMINSERVER_ID);
// Force write of server.xml changes because the check to ensure
// that manual edits are not lost (the method canApplyConfigChanges)
// is already invoked from MBeanServer just before invoking this
// (applyConfigChanges) method.
//ie.applyServerXmlChanges(true);
initDelegate();
ConfigContext ctx = mDelegate.getConfigContext(
ServerManager.ADMINSERVER_ID);
ctx.resetConfigChangeList();
mRestartNeeded = true;
/* New for 8.0 - temporary - gen server.xml b4 notif */
/* This call most likely goes away */
if (ManagedServerInstance.PORT_DOMAIN_TO_SERVER) {
final String domainXMLPath = ie.getConfigFilePath();
final String serverXMLPath = System.getProperty(Constants.IAS_ROOT)
+ "/"
+ ie.getName()
+ "/config/"
+ ie.kServerXMLFileName;
new Domain2ServerTransformer(domainXMLPath, serverXMLPath).transform();
}
/* New for 8.0 - temporary - gen server.xml b4 notif */
} catch (ConfigException ce) {
_logger.log(Level.INFO, "mbean.config.admin.apply_failed",
ce.getLocalizedMessage());
_logger.log(Level.FINEST, ce.getMessage(), ce);
throw new ServerInstanceException(ce.getLocalizedMessage());
}
return mRestartNeeded;
|
public boolean | canApplyConfigChanges()Can config changes be applied. This method returns true
- if live server.xml has not been manually edited or
- if live server.xml has been manully edited but no other changes
have been made through the GUI or CLI to backup server.xml.
.
This method is explicitly coded to not throw any exception and will
return false in case there is any exception in processing.
boolean canApply = false;
try {
initDelegate();
//InstanceEnvironment ie = new InstanceEnvironment(
// ServerManager.ADMINSERVER_ID);
/*
if (ie.hasHotXmlChanged()) {
if (ie.canReloadManualXmlChanges()) {
ie.useManualServerXmlChanges();
mDelegate.reloadAfterChange(ie);
canApply = true;
}
} else {
*/
canApply = true;
/*
}
**/
} catch (Exception ex) {
_logger.log(Level.INFO, "mbean.config.admin.canapply_failed",
ex.getLocalizedMessage());
_logger.log(Level.FINEST, ex.getLocalizedMessage(), ex);
}
return canApply;
|
public com.sun.enterprise.admin.util.HostAndPort | getHostAndPort()
return getHttpListenerHostPort();
|
private com.sun.enterprise.admin.util.HostAndPort | getHttpListenerHostPort()Returns the host & port of the http listener 'http-listener-1'.
(host by default is localhost).
HostAndPort hAndp = null;
try
{
//ms1 Server server = (Server) super.getBaseConfigBean();
Config config = (Config) super.getConfigBeanByXPath(ServerXPathHelper.XPATH_CONFIG);
HttpService https = config.getHttpService();
HttpListener[] hlArray = https.getHttpListener();
//check not needed since there should always be atleast 1 httplistener
//if you don't find one, use first one.
HttpListener ls = hlArray[0];
//default is the first one that is enabled.
for(int i = 0;i<hlArray.length;i++) {
if(hlArray[i].isEnabled()) {
ls = hlArray[i];
break;
}
}
String port = ls.getPort();
int intPort = Integer.parseInt (port);
hAndp = new HostAndPort("localhost", intPort);
}
catch (Exception e)
{
throw new ServerInstanceException(e.getLocalizedMessage());
}
return hAndp;
|
private synchronized void | initDelegate()
if (mDelegate != null)
{
return;
}
try
{
HostAndPort hp = getHttpListenerHostPort();
mDelegate = new ManagedServerInstance(ServerManager.ADMINSERVER_ID,
hp, false);
}
catch (ServerInstanceException sie)
{
throw sie;
}
catch (PortInUseException piue)
{
}
catch (Exception e)
{
throw new ServerInstanceException(e.getLocalizedMessage());
}
|
public boolean | isApplyNeeded(boolean check)Is apply changes required. This method added to sync up with
ManagedServerInstance. SOM uses same object for admin server mbean
non admin server mbean. Therefore the method signatures should be same.
return isApplyNeeded();
|
public boolean | isApplyNeeded()Is apply changes required. This method returns true if any changes
have been made to server.xml that have not been applied yet.
boolean applyNeeded = false;
try
{
initDelegate();
ConfigContext ctx = mDelegate.getConfigContext(
ServerManager.ADMINSERVER_ID);
applyNeeded = ctx.isChanged();
} catch (ConfigException ce) {
_logger.log(Level.INFO, "mbean.config.admin.applyneeded_failed",
ce.getMessage());
_logger.log(Level.FINEST, ce.getMessage(), ce);
throw new ServerInstanceException(ce.getLocalizedMessage());
}
return applyNeeded;
|
public boolean | isRestartNeeded()Is restart needed. For admin server instance, there is no dynamic
reconfiguration, so restart is needed whenever any change is applied.
return mRestartNeeded;
|
public boolean | useManualConfigChanges()Use manual config changes. This method is invoked if the user decides
to keep the hand edits to server.xml.
try {
initDelegate();
InstanceEnvironment ie =
new InstanceEnvironment(ServerManager.ADMINSERVER_ID);
// copy server.xml from hot to back
//ie.useManualServerXmlChanges();
// Reinitialize mbeans
mDelegate.reloadAfterChange(ie);
// Set restart needed to true because we do not know whether admin
// server is already running with the changes in server.xml -- the
// policy is say restart is needed unless you know otherwise.
mRestartNeeded = true;
} catch (ConfigException ce) {
_logger.log(Level.INFO, "mbean.config.admin.usemanual_failed",
ce.getMessage());
_logger.log(Level.FINEST, ce.getMessage(), ce);
throw new ServerInstanceException(ce.getLocalizedMessage());
}
return mRestartNeeded;
|