Methods Summary |
---|
private void | checkHotConfigChanges(javax.management.ObjectName mbeanName)
//different case
try {
//check whether the mbeanName pertains to a server instance.
// String instanceName = ObjectNameHelper.getServerInstanceName(mbeanName);
String instanceName = ApplicationServer.getServerContext().getInstanceName();
ObjectName instanceObjectName = ObjectNames.getServerInstanceObjectName(instanceName);
Object canApply = this.invoke(instanceObjectName, HOT_CONFIG_METHOD_NAME,
null, null);
//debug("return value" + canApply);
if (canApply.equals(Boolean.FALSE)) {
String msg = localStrings.getString(
"admin.server.core.jmx.configuration_changed_apply_changes",
instanceName);
throw new AFRuntimeStoreException( msg );
}
} catch(AFRuntimeStoreException af) {
throw af;
} catch (Exception e) {
String msg = localStrings.getString( "admin.server.core.jmx.bad_server_configuration" );
sLogger.log(Level.INFO, msg, e);
throw new AFRuntimeException( msg, e );
}
|
private javax.management.ObjectInstance | createAndRegister(java.lang.String className, javax.management.ObjectName objectName)
final Class mbeanClass = Class.forName( className );
final Object mbeanImpl = mbeanClass.newInstance();
final ObjectInstance mbeanInstance = this.registerMBean( mbeanImpl, objectName );
sLogger.log(Level.FINE, "core.system_mbean_init_ok", objectName.toString() );
return( mbeanInstance );
|
public static synchronized com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor | createInstance(com.sun.enterprise.admin.AdminContext adminContext, javax.management.MBeanServer outerMBeanServer, javax.management.MBeanServer delegateMBeanServer)
if ( _Instance != null ) {
throw new IllegalStateException();
}
_Instance = new SunoneInterceptor(
adminContext, outerMBeanServer, delegateMBeanServer );
return _Instance;
|
protected final void | debug(java.lang.Object args)
mDebug.println( args );
|
private void | generateEntryContext(java.lang.Object obj)
ServerEntryHelper.generateMbeanEntryContext((ObjectName) obj);
|
public java.lang.Object | getAttribute(javax.management.ObjectName objectName, java.lang.String attributeName)
if(isInstanceMBean(objectName)) {
checkHotConfigChanges(objectName);
}
registerWithPersistenceCheck(objectName);
//logMBeanInfo(objectName);
Object value = proxyMBeanServer.getAttribute(objectName, attributeName);
return ( value );
|
public javax.management.AttributeList | getAttributes(javax.management.ObjectName objectName, java.lang.String[] attrNames)//, RuntimeOperationsException
// if(isInstanceMBean(objectName))
{
checkHotConfigChanges(objectName);
}
registerWithPersistenceCheck(objectName);
return ( proxyMBeanServer.getAttributes(objectName, attrNames) );
|
public java.lang.ClassLoader | getClassLoader(javax.management.ObjectName objectName)
debug( "SunoneInterceptor: getClassLoader: " + objectName );
registerWithPersistenceCheck(objectName);
return proxyMBeanServer.getClassLoader( objectName );
|
public java.lang.ClassLoader | getClassLoaderFor(javax.management.ObjectName objectName)
debug( "SunoneInterceptor: getClassLoaderFor: " + objectName );
registerWithPersistenceCheck(objectName);
return proxyMBeanServer.getClassLoaderFor( objectName );
|
private javax.management.loading.ClassLoaderRepository | getClassLoaderRepository()
debug( "SunoneInterceptor: getClassLoaderRepository()" );
return ( proxyMBeanServer.getClassLoaderRepository() );
|
public static synchronized com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor | getInstance()
if ( _Instance == null ) {
throw new IllegalStateException();
}
return _Instance;
|
public javax.management.MBeanInfo | getMBeanInfo(javax.management.ObjectName objName)
registerWithPersistenceCheck(objName);
return ( proxyMBeanServer.getMBeanInfo(objName) );
|
private void | initialize()Initializes the MBeanServer. This method registers the System MBeans.
The System MBeans are assumed to have default constructor.
final ObjectName controllerObjectName
= ObjectNames.getControllerObjectName();
final ObjectName configObjectName
= ObjectNames.getGenericConfiguratorObjectName();
final ObjectName[] objectNames = {
controllerObjectName,
configObjectName };
final String controllerClassName =
"com.sun.enterprise.admin.server.core.mbean.config.ServerController";
final String configClassName =
"com.sun.enterprise.admin.server.core.mbean.config.GenericConfigurator";
final String[] clNames = {controllerClassName, configClassName};
for (int i = 0 ; i < clNames.length ; i++) {
createAndRegister( clNames[i], objectNames[ i ] );
}
registerDottedNameSupport();
|
public java.lang.Object | invoke(javax.management.ObjectName objectName, java.lang.String operationName, java.lang.Object[] params, java.lang.String[] signature)
generateEntryContext(objectName);
if(isInstanceMBean(objectName) && isConfigCheckRequired(operationName)) {
checkHotConfigChanges(objectName);
}
if(FORCE_APPLY_METHOD_NAME.equals(operationName)) {
// Manual changes to config will be overwritten, so persist the
// state restart is required.
String instanceName =
ObjectNameHelper.getServerInstanceName(objectName);
AdminEventCache cache = AdminEventCache.getInstance(instanceName);
cache.setRestartNeeded(true);
//operationName = APPLY_METHOD_NAME;
}
registerWithPersistenceCheck(objectName);
//logMBeanInfo(objectName);
Object actualResult = proxyMBeanServer.invoke(objectName, operationName,
params, signature );
return ( actualResult );
|
private boolean | isConfigCheckRequired(java.lang.String operationName)
//debug("Entering isConfigCheckRequired:" + operationName);
if(GET_HOST_AND_PORT_METHOD_NAME.equals(operationName)) {
//debug("getHostAndPort: returning FALSE");
return false;
}
if(FORCE_APPLY_METHOD_NAME.equals(operationName)) {
//debug("overwriteConfigChanges: returning FALSE");
return false;
}
if(USE_MANUAL_METHOD_NAME.equals(operationName)) {
//debug("useManualConfigChanges: returning FALSE");
return false;
}
if(HOT_CONFIG_METHOD_NAME.equals(operationName)) {
return false;
}
//START: Optimization to prevent multiple checks for changes
if("getMBeanInfo".equals(operationName)) {
return false;
}
//END: Optimization to prevent multiple checks for changes
//debug("RETURNING true");
return true;
|
private boolean | isInstanceMBean(javax.management.ObjectName mbeanName)
if(ObjectNameHelper.getServerInstanceName(mbeanName) != null) {
return true;
} else {
return false;
}
|
private void | logMBeanInfo(javax.management.ObjectName oName)
// if we are not logging at the finest level, just return
if (!sLogger.isLoggable(Level.FINEST)) {
return;
}
//This method assumes that the mbean is registered.
MBeanInfo info = null;
try {
info = proxyMBeanServer.getMBeanInfo(oName);
} catch (Exception e) {
e.printStackTrace();
return;
}
sLogger.log(Level.FINEST,"\nCLASSNAME: \t"+ info.getClassName());
sLogger.log(Level.FINEST,"\nDESCRIPTION: \t"+ info.getDescription());
sLogger.log(Level.FINEST,"\nATTRIBUTES");
MBeanAttributeInfo[] attrInfo = info.getAttributes();
if (attrInfo.length>0) {
for(int i=0; i<attrInfo.length; i++) {
sLogger.log(Level.FINEST," ** NAME: \t"+ attrInfo[i].getName());
sLogger.log(Level.FINEST," DESCR: \t"+ attrInfo[i].getDescription());
sLogger.log(Level.FINEST," TYPE: \t"+ attrInfo[i].getType() +
"\tREAD: "+ attrInfo[i].isReadable() +
"\tWRITE: "+ attrInfo[i].isWritable());
}
} else
sLogger.log(Level.FINEST," ** No attributes **");
sLogger.log(Level.FINEST,"\nCONSTRUCTORS");
MBeanConstructorInfo[] constrInfo = info.getConstructors();
for(int i=0; i<constrInfo.length; i++) {
sLogger.log(Level.FINEST," ** NAME: \t"+ constrInfo[i].getName());
sLogger.log(Level.FINEST," DESCR: \t"+ constrInfo[i].getDescription());
sLogger.log(Level.FINEST," PARAM: \t"+ constrInfo[i].getSignature().length +" parameter(s)");
}
sLogger.log(Level.FINEST,"\nOPERATIONS");
MBeanOperationInfo[] opInfo = info.getOperations();
if (opInfo.length>0) {
for(int i=0; i<opInfo.length; i++) {
sLogger.log(Level.FINEST," ** NAME: \t"+ opInfo[i].getName());
sLogger.log(Level.FINEST," DESCR: \t"+ opInfo[i].getDescription());
sLogger.log(Level.FINEST," PARAM: \t"+ opInfo[i].getSignature().length +" parameter(s)");
}
} else
sLogger.log(Level.FINEST," ** No operations ** ");
sLogger.log(Level.FINEST,"\nNOTIFICATIONS");
MBeanNotificationInfo[] notifInfo = info.getNotifications();
if (notifInfo.length>0) {
for(int i=0; i<notifInfo.length; i++) {
sLogger.log(Level.FINEST," ** NAME: \t"+ notifInfo[i].getName());
sLogger.log(Level.FINEST," DESCR: \t"+ notifInfo[i].getDescription());
}
} else
sLogger.log(Level.FINEST," ** No notifications **");
|
private void | logMBeanServerInfo()Logs the MBeanServer information. It is logged to the server's output/error
log, to convey the information about MBeanServer implementation used.
try {
final String name = "JMImplementation:type=MBeanServerDelegate";
final ObjectName oName = new ObjectName(name);
sLogger.log(Level.FINE, "core.mbs_info");
//log the implementation name
String attrName = "ImplementationName";
String result = (String) proxyMBeanServer.
getAttribute(oName, attrName);
sLogger.log(Level.FINE, "core.mbs_implementation", result);
//log the implementation vendor
attrName = "ImplementationVendor";
result = (String) proxyMBeanServer.getAttribute(oName, attrName);
sLogger.log(Level.FINE, "core.mbs_vendor", result);
//log the impl version
attrName = "ImplementationVersion";
result = (String) proxyMBeanServer.getAttribute(oName, attrName);
sLogger.log(Level.FINE, "core.jmx_impl_version", result);
//log the MBeanServerId
attrName = "MBeanServerId";
result = (String) proxyMBeanServer.getAttribute(oName, attrName);
sLogger.log(Level.FINE, "core.mbs_id", result);
result = proxyMBeanServer.getClass().getName();
sLogger.log(Level.FINE, "core_mbs_classname", result);
}
catch(Exception e) {
throw new RuntimeException (e);
}
|
private synchronized void | manufactureAndRegisterMBean(javax.management.ObjectName oName)this method added to synchronize lazy loaded MBeans manufacturing and registering
//the "second" check inside synchronized area (it will perevent double manufacturing)
if ( outerMBeanServer.isRegistered(oName) ) {
//sLogger.log(Level.FINE, "core.mbean_exists", oName);
debug( "manufactureAndRegisterMBean: already registered: " + oName );
return; //already registered
}
//call to lazy loading here
final Object product = manufactureMBean(oName);
if(product==null)
{
debug( "manufactureAndRegisterMBean: can't manufacture: " + oName );
final String msg = localStrings.getString(
"admin.server.core.jmx.lazybean_not_found",
oName.toString());
throw new InstanceNotFoundException(msg);
}
//register MBean.
debug( "manufactureAndRegisterMBean: registering: " + oName );
this.registerMBean(product, oName);
debug( "manufactureAndRegisterMBean: registered: " + oName );
sLogger.log(Level.FINE, "core.create_and_register", oName);
|
private java.lang.Object | manufactureMBean(javax.management.ObjectName oName)
final PersistenceChecker checker = new PersistenceChecker();
checker.setAdminContext(adminContext);
final Object storedObject = checker.findElement(oName);
Object match = null;
if (storedObject != null) {
MBeanManufacturer producer = new MBeanManufacturer(oName, storedObject);
producer.setAdminContext(adminContext);
match = producer.createMBeanInstance();
}
else {
//this is severe - storage is not in sync with whatever is requested to be done.
sLogger.log(Level.FINEST, "core.not_in_config", oName);
}
//Actually it should be asserted that match is NOT null.
return ( match );
|
public synchronized void | registerConfigMBeans()
if(! _alreadyCalled ) {
_alreadyCalled = true;
try {
final MBeanRegistry mr = MBeanRegistryFactory.getAdminMBeanRegistry();
mr.instantiateAndRegisterAllConfigMBeans(
adminContext.getAdminConfigContext(),
ApplicationServer.getServerContext().getDefaultDomainName());
}
catch (Throwable t) {
sLogger.log(Level.WARNING, "Error in registering configMBeans", t);
}
}
|
private void | registerDottedNameSupport()
final Class initerClass = Class.forName( DottedMBeansIniterClassName );
// invoke new DottedNamesMBeanIniter( MBeanServer m )
final Class [] signature = new Class [] { MBeanServer.class };
final java.lang.reflect.Constructor constructor = initerClass.getConstructor( signature );
constructor.newInstance( new Object [] { outerMBeanServer } );
// done--it will have done its job
|
private javax.management.ObjectInstance | registerMBean(java.lang.Object object, javax.management.ObjectName objectName)
// !!! registration must be done with 'outerMBeanServer';
// we are not delegating here and so the "outside world" must see
// the registration
return outerMBeanServer.registerMBean(object, objectName);
|
private void | registerWithPersistenceCheck(javax.management.ObjectName oName)This method does the following in a sequential manner:
If the MBean with given ObjectName is registered, do nothing.
If the MBean does not exist, create the MBean by "manufacturing process".
If the MBean is thus manufactured, then register that MBean in MBeanServer.
if ( "ias".equals( oName.getDomain() ) ) {
throw new RuntimeException( "JMX domain 'ias' not suppported" );
}
if (! outerMBeanServer.isRegistered(oName) ) {
debug( "MBean NOT registered, will try to manufacture: " + oName );
try {
//Manufacture the MBean now.
manufactureAndRegisterMBean(oName);
debug( "Manufactured: " + oName );
}
catch (InstanceNotFoundException infe)
{
debug( "FAILED to manufacture: " + oName + " | " + infe );
throw infe;
}
catch (RuntimeException re)
{
debug( "FAILED to manufacture: " + oName + " | " + re );
throw re;
}
catch (Exception e) {
debug( "FAILED to manufacture: " + oName + " | " + e );
throw new RuntimeException(e);
}
}
|
public void | setAttribute(javax.management.ObjectName objectName, javax.management.Attribute attribute)
if(isInstanceMBean(objectName)) {
checkHotConfigChanges(objectName);
}
registerWithPersistenceCheck(objectName);
//logMBeanInfo(objectName);
proxyMBeanServer.setAttribute(objectName, attribute);
|
public javax.management.AttributeList | setAttributes(javax.management.ObjectName objectName, javax.management.AttributeList attributeList)
if(isInstanceMBean(objectName)) {
checkHotConfigChanges(objectName);
}
registerWithPersistenceCheck(objectName);
return ( proxyMBeanServer.setAttributes(objectName, attributeList) );
|
private void | shutdown()
MBeanServerFactory.releaseMBeanServer(proxyMBeanServer);
sLogger.log(Level.FINE, "core.release_mbs");
|