private void addInstanceIdToEngineName() { int instanceId = containerCounter.incrementAndGet(); if (instanceId > 0) { Engine engine = this.tomcat.getEngine(); engine.setName(engine.getName() + "-" + instanceId); } }
void start() throws Exception { assert hostName() != null; started = false; connector = connectorFactory.apply(hostName()); final Service service = connector.getService(); final Engine engine = TomcatUtil.engine(service, hostName()); final String engineName = engine.getName(); if (activeEngines.contains(engineName)) { throw new TomcatServiceException("duplicate engine name: " + engineName); } server = service.getServer(); if (!TOMCAT_START_STATES.contains(server.getState())) { logger.info("Starting an embedded Tomcat: {}", toString(server)); server.start(); started = true; } else { throw new TomcatServiceException("Cannot manage already running server: " + engineName); } activeEngines.add(engineName); this.engineName = engineName; }
if (!config.engineName().equals(expectedEngine.getName())) { throw new TomcatServiceException( "A configurator should never change the name of the default engine.");
/** * {@inhericDoc} * @see java.lang.Object#toString() */ public String toString() { return this.engine.getName(); } }
/** * {@inhericDoc} * @see org.jboss.modcluster.Engine#getName() */ public String getName() { return this.engine.getName(); }
@Override public String toString() { return this.engine.getName(); } }
@Override public String getName() { return this.engine.getName(); }
@Override public String getEngineName() { return this.getEngine().getName(); }
/** * Get config base. */ protected File getConfigBase(String hostName) { File configBase = new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf"); if (!configBase.exists()) { return null; } if (engine != null) { configBase = new File(configBase, engine.getName()); } if (installedHost != null) { configBase = new File(configBase, hostName); } if (!configBase.mkdirs() && !configBase.isDirectory()) { return null; } return configBase; }
/** * Get config base. */ protected File getConfigBase(String hostName) { File configBase = new File(System.getProperty(Globals.CATALINA_BASE_PROP), "conf"); if (!configBase.exists()) { return null; } if (engine != null) { configBase = new File(configBase, engine.getName()); } if (installedHost != null) { configBase = new File(configBase, hostName); } if (!configBase.mkdirs() && !configBase.isDirectory()) { return null; } return configBase; }
/** * Get config base. */ protected File getConfigBase(String hostName) { File configBase = new File(context.getCatalinaBase(), "conf"); if (!configBase.exists()) { return null; } if (engine != null) { configBase = new File(configBase, engine.getName()); } if (installedHost != null) { configBase = new File(configBase, hostName); } if (!configBase.mkdirs() && !configBase.isDirectory()) { return null; } return configBase; } }
/** * Get config base. * @param hostName The host name * @return the config base for the host */ protected File getConfigBase(String hostName) { File configBase = new File(context.getCatalinaBase(), "conf"); if (!configBase.exists()) { return null; } if (engine != null) { configBase = new File(configBase, engine.getName()); } if (installedHost != null) { configBase = new File(configBase, hostName); } if (!configBase.mkdirs() && !configBase.isDirectory()) { return null; } return configBase; } }
/** * Deregister the MBean for this * <code>Engine</code> object. * * @param engine The Engine 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(Engine engine) throws Exception { String domain = engine.getName(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, engine); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
/** * Deregister the MBean for this * <code>Engine</code> object. * * @param engine The Engine to be managed * * @exception Exception if an MBean cannot be deregistered */ static void destroyMBean(Engine engine) throws Exception { String domain = engine.getName(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, engine); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
/** * Deregister the MBean for this * <code>Engine</code> object. * * @param engine The Engine to be managed * * @exception Exception if an MBean cannot be deregistered */ static void destroyMBean(Engine engine) throws Exception { String domain = engine.getName(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, engine); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
/** * Deregister the MBean for this * <code>Engine</code> object. * * @param engine The Engine to be managed * * @exception Exception if an MBean cannot be deregistered */ static void destroyMBean(Engine engine) throws Exception { String domain = engine.getName(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, engine); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
/** * Deregister the MBean for this * <code>Engine</code> object. * * @param engine The Engine 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(Engine engine) throws Exception { String domain = engine.getName(); if (domain == null) domain = mserver.getDefaultDomain(); ObjectName oname = createObjectName(domain, engine); if( mserver.isRegistered(oname) ) mserver.unregisterMBean(oname); }
/** * Render a list of the currently active Contexts in our virtual host. * * @param writer Writer to render to * @param smClient StringManager for the client's locale */ protected void list(PrintWriter writer, StringManager smClient) { if (debug >= 1) { log(sm.getString("hostManagerServlet.list", engine.getName())); } writer.println(smClient.getString("hostManagerServlet.listed", engine.getName())); Container[] hosts = engine.findChildren(); for (int i = 0; i < hosts.length; i++) { Host host = (Host) hosts[i]; String name = host.getName(); String[] aliases = host.findAliases(); writer.println(smClient.getString("hostManagerServlet.listitem", name, StringUtils.join(aliases))); } }
public static void main(String[] args){ Engine eng1 = new Engine("abc"); Car car1 = new Car(); car1.setEngine(eng1); Car car2 = new Car(); car2.setEngine(car1.getEngine()); //additional code to show the last statement car2.getEngine().setName("foo"); System.out.println(car2.getEngine().getName()); //prints "foo" System.out.println(car1.getEngine().getName()); //prints "foo" too System.out.println(eng1.getName()); //prints "foo" since it is the same object reference used from the beginning }
@Test public void getName() { String expected = "name"; when(this.engine.getName()).thenReturn(expected); String result = this.catalinaEngine.getName(); assertSame(expected, result); }