Methods Summary |
---|
protected com.sun.enterprise.admin.mbeans.DomainStatusMBean | getDomainStatus()
DomainStatusMBean domainStatus = null;
try {
final MBeanServer mbeanServer = getMBeanServer();
final Set<ObjectName> candidates = QueryMgrImpl.queryPatternObjectNameSet(
mbeanServer, JMXUtil.newObjectNamePattern(
"*", DomainStatusMBean.DOMAIN_STATUS_PROPS ) );
final ObjectName on = GSetUtil.getSingleton( candidates );
domainStatus = (DomainStatusMBean)MBeanServerInvocationHandler.
newProxyInstance( mbeanServer, on, DomainStatusMBean.class, false );
} catch (Exception e) {
final Throwable rootCause = ExceptionUtil.getRootCause( e );
getMBeanLogger().warning( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
}
return( domainStatus );
|
private javax.management.MBeanAttributeInfo[] | getMBeanAttributeInfo()
MBeanAttributeInfo[] dAttributes = new MBeanAttributeInfo[1];
dAttributes[0] = new MBeanAttributeInfo("state",
"java.lang.Integer",
"server state",
true,
false,
false);
return dAttributes;
|
public synchronized javax.management.MBeanInfo | getMBeanInfo()
// compute the MBeanInfo only once!
if ( mMBeanInfo == null )
{
final MBeanInfo superMBeanInfo = super.getMBeanInfo();
mMBeanInfo = new MBeanInfo(
superMBeanInfo.getClassName(),
superMBeanInfo.getDescription(),
mergeAttributeInfos(superMBeanInfo.getAttributes(), getMBeanAttributeInfo()),
superMBeanInfo.getConstructors(),
mergeOperationInfos(superMBeanInfo.getOperations(), getMBeanOperationInfo()),
superMBeanInfo.getNotifications() );
}
return mMBeanInfo;
|
private javax.management.MBeanOperationInfo[] | getMBeanOperationInfo()
MBeanOperationInfo[] dOperations = new MBeanOperationInfo[3];
dOperations[0] = new MBeanOperationInfo("start",
"start server instance",
null,
"void",
MBeanOperationInfo.ACTION);
dOperations[1] = new MBeanOperationInfo("stop",
"stop server instance",
null,
"void",
MBeanOperationInfo.ACTION);
dOperations[2] = new MBeanOperationInfo("startRecursive",
"start server instance",
null,
"void",
MBeanOperationInfo.ACTION);
return dOperations;
|
public boolean | getRestartRequired()
// there might not be a Delegate. Default to 'true', since a non-running server
// must be restarted!
boolean required = true;
if ( getDelegate() != null )
{
try {
final Object result = getDelegate().getAttribute( "restartRequired" );
required = Boolean.valueOf( "" + result );
}
catch( AttributeNotFoundException e ) {
logWarning( ExceptionUtil.toString(e) );
required = true;
}
}
return required;
|
protected java.lang.String | getServerName()
return( getSelfName() );
|
public int | getstate()
try {
return (getDomainStatus().getstate(getServerName()));
} catch (Exception e) {
final Throwable rootCause = ExceptionUtil.getRootCause( e );
getMBeanLogger().warning( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
}
return StateManageable.STATE_FAILED;
|
public void | handleNotification(javax.management.Notification notif, java.lang.Object obj)
final String notifType = notif.getType();
if ( notifType.equals( DomainStatusMBean.SERVER_STATUS_NOTIFICATION_TYPE ) )
{
final String serverName = (String)
Util.getAMXNotificationValue( notif, DomainStatusMBean.SERVER_NAME_KEY );
if ( serverName.equals( getServerName() ) )
{
setDelegate();
}
}
|
private boolean | isDASJ2EEServer()Does this particular J2EEServer represent the DAS?
return DAS_SERVER_NAME.equals( getName() );
|
public boolean | isstateManageable()
return true;
|
private javax.management.MBeanAttributeInfo[] | mergeAttributeInfos(javax.management.MBeanAttributeInfo[] infos1, javax.management.MBeanAttributeInfo[] infos2)
final MBeanAttributeInfo[] infos =
new MBeanAttributeInfo[ infos1.length + infos2.length ];
System.arraycopy( infos1, 0, infos, 0, infos1.length );
System.arraycopy( infos2, 0, infos, infos1.length, infos2.length );
return( infos );
|
private javax.management.MBeanOperationInfo[] | mergeOperationInfos(javax.management.MBeanOperationInfo[] infos1, javax.management.MBeanOperationInfo[] infos2)
final MBeanOperationInfo[] infos =
new MBeanOperationInfo[ infos1.length + infos2.length ];
System.arraycopy( infos1, 0, infos, 0, infos1.length );
System.arraycopy( infos2, 0, infos, infos1.length, infos2.length );
return( infos );
|
public void | preRegisterDone()
super.preRegisterDone( );
setstartTime( 0 );
setDelegate();
|
private boolean | remoteServerIsRunning()
return (StateManageable.STATE_RUNNING == getstate());
|
private boolean | remoteServerIsStartable()
final int cState = getstate();
return (StateManageable.STATE_STOPPED == cState) ||
(StateManageable.STATE_FAILED == cState);
|
private boolean | remoteServerIsStoppable()
int cState = getstate();
if ((StateManageable.STATE_STARTING == cState) ||
(StateManageable.STATE_RUNNING == cState) ||
(StateManageable.STATE_FAILED == cState))
{
return true;
}
else
{
return false;
}
|
private synchronized void | setDelegate()
if ( remoteServerIsRunning() )
{
try {
// get the object name for the old jsr77 server mBean
com.sun.enterprise.ManagementObjectManager mgmtObjManager =
com.sun.enterprise.Switch.getSwitch().getManagementObjectManager();
final String strON = mgmtObjManager.getServerBaseON(false, getServerName());
final MBeanServerConnection remoteConn =
getDomainStatus().getServerMBeanServerConnection( getServerName() );
final ObjectName onPattern = new ObjectName(strON + ",*");
final Set<ObjectName> names = JMXUtil.queryNames( remoteConn, onPattern, null);
assert( names.size() == 1 );
final ObjectName serverON = GSetUtil.getSingleton( names );
final Delegate delegate = new DelegateToMBeanDelegate( remoteConn, serverON );
setDelegate( delegate );
setstartTime(System.currentTimeMillis());
}
catch (Exception e) {
final Throwable rootCause = ExceptionUtil.getRootCause( e );
getMBeanLogger().warning(
rootCause.toString() + "\n" + ExceptionUtil.getStackTrace( rootCause ) );
}
}
else
{
setDelegate( DummyDelegate.INSTANCE );
setstartTime(0);
}
|
public void | start()
if ( remoteServerIsStartable() )
{
startRemoteServer();
}
else
{
throw new RuntimeException("server is not in a startable state");
}
|
public void | startRecursive()
start();
|
private void | startRemoteServer()
try {
// get the object name for servers config mBean
ObjectName on = DomainStatusHelper.getServersConfigObjectName();
// invoke start method on servers config mBean
// get mBean server
final MBeanServer server = getMBeanServer();
// form the parameters
Object[] params = new Object[1];
params[0] = getServerName();
String[] signature = {"java.lang.String"};
// invoke the start method
server.invoke(on, "startServerInstance", params, signature);
} catch (javax.management.MalformedObjectNameException mfone) {
final Throwable rootCause = ExceptionUtil.getRootCause( mfone );
getMBeanLogger().warning( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
throw new RuntimeException(mfone);
} catch (javax.management.InstanceNotFoundException infe) {
final Throwable rootCause = ExceptionUtil.getRootCause( infe );
getMBeanLogger().warning( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
throw new RuntimeException(infe);
} catch (javax.management.MBeanException mbe) {
final Throwable rootCause = ExceptionUtil.getRootCause( mbe );
getMBeanLogger().warning( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
throw new RuntimeException(mbe);
} catch (javax.management.ReflectionException rfe) {
final Throwable rootCause = ExceptionUtil.getRootCause( rfe );
getMBeanLogger().warning( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
throw new RuntimeException(rfe);
}
|
public void | stop()
if ( isDASJ2EEServer() )
{
getDelegate().invoke( "stop", (Object[])null, (String[])null);
}
else if ( remoteServerIsStoppable() )
{
stopRemoteServer();
}
else
{
throw new RuntimeException("server is not in a stoppable state");
}
|
private void | stopRemoteServer()
try {
// get the object name for servers config mBean
ObjectName on = DomainStatusHelper.getServersConfigObjectName();
// invoke stop method on servers config mBean
// get mBean server
final MBeanServer server = getMBeanServer();
// form the parameters
Object[] params = new Object[1];
params[0] = getServerName();
String[] signature = {"java.lang.String"};
// invoke the start method
server.invoke(on, "stopServerInstance", params, signature);
} catch (javax.management.MalformedObjectNameException mfone) {
final Throwable rootCause = ExceptionUtil.getRootCause( mfone );
getMBeanLogger().warning( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
throw new RuntimeException(mfone);
} catch (javax.management.InstanceNotFoundException infe) {
// in case of PE and DAS
// it is desit]rable that the instance be not stopped
// hence the log level is fine
final Throwable rootCause = ExceptionUtil.getRootCause( infe );
getMBeanLogger().fine( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
throw new RuntimeException(infe);
} catch (javax.management.MBeanException mbe) {
final Throwable rootCause = ExceptionUtil.getRootCause( mbe );
getMBeanLogger().warning( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
throw new RuntimeException(mbe);
} catch (javax.management.ReflectionException rfe) {
final Throwable rootCause = ExceptionUtil.getRootCause( rfe );
getMBeanLogger().warning( rootCause.toString() + "\n" +
ExceptionUtil.getStackTrace( rootCause ) );
throw new RuntimeException(rfe);
}
|