FileDocCategorySizeDatePackage
LoaderOfOldMonitor.javaAPI DocGlassfish v2 API14943Fri May 04 22:23:42 BST 2007com.sun.enterprise.management.support

LoaderOfOldMonitor

public final class LoaderOfOldMonitor extends LoaderOfOld
Loads MBeans.

Fields Summary
private static final Set
IGNORE_TYPES
Do not attempt to create corresponding "new" mbeans for these types
private static final Set
NEEDS_SUPPORT
These types need to be supported.
Constructors Summary
LoaderOfOldMonitor(Loader loader)

		super( loader );
	
Methods Summary
public java.util.SetfindAllOldCandidates()

		final ObjectName	pattern	= JMXUtil.newObjectName( "com.sun.appserv:category=monitor,*" );
		final Set<ObjectName> all	= JMXUtil.queryNames( getMBeanServer(), pattern, null );
		
		return( all );
	
private final java.lang.StringformApplicationAndServerProps(javax.management.ObjectName oldObjectName)

		final String	serverName	= oldObjectName.getKeyProperty( "server" );
		final String serverProp	= Util.makeProp( XTypes.SERVER_ROOT_MONITOR, serverName );
		
		String	props	= serverProp;
		
		String	applicationName	= oldObjectName.getKeyProperty( "application" );
		if ( applicationName == null )
		{
			applicationName	= AMX.NULL_NAME;
		}
		final String	applicationProp	= Util.makeProp( XTypes.APPLICATION_MONITOR, applicationName );
		
		props	= Util.concatenateProps( props, applicationProp );
		
		return( props );
	
private java.lang.StringgetContextRoot(java.lang.String webModuleName)


        ConfigBean cb = null;
        ConfigContext cCtx = AdminService.getAdminService().
                getAdminContext().getAdminConfigContext();

        try {
            cb = ApplicationHelper.findApplication(cCtx, webModuleName);
        } catch(Exception e) {
            // ignore
            return null;
        }
        if (cb instanceof WebModule) {
            String ctxRoot = ((WebModule) cb).getContextRoot();
            if ((ctxRoot != null) && (ctxRoot.length() > 0)) {
               if (ctxRoot.charAt(0) == '/"){
                    ctxRoot = ctxRoot.substring(1,ctxRoot.length()) ;
               }
            }
            return ctxRoot;
        } else {
            return null;
        }
    
protected java.util.SetgetIgnoreTypes()

		return( IGNORE_TYPES );
	
protected java.util.SetgetNeedsSupport()



		 
	
	
		return( NEEDS_SUPPORT );
	
public booleanisOldMBean(javax.management.ObjectName oldObjectName)

		return isOldMonitorObjectName( oldObjectName );
	
private booleanisOldMonitorObjectName(javax.management.ObjectName objectName)

		boolean	isOldMonitor	= false;
		
		if ( objectName.getDomain().equals( "com.sun.appserv" ) &&
				"monitor".equals( objectName.getKeyProperty( "category" ) ) )
		{
			final String	type	= objectName.getKeyProperty( "type" );
			
			isOldMonitor	= ! getIgnoreTypes().contains( type );
		}
		
		return( isOldMonitor );
	
private static voidmySleep(long millis)

		try
		{
			Thread.sleep( millis );
		}
		catch( InterruptedException e )
		{
		}
	
protected javax.management.ObjectNameoldToNewObjectName(javax.management.ObjectName oldObjectName)
Finding the monitoring peer for a WebModule is very complex as of version 8.1, due to the inconsistent names used for JSR 77 MBeans versus their monitoring equivalents. Mix in virtual servers, and context root versus module name, and it's a real witches-brew of naming--Lloyd Chambers 27 Oct 2004 Here are some facts: (1) the name property of a j2eeType=WebModule ObjectName is formed as //. always starts with "/". by default is the same as the name of the web module, but need not be. A typical name is thus: //server/MyModule (2) the name property of a type=standalone-web-module ObjectName is always the module name, never the context root. The name property of a type=web-module (embedded war) is the module name + ".war". The virtual server is not specified, since a type=standalone-web-module or type=web-module MBean is only a holder for webmodule-virtual-server mbeans. Thus, the usual parallel structure is malformed. in the case of monitoring mbeans for web modules. Examples: (a) j2eeType=WebModule,name=//server/bookstore,J2EEServer=server,J2EEApplication=null (b) type=standalone-web-module,name=bookstore,category=monitor,server=server (c) type=web-module,name=logging-helloworld.war,application=logging-helloworld,category=monitor,server=server (3) type=servlet is a monitoring mbean which contains properties standalone-web-module or web-module and the webmodule-virtual-server in which it resides. For example: (a) type=servlet,name=LoggingServlet,application=logging-helloworld,category=monitor, server=server,web-module=logging-helloworld.war,webmodule-virtual-server=server (b) type=servlet,name=jsp,category=monitor,server=server,standalone-web-module=bookstore,webmodule-virtual-server=server

see
ServletImpl #getMonitoringPeerObjectName

		final String	oldType	= oldObjectName.getKeyProperty( "type" );
		final String	domainName	= mLoader.getAMXJMXDomainName();
		
		ObjectName	newObjectName	= null;
		
		/*
		if ( oldType.equals( "webmodule-virtual-server" ) )
		{
		*
			Make the peer of a WebModule be a WebModuleVirtualServerMonitor
		 *
			final String	virtualServerName	= oldObjectName.getKeyProperty( "name" );
			final String	webModuleName		= WebModuleSupport.getWebModuleName( oldObjectName );
			final String compositeName	= WebModuleSupport.formCompositeName( virtualServerName, webModuleName );
			
			final String requiredProps	=
				Util.makeRequiredProps( XTypes.WEB_MODULE_VIRTUAL_SERVER_MONITOR, compositeName );
			
			final String	containmentProps	= formApplicationAndServerProps( oldObjectName );
			final String	props	= Util.concatenateProps( requiredProps, containmentProps );
			
			newObjectName	= JMXUtil.newObjectName( domainName, props );
		}
		else
		*/if ( oldType.equals( "servlet" ) )
		{
		    // A ServletMonitor is contained by its WebModuleVirtualServerMonitor
			// a monitor for a Servlet
			final String	webModuleVirtualServerMonitorName	= oldObjectName.getKeyProperty( "webmodule-virtual-server" );
			
			final String requiredProps	=
				Util.makeRequiredProps( XTypes.SERVLET_MONITOR, oldObjectName.getKeyProperty( "name" ) );
			
			final String containerProp  =
			    Util.makeProp( XTypes.WEB_MODULE_VIRTUAL_SERVER_MONITOR, webModuleVirtualServerMonitorName );
			final String	containmentProps	= formApplicationAndServerProps( oldObjectName );
			
			final String	props	= Util.concatenateProps( requiredProps, containerProp, containmentProps);
			
			newObjectName	= JMXUtil.newObjectName( domainName, props );
		}
		else
		if ( oldType.equals( "webservice-endpoint" ))
		{
			// a monitor for a web service endpoint
            // first look for a EJB web service endpoint
            String ejbModName =
            oldObjectName.getKeyProperty("standalone-ejb-module");
            if ( ejbModName == null)
            {
                // try if this is a ejb module in an application
                ejbModName = oldObjectName.getKeyProperty("ejb-module");
            }
            if ( ejbModName != null)
            {
                final String requiredProps	=
                    Util.makeRequiredProps( XTypes.WEBSERVICE_ENDPOINT_MONITOR, oldObjectName.getKeyProperty( "name" ) );
			
                final String modProp = Util.makeProp( XTypes.EJB_MODULE_MONITOR, ejbModName );
                final String containmentProps = formApplicationAndServerProps( oldObjectName );
			
                final String props	=
                    Util.concatenateProps( requiredProps, modProp, containmentProps);
			
                newObjectName	= JMXUtil.newObjectName( domainName, props );
            }
            else 
            {
                /*
                String	virtualServerName	= oldObjectName.getKeyProperty( "webmodule-virtual-server" );
                if ( virtualServerName == null)
                {
                    virtualServerName = "server";
                }

                final String	webModuleName= WebModuleSupport.getWebModuleName( oldObjectName );
                
                final String 	vsMonitorCompositeName	=
                    WebModuleSupport.formCompositeName( virtualServerName, webModuleName );
			
                final String requiredProps	=
                    Util.makeRequiredProps( XTypes.WEBSERVICE_ENDPOINT_MONITOR, oldObjectName.getKeyProperty( "name" ) );
			
                final String	virtualServerProp	= Util.makeProp( XTypes.WEB_MODULE_VIRTUAL_SERVER_MONITOR, vsMonitorCompositeName );
                final String	containmentProps	= formApplicationAndServerProps( oldObjectName );
			
                final String	props	= Util.concatenateProps( requiredProps, virtualServerProp, containmentProps);
			
                newObjectName	= JMXUtil.newObjectName( domainName, props );
                */
                final String requiredProps	=
                    Util.makeRequiredProps( XTypes.WEBSERVICE_ENDPOINT_MONITOR, oldObjectName.getKeyProperty( "name" ) );
			
                final String webModuleVirtualServerMonitorName	=
                    oldObjectName.getKeyProperty( "webmodule-virtual-server" );
                final String modProp =
                    Util.makeProp( XTypes.WEB_MODULE_VIRTUAL_SERVER_MONITOR, webModuleVirtualServerMonitorName );
                final String containmentProps = formApplicationAndServerProps( oldObjectName );
			
                final String props	=
                    Util.concatenateProps( requiredProps, modProp, containmentProps);
			
                newObjectName	= JMXUtil.newObjectName( domainName, props );
            }

        }
        else 
		{
			final OldTypeToJ2EETypeMapper	mapper	= OldMonitorTypes.getInstance();
			final OldProps	oldProps	= new OldProps( oldObjectName, mapper);

			String	props	= oldProps.getNewProps();
			newObjectName	=  JMXUtil.newObjectName( domainName, props );

			/*
				If it's containment hierarchy includes an APPLICATION_MONITOR, then if one
				is not present (eg a standalone web or ejb monitor),
				then insert one with name AMX.NULL_NAME.
			 */
			final String	j2eeType	= newObjectName.getKeyProperty( AMX.J2EE_TYPE_KEY );
			final String[]	fullType	= TypeInfos.getInstance().getJ2EETypeChain( newObjectName );
			for( int i = 0; i < fullType.length - 1; ++i )
			{
				if ( fullType[ i ].equals( XTypes.APPLICATION_MONITOR ) &&
					newObjectName.getKeyProperty( XTypes.APPLICATION_MONITOR ) == null )
				{
					final String	prop	= Util.makeProp( XTypes.APPLICATION_MONITOR, AMX.NULL_NAME );
					newObjectName	= JMXUtil.newObjectName( newObjectName, prop );
					break;
				}
			}
		} 		
		return( newObjectName );