org.apache.catalina.Engine Java Examples
The following examples show how to use
org.apache.catalina.Engine.
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: MapperListener.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public void startInternal() throws LifecycleException { setState(LifecycleState.STARTING); // Find any components that have already been initialized since the // MBean listener won't be notified as those components will have // already registered their MBeans findDefaultHost(); Engine engine = (Engine) connector.getService().getContainer(); addListeners(engine); Container[] conHosts = engine.findChildren(); for (Container conHost : conHosts) { Host host = (Host) conHost; if (!LifecycleState.NEW.equals(host.getState())) { // Registering the host will register the context and wrappers registerHost(host); } } }
Example #2
Source File: ContextConfig.java From Tomcat8-Source-Read with MIT License | 6 votes |
private Server getServer() { Container c = context; while (c != null && !(c instanceof Engine)) { c = c.getParent(); } if (c == null) { return null; } Service s = ((Engine)c).getService(); if (s == null) { return null; } return s.getServer(); }
Example #3
Source File: EngineConfig.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Process the START event for an associated Engine. * * @param event The lifecycle event that has occurred */ @Override public void lifecycleEvent(LifecycleEvent event) { // Identify the engine we are associated with try { engine = (Engine) event.getLifecycle(); } catch (ClassCastException e) { log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e); return; } // Process the event that has occurred if (event.getType().equals(Lifecycle.START_EVENT)) start(); else if (event.getType().equals(Lifecycle.STOP_EVENT)) stop(); }
Example #4
Source File: RewriteValve.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Find the configuration path where the rewrite configuration file * will be stored. * @param resourceName The rewrite configuration file name * @return the full rewrite configuration path */ protected String getHostConfigPath(String resourceName) { StringBuffer result = new StringBuffer(); Container container = getContainer(); Container host = null; Container engine = null; while (container != null) { if (container instanceof Host) host = container; if (container instanceof Engine) engine = container; container = container.getParent(); } if (engine != null) { result.append(engine.getName()).append('/'); } if (host != null) { result.append(host.getName()).append('/'); } result.append(resourceName); return result.toString(); }
Example #5
Source File: RealmBase.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Return the Server object that is the ultimate parent for the container * with which this Realm is associated. If the server cannot be found (eg * because the container hierarchy is not complete), <code>null</code> is * returned. * @return the Server associated with the realm */ protected Server getServer() { Container c = container; if (c instanceof Context) { c = c.getParent(); } if (c instanceof Host) { c = c.getParent(); } if (c instanceof Engine) { Service s = ((Engine)c).getService(); if (s != null) { return s.getServer(); } } return null; }
Example #6
Source File: Embedded.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Add a new Engine to the set of defined Engines. * * @param engine The engine to be added */ public synchronized void addEngine(Engine engine) { if( log.isDebugEnabled() ) log.debug("Adding engine (" + engine.getInfo() + ")"); // Add this Engine to our set of defined Engines Engine results[] = new Engine[engines.length + 1]; for (int i = 0; i < engines.length; i++) results[i] = engines[i]; results[engines.length] = engine; engines = results; // Start this Engine if necessary if (getState().isAvailable()) { try { engine.start(); } catch (LifecycleException e) { log.error("Engine.start", e); } } this.container = engine; }
Example #7
Source File: HostConfig.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Return a File object representing the "configuration root" directory * for our associated Host. */ protected File configBase() { if (configBase != null) { return configBase; } if (host.getXmlBase()!=null) { configBase = returnCanonicalPath(host.getXmlBase()); } else { StringBuilder xmlDir = new StringBuilder("conf"); Container parent = host.getParent(); if (parent instanceof Engine) { xmlDir.append('/'); xmlDir.append(parent.getName()); } xmlDir.append('/'); xmlDir.append(host.getName()); configBase = returnCanonicalPath(xmlDir.toString()); } return (configBase); }
Example #8
Source File: ContextConfig.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
private Server getServer() { Container c = context; while (c != null && !(c instanceof Engine)) { c = c.getParent(); } if (c == null) { return null; } Service s = ((Engine)c).getService(); if (s == null) { return null; } return s.getServer(); }
Example #9
Source File: RealmBase.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Return the Server object that is the ultimate parent for the container * with which this Realm is associated. If the server cannot be found (eg * because the container hierarchy is not complete), <code>null</code> is * returned. */ protected Server getServer() { Container c = container; if (c instanceof Context) { c = c.getParent(); } if (c instanceof Host) { c = c.getParent(); } if (c instanceof Engine) { Service s = ((Engine)c).getService(); if (s != null) { return s.getServer(); } } return null; }
Example #10
Source File: SimpleTcpCluster.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * @param name * @param manager * @return TODO */ @Override public String getManagerName(String name, Manager manager) { String clusterName = name ; if ( clusterName == null ) clusterName = manager.getContainer().getName(); if(getContainer() instanceof Engine) { Container context = manager.getContainer() ; if(context != null && context instanceof Context) { Container host = ((Context)context).getParent(); if(host != null && host instanceof Host && clusterName!=null && !(clusterName.startsWith(host.getName() +"#"))) { clusterName = host.getName() +"#" + clusterName ; } } } return clusterName; }
Example #11
Source File: EngineConfig.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Process the START event for an associated Engine. * * @param event The lifecycle event that has occurred */ @Override public void lifecycleEvent(LifecycleEvent event) { // Identify the engine we are associated with try { engine = (Engine) event.getLifecycle(); } catch (ClassCastException e) { log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e); return; } // Process the event that has occurred if (event.getType().equals(Lifecycle.START_EVENT)) start(); else if (event.getType().equals(Lifecycle.STOP_EVENT)) stop(); }
Example #12
Source File: Embedded.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Add a new Engine to the set of defined Engines. * * @param engine The engine to be added */ public synchronized void addEngine(Engine engine) { if( log.isDebugEnabled() ) log.debug("Adding engine (" + engine.getInfo() + ")"); // Add this Engine to our set of defined Engines Engine results[] = new Engine[engines.length + 1]; for (int i = 0; i < engines.length; i++) results[i] = engines[i]; results[engines.length] = engine; engines = results; // Start this Engine if necessary if (getState().isAvailable()) { try { engine.start(); } catch (LifecycleException e) { log.error("Engine.start", e); } } this.container = engine; }
Example #13
Source File: ApplicationContext.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
private void populateSessionTrackingModes() { // URL re-writing is always enabled by default defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL); supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL); if (context.getCookies()) { defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE); supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE); } // SSL not enabled by default as it can only used on its own // Context > Host > Engine > Service Service s = ((Engine) context.getParent().getParent()).getService(); Connector[] connectors = s.findConnectors(); // Need at least one SSL enabled connector to use the SSL session ID. for (Connector connector : connectors) { if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) { supportedSessionTrackingModes.add(SessionTrackingMode.SSL); break; } } }
Example #14
Source File: TestHostConfigAutomaticDeployment.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
private static File getConfigBaseFile(Host host) { String path = null; if (host.getXmlBase() != null) { path = host.getXmlBase(); } else { StringBuilder xmlDir = new StringBuilder("conf"); Container parent = host.getParent(); if (parent instanceof Engine) { xmlDir.append('/'); xmlDir.append(parent.getName()); } xmlDir.append('/'); xmlDir.append(host.getName()); path = xmlDir.toString(); } return getCanonicalPath(path); }
Example #15
Source File: RealmBase.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Return the Server object that is the ultimate parent for the container * with which this Realm is associated. If the server cannot be found (eg * because the container hierarchy is not complete), <code>null</code> is * returned. */ protected Server getServer() { Container c = container; if (c instanceof Context) { c = c.getParent(); } if (c instanceof Host) { c = c.getParent(); } if (c instanceof Engine) { Service s = ((Engine)c).getService(); if (s != null) { return s.getServer(); } } return null; }
Example #16
Source File: EngineConfig.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Process the START event for an associated Engine. * * @param event The lifecycle event that has occurred */ @Override public void lifecycleEvent(LifecycleEvent event) { // Identify the engine we are associated with try { engine = (Engine) event.getLifecycle(); } catch (ClassCastException e) { log.error(sm.getString("engineConfig.cce", event.getLifecycle()), e); return; } // Process the event that has occurred if (event.getType().equals(Lifecycle.START_EVENT)) start(); else if (event.getType().equals(Lifecycle.STOP_EVENT)) stop(); }
Example #17
Source File: DeltaManager.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { super.startInternal(); // Load unloaded sessions, if any try { if (cluster == null) { log.error(sm.getString("deltaManager.noCluster", getName())); return; } else { if (log.isInfoEnabled()) { String type = "unknown" ; if( cluster.getContainer() instanceof Host){ type = "Host" ; } else if( cluster.getContainer() instanceof Engine){ type = "Engine" ; } log.info(sm.getString("deltaManager.registerCluster", getName(), type, cluster.getClusterName())); } } if (log.isInfoEnabled()) log.info(sm.getString("deltaManager.startClustering", getName())); getAllClusterSessions(); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); log.error(sm.getString("deltaManager.managerLoad"), t); } setState(LifecycleState.STARTING); }
Example #18
Source File: ServingLayer.java From oryx with Apache License 2.0 | 5 votes |
private void configureEngine(Engine engine) { if (userName != null && password != null) { InMemoryRealm realm = new InMemoryRealm(); realm.addUser(userName, password); engine.setRealm(realm); } }
Example #19
Source File: PersistentValve.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void setContainer(Container container) { super.setContainer(container); if (container instanceof Engine || container instanceof Host) { clBindRequired = true; } else { clBindRequired = false; } }
Example #20
Source File: SingleSignOn.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override protected synchronized void startInternal() throws LifecycleException { Container c = getContainer(); while (c != null && !(c instanceof Engine)) { c = c.getParent(); } if (c instanceof Engine) { engine = (Engine) c; } super.startInternal(); }
Example #21
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Calculate the key properties string to be added to an object's * {@link ObjectName} to indicate that it is associated with that container. * * @param container The container the object is associated with * @return A string suitable for appending to the ObjectName * @deprecated To be removed since to creates a circular dependency. Will * be replaced in Tomcat 8 by a new method on {@link * Container}. */ @Deprecated public static String getContainerKeyProperties(Container container) { Container c = container; StringBuilder keyProperties = new StringBuilder(); int containerCount = 0; // Work up container hierarchy, add a component to the name for // each container while (!(c instanceof Engine)) { if (c instanceof Wrapper) { keyProperties.append(",servlet="); keyProperties.append(c.getName()); } else if (c instanceof Context) { keyProperties.append(",context="); ContextName cn = new ContextName(c.getName(), false); keyProperties.append(cn.getDisplayName()); } else if (c instanceof Host) { keyProperties.append(",host="); keyProperties.append(c.getName()); } else if (c == null) { // May happen in unit testing and/or some embedding scenarios keyProperties.append(",container"); keyProperties.append(containerCount++); keyProperties.append("=null"); break; } else { // Should never happen... keyProperties.append(",container"); keyProperties.append(containerCount++); keyProperties.append('='); keyProperties.append(c.getName()); } c = c.getParent(); } return keyProperties.toString(); }
Example #22
Source File: PersistentValve.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void setContainer(Container container) { super.setContainer(container); if (container instanceof Engine || container instanceof Host) { clBindRequired = true; } else { clBindRequired = false; } }
Example #23
Source File: MBeanUtils.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * 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); }
Example #24
Source File: TomcatWsRegistry.java From tomee with Apache License 2.0 | 5 votes |
public TomcatWsRegistry() { final StandardServer standardServer = TomcatHelper.getServer(); for (final Service service : standardServer.findServices()) { if (service.getContainer() instanceof Engine) { connectors = Arrays.asList(service.findConnectors()); engine = (Engine) service.getContainer(); break; } } }
Example #25
Source File: TomcatRsRegistry.java From tomee with Apache License 2.0 | 5 votes |
public TomcatRsRegistry() { for (final Service service : TomcatHelper.getServer().findServices()) { if (service.getContainer() instanceof Engine) { connectors = Arrays.asList(service.findConnectors()); break; } } hosts = SystemInstance.get().getComponent(Hosts.class); }
Example #26
Source File: MBeanFactory.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Create a new StandardHost. * * @param parent MBean Name of the associated parent component * @param name Unique name of this Host * @param appBase Application base directory name * @param autoDeploy Should we auto deploy? * @param deployOnStartup Deploy on server startup? * @param deployXML Should we deploy Context XML config files property? * @param unpackWARs Should we unpack WARs when auto deploying? * * @exception Exception if an MBean cannot be created or registered */ public String createStandardHost(String parent, String name, String appBase, boolean autoDeploy, boolean deployOnStartup, boolean deployXML, boolean unpackWARs) throws Exception { // Create a new StandardHost instance StandardHost host = new StandardHost(); host.setName(name); host.setAppBase(appBase); host.setAutoDeploy(autoDeploy); host.setDeployOnStartup(deployOnStartup); host.setDeployXML(deployXML); host.setUnpackWARs(unpackWARs); // add HostConfig for active reloading HostConfig hostConfig = new HostConfig(); host.addLifecycleListener(hostConfig); // Add the new instance to its parent component ObjectName pname = new ObjectName(parent); Service service = getService(pname); Engine engine = (Engine) service.getContainer(); engine.addChild(host); // Return the corresponding MBean name return (host.getObjectName().toString()); }
Example #27
Source File: MapperListener.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private void findDefaultHost() { Engine engine = (Engine) connector.getService().getContainer(); String defaultHost = engine.getDefaultHost(); boolean found = false; if (defaultHost != null && defaultHost.length() >0) { Container[] containers = engine.findChildren(); for (Container container : containers) { Host host = (Host) container; if (defaultHost.equalsIgnoreCase(host.getName())) { found = true; break; } String[] aliases = host.findAliases(); for (String alias : aliases) { if (defaultHost.equalsIgnoreCase(alias)) { found = true; break; } } } } if(found) { mapper.setDefaultHostName(defaultHost); } else { log.warn(sm.getString("mapperListener.unknownDefaultHost", defaultHost, connector)); } }
Example #28
Source File: NamingResources.java From tomcatsrc with Apache License 2.0 | 5 votes |
private Server getServer() { if (container instanceof Server) { return (Server) container; } if (container instanceof Context) { // Could do this in one go. Lots of casts so split out for clarity Engine engine = (Engine) ((Context) container).getParent().getParent(); return engine.getService().getServer(); } return null; }
Example #29
Source File: FailedContext.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public String getMBeanKeyProperties() { Container c = this; StringBuilder keyProperties = new StringBuilder(); int containerCount = 0; // Work up container hierarchy, add a component to the name for // each container while (!(c instanceof Engine)) { if (c instanceof Context) { keyProperties.append(",context="); ContextName cn = new ContextName(c.getName(), false); keyProperties.append(cn.getDisplayName()); } else if (c instanceof Host) { keyProperties.append(",host="); keyProperties.append(c.getName()); } else if (c == null) { // May happen in unit testing and/or some embedding scenarios keyProperties.append(",container"); keyProperties.append(containerCount++); keyProperties.append("=null"); break; } else { // Should never happen... keyProperties.append(",container"); keyProperties.append(containerCount++); keyProperties.append('='); keyProperties.append(c.getName()); } c = c.getParent(); } return keyProperties.toString(); }
Example #30
Source File: NamingResources.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
private Server getServer() { if (container instanceof Server) { return (Server) container; } if (container instanceof Context) { // Could do this in one go. Lots of casts so split out for clarity Engine engine = (Engine) ((Context) container).getParent().getParent(); return engine.getService().getServer(); } return null; }