/** * Return the MBean Names of the set of defined environment entries for * this web application */ public String[] getEnvironments() { ContextEnvironment[] envs = ((NamingResources)this.resource).findEnvironments(); ArrayList<String> results = new ArrayList<String>(); for (int i = 0; i < envs.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), envs[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for environment " + envs[i]); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
/** * Return the MBean Names of all the defined resource references for this * application. */ public String[] getResources() { ContextResource[] resources = ((NamingResources)this.resource).findResources(); ArrayList<String> results = new ArrayList<String>(); for (int i = 0; i < resources.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resources[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for resource " + resources[i]); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
/** * Return the MBean Names of all the defined resource link references for * this application. */ public String[] getResourceLinks() { ContextResourceLink[] resourceLinks = ((NamingResources)this.resource).findResourceLinks(); ArrayList<String> results = new ArrayList<String>(); for (int i = 0; i < resourceLinks.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for resource " + resourceLinks[i]); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
/** * Remove any resource link reference with the specified name. * * @param resourceLinkName Name of the resource link reference to remove */ public void removeResourceLink(String resourceLinkName) { resourceLinkName = ObjectName.unquote(resourceLinkName); NamingResources nresources = (NamingResources) this.resource; if (nresources == null) { return; } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink == null) { throw new IllegalArgumentException ("Invalid resource Link name '" + resourceLinkName + "'"); } nresources.removeResourceLink(resourceLinkName); }
/** * Create, register, and return an MBean for this * <code>NamingResources</code> object. * * @param resource The NamingResources to be managed * * @exception Exception if an MBean cannot be created or registered * * @deprecated Unused. Will be removed in Tomcat 8.0.x */ @Deprecated static DynamicMBean createMBean(NamingResources resource) throws Exception { String mname = createManagedName(resource); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with "+mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); DynamicMBean mbean = managed.createMBean(resource); ObjectName oname = createObjectName(domain, resource); if( mserver.isRegistered( oname )) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); return (mbean); }
/** * Deregister the MBean for this * <code>NamingResources</code> object. * * @param resources The NamingResources to be managed * * @exception Exception if an MBean cannot be deregistered * @deprecated Unused. Will be removed in Tomcat 8.0.x */ @Deprecated static void destroyMBean(NamingResources resources) throws Exception { String mname = createManagedName(resources); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, resources); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
/** * Return the MBean Names of the set of defined environment entries for * this web application */ public String[] getEnvironments() { ContextEnvironment[] envs = ((NamingResources)this.resource).findEnvironments(); ArrayList results = new ArrayList(); for (int i = 0; i < envs.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), envs[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for environment " + envs[i]); iae.initCause(e); throw iae; } } return ((String[]) results.toArray(new String[results.size()])); }
/** * Return the MBean Names of all the defined resource link references for * this application. */ public String[] getResourceLinks() { ContextResourceLink[] resourceLinks = ((NamingResources)this.resource).findResourceLinks(); ArrayList results = new ArrayList(); for (int i = 0; i < resourceLinks.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for resource " + resourceLinks[i]); iae.initCause(e); throw iae; } } return ((String[]) results.toArray(new String[results.size()])); }
/** * Create, register, and return an MBean for this * <code>NamingResources</code> object. * * @param resource * The NamingResources to be managed * * @exception Exception * if an MBean cannot be created or registered * * @deprecated Unused. Will be removed in Tomcat 8.0.x */ @Deprecated static DynamicMBean createMBean(NamingResources resource) throws Exception { String mname = createManagedName(resource); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with " + mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); DynamicMBean mbean = managed.createMBean(resource); ObjectName oname = createObjectName(domain, resource); if (mserver.isRegistered(oname)) { mserver.unregisterMBean(oname); } mserver.registerMBean(mbean, oname); return (mbean); }
/** * Return the MBean Names of all the defined resource link references for * this application. */ public String[] getResourceLinks() { ContextResourceLink[] resourceLinks = ((NamingResources) this.resource).findResourceLinks(); ArrayList<String> results = new ArrayList<String>(); for (int i = 0; i < resourceLinks.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException( "Cannot create object name for resource " + resourceLinks[i]); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
/** * Deregister the MBean for this * <code>NamingResources</code> object. * * @param resources The NamingResources to be managed * * @exception Exception if an MBean cannot be deregistered */ static void destroyMBean(NamingResources resources) throws Exception { String mname = createManagedName(resources); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, resources); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
/** * Construct a default instance of this class. */ public StandardServer() { super(); ServerFactory.setServer(this); globalNamingResources = new NamingResources(); globalNamingResources.setContainer(this); if (isUseNaming()) { if (namingContextListener == null) { namingContextListener = new NamingContextListener(); addLifecycleListener(namingContextListener); } } }
/** * Return the MBean Names of all the defined resource references for this * application. */ public String[] getResources() { ContextResource[] resources = ((NamingResources) this.resource).findResources(); ArrayList<String> results = new ArrayList<String>(); for (int i = 0; i < resources.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resources[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException( "Cannot create object name for resource " + resources[i]); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
/** * Return the MBean Names of the set of defined environment entries for * this web application */ public String[] getEnvironments() { ContextEnvironment[] envs = ((NamingResources)this.resource).findEnvironments(); ArrayList results = new ArrayList(); for (int i = 0; i < envs.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), envs[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException ("Cannot create object name for environment " + envs[i]); } } return ((String[]) results.toArray(new String[results.size()])); }
/** * Return the MBean Names of all the defined resource link references for * this application. */ public String[] getResourceLinks() { ContextResourceLink[] resourceLinks = ((NamingResources)this.resource).findResourceLinks(); ArrayList results = new ArrayList(); for (int i = 0; i < resourceLinks.length; i++) { try { ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]); results.add(oname.toString()); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException ("Cannot create object name for resource " + resourceLinks[i]); } } return ((String[]) results.toArray(new String[results.size()])); }
/** * Remove any resource link reference with the specified name. * * @param resourceLinkName Name of the resource link reference to remove */ public void removeResourceLink(String resourceLinkName) { resourceLinkName = URLDecoder.decode(resourceLinkName); NamingResources nresources = (NamingResources) this.resource; if (nresources == null) { return; } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink == null) { throw new IllegalArgumentException ("Invalid resource Link name '" + resourceLinkName + "'"); } nresources.removeResourceLink(resourceLinkName); }
/** * Create, register, and return an MBean for this * <code>NamingResources</code> object. * * @param resource The NamingResources to be managed * * @exception Exception if an MBean cannot be created or registered */ public static ModelMBean createMBean(NamingResources resource) throws Exception { String mname = createManagedName(resource); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { Exception e = new Exception("ManagedBean is not found with "+mname); throw new MBeanException(e); } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ModelMBean mbean = managed.createMBean(resource); ObjectName oname = createObjectName(domain, resource); mserver.registerMBean(mbean, oname); return (mbean); }
/** * Deregister the MBean for this * <code>NamingResources</code> object. * * @param resources The NamingResources to be managed * * @exception Exception if an MBean cannot be deregistered */ public static void destroyMBean(NamingResources resources) throws Exception { String mname = createManagedName(resources); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, resources); mserver.unregisterMBean(oname); }
/** * Add additional parameters to the reference. */ private void addAdditionalParameters(NamingResources resources, Reference ref, String name) { if (resources == null) { resources = namingResources; } ResourceParams resourceParameters = resources.findResourceParams(name); if (debug >= 2) log(" Resource parameters for " + name + " = " + resourceParameters); if (resourceParameters == null) return; Hashtable params = resourceParameters.getParameters(); Enumeration _enum = params.keys(); while (_enum.hasMoreElements()) { String paramName = (String) _enum.nextElement(); String paramValue = (String) params.get(paramName); StringRefAddr refAddr = new StringRefAddr(paramName, paramValue); ref.add(refAddr); } }
/** * Deregister the MBean for this <code>NamingResources</code> object. * * @param resources * The NamingResources to be managed * * @exception Exception * if an MBean cannot be deregistered * @deprecated Unused. Will be removed in Tomcat 8.0.x */ @Deprecated static void destroyMBean(NamingResources resources) throws Exception { String mname = createManagedName(resources); ManagedBean managed = registry.findManagedBean(mname); if (managed == null) { return; } String domain = managed.getDomain(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, resources); if (mserver.isRegistered(oname)) mserver.unregisterMBean(oname); }
/** * Return the naming resources associated with this web application. */ @Override public NamingResources getNamingResources() { if (namingResources == null) { setNamingResources(new NamingResources()); } return (namingResources); }
/** * Remove any resource link reference with the specified name. * * @param resourceLinkName * Name of the resource link reference to remove */ public void removeResourceLink(String resourceLinkName) { resourceLinkName = ObjectName.unquote(resourceLinkName); NamingResources nresources = (NamingResources) this.resource; if (nresources == null) { return; } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink == null) { throw new IllegalArgumentException("Invalid resource Link name '" + resourceLinkName + "'"); } nresources.removeResourceLink(resourceLinkName); }
/** * Remove any environment entry with the specified name. * * @param envName Name of the environment entry to remove */ public void removeEnvironment(String envName) { NamingResources nresources = (NamingResources) this.resource; if (nresources == null) { return; } ContextEnvironment env = nresources.findEnvironment(envName); if (env == null) { throw new IllegalArgumentException ("Invalid environment name '" + envName + "'"); } nresources.removeEnvironment(envName); }
/** * Set the global naming resources. * * @param globalNamingResources The new global naming resources */ @Override public void setGlobalNamingResources (NamingResources globalNamingResources) { NamingResources oldGlobalNamingResources = this.globalNamingResources; this.globalNamingResources = globalNamingResources; this.globalNamingResources.setContainer(this); support.firePropertyChange("globalNamingResources", oldGlobalNamingResources, this.globalNamingResources); }
/** * Remove any environment entry with the specified name. * * @param envName * Name of the environment entry to remove */ public void removeEnvironment(String envName) { NamingResources nresources = (NamingResources) this.resource; if (nresources == null) { return; } ContextEnvironment env = nresources.findEnvironment(envName); if (env == null) { throw new IllegalArgumentException("Invalid environment name '" + envName + "'"); } nresources.removeEnvironment(envName); }
/** * Remove any environment entry with the specified name. * * @param envName Name of the environment entry to remove */ public void removeEnvironment(String envName) { NamingResources nresources = getNamingResources(); if (nresources == null) { return; } ContextEnvironment env = nresources.findEnvironment(envName); if (env == null) { throw new IllegalArgumentException ("Invalid environment name '" + envName + "'"); } nresources.removeEnvironment(envName); }
/** * Remove any resource reference with the specified name. * * @param resourceName Name of the resource reference to remove */ public void removeResource(String resourceName) { resourceName = ObjectName.unquote(resourceName); NamingResources nresources = getNamingResources(); if (nresources == null) { return; } ContextResource resource = nresources.findResource(resourceName); if (resource == null) { throw new IllegalArgumentException ("Invalid resource name '" + resourceName + "'"); } nresources.removeResource(resourceName); }
/** * Remove any resource link with the specified name. * * @param resourceLinkName Name of the resource reference to remove */ public void removeResourceLink(String resourceLinkName) { resourceLinkName = ObjectName.unquote(resourceLinkName); NamingResources nresources = getNamingResources(); if (nresources == null) { return; } ContextResourceLink resource = nresources.findResourceLink(resourceLinkName); if (resource == null) { throw new IllegalArgumentException ("Invalid resource name '" + resourceLinkName + "'"); } nresources.removeResourceLink(resourceLinkName); }
/** * Create the MBeans for the specified NamingResources and its * nested components. * * @param resources NamingResources for which to create MBeans */ protected void createMBeans(NamingResources resources) throws Exception { // Create the MBean for the NamingResources itself if (log.isDebugEnabled()) { log.debug("Creating MBean for NamingResources " + resources); } MBeanUtils.createMBean(resources); resources.addPropertyChangeListener(this); // Create the MBeans for each child environment entry ContextEnvironment environments[] = resources.findEnvironments(); for (int i = 0; i < environments.length; i++) { createMBeans(environments[i]); } // Create the MBeans for each child resource entry ContextResource cresources[] = resources.findResources(); for (int i = 0; i < cresources.length; i++) { createMBeans(cresources[i]); } // Create the MBeans for each child resource link entry ContextResourceLink cresourcelinks[] = resources.findResourceLinks(); for (int i = 0; i < cresourcelinks.length; i++) { createMBeans(cresourcelinks[i]); } }
/** * Create the MBeans for the specified Server and its nested components. * * @param server Server for which to create MBeans * * @exception Exception if an exception is thrown during MBean creation */ protected void createMBeans(Server server) throws Exception { // Create the MBean for the Server itself if (log.isDebugEnabled()) log.debug("Creating MBean for Server " + server); //MBeanUtils.createMBean(server); if (server instanceof StandardServer) { ((StandardServer) server).addPropertyChangeListener(this); } // Create the MBeans for the global NamingResources (if any) NamingResources resources = server.getGlobalNamingResources(); if (resources != null) { createMBeans(resources); } // Create the MBeans for each child Service Service services[] = server.findServices(); for (int i = 0; i < services.length; i++) { // FIXME - Warp object hierarchy not currently supported if (services[i].getContainer().getClass().getName().equals ("org.apache.catalina.connector.warp.WarpEngine")) { if (log.isDebugEnabled()) { log.debug("Skipping MBean for Service " + services[i]); } continue; } createMBeans(services[i]); } }