/** * Add a resource link for this web application. * * @param resourceLink New resource link */ public void addResourceLink(ContextResourceLink resourceLink) { if (entries.contains(resourceLink.getName())) { return; } else { entries.add(resourceLink.getName()); } synchronized (resourceLinks) { resourceLink.setNamingResources(this); resourceLinks.put(resourceLink.getName(), resourceLink); } support.firePropertyChange("resourceLink", null, resourceLink); // Register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.createMBean(resourceLink); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanCreateFail", resourceLink.getName()), e); } } }
/** * Remove any environment entry with the specified name. * * @param name Name of the environment entry to remove */ public void removeEnvironment(String name) { entries.remove(name); ContextEnvironment environment = null; synchronized (envs) { environment = envs.remove(name); } if (environment != null) { support.firePropertyChange("environment", environment, null); // De-register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.destroyMBean(environment); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanDestroyFail", environment.getName()), e); } } environment.setNamingResources(null); } }
/** * Remove any resource reference with the specified name. * * @param name Name of the resource reference to remove */ public void removeResource(String name) { entries.remove(name); ContextResource resource = null; synchronized (resources) { resource = resources.remove(name); } if (resource != null) { support.firePropertyChange("resource", resource, null); // De-register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.destroyMBean(resource); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanDestroyFail", resource.getName()), e); } } resource.setNamingResources(null); } }
/** * Remove any resource link with the specified name. * * @param name Name of the resource link to remove */ public void removeResourceLink(String name) { entries.remove(name); ContextResourceLink resourceLink = null; synchronized (resourceLinks) { resourceLink = resourceLinks.remove(name); } if (resourceLink != null) { support.firePropertyChange("resourceLink", resourceLink, null); // De-register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.destroyMBean(resourceLink); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanDestroyFail", resourceLink.getName()), e); } } resourceLink.setNamingResources(null); } }
/** * Add a resource link for this web application. * * @param resourceLink * New resource link */ public void addResourceLink(ContextResourceLink resourceLink) { if (entries.contains(resourceLink.getName())) { return; } else { entries.add(resourceLink.getName()); } synchronized (resourceLinks) { resourceLink.setNamingResources(this); resourceLinks.put(resourceLink.getName(), resourceLink); } support.firePropertyChange("resourceLink", null, resourceLink); // Register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.createMBean(resourceLink); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanCreateFail", resourceLink.getName()), e); } } }
/** * Remove any environment entry with the specified name. * * @param name * Name of the environment entry to remove */ public void removeEnvironment(String name) { entries.remove(name); ContextEnvironment environment = null; synchronized (envs) { environment = envs.remove(name); } if (environment != null) { support.firePropertyChange("environment", environment, null); // De-register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.destroyMBean(environment); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanDestroyFail", environment.getName()), e); } } environment.setNamingResources(null); } }
/** * Remove any resource reference with the specified name. * * @param name * Name of the resource reference to remove */ public void removeResource(String name) { entries.remove(name); ContextResource resource = null; synchronized (resources) { resource = resources.remove(name); } if (resource != null) { support.firePropertyChange("resource", resource, null); // De-register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.destroyMBean(resource); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanDestroyFail", resource.getName()), e); } } resource.setNamingResources(null); } }
/** * Remove any resource link with the specified name. * * @param name * Name of the resource link to remove */ public void removeResourceLink(String name) { entries.remove(name); ContextResourceLink resourceLink = null; synchronized (resourceLinks) { resourceLink = resourceLinks.remove(name); } if (resourceLink != null) { support.firePropertyChange("resourceLink", resourceLink, null); // De-register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.destroyMBean(resourceLink); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanDestroyFail", resourceLink.getName()), e); } } resourceLink.setNamingResources(null); } }
/** * Load and initialize an instance of this servlet, if there is not already * at least one initialized instance. This can be used, for example, to load * servlets that are marked in the deployment descriptor to be loaded at * server startup time. * <p> * <b>IMPLEMENTATION NOTE</b>: Servlets whose classnames begin with * <code>org.apache.catalina.</code> (so-called "container" servlets) are * loaded by the same classloader that loaded this class, rather than the * classloader for the current web application. This gives such classes * access to Catalina internals, which are prevented for classes loaded for * web applications. * * @exception ServletException * if the servlet init() method threw an exception * @exception ServletException * if some other loading problem occurs */ @Override public synchronized void load() throws ServletException { instance = loadServlet(); if (!instanceInitialized) { initServlet(instance); } if (isJspServlet) { StringBuilder oname = new StringBuilder(MBeanUtils.getDomain(getParent())); oname.append(":type=JspMonitor,name="); oname.append(getName()); oname.append(getWebModuleKeyProperties()); try { jspMonitorON = new ObjectName(oname.toString()); Registry.getRegistry(null, null).registerComponent(instance, jspMonitorON, null); } catch (Exception ex) { log.info("Error registering JSP monitoring with jmx " + instance); } } }
/** * Add a resource reference for this web application. * * @param resource New resource reference */ public void addResource(ContextResource resource) { if (entries.containsKey(resource.getName())) { return; } else { entries.put(resource.getName(), resource.getType()); } synchronized (resources) { resource.setNamingResources(this); resources.put(resource.getName(), resource); } support.firePropertyChange("resource", null, resource); // Register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.createMBean(resource); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanCreateFail", resource.getName()), e); } } }
@SuppressWarnings("deprecation") @Override protected void initInternal() throws LifecycleException { super.initInternal(); if (clusterDeployer != null) { StringBuilder name = new StringBuilder("type=Cluster"); Container container = getContainer(); name.append(MBeanUtils.getContainerKeyProperties(container)); name.append(",component=Deployer"); onameClusterDeployer = register(clusterDeployer, name.toString()); } }
@SuppressWarnings("deprecation") @Override protected String getDomainInternal() { Container container = getContainer(); if (container == null) { return null; } return MBeanUtils.getDomain(container); }
@SuppressWarnings("deprecation") @Override protected String getObjectNameKeyProperties() { StringBuilder name = new StringBuilder("type=Cluster"); Container container = getContainer(); if (container != null) { name.append(MBeanUtils.getContainerKeyProperties(container)); } return name.toString(); }
@SuppressWarnings("deprecation") private void registerMember(Member member) { // JMX registration StringBuilder name = new StringBuilder("type=Cluster"); Container container = getContainer(); if (container != null) { name.append(MBeanUtils.getContainerKeyProperties(container)); } name.append(",component=Member,name="); name.append(ObjectName.quote(member.getName())); ObjectName oname = register(member, name.toString()); memberOnameMap.put(member, oname); }
/** * Stop associated {@link ClassLoader} and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected void stopInternal() throws LifecycleException { if (log.isDebugEnabled()) log.debug(sm.getString("webappLoader.stopping")); setState(LifecycleState.STOPPING); // Remove context attributes as appropriate if (container instanceof Context) { ServletContext servletContext = ((Context) container).getServletContext(); servletContext.removeAttribute(Globals.CLASS_PATH_ATTR); } // Throw away our current class loader if (classLoader != null) { ((Lifecycle) classLoader).stop(); DirContextURLStreamHandler.unbind(classLoader); } try { StandardContext ctx=(StandardContext)container; String contextName = ctx.getName(); if (!contextName.startsWith("/")) { contextName = "/" + contextName; } ObjectName cloname = new ObjectName (MBeanUtils.getDomain(ctx) + ":type=WebappClassLoader,context=" + contextName + ",host=" + ctx.getParent().getName()); Registry.getRegistry(null, null).unregisterComponent(cloname); } catch (Exception e) { log.error("LifecycleException ", e); } classLoader = null; }
/** * Add a resource reference for this web application. * * @param resource New resource reference */ public void addResource(ContextResource resource) { if (entries.contains(resource.getName())) { return; } else { if (!checkResourceType(resource)) { throw new IllegalArgumentException(sm.getString( "namingResources.resourceTypeFail", resource.getName(), resource.getType())); } entries.add(resource.getName()); } synchronized (resources) { resource.setNamingResources(this); resources.put(resource.getName(), resource); } support.firePropertyChange("resource", null, resource); // Register with JMX if (resourceRequireExplicitRegistration) { try { MBeanUtils.createMBean(resource); } catch (Exception e) { log.warn(sm.getString("namingResources.mbeanCreateFail", resource.getName()), e); } } }
@Override protected String getObjectNameKeyProperties() { Object c = getContainer(); if (c instanceof Container) { return "type=NamingResources" + MBeanUtils.getContainerKeyProperties((Container) c); } // Server or just unknown return "type=NamingResources"; }
@Override public String getObjectNameKeyProperties() { StringBuilder keyProperties = new StringBuilder("type=Realm"); keyProperties.append(getRealmSuffix()); keyProperties.append(MBeanUtils.getContainerKeyProperties(container)); return keyProperties.toString(); }
/** * Obtain the MBean domain for this server. The domain is obtained using * the following search order: * <ol> * <li>Name of first {@link org.apache.catalina.Engine}.</li> * <li>Name of first {@link Service}.</li> * </ol> */ @Override protected String getDomainInternal() { String domain = null; Service[] services = findServices(); if (services.length > 0) { Service service = services[0]; if (service != null) { domain = MBeanUtils.getDomain(service); } } return domain; }
@Override protected String getObjectNameKeyProperties() { StringBuilder keyProperties = new StringBuilder("type=Host"); keyProperties.append(MBeanUtils.getContainerKeyProperties(this)); return keyProperties.toString(); }
/** * Load and initialize an instance of this servlet, if there is not already * at least one initialized instance. This can be used, for example, to * load servlets that are marked in the deployment descriptor to be loaded * at server startup time. * <p> * <b>IMPLEMENTATION NOTE</b>: Servlets whose classnames begin with * <code>org.apache.catalina.</code> (so-called "container" servlets) * are loaded by the same classloader that loaded this class, rather than * the classloader for the current web application. * This gives such classes access to Catalina internals, which are * prevented for classes loaded for web applications. * * @exception ServletException if the servlet init() method threw * an exception * @exception ServletException if some other loading problem occurs */ @Override public synchronized void load() throws ServletException { instance = loadServlet(); if (!instanceInitialized) { initServlet(instance); } if (isJspServlet) { StringBuilder oname = new StringBuilder(MBeanUtils.getDomain(getParent())); oname.append(":type=JspMonitor,name="); oname.append(getName()); oname.append(getWebModuleKeyProperties()); try { jspMonitorON = new ObjectName(oname.toString()); Registry.getRegistry(null, null) .registerComponent(instance, jspMonitorON, null); } catch( Exception ex ) { log.info("Error registering JSP monitoring with jmx " + instance); } } }