FileDocCategorySizeDatePackage
J2EEManagementObjectManager.javaAPI DocGlassfish v2 API77099Fri May 04 22:24:36 BST 2007com.sun.enterprise.management.util

J2EEManagementObjectManager

public class J2EEManagementObjectManager extends Object implements com.sun.enterprise.ManagementObjectManager
J2EEManagementObjectManager is responsible for managing all JSR77 managed objects (MBeans). It is a "glue" integration layer between the J2EE RI and JMX (Java Management Extensions) and JSR77 implementations. It includes functionality for initializing JMX, registering and unregistering managed objects, starting and stopping J2EE modules, etc. The register/unregister methods are called from J2EE RI code when the RI objects corresponding to the MBeans are created/removed. RI code uses only the com.sun.enterprise.ManagementObjectManager interface.
author
Prakash Aradhya, Sanjeev Krishnan

Fields Summary
private com.sun.enterprise.management.agent.MEJB
mejbRef
private com.sun.enterprise.management.agent.MEJBUtility
mejbUtility
private static MBeanServer
server
private static String
domain
private static final String
QUEUE
private static final String
TOPIC
private static final String
DEFAULT_VIRTUAL_SERVER
private static Logger
_logger
private static boolean
_bHtmlAdaptorServerRegistered
Register html adaptor Used for testing only
Constructors Summary
public J2EEManagementObjectManager()


    /* uncomment the following if the HtmlAdaptorServer is needed */
    //private static HtmlAdaptorServer htmlAdaptorServer = null;

    /* Static initializer for mBean server */
     
        if (server == null) {
            initMBeanServer();
        }
        if ((server != null)) {
            registerHTMLAdaptor();
        }
    
        
	// set the default managed object agent
	// WARNING: This must be done before any managed objects are created    
	// if (moagentNotSet) {
        	//MOAgentFactory.setAgents(
		//    "com.sun.management.j2se.MOAgents.J2EEAgentImpl", 
		//    "com.sun.management.j2se.MOAgents.J2EEClientImpl");
//		moagentNotSet = false;
//	}
    
Methods Summary
private void_registerJ2EEClusters(java.lang.String[] clusters)

        final ConfigContext ctx = getAdminConfigContext();
        final MBeanServer   mbs = getAdminMBeanServer();
        final String        amxJMXDomain  = BootUtil.getInstance().getAMXJMXDomainName();
        final String        j2eeTypeProp    = AMX.J2EE_TYPE_KEY + '=" + J2EECluster.J2EE_TYPE;
        for (int i = 0; i < clusters.length; i++) {
            final String nameProp = AMX.NAME_KEY + '=" + clusters[i];
            final String props = Util.concatenateProps(j2eeTypeProp, nameProp);
            final ObjectName on = JMXUtil.newObjectName(amxJMXDomain, props);
            try {
                mbs.registerMBean(new J2EEClusterImpl(null), on);
                _logger.info(on + " is registered.");
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage());
            }
        }
    
public voidcreateAppClientModuleMBean(java.lang.String appName, java.lang.String parentName, java.lang.String serverName, java.lang.String deploymentDescriptor)


        StartStopCallback sscb = new StartStopCallback();
        J2EEModuleCallBackImpl module = new J2EEModuleCallBackImpl(appName,
                parentName, serverName, deploymentDescriptor, sscb);

	AppClientModuleMdl managedResource = new AppClientModuleMdl(module);
	instantiateAndRegisterRuntimeMBean( "AppClientModule", managedResource, 
		null, parentName, appName);
    
public voidcreateAppMBean(com.sun.enterprise.deployment.Application application, java.lang.String serverName, java.lang.String appLocation)


	// get the standard deployment descriptor file
        String xmlDesc = null;

        String j2eeDDLocation = application.getGeneratedXMLDirectory() + 
                                File.separator + 
                                DescriptorConstants.APPLICATION_DD_ENTRY;

        // get the string for deployment descriptor file
        xmlDesc = getStringForDDxml(j2eeDDLocation);

        StartStopCallback sscb = new StartStopCallback();

        J2EEModuleCallBackImpl module = new J2EEModuleCallBackImpl(
                application.getRegistrationName(),
                application.getRegistrationName(), serverName, xmlDesc, sscb);

	J2EEApplicationMdl managedResource = new J2EEApplicationMdl(module, application);
	instantiateAndRegisterRuntimeMBean( "J2EEApplication", managedResource, 
		application.getRegistrationName());

    
public voidcreateAppMBeanModules(com.sun.enterprise.deployment.Application application, java.lang.String serverName, java.lang.String appLocation)
Create application mBean modules J2EE Application may have several modules. According to JSR77 spec. each module will have an mBean.


        boolean registerComponents = false;

        // Register EJB modules
        java.util.Set ejbBundles = application.getEjbBundleDescriptors();

        for (Iterator it = ejbBundles.iterator(); it.hasNext();) {
            EjbBundleDescriptor bundleDesc = (EjbBundleDescriptor) it.next();
            registerEjbModuleAndItsComponents(bundleDesc, serverName,
                registerComponents, appLocation);
        }

	// Web module registration will be done within Tomcat container
	// FIXME: when webcore based regn needs to be done during 8.0 SE/EE
        // Register Web modules
	/*
        java.util.Set webBundles = application.getWebBundleDescriptors();

        for (Iterator it = webBundles.iterator(); it.hasNext();) {
            WebBundleDescriptor bundleDesc = (WebBundleDescriptor) it.next();
            registerWebModuleAndItsComponents(bundleDesc, serverName,
                registerComponents, appLocation);
        }
	*/

        // Register RAR modules
        java.util.Set rarBundles = application.getRarDescriptors();

        for (Iterator it = rarBundles.iterator(); it.hasNext();) {
            ConnectorDescriptor bundleDesc = (ConnectorDescriptor) it.next();
            registerResourceAdapterModuleAndItsComponents(bundleDesc,
                serverName, registerComponents, appLocation);
        }

        // Register AppClient modules
        java.util.Set appClientBundles = application.getApplicationClientDescriptors();

        for (Iterator it = appClientBundles.iterator(); it.hasNext();) {
            ApplicationClientDescriptor bundleDesc = (ApplicationClientDescriptor) it.next();
            registerAppClient(bundleDesc, serverName, appLocation);
        }
    
public voidcreateAppMBeans(com.sun.enterprise.deployment.Application application, java.lang.String serverName, java.lang.String appLocation)
Register all the modules of the application and its' children objects.


        boolean registerComponents = true;

        // Register EJB modules
        java.util.Set ejbBundles = application.getEjbBundleDescriptors();

        for (Iterator it = ejbBundles.iterator(); it.hasNext();) {
            EjbBundleDescriptor bundleDesc = (EjbBundleDescriptor) it.next();
            registerEjbModuleAndItsComponents(bundleDesc, serverName,
                registerComponents, appLocation);
        }

	// Web module registration will be done within Tomcat container
	// FIXME: when webcore based regn needs to be done during 8.0 SE/EE
        // Register Web modules
	/*
        java.util.Set webBundles = application.getWebBundleDescriptors();

        for (Iterator it = webBundles.iterator(); it.hasNext();) {
            WebBundleDescriptor bundleDesc = (WebBundleDescriptor) it.next();
            registerWebModuleAndItsComponents(bundleDesc, serverName,
                registerComponents, appLocation);
        }
	*/

        // Register RAR modules
        java.util.Set rarBundles = application.getRarDescriptors();

        for (Iterator it = rarBundles.iterator(); it.hasNext();) {
            ConnectorDescriptor bundleDesc = (ConnectorDescriptor) it.next();
            registerResourceAdapterModuleAndItsComponents(bundleDesc,
                serverName, registerComponents, appLocation);
        }

        // Register AppClient modules
        java.util.Set appClientBundles = application.getApplicationClientDescriptors();

        for (Iterator it = appClientBundles.iterator(); it.hasNext();) {
            ApplicationClientDescriptor bundleDesc = (ApplicationClientDescriptor) it.next();
            registerAppClient(bundleDesc, serverName, appLocation);
        }
    
public voidcreateEJBMBean(com.sun.enterprise.deployment.EjbDescriptor ejbDescriptor, java.lang.String serverName)



        String ejbName = ejbDescriptor.getName();
        String ejbType = ejbDescriptor.getType();
        String ejbSessionType = null;
        if (ejbType.equals("Session")) {
            ejbSessionType = ((EjbSessionDescriptor) ejbDescriptor).getSessionType();
	}

        String moduleName = getModuleName(ejbDescriptor.getEjbBundleDescriptor());
        String appName = getApplicationName(ejbDescriptor.getEjbBundleDescriptor());

        Object ejbMB = null;
        String j2eeType = null;

        if (ejbType.equals("Entity")) {
            j2eeType = "EntityBean";
        } else if (ejbType.equals("Message-driven")) {
            j2eeType = "MessageDrivenBean";
        } else if (ejbType.equals("Session")) {
            if (ejbSessionType.equals("Stateless")) {
                j2eeType = "StatelessSessionBean";
            } else if (ejbSessionType.equals("Stateful")) {
                j2eeType = "StatefulSessionBean";
            }
        }

        if (ejbType.equals("Entity")) {
	    EntityBeanMdl managedResource = 
		new EntityBeanMdl(ejbName, moduleName, appName, serverName);
	    instantiateAndRegisterRuntimeMBean("EntityBean", managedResource,
		appName, moduleName, ejbName);
        } else if (ejbType.equals("Message-driven")) {
	    MessageDrivenBeanMdl managedResource = 
		new MessageDrivenBeanMdl(
		ejbName, moduleName, appName, serverName);
	    instantiateAndRegisterRuntimeMBean("MessageDrivenBean", managedResource,
		appName, moduleName, ejbName);
        } else if (ejbType.equals("Session")) {
            if (ejbSessionType.equals("Stateless")) {
	    	StatelessSessionBeanMdl managedResource = 
			new StatelessSessionBeanMdl(
			ejbName, moduleName, appName, serverName);
	    	instantiateAndRegisterRuntimeMBean("StatelessSessionBean", managedResource,
			appName, moduleName, ejbName);
            } else if (ejbSessionType.equals("Stateful")) {
	    	StatefulSessionBeanMdl managedResource = 
			new StatefulSessionBeanMdl(
			ejbName, moduleName, appName, serverName);
	    	instantiateAndRegisterRuntimeMBean("StatefulSessionBean", managedResource,
			appName, moduleName, ejbName);
            }
        }

    
public voidcreateEJBMBeans(com.sun.enterprise.deployment.EjbBundleDescriptor ejbBundleDescriptor, java.lang.String serverName)



        //Vector beanDescriptors = application.getEjbDescriptors();
        java.util.Set ejbs = ejbBundleDescriptor.getEjbs();

        for (Iterator it = ejbs.iterator(); it.hasNext();) {
            EjbDescriptor nextDescriptor = (EjbDescriptor) it.next();

            createEJBMBean(nextDescriptor, serverName);
        }
    
public voidcreateEJBModuleMBean(com.sun.enterprise.deployment.EjbBundleDescriptor ejbBundleDescriptor, java.lang.String serverName, java.lang.String appLocation)



	// get the string for deployment descriptor file
        String xmlDesc = getStringForDDxml(
                getModuleLocation(ejbBundleDescriptor, "EJBModule"));

        String moduleName = getModuleName(ejbBundleDescriptor);
        String applicationName = getApplicationName(ejbBundleDescriptor);

        StartStopCallback sscb = new StartStopCallback();
        J2EEModuleCallBackImpl module = new J2EEModuleCallBackImpl(moduleName,
                applicationName, serverName, xmlDesc, sscb);

	EJBModuleMdl managedResource = new EJBModuleMdl(module, ejbBundleDescriptor);

	instantiateAndRegisterRuntimeMBean( "EJBModule", managedResource, 
		null, applicationName, moduleName);
        try {
            createWSEndpointMBeans(ejbBundleDescriptor, serverName);
        } catch (MBeanException mbe) {
            _logger.log(Level.WARNING, 
                "admin.registerEjbModuleAndItsComponents exception", mbe);
        }
    
public voidcreateRARMBean(com.sun.enterprise.deployment.ConnectorDescriptor cd, java.lang.String serverName)



        String rarName = cd.getName();
        String moduleName = getModuleName(cd);
        String appName = getApplicationName(cd);

	ResourceAdapterMdl managedResource = 
		new ResourceAdapterMdl(rarName, moduleName, appName, serverName);

	instantiateAndRegisterRuntimeMBean( "ResourceAdapter", managedResource, 
		appName, moduleName, rarName);

    
public voidcreateRARMBeans(com.sun.enterprise.deployment.ConnectorDescriptor cd, java.lang.String serverName)


        createRARMBean(cd, serverName);
    
public voidcreateRARModuleMBean(com.sun.enterprise.deployment.ConnectorDescriptor bundleDesc, java.lang.String serverName, java.lang.String appLocation)


	// get the string for deployment descriptor file

	// fix for CTS bug# 6411637
        // if resource adapter module name is one of connector system apps
        // then set the location of deployment descriptor to the original
        // location and not the generated directory. These system apps are
        // directly loaded without generating descriptors

        String modLocation = "";
	if (bundleDesc.getModuleDescriptor().isStandalone()) {
            modLocation = appLocation + File.separator + 
                DescriptorConstants.RAR_DD_ENTRY;
        } else {
	    String moduleName = FileUtils.makeFriendlyFileName(
			 bundleDesc.getModuleDescriptor().getArchiveUri());
	    modLocation = appLocation + File.separator + moduleName + File.separator +
			  DescriptorConstants.RAR_DD_ENTRY;
        }

        String xmlDesc = getStringForDDxml(modLocation);

        String applicationName = getApplicationName(bundleDesc);

        String resAdName = getModuleName(bundleDesc);

        StartStopCallback sscb = new StartStopCallback();
        J2EEModuleCallBackImpl module = new J2EEModuleCallBackImpl(resAdName,
                applicationName, serverName, xmlDesc, sscb);

	ResourceAdapterModuleMdl managedResource = 
		new ResourceAdapterModuleMdl(module, resAdName);

	instantiateAndRegisterRuntimeMBean( "ResourceAdapterModule", managedResource, 
		null, applicationName, resAdName);

    
public voidcreateWSEndpointMBean(java.lang.String ctxRoot, com.sun.enterprise.deployment.WebServiceEndpoint wsDescriptor, java.lang.String serverName)
Creates the specified web service endpoint runtime mbean

param
ctxRoot context root for this web service endpoint
param
descriptor descriptor of the web service endpoint
param
serverName instance on which these mbean is created
throws
MBeanException incase of error



        BundleDescriptor bd = wsDescriptor.getBundleDescriptor();
        boolean isEjb = false;

        if ( bd instanceof EjbBundleDescriptor) {
            isEjb = true;
        }

        String epName = wsDescriptor.getEndpointName();
        String appName =  getApplicationName(bd);
        String regName = bd.getApplication().getRegistrationName();
        String moduleName = getModuleName(bd);

        if (ctxRoot != null ) {
            ServletWebServiceEndpointMdl managedResource = 
                new ServletWebServiceEndpointMdl(epName, moduleName, regName, 
                    serverName, bd.getApplication().isVirtual(), isEjb);
            String cRoot = null;
            if (( ctxRoot.length() > 0) && (ctxRoot.charAt(0) != '/")){
                cRoot = "/" + ctxRoot;
            } else {
                cRoot = ctxRoot;
            }
            instantiateAndRegisterRuntimeMBean(managedResource.getMBeanName(),
             managedResource, appName, WebModuleSupport.VIRTUAL_SERVER_PREFIX
             + DEFAULT_VIRTUAL_SERVER + cRoot, epName);
        } else {
            EJBWebServiceEndpointMdl managedResource = 
            new EJBWebServiceEndpointMdl(epName, moduleName,regName, serverName,
             bd.getApplication().isVirtual(),isEjb);
            instantiateAndRegisterRuntimeMBean(managedResource.getMBeanName(),
            managedResource, appName, moduleName, epName);
        }
    
public voidcreateWSEndpointMBeans(com.sun.enterprise.deployment.BundleDescriptor bundleDescriptor, java.lang.String serverName)
Creates all the web service endpoint runtime mbeans for the web or ejb bundle.

param
bundleDescriptor descriptor of the web/ejb bundle
param
serverName instance on which these mbeans are created
throws
MBeanException incase of error

 

        if ( bundleDescriptor  == null) {
            return;
        }

        String ctxRoot = null;
        if ( bundleDescriptor instanceof WebBundleDescriptor) {
            ctxRoot = ((WebBundleDescriptor) bundleDescriptor).getContextRoot();
        }

        WebServicesDescriptor wss = bundleDescriptor.getWebServices();
        if ( wss != null) {
            java.util.Collection wsEps = wss.getEndpoints();

            for (Iterator it = wsEps.iterator(); it.hasNext();) {
                WebServiceEndpoint nextDescriptor = 
                        (WebServiceEndpoint) it.next();

                createWSEndpointMBean(ctxRoot, nextDescriptor, serverName);
            }
        }
    
public voidcreateWebMBean(java.lang.String servletName, java.lang.String moduleName, java.lang.String appName, java.lang.String serverName)


	ServletMdl managedResource = new ServletMdl(servletName, moduleName,
		appName, serverName);

        instantiateAndRegisterRuntimeMBean( "Servlet", managedResource, 
            appName, moduleName, servletName);

    
public voidcreateWebMBeans(com.sun.enterprise.deployment.WebBundleDescriptor webBundleDescriptor, java.lang.String serverName)


        Set set = webBundleDescriptor.getWebComponentDescriptorsSet();

        String applicationName = webBundleDescriptor.getApplication()
                                                    .getRegistrationName();

        if (applicationName == null) {
            applicationName = "null";
        }

        for (Iterator it = set.iterator(); it.hasNext();) {
            WebComponentDescriptor nextDescriptor = (WebComponentDescriptor) it.next();
            createWebMBean(nextDescriptor.getCanonicalName(),
                webBundleDescriptor.getModuleID(), applicationName, serverName);
        }
    
public voidcreateWebModuleMBean(java.lang.String appName, java.lang.String parentName, java.lang.String serverName, java.lang.String deploymentDescriptor)


        StartStopCallback sscb = new StartStopCallback();
        J2EEModuleCallBackImpl module = new J2EEModuleCallBackImpl(appName,
                parentName, serverName, deploymentDescriptor, sscb);

        WebModuleMdl managedResource = new WebModuleMdl(module);

        instantiateAndRegisterRuntimeMBean( "WebModule", managedResource, 
		null, parentName, appName);
    
public voiddeleteAppClientModuleMBean(java.lang.String applicationName, java.lang.String parentName, java.lang.String serverName)


        try {
		String namePattern = 
			(domain + ":" + 
		 	"j2eeType=AppClientModule" + "," + 
		 	"name=" + applicationName + "," + 
		 	"J2EEApplication=" + parentName + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");
		ObjectName objName = findObjectName(namePattern);
	    	if (objName != null) {
            		unregister(objName);
	    	}
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voiddeleteAppMBean(com.sun.enterprise.deployment.Application application, java.lang.String serverName)


        try {
		String namePattern = 
			(domain + ":" + 
		 	"j2eeType=J2EEApplication" + "," + 
		 	"name=" + application.getRegistrationName() + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");

		ObjectName objName = findObjectName(namePattern);

		if (objName != null) {
            		unregister(objName);
		}
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voiddeleteAppMBeans(com.sun.enterprise.deployment.Application application, java.lang.String serverName)


        try {
	    String namePattern = 
			(domain + ":" + 
		 	"j2eeType=J2EEApplication" + "," + 
		 	"name=" + application.getRegistrationName() + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");

	    ObjectName objName = findObjectName(namePattern);

	    if (objName != null) {
            	String[] modulesArr = (String[]) server.getAttribute(objName,
                    "modules");
            	ObjectName[] deployedModules = toObjectNameArray(modulesArr);

            	for (int moduleIndex = 0; moduleIndex < deployedModules.length;
                    moduleIndex++) {
                	unregisterModuleAndItsComponents(deployedModules[moduleIndex]);
            	}
	    }
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voiddeleteEJBMBean(com.sun.enterprise.deployment.EjbDescriptor ejbDescriptor, java.lang.String serverName)



        String ejbName = ejbDescriptor.getName();
        String ejbType = ejbDescriptor.getType();
        String ejbSessionType = null;
        if (ejbType.equals("Session")) {
            ejbSessionType = ((EjbSessionDescriptor) ejbDescriptor).getSessionType();
	}

        String moduleName = getModuleName(ejbDescriptor.getEjbBundleDescriptor());
        String appName = getApplicationName(ejbDescriptor.getEjbBundleDescriptor());

        String j2eeType = null;

        if (ejbType.equals("Entity")) {
            j2eeType = "EntityBean";
        } else if (ejbType.equals("Message-driven")) {
            j2eeType = "MessageDrivenBean";
        } else if (ejbType.equals("Session")) {
            if (ejbSessionType.equals("Stateless")) {
                j2eeType = "StatelessSessionBean";
            } else if (ejbSessionType.equals("Stateful")) {
                j2eeType = "StatefulSessionBean";
            }
        }

        try {
		String namePattern = 
			(domain + ":" + 
		 	"j2eeType=" + j2eeType + "," + 
		 	"name=" + ejbName + "," + 
			"EJBModule=" + moduleName + "," + 
		 	"J2EEApplication=" + appName + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");

		ObjectName objName = findObjectName(namePattern);

	    	if (objName != null) {
            		unregister(objName);
	    	}
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voiddeleteEJBMBeans(com.sun.enterprise.deployment.EjbBundleDescriptor ejbBundleDescriptor, java.lang.String serverName)



        java.util.Set ejbs = ejbBundleDescriptor.getEjbs();

        for (Iterator it = ejbs.iterator(); it.hasNext();) {

            EjbDescriptor nextDescriptor = (EjbDescriptor) it.next();

            deleteEJBMBean(nextDescriptor, serverName);
        }

    
public voiddeleteEJBModuleMBean(com.sun.enterprise.deployment.EjbBundleDescriptor ejbBundleDescriptor, java.lang.String serverName)



        String moduleName = getModuleName(ejbBundleDescriptor);
        String applicationName = getApplicationName(ejbBundleDescriptor);

        try {
		String namePattern = 
			(domain + ":" + 
		 	"j2eeType=EJBModule" + "," + 
		 	"name=" + moduleName + "," + 
		 	"J2EEApplication=" + applicationName + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");

		ObjectName objName = findObjectName(namePattern);

	    	if (objName != null) {
            		unregister(objName);
	    	}
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voiddeleteRARMBean(com.sun.enterprise.deployment.ConnectorDescriptor cd, java.lang.String serverName)



        String rarName = cd.getName();
        String moduleName = getModuleName(cd);
        String appName = getApplicationName(cd);

        try {
		String namePattern = 
			(domain + ":" + 
		 	"j2eeType=ResourceAdapter" + "," + 
		 	"name=" + rarName + "," + 
			"ResourceAdapterModule=" + moduleName + "," +
		 	"J2EEApplication=" + appName + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");
		ObjectName objName = findObjectName(namePattern);

	    	if (objName != null) {
            		unregister(objName);
	    	}
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voiddeleteRARMBeans(com.sun.enterprise.deployment.ConnectorDescriptor cd, java.lang.String serverName)



        deleteRARMBean(cd, serverName);
    
public voiddeleteRARModuleMBean(com.sun.enterprise.deployment.ConnectorDescriptor cd, java.lang.String serverName)



        String moduleName = getModuleName(cd);
        String applicationName = getApplicationName(cd);

        try {
		String namePattern = 
			(domain + ":" + 
		 	"j2eeType=ResourceAdapterModule" + "," + 
		 	"name=" + moduleName + "," + 
		 	"J2EEApplication=" + applicationName + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");

		ObjectName objName = findObjectName(namePattern);

	    	if (objName != null) {
            		unregister(objName);
	    	}
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voiddeleteWSEndpointMBean(java.lang.String ctxRoot, com.sun.enterprise.deployment.WebServiceEndpoint wsDescriptor, java.lang.String serverName)
Deletes the specified web service endpoint runtime mbean

param
descriptor descriptor of the web service endpoint
param
serverName instance on which these mbean is deleted
throws
MBeanException incase of error


        String epName = wsDescriptor.getEndpointName();
        BundleDescriptor bd = wsDescriptor.getBundleDescriptor();

        String moduleName = getModuleName(bd);
        String appName = getApplicationName(bd);

        try {
		String namePattern = null;

        if ( bd instanceof EjbBundleDescriptor) {
			namePattern = (domain + ":" + 
		 	"j2eeType=WebServiceEndpoint," + 
		 	"name=" + epName + "," + 
			"EJBModule=" + moduleName + "," + 
		 	"J2EEApplication=" + appName + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");
        } else if ( bd instanceof WebBundleDescriptor) {
			namePattern = (domain + ":" + 
		 	"j2eeType=WebServiceEndpoint," + 
		 	"name=" + epName + "," + 
			"WebModule=" + WebModuleSupport.VIRTUAL_SERVER_PREFIX
             + DEFAULT_VIRTUAL_SERVER + ctxRoot + "," + 
		 	"J2EEApplication=" + appName + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");
        }

		ObjectName objName = findObjectName(namePattern);

	    	if (objName != null) {
            		unregister(objName);
	    	} 
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voiddeleteWSEndpointMBeans(com.sun.enterprise.deployment.BundleDescriptor bundleDescriptor, java.lang.String serverName)
Deletes all the web service endpoint runtime mbeans for the web or ejb bundle.

param
bundleDescriptor descriptor of the web/ejb bundle
param
serverName instance on which these mbeans are deleted
throws
MBeanException incase of error


        if ( bundleDescriptor == null) {
            return;
        }

        String ctxRoot = null;
        if ( bundleDescriptor instanceof WebBundleDescriptor) {
            ctxRoot = ((WebBundleDescriptor) bundleDescriptor).getContextRoot();
        }

        WebServicesDescriptor wsd = bundleDescriptor.getWebServices();
        if ( wsd == null) {
            return;
        }

        java.util.Collection wsEps = wsd.getEndpoints();

        for (Iterator it = wsEps.iterator(); it.hasNext();) {
            WebServiceEndpoint nextDescriptor = (WebServiceEndpoint) it.next();

            try {
                deleteWSEndpointMBean(ctxRoot, nextDescriptor, serverName);
            } catch (MBeanException mbe) {
                _logger.log(Level.WARNING, 
                    "admin.deleteEJBMBeans exception", mbe);
            }
        }


    
public voiddeleteWebMBean(java.lang.String servletName, java.lang.String moduleName, java.lang.String appName, java.lang.String serverName)


        if (server == null) {
            initMBeanServer();
        }

        try {
		String namePattern = 
			(domain + ":" + 
		 	"j2eeType=Servlet" + "," + 
		 	"name=" + servletName + "," + 
			"WebModule=" + moduleName + "," +
		 	"J2EEApplication=" + appName + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");
		ObjectName objName = findObjectName(namePattern);

	    	if (objName != null) {
            		unregister(objName);
	    	}
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voiddeleteWebMBeans(com.sun.enterprise.deployment.WebBundleDescriptor webBundleDescriptor, java.lang.String serverName)


        Set set = webBundleDescriptor.getWebComponentDescriptorsSet();

        String applicationName = webBundleDescriptor.getApplication()
                                                    .getRegistrationName();

        if (applicationName == null) {
            applicationName = "null";
        }

        for (Iterator it = set.iterator(); it.hasNext();) {
            WebComponentDescriptor nextDescriptor = (WebComponentDescriptor) it.next();
            deleteWebMBean(nextDescriptor.getCanonicalName(),
                webBundleDescriptor.getModuleID(), applicationName, serverName);
        }
    
public voiddeleteWebModuleMBean(java.lang.String appName, java.lang.String parentName, java.lang.String serverName)


        try {
		String namePattern = 
			(domain + ":" + 
		 	"j2eeType=WebModule" + "," + 
		 	"name=" + appName + "," + 
		 	"J2EEApplication=" + parentName + "," + 
		 	"J2EEServer=" + serverName + "," +
		 	"*");

		ObjectName objName = findObjectName(namePattern);

	    	if (objName != null) {
            		unregister(objName);
	    	}
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public javax.management.ObjectNamefindObjectName(java.lang.String namePattern)


	ObjectName [] objNameArr = findObjectNames(namePattern);

	if ((objNameArr != null) && (objNameArr.length > 0)) { 
		if (objNameArr.length > 1) {
	    		throw new MBeanException(new Exception(
			"Found more than one mBean matchin the given object name pattern"));
		}
		return objNameArr[0];
	}

	return null;
    
private javax.management.ObjectName[]findObjectNames(java.lang.String namePattern)


	ObjectName [] objNameArr = null;
	ObjectName objNamePattern = null;

	//String pattern = J2EEDomainMdl.DOMAINNAME + ":" + keys + ",*";

	try {
		objNamePattern = new ObjectName(namePattern);
	} catch (javax.management.MalformedObjectNameException mfone) {
	    throw new MBeanException(mfone);
	}

	Set s = new HashSet();
	s = server.queryNames(objNamePattern, null);
	if (s != null) {
		objNameArr = (ObjectName[]) s.toArray( new ObjectName[s.size()]);
		return objNameArr;
	}

	return objNameArr;
    
private com.sun.enterprise.config.ConfigContextgetAdminConfigContext()

        return AdminService.getAdminService().getAdminContext().
            getAdminConfigContext();
    
private javax.management.MBeanServergetAdminMBeanServer()

        return AdminService.getAdminService().getAdminContext().
            getMBeanServer();
    
private java.lang.String[]getAllServerNamesInDomain()

        // get the list of all instances for this domain
        ConfigContext configContext =
                AdminService.getAdminService().getAdminContext().getAdminConfigContext();
        Server [] serverArr = null;
        try {
            serverArr = ServerHelper.getServersInDomain(configContext);
        } catch (ConfigException ce) {
            ce.printStackTrace();
            _logger.log(Level.WARNING, "admin.get_servers_in_domain_error", ce);
        }
        if ((serverArr == null) || (serverArr.length == 0)) {
                return null;
        }

        String [] strServerArr = new String[serverArr.length];

        for (int i=0; i<serverArr.length; i++) {
                strServerArr[i] = serverArr[i].getName();
        }

        return strServerArr;
    
public java.lang.StringgetApplicationName(com.sun.enterprise.deployment.BundleDescriptor bd)


        String applicationName = "null";

        if (bd.getModuleDescriptor().isStandalone()) {
                return applicationName;
        } else {
            if (bd.getApplication() != null) {
                applicationName = bd.getApplication().getRegistrationName();

                if (applicationName == null) {
                    applicationName = "null";
                }
            }
        }
        return applicationName;
    
private javax.management.ObjectName[]getComponents(javax.management.ObjectName module)


        ObjectName[] components = null;

        try {
          if (module.getKeyProperty("j2eeType").equals("AppClientModule")) {
            // There should not be any components for app client module
            components = new ObjectName[] {  };
          } else if (module.getKeyProperty("j2eeType").equals("EJBModule")) {
            components = toObjectNameArray((String[]) server.getAttribute(
                        module, "ejbs"));
          } else if (module.getKeyProperty("j2eeType").equals("WebModule")) {
            components = toObjectNameArray((String[]) server.getAttribute(
                        module, "servlets"));
          } else if (module.getKeyProperty("j2eeType").equals("ResourceAdapterModule")) {
            components = toObjectNameArray((String[]) server.getAttribute(
                        module, "resourceAdapters"));
          }
        } catch (Exception e) {
          throw new MBeanException(e);
        }

        return components;
    
public java.lang.StringgetJ2eeTypeForEjb(com.sun.enterprise.deployment.EjbDescriptor ejbDescriptor)



        String ejbType = ejbDescriptor.getType();
        String ejbSessionType = null;
        if (ejbType.equals("Session")) {
            ejbSessionType = ((EjbSessionDescriptor) ejbDescriptor).getSessionType();
	}

        String j2eeType = null;

        if (ejbType.equals("Entity")) {
            j2eeType = "EntityBean";
        } else if (ejbType.equals("Message-driven")) {
            j2eeType = "MessageDrivenBean";
        } else if (ejbType.equals("Session")) {
            if (ejbSessionType.equals("Stateless")) {
                j2eeType = "StatelessSessionBean";
            } else if (ejbSessionType.equals("Stateful")) {
                j2eeType = "StatefulSessionBean";
            }
        }

	return j2eeType;
    
private java.lang.StringgetJVMId()

        final String serverName =
                ApplicationServer.getServerContext().getInstanceName();
        return serverName + System.currentTimeMillis();
    
com.sun.enterprise.management.agent.MEJBgetMEJB()

        if ( mejbRef == null ) {
            InitialContext ic = new InitialContext();
            java.lang.Object objref = ic.lookup(
			    System.getProperty("mejb.name","ejb/mgmt/MEJB"));
        }
        return mejbRef;
    
public com.sun.enterprise.management.agent.MEJBUtilitygetMEJBUtility()

        if(this.mejbUtility == null){
            this.mejbUtility = MEJBUtility.getMEJBUtility();
        }
        return this.mejbUtility;
    
private javax.management.ObjectNamegetManagedObjectModule(java.lang.String moduleID, int moduleType)

        
        return null;
    
private java.lang.StringgetModuleLocation(com.sun.enterprise.deployment.BundleDescriptor bd, java.lang.String j2eeType)


	String moduleName = null;
	String modLocation = null;
    String ddRoot = bd.getApplication().getGeneratedXMLDirectory();

	if (bd.getModuleDescriptor().isStandalone()) {

	    moduleName = bd.getApplication().getRegistrationName();

          	if (j2eeType.equals("AppClientModule")) {
	    		modLocation = ddRoot + File.separator +
				DescriptorConstants.APP_CLIENT_DD_ENTRY;
          	} else if (j2eeType.equals("EJBModule")) {
	    		modLocation = ddRoot + File.separator +
				DescriptorConstants.EJB_DD_ENTRY;
          	} else if (j2eeType.equals("WebModule")) {
	    		modLocation = ddRoot + File.separator +
				DescriptorConstants.WEB_DD_ENTRY;
          	} else if (j2eeType.equals("ResourceAdapterModule")) {
	    		modLocation = ddRoot + File.separator +
				DescriptorConstants.RAR_DD_ENTRY;
          	}

	} else {

	    moduleName = FileUtils.makeFriendlyFileName(
			 bd.getModuleDescriptor().getArchiveUri());

          	if (j2eeType.equals("AppClientModule")) {
	    		modLocation = ddRoot + File.separator + moduleName + File.separator +
				DescriptorConstants.APP_CLIENT_DD_ENTRY;
          	} else if (j2eeType.equals("EJBModule")) {
	    		modLocation = ddRoot + File.separator + moduleName + File.separator +
				DescriptorConstants.EJB_DD_ENTRY;
          	} else if (j2eeType.equals("WebModule")) {
	    		modLocation = ddRoot + File.separator + moduleName + File.separator +
				DescriptorConstants.WEB_DD_ENTRY;
          	} else if (j2eeType.equals("ResourceAdapterModule")) {
	    		modLocation = ddRoot + File.separator + moduleName + File.separator +
				DescriptorConstants.RAR_DD_ENTRY;
          	}
	}

	return modLocation;
    
public java.lang.StringgetModuleName(com.sun.enterprise.deployment.BundleDescriptor bd)


	String moduleName = null;

	if (bd.getModuleDescriptor().isStandalone()) {
	    moduleName = bd.getApplication().getRegistrationName();
	} else {
	    moduleName = bd.getModuleDescriptor().getArchiveUri();
	}

	return moduleName;

    
public java.lang.ObjectgetModuleUserData(java.lang.String moduleID, int moduleType)

        return null;
    
public java.lang.StringgetServerBaseON(boolean amx, java.lang.String serverName)


            String domainName = null;
    
            // get domain name
            if (amx) {
		try {
                    ObjectName pattern = Util.newObjectNamePattern( 
                        "*", LoaderMBean.LOADER_NAME_PROPS );
                    Set names = server.queryNames(pattern, null);
                    assert( names.size() == 1 );
                    ObjectName loaderON = (ObjectName) SetUtil.getSingleton(names);
                    domainName = 
                        (String) server.getAttribute(loaderON, "AdministrativeDomainName");
		} catch (Exception e) {
		    throw new RuntimeException(e);
		}
		//domainName = "amx";
            } else {
		/*
                ObjectName pattern = Util.newObjectNamePattern( 
                    "*", "j2eeType=J2EEDomain,category=runtime");
                Set names = server.queryNames(pattern, null);
                assert( names.size() == 1 );
                ObjectName domainON = (ObjectName) SetUtil.getSingleton(names);
                domainName = (String) server.getAttribute(domainON, "name");
		*/
                domainName =
		ApplicationServer.getServerContext().getDefaultDomainName();
            }
            
            return getServerBaseON(domainName, serverName);
    
    
private java.lang.StringgetServerBaseON(java.lang.String domainName, java.lang.String serverName)

            return( domainName + ":" + "j2eeType=J2EEServer,name=" + serverName);
    
public java.lang.IntegergetState(java.lang.String namePattern)

	ObjectName objName = findObjectName(namePattern);
	if (objName != null) {
            try {
		Integer intObj = (Integer) server.getAttribute(objName, "state");
		return intObj;
	    } catch (javax.management.InstanceNotFoundException infe) {
            } catch (Exception e) {
            	throw new MBeanException(e);
	    }
	}
	return null;
    
private java.lang.StringgetStringForDDxml(java.lang.String fileName)

	FileReader fr = null;
	    try {

            if (!(new File(fileName)).exists()) {
                _logger.log(Level.FINE, "Descriptor does not exist " + fileName);
                return null;
            }

		fr = new FileReader(fileName);
		StringWriter sr = new StringWriter();

		char[] buf = new char[1024];
		int len = 0;
		while (len != -1) {
			try {
				len = fr.read(buf, 0, buf.length);
			} catch (EOFException eof) {
				break;
			}
			if (len != -1) {
				sr.write(buf, 0, len);
			}
		}

		fr.close();
		sr.close();

		return sr.toString();

	} catch (FileNotFoundException fnfe) {
        	//System.out.println("FileNotFoundException ...");
	    	throw new MBeanException(fnfe);
	} catch (IOException ioe) {
        	//System.out.println("IOException ...");
	    	throw new MBeanException(ioe);
	} finally {
		if (fr != null) {
			try {
				fr.close();
			} catch (IOException ioe) {
			}
		}
	}
    
private static voidinitMBeanServer()


        // get or create mBean server
        try {
	    server = MBeanServerFactory.getMBeanServer();
        } catch (Exception e) {
            e.printStackTrace();
        }
    
private voidinstantiateAndRegisterRuntimeMBean(java.lang.String type, java.lang.Object managed)

        instantiateAndRegisterRuntimeMBean(type, managed, null, null, null);
    
private voidinstantiateAndRegisterRuntimeMBean(java.lang.String type, java.lang.Object managed, java.lang.String name)

        instantiateAndRegisterRuntimeMBean(type, managed, null, null, name);
    
private voidinstantiateAndRegisterRuntimeMBean(java.lang.String type, java.lang.Object managed, java.lang.String parentName, java.lang.String name)

        instantiateAndRegisterRuntimeMBean(type, managed, null, parentName, name);
    
private voidinstantiateAndRegisterRuntimeMBean(java.lang.String type, java.lang.Object managed, java.lang.String grandParentName, java.lang.String parentName, java.lang.String name)


        MBeanRegistry registry  = MBeanRegistryFactory.getRuntimeMBeanRegistry();
        String domainName = ApplicationServer.getServerContext().getDefaultDomainName();
        String serverName = ApplicationServer.getServerContext().getInstanceName();
 
        try {
            if(grandParentName!=null) {

               registry.instantiateMBean(
			type, 
			new String[]{domainName, serverName, grandParentName, 
				     parentName, name}, 
			managed, AdminService.getAdminService().getAdminContext().getAdminConfigContext(), true); //FIXME
            } else {
                if(parentName!=null) {
                   registry.instantiateMBean( 
				type, 
				new String[]{domainName, serverName, 
				             parentName, name}, 
				managed, AdminService.getAdminService().getAdminContext().getAdminConfigContext(), true); //FIXME
                } else {
                    if(name!=null) {
                       registry.instantiateMBean( 
				type, new String[]{domainName, serverName,name}, 
				managed, AdminService.getAdminService().getAdminContext().getAdminConfigContext(), true); //FIXME
                    } else {
                       registry.instantiateMBean( 
				type, new String[]{domainName, serverName}, 
				managed, AdminService.getAdminService().getAdminContext().getAdminConfigContext(), true); //FIXME
		    }
		}
	    }
        } catch (Exception e) {
            System.out.println("Exception msg:"+e.getMessage());
            e.printStackTrace();
        }
    
private voidregister(java.lang.Object object, javax.management.ObjectName objectName)

        if (server == null) {
            initMBeanServer();
        }

        try {
            if (!server.isRegistered(objectName)) {
                server.registerMBean(object, objectName);
            }
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voidregisterAdminObjectResource(java.lang.String name, java.lang.String raName, java.lang.String resType, java.lang.String[] propNames, java.lang.String[] propValues)

        //username and password for nulls in that order
        if(QUEUE.equals(resType) || TOPIC.equals(resType)) {
            registerJMSResource(name, resType, null, null, propNames, propValues);                   
        }
    
public voidregisterAllJ2EEClusters()

        try {
            final Cluster[] clusters = ClusterHelper.getClustersInDomain(
                getAdminConfigContext());
            if ((null == clusters) || (clusters.length == 0)) {
                return;
            }
            final ArrayList al = new ArrayList(clusters.length);
            for (int i = 0; i < clusters.length; i++) {
                al.add(clusters[i].getName());
            }
            final String[] sa = (String[])al.toArray(new String[0]);
            _registerJ2EEClusters(sa);
        } catch (ConfigException ce) {
            throw new RuntimeException(ce.getMessage());
        }
    
public voidregisterAppClient(com.sun.enterprise.deployment.ApplicationClientDescriptor bundleDesc, java.lang.String serverName, java.lang.String appLocation)


	// get the string for deployment descriptor file
        String xmlDesc = getStringForDDxml(
                getModuleLocation(bundleDesc, "AppClientModule"));

        String applicationName = "null";

        if (bundleDesc.getApplication() != null) {
            if (!bundleDesc.getModuleDescriptor().isStandalone()) {
                applicationName = bundleDesc.getApplication()
                                            .getRegistrationName();

                if (applicationName == null) {
                    applicationName = "null";
                }
            }
        }

        createAppClientModuleMBean(getModuleName(bundleDesc), applicationName,
            serverName, xmlDesc);
    
public voidregisterConfigJ2EEServer(java.lang.String instance)

throw new RuntimeException(">>>>>>>>>>>>>>>>>>>> registerConfigJ2EEServer not implemented <<<<<<<<<<<<<<<<<");
	//new J2EEServerMdlEmmaAgent(new EmmaOptions(J2EEDomainMdl.DOMAINNAME));
    
public voidregisterDasJ2EEServer(java.lang.String serverName)


	// vars
	DomainStatusHelper dsh = new DomainStatusHelper();

	try {
	    // check if the DomainStatusMBean is registered or not
	    if (! server.isRegistered(dsh.getDomainStatusObjectName())) {
		registerDomainStatusMBean();
	    }

	    // set this server state to STARTING if not already set
	    try {
		dsh.getstate(serverName);
            } catch (Exception e) {
	        Object[] params = new Object[2];
	        params[0] = (Object) serverName;
	        params[1] = (Object) Integer.valueOf(StateManageable.STATE_STARTING);
	        String[] signature = {"java.lang.String", "java.lang.Integer"};
	        server.invoke(dsh.getDomainStatusObjectName(), "setstate", params, signature);
	    }

	    // object name for j2ee server
	    /*
	    String strON = (
                ApplicationServer.getServerContext().getDefaultDomainName() + ":" +
		"j2eeType=J2EEServer," +
		"name=" + serverName +
		",category=dasJ2EE"
		);
	    ObjectName on = new ObjectName(strON);
	    */
	    ObjectName on = new ObjectName(getServerBaseON(true, serverName));

	    DASJ2EEServerImpl ds = new DASJ2EEServerImpl();
	    ObjectInstance oi = server.registerMBean(ds, on);

	    // register the notification listener
	    server.addNotificationListener(
		dsh.getDomainStatusObjectName(), 
		oi.getObjectName(),
		null, null);
	} catch(MalformedObjectNameException e) {
            e.printStackTrace();
            _logger.log(Level.WARNING, "admin.registerDasJ2EEServer exception", e);
	} catch(javax.management.InstanceAlreadyExistsException iae) {
	} catch(javax.management.InstanceNotFoundException infe) {
            infe.printStackTrace();
            _logger.log(Level.WARNING, "admin.registerDasJ2EEServer exception", infe);
	} catch(javax.management.MBeanRegistrationException mre) {
            mre.printStackTrace();
            _logger.log(Level.WARNING, "admin.registerDasJ2EEServer exception", mre);
	} catch(javax.management.NotCompliantMBeanException ncmbe) {
	    ncmbe.printStackTrace();
            _logger.log(Level.WARNING, "admin.registerDasJ2EEServer exception", ncmbe);
	} catch(javax.management.MBeanException mbe) {
	    mbe.printStackTrace();
            _logger.log(Level.WARNING, "admin.registerDasJ2EEServer exception", mbe);
	} catch(javax.management.ReflectionException rfe) {
	    rfe.printStackTrace();
            _logger.log(Level.WARNING, "admin.registerDasJ2EEServer exception", rfe);
	}
    
public voidregisterDasJ2EEServers()

	// get the list of servers
	String [] allServers = getAllServerNamesInDomain();
	if ((allServers == null) || (allServers.length == 0)) return;
	// register for each server
	for (int i=0; i<allServers.length; i++) {
                registerDasJ2EEServer(allServers[i]);
        }
    
private voidregisterDomainStatusMBean()

	try {
		ObjectName on = DomainStatusHelper.getDomainStatusObjectName();

		server.registerMBean(new DomainStatus(), on);

		// set this server state to RUNNING
		Object[] params = new Object[2];
		params[0] = (Object) ApplicationServer.getServerContext().getInstanceName();
		params[1] = (Object) Integer.valueOf(StateManageable.STATE_RUNNING);
		String[] signature = {"java.lang.String", "java.lang.Integer"};
		server.invoke(on, "setstate", params, signature);

	} catch (MalformedObjectNameException mne) {
		throw new RuntimeException(mne);
	} catch (InstanceNotFoundException infe) {
		throw new RuntimeException(infe);
	} catch (InstanceAlreadyExistsException iae) {
		throw new RuntimeException(iae);
	} catch (MBeanRegistrationException mre) {
		throw new RuntimeException(mre);
	} catch (NotCompliantMBeanException ncmbe) {
		throw new RuntimeException(ncmbe);
	} catch (MBeanException mbe) {
		throw new RuntimeException(mbe);
	} catch (ReflectionException rfe) {
		throw new RuntimeException(rfe);
	}
    
public voidregisterEjbModuleAndItsComponents(com.sun.enterprise.deployment.EjbBundleDescriptor ejbBundleDescriptor, java.lang.String serverName, boolean registerComponents, java.lang.String appLocation)



        createEJBModuleMBean(ejbBundleDescriptor, serverName, appLocation);

        if (registerComponents) {
            createEJBMBeans(ejbBundleDescriptor, serverName);
        }
    
private static voidregisterHTMLAdaptor()

        
        /* uncomment the following if the HtmlAdaptorServer is needed */
        if(_bHtmlAdaptorServerRegistered)
            return;
        try {
            String strPort = System.getProperty("html.adaptor.port");
            if(strPort==null || strPort.trim().length()<1)
                return;
            //final int freePort = NetUtils.getFreePort();
            int port = (Integer.valueOf(strPort.trim())).intValue();
            Class cl =  Class.forName("com.sun.jdmk.comm.HtmlAdaptorServer");
            Constructor contr = cl.getConstructor(new Class[]{Integer.TYPE});
            Object adaptor = contr.newInstance(new Object[]{Integer.valueOf(port)});
            Method method = cl.getMethod("start");
            ObjectName htmlAdaptorObjectName = new ObjectName(
                    "Adaptor:name=html,port="+port);
            server.registerMBean(adaptor, htmlAdaptorObjectName);
            method.invoke(adaptor);
            _bHtmlAdaptorServerRegistered = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
	
    
public voidregisterJ2EECluster(java.lang.String clusterName)

        try {
            if (!ClusterHelper.isACluster(getAdminConfigContext(), clusterName)) {
                throw new RuntimeException(clusterName + " is not a valid cluster.");
            }
        } catch (ConfigException ce) {
            throw new RuntimeException(ce.getMessage());
        }
        _registerJ2EEClusters(new String[] {clusterName});
    
public voidregisterJ2EEDomain()

        instantiateAndRegisterRuntimeMBean("J2EEDomain", null);
	registerDomainStatusMBean();
    
public voidregisterJ2EEServer()

        J2EEServerMdl managedServerMdlObject = new J2EEServerMdl(
                ApplicationServer.getServerContext().getInstanceName(),
                com.sun.appserv.server.util.Version.getVersion());
        instantiateAndRegisterRuntimeMBean("J2EEServer", managedServerMdlObject);
    
public voidregisterJCAConnectionFactory(java.lang.String jcaResName, java.lang.String jcaConnFactName, java.lang.String managedConFact)

        Object managedBean = (Object)new JCAConnectionFactoryMdl(
            jcaResName, ApplicationServer.getServerContext().getInstanceName(), 
            jcaConnFactName, managedConFact);
        instantiateAndRegisterRuntimeMBean("JCAConnectionFactory", managedBean, jcaResName, jcaConnFactName);
    
public voidregisterJCAManagedConnectionFactory(java.lang.String connFactName)

        Object managedBean = (Object)new JCAManagedConnectionFactoryMdl(
            connFactName, ApplicationServer.getServerContext().getInstanceName());
        instantiateAndRegisterRuntimeMBean("JCAManagedConnectionFactory", managedBean, connFactName);
    
public voidregisterJCAResource(java.lang.String name, java.lang.String raName, java.lang.String username, java.lang.String password, java.lang.String[] propNames, java.lang.String[] propValues)

        Object managedBean = (Object)new JCAResourceMdl(name,
                                ApplicationServer.getServerContext().getInstanceName(),
                                raName, username, password, propNames, propValues);
        instantiateAndRegisterRuntimeMBean("JCAResource", managedBean, raName, name);
       
    
public voidregisterJDBCDataSource(java.lang.String dsJndiName, java.lang.String dsName, java.lang.String url, java.lang.String username, java.lang.String password, java.lang.String[] propNames, java.lang.String[] propValues)

        Object managedBean = (Object)new JDBCDataSourceMdl(dsJndiName, dsName, url,
                                username,
                                ApplicationServer.getServerContext().getInstanceName(),
                                password,
                                propNames, 
                                propValues); 
        instantiateAndRegisterRuntimeMBean("JDBCDataSource", managedBean, dsJndiName, dsJndiName); //FIXME: why no dsJndiName,dsName
    
public voidregisterJDBCDriver(java.lang.String name)

        instantiateAndRegisterRuntimeMBean("JDBCDriver", null, name);
    
public voidregisterJDBCResource(java.lang.String name)

        instantiateAndRegisterRuntimeMBean("JDBCResource", null, name);
    
public voidregisterJMSResource(java.lang.String name, java.lang.String resType, java.lang.String username, java.lang.String password, java.lang.String[] propNames, java.lang.String[] propValues)

	    Object managedBean = (Object)new JMSResourceMdl(name, 
				                    ApplicationServer.getServerContext().getInstanceName(),
                                    resType, username, password, propNames, propValues);
        instantiateAndRegisterRuntimeMBean("JMSResource", managedBean, name);
    
public voidregisterJNDIResource(java.lang.String name)

        instantiateAndRegisterRuntimeMBean("JNDIResource", null, name);
    
public voidregisterJTAResource(java.lang.String name)

        instantiateAndRegisterRuntimeMBean("JTAResource", null, name);
    
public voidregisterJVM()

        //instantiateAndRegisterRuntimeMBean("JVM", null, 
	//			MOAgentFactory.getAgent().getJVMId());
        instantiateAndRegisterRuntimeMBean("JVM", null, 
				getJVMId());
   
public voidregisterJavaMailResource(java.lang.String name)

        instantiateAndRegisterRuntimeMBean("JavaMailResource", null, name);
    
public voidregisterRMI_IIOPResource(java.lang.String name)

        instantiateAndRegisterRuntimeMBean("RMI_IIOPResource", null, name);
    
public voidregisterResourceAdapterModuleAndItsComponents(com.sun.enterprise.deployment.ConnectorDescriptor bundleDesc, java.lang.String serverName, boolean registerComponents, java.lang.String appLocation)




        createRARModuleMBean(bundleDesc, serverName, appLocation);

        if (registerComponents) {
            createRARMBeans(bundleDesc, serverName);
        }
    
public voidregisterTransactionService()

	TransactionServiceMdl ts = new TransactionServiceMdl();
        instantiateAndRegisterRuntimeMBean("TransactionService", ts);
   
public voidregisterWebModuleAndItsComponents(com.sun.enterprise.deployment.WebBundleDescriptor webBundleDescriptor, java.lang.String serverName, boolean registerComponents, java.lang.String appLocation)


	// get the string for deployment descriptor file
	String xmlDesc = getStringForDDxml(
                getModuleLocation(webBundleDescriptor, "WebModule"));

        String applicationName = "null";

        if (webBundleDescriptor.getApplication() != null) {
            if (!webBundleDescriptor.getModuleDescriptor().isStandalone()) {
                applicationName = webBundleDescriptor.getApplication()
                                                     .getRegistrationName();

                if (applicationName == null) {
                    applicationName = "null";
                }
            }
        }

        createWebModuleMBean(webBundleDescriptor.getModuleID(),
            applicationName, serverName, xmlDesc);

        if (registerComponents) {
            createWebMBeans(webBundleDescriptor, serverName);
        }
        try {
            createWSEndpointMBeans(webBundleDescriptor, serverName);
        } catch (MBeanException mbe) {
            _logger.log(Level.WARNING, 
                "admin.registerWebModuleAndItsComponents exception", mbe);
        }
    
public voidsetApplicationState(int state, com.sun.enterprise.deployment.Application application, java.lang.String serverName)


        String applicationName = application.getRegistrationName();
	String namePattern = 
		(domain + ":" + 
		 "j2eeType=J2EEApplication" + "," + 
		 "name=" + applicationName + "," + 
		 "J2EEServer=" + serverName + "," +
		 "*");
	ObjectName objName = findObjectName(namePattern);
	if (objName != null) {
		setState(objName, state);
	}
    
public voidsetEJBModuleState(int state, com.sun.enterprise.deployment.EjbBundleDescriptor ejbBundleDescriptor, java.lang.String serverName)


        String moduleName = getModuleName(ejbBundleDescriptor);
        String applicationName = getApplicationName(ejbBundleDescriptor);
	String namePattern = 
		(domain + ":" + 
		 "j2eeType=EJBModule" + "," + 
		 "name=" + moduleName + "," + 
		 "J2EEApplication=" + applicationName + "," + 
		 "J2EEServer=" + serverName + "," +
		 "*");
	ObjectName objName = findObjectName(namePattern);
	if (objName != null) {
		setState(objName, state);
	}
    
public voidsetModuleUserData(java.lang.String moduleID, java.lang.Object obj, int moduleType)

    
public voidsetRARModuleState(int state, com.sun.enterprise.deployment.ConnectorDescriptor connectorDescriptor, java.lang.String serverName)


        String moduleName = getModuleName(connectorDescriptor);
        String applicationName = getApplicationName(connectorDescriptor);
	String namePattern = 
		(domain + ":" + 
		 "j2eeType=ResourceAdapterModule" + "," + 
		 "name=" + moduleName + "," + 
		 "J2EEApplication=" + applicationName + "," + 
		 "J2EEServer=" + serverName + "," +
		 "*");
	ObjectName objName = findObjectName(namePattern);
	if (objName != null) {
		setState(objName, state);
	}
    
private voidsetState(javax.management.ObjectName objName, int state)
Set state for the given object name array corresponding to a module or application

        try {
            if (server.isRegistered(objName)) {
            	Integer stateValueObj = Integer.valueOf(state);
            	server.setAttribute(objName,
                	(new javax.management.Attribute("state", stateValueObj)));
            }
        } catch (javax.management.InstanceNotFoundException infe) {
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public javax.management.ObjectName[]toObjectNameArray(java.lang.String[] strings)
Returns array of javax.management.ObjectName corresponding to the given string array of object names

        // It could be possible that strings are null
        if (strings != null) {
            ObjectName[] objectNames = new ObjectName[strings.length];

            for (int i = 0; i < strings.length; i++) {
                try {
                    objectNames[i] = new ObjectName(strings[i]);
                } catch (MalformedObjectNameException mne) {
                    throw new MBeanException(mne);
                }
            }

            return objectNames;
        }

        // return an empty array
        return new ObjectName[] {  };
    
public voidunregister(javax.management.ObjectName objectName)


        try {
            if (server.isRegistered(objectName)) {
                server.unregisterMBean(objectName);
            }
        } catch (javax.management.InstanceNotFoundException infe) {
        } catch (Exception e) {
            throw new MBeanException(e);
        }
    
public voidunregisterAdminObjectResource(java.lang.String name, java.lang.String resourceType)
Unregisters the jms resource managed object if the type is Queue or Topic.

        if(QUEUE.equals(resourceType) || TOPIC.equals(resourceType)) {
            unregisterResource(name,"JMSResource");              
        }
    
public voidunregisterAppClient(com.sun.enterprise.deployment.ApplicationClientDescriptor bundleDesc, java.lang.String serverName)


        String applicationName = "null";

        if (bundleDesc.getApplication() != null) {
            if (!bundleDesc.getModuleDescriptor().isStandalone()) {
                applicationName = bundleDesc.getApplication()
                                            .getRegistrationName();

                if (applicationName == null) {
                    applicationName = "null";
                }
            }
        }

        deleteAppClientModuleMBean(getModuleName(bundleDesc), applicationName,
            serverName);
    
public voidunregisterDasJ2EEServer(java.lang.String serverName)

	try {
	    /*
	    ObjectName onPattern = new ObjectName(
                ApplicationServer.getServerContext().getDefaultDomainName() + ":" +
		"j2eeType=J2EEServer," +
		"name=" + serverName +
		",group=jsr77" +
		",*"
		);
	    */
	    ObjectName onPattern = new ObjectName(
		getServerBaseON(true, serverName) + 
		",*"
		);
	    // query mBean server
	    Set s = new HashSet();
	    s = server.queryNames(onPattern, null);
	    if ((s != null) && (s.size() > 0)) {
		ObjectName [] objNameArr = 
		    (ObjectName[]) s.toArray( new ObjectName[s.size()]);
	        server.unregisterMBean(objNameArr[0]);
	    }
	} catch(MalformedObjectNameException e) {
            e.printStackTrace();
            _logger.log(Level.WARNING, "admin.unregisterDASJ2EEServer exception", e);
	} catch (javax.management.InstanceNotFoundException infe) {
            _logger.log(Level.FINE, "admin.unregisterDASJ2EEServer exception", infe);
	} catch (MBeanException mbe) {
            _logger.log(Level.FINE, "admin.unregisterDASJ2EEServer exception", mbe);
	} catch (Exception ex) {
	    ex.printStackTrace();
            _logger.log(Level.FINE, "admin.unregisterDASJ2EEServer exception", ex);
	}
    
public voidunregisterJ2EECluster(java.lang.String clusterName)

        if ((null == clusterName) || "".equals(clusterName)) {
            throw new IllegalArgumentException();
        }
        ObjectName on = null;
        final MBeanServer mbs = getAdminMBeanServer();
        final ProxyFactory proxyFactory = ProxyFactory.getInstance(
            new MBeanServerConnectionSource(mbs));
        final Set proxies = proxyFactory.getDomainRoot().getQueryMgr().
            queryJ2EETypeSet(J2EECluster.J2EE_TYPE);
        final Iterator it = proxies.iterator();
        while (it.hasNext()) {
            J2EECluster cluster = (J2EECluster)it.next();
            if (cluster.getName().equals(clusterName)) {
                on = Util.getObjectName(cluster);
                break;
            }
        }
        try {
            mbs.unregisterMBean(on);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    
public voidunregisterJCAResource(java.lang.String moduleName)

    
public voidunregisterJDBCResource(java.lang.String name)

        unregisterResource(name,"JDBCResource");
    
public voidunregisterJMSResource(java.lang.String name)

        unregisterResource(name,"JMSResource");
    
public voidunregisterJavaMailResource(java.lang.String name)

        unregisterResource(name,"JavaMailResource");
    
public voidunregisterModuleAndItsComponents(javax.management.ObjectName objectName)


        // unregister its components
        ObjectName[] comps = getComponents(objectName);

        for (int compsIndex = 0; compsIndex < comps.length; compsIndex++) {
            unregister(comps[compsIndex]);
        }

        // unregister module itself
        unregister(objectName);
    
voidunregisterResource(java.lang.String name, java.lang.String type)
Unregisters a resource mbean given the resource jndi name and the Managed Object type such as JDBCResource, JavaMailResource, etc.

param
name The jndi name of the resource to be unregistered.
param
type The managed object type such as JDBCResource.
throws
Exception if the mbean cannot be unregistered.

        final MBeanRegistry registry =
                MBeanRegistryFactory.getRuntimeMBeanRegistry();
        final String domainName =
                ApplicationServer.getServerContext().getDefaultDomainName();
        final String serverName =
                ApplicationServer.getServerContext().getInstanceName();
        final String[] location = new String[] {domainName, serverName, name};
        final ObjectName on = registry.getMbeanObjectName(type, location);
        if (on == null) {
            return;
        }
        final MBeanServer mbs =
               AdminService.getAdminService().getAdminContext().getMBeanServer();
        if (mbs.isRegistered(on)) {
            mbs.unregisterMBean(on);
        }
    
private voidunregisterStandAloneAndItsComponents(java.lang.String moduleType, java.lang.String moduleName)

    
public voidunregisterStandAloneModule(java.lang.String moduleType, java.lang.String name)

        try {
            unregisterStandAloneAndItsComponents(moduleType, name);
        } catch ( Exception ex ) {
            throw new RuntimeException(ex);
        }