org.apache.tomcat.util.modeler.Registry Java Examples
The following examples show how to use
org.apache.tomcat.util.modeler.Registry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Create and configure (if necessary) and return the registry of * managed object descriptions. */ public static synchronized Registry createRegistry() { if (registry == null) { registry = Registry.getRegistry(null, null); ClassLoader cl = MBeanUtils.class.getClassLoader(); registry.loadDescriptors("org.apache.catalina.mbeans", cl); registry.loadDescriptors("org.apache.catalina.authenticator", cl); registry.loadDescriptors("org.apache.catalina.core", cl); registry.loadDescriptors("org.apache.catalina", cl); registry.loadDescriptors("org.apache.catalina.deploy", cl); registry.loadDescriptors("org.apache.catalina.loader", cl); registry.loadDescriptors("org.apache.catalina.realm", cl); registry.loadDescriptors("org.apache.catalina.session", cl); registry.loadDescriptors("org.apache.catalina.startup", cl); registry.loadDescriptors("org.apache.catalina.users", cl); registry.loadDescriptors("org.apache.catalina.ha", cl); registry.loadDescriptors("org.apache.catalina.connector", cl); registry.loadDescriptors("org.apache.catalina.valves", cl); } return (registry); }
Example #2
Source File: AbstractProtocol.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
protected void unregister(Processor<S> processor) { if (getProtocol().getDomain() != null) { synchronized (this) { try { Request r = processor.getRequest(); if (r == null) { // Probably an UpgradeProcessor return; } RequestInfo rp = r.getRequestProcessor(); rp.setGlobalProcessor(null); ObjectName rpName = rp.getRpName(); if (getLog().isDebugEnabled()) { getLog().debug("Unregister " + rpName); } Registry.getRegistry(null, null).unregisterComponent( rpName); rp.setRpName(null); } catch (Exception e) { getLog().warn("Error unregistering request", e); } } } }
Example #3
Source File: MBeanUtils.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Create and configure (if necessary) and return the registry of * managed object descriptions. */ public static synchronized Registry createRegistry() { if (registry == null) { registry = Registry.getRegistry(null, null); ClassLoader cl = MBeanUtils.class.getClassLoader(); registry.loadDescriptors("org.apache.catalina.mbeans", cl); registry.loadDescriptors("org.apache.catalina.authenticator", cl); registry.loadDescriptors("org.apache.catalina.core", cl); registry.loadDescriptors("org.apache.catalina", cl); registry.loadDescriptors("org.apache.catalina.deploy", cl); registry.loadDescriptors("org.apache.catalina.loader", cl); registry.loadDescriptors("org.apache.catalina.realm", cl); registry.loadDescriptors("org.apache.catalina.session", cl); registry.loadDescriptors("org.apache.catalina.startup", cl); registry.loadDescriptors("org.apache.catalina.users", cl); registry.loadDescriptors("org.apache.catalina.ha", cl); registry.loadDescriptors("org.apache.catalina.connector", cl); registry.loadDescriptors("org.apache.catalina.valves", cl); } return (registry); }
Example #4
Source File: AbstractProtocol.java From tomcatsrc with Apache License 2.0 | 6 votes |
protected void register(AbstractProcessor<S> processor) { if (getProtocol().getDomain() != null) { synchronized (this) { try { long count = registerCount.incrementAndGet(); RequestInfo rp = processor.getRequest().getRequestProcessor(); rp.setGlobalProcessor(global); ObjectName rpName = new ObjectName( getProtocol().getDomain() + ":type=RequestProcessor,worker=" + getProtocol().getName() + ",name=" + getProtocol().getProtocolName() + "Request" + count); if (getLog().isDebugEnabled()) { getLog().debug("Register " + rpName); } Registry.getRegistry(null, null).registerComponent(rp, rpName, null); rp.setRpName(rpName); } catch (Exception e) { getLog().warn("Error registering request"); } } } }
Example #5
Source File: MBeanUtils.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Create and configure (if necessary) and return the registry of * managed object descriptions. * @return the singleton registry */ public static synchronized Registry createRegistry() { if (registry == null) { registry = Registry.getRegistry(null, null); ClassLoader cl = MBeanUtils.class.getClassLoader(); registry.loadDescriptors("org.apache.catalina.mbeans", cl); registry.loadDescriptors("org.apache.catalina.authenticator", cl); registry.loadDescriptors("org.apache.catalina.core", cl); registry.loadDescriptors("org.apache.catalina", cl); registry.loadDescriptors("org.apache.catalina.deploy", cl); registry.loadDescriptors("org.apache.catalina.loader", cl); registry.loadDescriptors("org.apache.catalina.realm", cl); registry.loadDescriptors("org.apache.catalina.session", cl); registry.loadDescriptors("org.apache.catalina.startup", cl); registry.loadDescriptors("org.apache.catalina.users", cl); registry.loadDescriptors("org.apache.catalina.ha", cl); registry.loadDescriptors("org.apache.catalina.connector", cl); registry.loadDescriptors("org.apache.catalina.valves", cl); registry.loadDescriptors("org.apache.catalina.storeconfig", cl); registry.loadDescriptors("org.apache.tomcat.util.descriptor.web", cl); } return registry; }
Example #6
Source File: AbstractEndpoint.java From Tomcat8-Source-Read with MIT License | 6 votes |
public void init() throws Exception { if (bindOnInit) { bind(); bindState = BindState.BOUND_ON_INIT; } if (this.domain != null) { // Register endpoint (as ThreadPool - historical name) oname = new ObjectName(domain + ":type=ThreadPool,name=\"" + getName() + "\""); Registry.getRegistry(null, null).registerComponent(this, oname, null); ObjectName socketPropertiesOname = new ObjectName(domain + ":type=ThreadPool,name=\"" + getName() + "\",subType=SocketProperties"); socketProperties.setObjectName(socketPropertiesOname); Registry.getRegistry(null, null).registerComponent(socketProperties, socketPropertiesOname, null); for (SSLHostConfig sslHostConfig : findSslHostConfigs()) { registerJmx(sslHostConfig); } } }
Example #7
Source File: TomcatOnlyApplication.java From spring-graalvm-native with Apache License 2.0 | 6 votes |
public static void main(String... args) throws Exception { Registry.disableRegistry(); tomcatBase.mkdir(); docBase.mkdir(); serverBase.mkdir(); Tomcat tomcat = new Tomcat(); tomcat.setBaseDir(serverBase.getAbsolutePath()); Connector connector = new Connector(Http11NioProtocol.class.getName()); connector.setPort(8080); tomcat.setConnector(connector); Context context = tomcat.addContext("", docBase.getAbsolutePath()); tomcat.addServlet(context, HelloFromTomcatServlet.class.getSimpleName(), new HelloFromTomcatServlet()); context.addServletMappingDecoded("/*", HelloFromTomcatServlet.class.getSimpleName()); tomcat.getHost().setAutoDeploy(false); tomcat.start(); }
Example #8
Source File: AbstractProtocol.java From Tomcat8-Source-Read with MIT License | 6 votes |
protected void unregister(Processor processor) { if (getProtocol().getDomain() != null) { synchronized (this) { try { Request r = processor.getRequest(); if (r == null) { // Probably an UpgradeProcessor return; } RequestInfo rp = r.getRequestProcessor(); rp.setGlobalProcessor(null); ObjectName rpName = rp.getRpName(); if (getLog().isDebugEnabled()) { getLog().debug("Unregister [" + rpName + "]"); } Registry.getRegistry(null, null).unregisterComponent( rpName); rp.setRpName(null); } catch (Exception e) { getLog().warn(sm.getString("abstractProtocol.processorUnregisterError"), e); } } } }
Example #9
Source File: AbstractProtocol.java From tomcatsrc with Apache License 2.0 | 6 votes |
protected void unregister(Processor<S> processor) { if (getProtocol().getDomain() != null) { synchronized (this) { try { Request r = processor.getRequest(); if (r == null) { // Probably an UpgradeProcessor return; } RequestInfo rp = r.getRequestProcessor(); rp.setGlobalProcessor(null); ObjectName rpName = rp.getRpName(); if (getLog().isDebugEnabled()) { getLog().debug("Unregister " + rpName); } Registry.getRegistry(null, null).unregisterComponent( rpName); rp.setRpName(null); } catch (Exception e) { getLog().warn("Error unregistering request", e); } } } }
Example #10
Source File: AbstractProtocol.java From Tomcat8-Source-Read with MIT License | 6 votes |
protected void register(Processor processor) { if (getProtocol().getDomain() != null) { synchronized (this) { try { long count = registerCount.incrementAndGet(); RequestInfo rp = processor.getRequest().getRequestProcessor(); rp.setGlobalProcessor(global); ObjectName rpName = new ObjectName( getProtocol().getDomain() + ":type=RequestProcessor,worker=" + getProtocol().getName() + ",name=" + getProtocol().getProtocolName() + "Request" + count); if (getLog().isDebugEnabled()) { getLog().debug("Register [" + processor + "] as [" + rpName + "]"); } Registry.getRegistry(null, null).registerComponent(rp, rpName, null); rp.setRpName(rpName); } catch (Exception e) { getLog().warn(sm.getString("abstractProtocol.processorRegisterError"), e); } } } }
Example #11
Source File: ApplicationFilterConfig.java From tomcatsrc with Apache License 2.0 | 6 votes |
private void unregisterJMX() { // unregister this component if (oname != null) { try { Registry.getRegistry(null, null).unregisterComponent(oname); if (log.isDebugEnabled()) log.debug(sm.getString( "applicationFilterConfig.jmxUnregister", getFilterClass(), getFilterName())); } catch(Exception ex) { log.error(sm.getString( "applicationFilterConfig.jmxUnregisterFail", getFilterClass(), getFilterName()), ex); } } }
Example #12
Source File: ApplicationFilterConfig.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
private void unregisterJMX() { // unregister this component if (oname != null) { try { Registry.getRegistry(null, null).unregisterComponent(oname); if (log.isDebugEnabled()) log.debug(sm.getString( "applicationFilterConfig.jmxUnregister", getFilterClass(), getFilterName())); } catch(Exception ex) { log.error(sm.getString( "applicationFilterConfig.jmxUnregisterFail", getFilterClass(), getFilterName()), ex); } } }
Example #13
Source File: AbstractProtocol.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public void destroy() { if(getLog().isInfoEnabled()) { getLog().info(sm.getString("abstractProtocolHandler.destroy", getName())); } try { endpoint.destroy(); } catch (Exception e) { getLog().error(sm.getString("abstractProtocolHandler.destroyError", getName()), e); } if (oname != null) { Registry.getRegistry(null, null).unregisterComponent(oname); } if (tpOname != null) Registry.getRegistry(null, null).unregisterComponent(tpOname); if (rgOname != null) Registry.getRegistry(null, null).unregisterComponent(rgOname); }
Example #14
Source File: MBeanUtils.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Create and configure (if necessary) and return the * <code>MBeanServer</code> with which we will be * registering our <code>DynamicMBean</code> implementations. */ public static synchronized MBeanServer createServer() { if (mserver == null) { mserver = Registry.getRegistry(null, null).getMBeanServer(); } return (mserver); }
Example #15
Source File: LifecycleMBeanBase.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Sub-classes wishing to perform additional initialization should override * this method, ensuring that super.initInternal() is the first call in the * overriding method. */ @Override protected void initInternal() throws LifecycleException { // If oname is not null then registration has already happened via // preRegister(). if (oname == null) { mserver = Registry.getRegistry(null, null).getMBeanServer(); oname = register(this, getObjectNameKeyProperties()); } }
Example #16
Source File: WebappLoader.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * 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; }
Example #17
Source File: JMXProxyServlet.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Initialize this servlet. */ @Override public void init() throws ServletException { // Retrieve the MBean server registry = Registry.getRegistry(null, null); mBeanServer = Registry.getRegistry(null, null).getMBeanServer(); }
Example #18
Source File: HostConfig.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Process a "start" event for this Host. */ public void start() { if (log.isDebugEnabled()) log.debug(sm.getString("hostConfig.start")); try { ObjectName hostON = host.getObjectName(); oname = new ObjectName (hostON.getDomain() + ":type=Deployer,host=" + host.getName()); Registry.getRegistry(null, null).registerComponent (this, oname, this.getClass().getName()); } catch (Exception e) { log.error(sm.getString("hostConfig.jmx.register", oname), e); } if (!appBase().isDirectory()) { log.error(sm.getString( "hostConfig.appBase", host.getName(), appBase().getPath())); host.setDeployOnStartup(false); host.setAutoDeploy(false); } if (host.getDeployOnStartup()) { // 部署应用 deployApps(); } }
Example #19
Source File: NamingContextListener.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Set the specified resources in the naming context. */ public void removeResource(String name) { try { envCtx.unbind(name); } catch (NamingException e) { logger.error(sm.getString("naming.unbindFailed", e)); } ObjectName on = objectNames.get(name); if (on != null) { Registry.getRegistry(null, null).unregisterComponent(on); } }
Example #20
Source File: StandardWrapper.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * 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); } } }
Example #21
Source File: CollectedInfo.java From tomcatsrc with Apache License 2.0 | 5 votes |
public void init(String host, int port) throws Exception { int iport = 0; String shost = null; mBeanServer = Registry.getRegistry(null, null).getMBeanServer(); String onStr = "*:type=ThreadPool,*"; ObjectName objectName = new ObjectName(onStr); Set<ObjectInstance> set = mBeanServer.queryMBeans(objectName, null); Iterator<ObjectInstance> iterator = set.iterator(); while (iterator.hasNext()) { ObjectInstance oi = iterator.next(); objName = oi.getObjectName(); String name = objName.getKeyProperty("name"); /* Name are: * http-8080 * jk-10.33.144.3-8009 * jk-jfcpc%2F10.33.144.3-8009 */ String [] elenames = name.split("-"); String sport = elenames[elenames.length-1]; iport = Integer.parseInt(sport); String [] shosts = elenames[1].split("%2F"); shost = shosts[0]; if (port==0 && host==null) break; /* Take the first one */ if (host==null && iport==port) break; /* Only port done */ if (shost.compareTo(host) == 0) break; /* Done port and host are the expected ones */ } if (objName == null) throw(new Exception("Can't find connector for " + host + ":" + port)); this.port = iport; this.host = shost; }
Example #22
Source File: MbeansDescriptorsIntrospectionSource.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public List<ObjectName> loadDescriptors(Registry registry, String type, Object source) throws Exception { setRegistry(registry); setType(type); setSource(source); execute(); return mbeans; }
Example #23
Source File: MbeansDescriptorsDigesterSource.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public List<ObjectName> loadDescriptors( Registry registry, String type, Object source) throws Exception { setRegistry(registry); setType(type); setSource(source); execute(); return mbeans; }
Example #24
Source File: MbeansDescriptorsDOMSource.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public List<ObjectName> loadDescriptors( Registry registry, String type, Object source) throws Exception { setRegistry(registry); setType(type); setSource(source); execute(); return mbeans; }
Example #25
Source File: MbeansDescriptorsSerSource.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public List<ObjectName> loadDescriptors( Registry registry, String type, Object source) throws Exception { setRegistry(registry); setType(type); setSource(source); execute(); return mbeans; }
Example #26
Source File: NamingContextListener.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Set the specified resources in the naming context. */ public void removeResource(String name) { try { envCtx.unbind(name); } catch (NamingException e) { logger.error(sm.getString("naming.unbindFailed", e)); } ObjectName on = objectNames.get(name); if (on != null) { Registry.getRegistry(null, null).unregisterComponent(on); } }
Example #27
Source File: LifecycleMBeanBase.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Sub-classes wishing to perform additional initialization should override * this method, ensuring that super.initInternal() is the first call in the * overriding method. */ @Override protected void initInternal() throws LifecycleException { // If oname is not null then registration has already happened via // preRegister(). if (oname == null) { mserver = Registry.getRegistry(null, null).getMBeanServer(); oname = register(this, getObjectNameKeyProperties()); } }
Example #28
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Create and configure (if necessary) and return the * <code>MBeanServer</code> with which we will be * registering our <code>DynamicMBean</code> implementations. */ public static synchronized MBeanServer createServer() { if (mserver == null) { mserver = Registry.getRegistry(null, null).getMBeanServer(); } return (mserver); }
Example #29
Source File: HostConfig.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Process a "stop" event for this Host. */ public void stop() { if (log.isDebugEnabled()) log.debug(sm.getString("hostConfig.stop")); if (oname != null) { try { Registry.getRegistry(null, null).unregisterComponent(oname); } catch (Exception e) { log.error(sm.getString("hostConfig.jmx.unregister", oname), e); } } oname = null; }
Example #30
Source File: MbeansDescriptorsIntrospectionSource.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public List<ObjectName> loadDescriptors(Registry registry, String type, Object source) throws Exception { setRegistry(registry); setType(type); setSource(source); execute(); return mbeans; }