org.apache.catalina.core.StandardService Java Examples
The following examples show how to use
org.apache.catalina.core.StandardService.
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: MBeanFactory.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Creates a new StandardService and StandardEngine. * * @param domain Domain name for the container instance * @param defaultHost Name of the default host to be used in the Engine * @param baseDir Base directory value for Engine * @return the object name of the created service * * @exception Exception if an MBean cannot be created or registered */ public String createStandardServiceEngine(String domain, String defaultHost, String baseDir) throws Exception{ if (!(container instanceof Server)) { throw new Exception("Container not Server"); } StandardEngine engine = new StandardEngine(); engine.setDomain(domain); engine.setName(domain); engine.setDefaultHost(defaultHost); Service service = new StandardService(); service.setContainer(engine); service.setName(domain); ((Server) container).addService(service); return engine.getObjectName().toString(); }
Example #2
Source File: MBeanFactory.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Creates a new StandardService and StandardEngine. * * @param domain Domain name for the container instance * @param defaultHost Name of the default host to be used in the Engine * @param baseDir Base directory value for Engine * * @exception Exception if an MBean cannot be created or registered */ public String createStandardServiceEngine(String domain, String defaultHost, String baseDir) throws Exception{ if (!(container instanceof Server)) { throw new Exception("Container not Server"); } StandardEngine engine = new StandardEngine(); engine.setDomain(domain); engine.setName(domain); engine.setDefaultHost(defaultHost); engine.setBaseDir(baseDir); Service service = new StandardService(); service.setContainer(engine); service.setName(domain); ((Server) container).addService(service); return engine.getObjectName().toString(); }
Example #3
Source File: MBeanFactory.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Creates a new StandardService and StandardEngine. * * @param domain Domain name for the container instance * @param defaultHost Name of the default host to be used in the Engine * @param baseDir Base directory value for Engine * * @exception Exception if an MBean cannot be created or registered */ public String createStandardServiceEngine(String domain, String defaultHost, String baseDir) throws Exception{ if (!(container instanceof Server)) { throw new Exception("Container not Server"); } StandardEngine engine = new StandardEngine(); engine.setDomain(domain); engine.setName(domain); engine.setDefaultHost(defaultHost); engine.setBaseDir(baseDir); Service service = new StandardService(); service.setContainer(engine); service.setName(domain); ((Server) container).addService(service); return engine.getObjectName().toString(); }
Example #4
Source File: StandardServiceSF.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Store the specified service element children. * * @param aWriter Current output writer * @param indent Indentation level * @param aService Service to store * @param parentDesc The element description * @throws Exception Configuration storing error */ @Override public void storeChildren(PrintWriter aWriter, int indent, Object aService, StoreDescription parentDesc) throws Exception { if (aService instanceof StandardService) { StandardService service = (StandardService) aService; // Store nested <Listener> elements LifecycleListener listeners[] = ((Lifecycle) service) .findLifecycleListeners(); storeElementArray(aWriter, indent, listeners); // Store nested <Executor> elements Executor[] executors = service.findExecutors(); storeElementArray(aWriter, indent, executors); Connector connectors[] = service.findConnectors(); storeElementArray(aWriter, indent, connectors); // Store nested <Engine> element Engine container = service.getContainer(); if (container != null) { StoreDescription elementDesc = getRegistry().findDescription(container.getClass()); if (elementDesc != null) { IStoreFactory factory = elementDesc.getStoreFactory(); factory.store(aWriter, indent, container); } } } }
Example #5
Source File: MBeanFactory.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Remove an existing Context. * * @param contextName MBean Name of the component to remove * * @exception Exception if a component cannot be removed */ public void removeContext(String contextName) throws Exception { // Acquire a reference to the component to be removed ObjectName oname = new ObjectName(contextName); String domain = oname.getDomain(); StandardService service = (StandardService) getService(oname); Engine engine = service.getContainer(); String name = oname.getKeyProperty("name"); name = name.substring(2); int i = name.indexOf('/'); String hostName = name.substring(0,i); String path = name.substring(i); ObjectName deployer = new ObjectName(domain+":type=Deployer,host="+ hostName); String pathStr = getPathStr(path); if(mserver.isRegistered(deployer)) { mserver.invoke(deployer,"addServiced", new Object[]{pathStr}, new String[] {"java.lang.String"}); mserver.invoke(deployer,"unmanageApp", new Object[] {pathStr}, new String[] {"java.lang.String"}); mserver.invoke(deployer,"removeServiced", new Object[] {pathStr}, new String[] {"java.lang.String"}); } else { log.warn("Deployer not found for "+hostName); Host host = (Host) engine.findChild(hostName); Context context = (Context) host.findChild(pathStr); // Remove this component from its parent component host.removeChild(context); if(context instanceof StandardContext) try { ((StandardContext)context).destroy(); } catch (Exception e) { log.warn("Error during context [" + context.getName() + "] destroy ", e); } } }
Example #6
Source File: MBeanFactory.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Remove an existing Context. * * @param contextName MBean Name of the component to remove * * @exception Exception if a component cannot be removed */ public void removeContext(String contextName) throws Exception { // Acquire a reference to the component to be removed ObjectName oname = new ObjectName(contextName); String domain = oname.getDomain(); StandardService service = (StandardService) getService(oname); Engine engine = (Engine) service.getContainer(); String name = oname.getKeyProperty("name"); name = name.substring(2); int i = name.indexOf('/'); String hostName = name.substring(0,i); String path = name.substring(i); ObjectName deployer = new ObjectName(domain+":type=Deployer,host="+ hostName); String pathStr = getPathStr(path); if(mserver.isRegistered(deployer)) { mserver.invoke(deployer,"addServiced", new Object[]{pathStr}, new String[] {"java.lang.String"}); mserver.invoke(deployer,"unmanageApp", new Object[] {pathStr}, new String[] {"java.lang.String"}); mserver.invoke(deployer,"removeServiced", new Object[] {pathStr}, new String[] {"java.lang.String"}); } else { log.warn("Deployer not found for "+hostName); Host host = (Host) engine.findChild(hostName); Context context = (Context) host.findChild(pathStr); // Remove this component from its parent component host.removeChild(context); if(context instanceof StandardContext) try { ((StandardContext)context).destroy(); } catch (Exception e) { log.warn("Error during context [" + context.getName() + "] destroy ", e); } } }
Example #7
Source File: MBeanFactory.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * Remove an existing Context. * * @param contextName MBean Name of the component to remove * * @exception Exception if a component cannot be removed */ public void removeContext(String contextName) throws Exception { // Acquire a reference to the component to be removed ObjectName oname = new ObjectName(contextName); String domain = oname.getDomain(); StandardService service = (StandardService) getService(oname); Engine engine = (Engine) service.getContainer(); String name = oname.getKeyProperty("name"); name = name.substring(2); int i = name.indexOf('/'); String hostName = name.substring(0,i); String path = name.substring(i); ObjectName deployer = new ObjectName(domain+":type=Deployer,host="+ hostName); String pathStr = getPathStr(path); if(mserver.isRegistered(deployer)) { mserver.invoke(deployer,"addServiced", new Object[]{pathStr}, new String[] {"java.lang.String"}); mserver.invoke(deployer,"unmanageApp", new Object[] {pathStr}, new String[] {"java.lang.String"}); mserver.invoke(deployer,"removeServiced", new Object[] {pathStr}, new String[] {"java.lang.String"}); } else { log.warn("Deployer not found for "+hostName); Host host = (Host) engine.findChild(hostName); Context context = (Context) host.findChild(pathStr); // Remove this component from its parent component host.removeChild(context); if(context instanceof StandardContext) try { ((StandardContext)context).destroy(); } catch (Exception e) { log.warn("Error during context [" + context.getName() + "] destroy ", e); } } }
Example #8
Source File: StandardServiceModifierTest.java From pinpoint with Apache License 2.0 | 4 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); this.service = new StandardService(); this.service.setContainer(this.engine); }