Java Code Examples for org.apache.catalina.Container#getParent()
The following examples show how to use
org.apache.catalina.Container#getParent() .
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: 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 2
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 3
Source File: TomcatWebAppBuilder.java From tomee with Apache License 2.0 | 6 votes |
private static boolean undeploy(final StandardContext standardContext, final ContextInfo contextInfo) { if (isReady(contextInfo.deployer)) { contextInfo.deployer.unmanageApp(standardContext.getName()); return true; } else if (contextInfo.host != null) { return undeploy(standardContext, contextInfo.host); } else { Container container = contextInfo.standardContext; while (container != null) { if (container instanceof Host) { break; } container = container.getParent(); } return container != null && undeploy(standardContext, container); } }
Example 4
Source File: ContainerBase.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Return the abbreviated name of this container for logging messages */ protected String logName() { if (logName != null) { return logName; } String loggerName = null; Container current = this; while (current != null) { String name = current.getName(); if ((name == null) || (name.equals(""))) { name = "/"; } else if (name.startsWith("##")) { name = "/" + name; } loggerName = "[" + name + "]" + ((loggerName != null) ? ("." + loggerName) : ""); current = current.getParent(); } logName = ContainerBase.class.getName() + "." + loggerName; return logName; }
Example 5
Source File: JDBCStore.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * @return the name for this instance (built from container name) */ public String getName() { if (name == null) { Container container = manager.getContainer(); String contextName = container.getName(); if (!contextName.startsWith("/")) { contextName = "/" + contextName; } String hostName = ""; String engineName = ""; if (container.getParent() != null) { Container host = container.getParent(); hostName = host.getName(); if (host.getParent() != null) { engineName = host.getParent().getName(); } } name = "/" + engineName + "/" + hostName + contextName; } return name; }
Example 6
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 7
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 8
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 9
Source File: MBeanUtils.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Determine the name of the domain to register MBeans for from a given * Container. * * @param container * * @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 getDomain(Container container) { String domain = null; Container c = container; while (!(c instanceof Engine) && c != null) { c = c.getParent(); } if (c != null) { domain = c.getName(); } return domain; }
Example 10
Source File: Request.java From Tomcat8-Source-Read with MIT License | 6 votes |
private Set<String> getNonAsyncClassNames() { Set<String> result = new HashSet<>(); Wrapper wrapper = getWrapper(); if (!wrapper.isAsyncSupported()) { result.add(wrapper.getServletClass()); } FilterChain filterChain = getFilterChain(); if (filterChain instanceof ApplicationFilterChain) { ((ApplicationFilterChain) filterChain).findNonAsyncFilters(result); } else { result.add(sm.getString("coyoteRequest.filterAsyncSupportUnknown")); } Container c = wrapper; while (c != null) { c.getPipeline().findNonAsyncValves(result); c = c.getParent(); } return result; }
Example 11
Source File: JDBCStore.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * @return the name for this instance (built from container name) */ public String getName() { if (name == null) { Container container = manager.getContainer(); String contextName = container.getName(); if (!contextName.startsWith("/")) { contextName = "/" + contextName; } String hostName = ""; String engineName = ""; if (container.getParent() != null) { Container host = container.getParent(); hostName = host.getName(); if (host.getParent() != null) { engineName = host.getParent().getName(); } } name = "/" + engineName + "/" + hostName + contextName; } return name; }
Example 12
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 13
Source File: ApplicationContext.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public String getVirtualServerName() { // Constructor will fail if context or its parent is null Container host = context.getParent(); Container engine = host.getParent(); return engine.getName() + "/" + host.getName(); }
Example 14
Source File: WebappClassLoaderBase.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public String getServiceName() { if (resources != null) { Container host = resources.getContext().getParent(); if (host != null) { Container engine = host.getParent(); if (engine != null) { return engine.getName(); } } } return null; }
Example 15
Source File: AuthenticatorBase.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 { // Look up the SingleSignOn implementation in our request processing // path, if there is one Container parent = context.getParent(); while ((sso == null) && (parent != null)) { Valve valves[] = parent.getPipeline().getValves(); for (int i = 0; i < valves.length; i++) { if (valves[i] instanceof SingleSignOn) { sso = (SingleSignOn) valves[i]; break; } } if (sso == null) parent = parent.getParent(); } if (log.isDebugEnabled()) { if (sso != null) log.debug("Found SingleSignOn Valve at " + sso); else log.debug("No SingleSignOn Valve is present"); } sessionIdGenerator = new StandardSessionIdGenerator(); sessionIdGenerator.setSecureRandomAlgorithm(getSecureRandomAlgorithm()); sessionIdGenerator.setSecureRandomClass(getSecureRandomClass()); sessionIdGenerator.setSecureRandomProvider(getSecureRandomProvider()); super.startInternal(); }
Example 16
Source File: SFContextServlet.java From sailfish-core with Apache License 2.0 | 5 votes |
private int determineTomcatHttpPort(ServletContext ctx) { try { Object o = FieldUtils.readField(ctx, "context", true); StandardContext sCtx = (StandardContext) FieldUtils.readField(o, "context", true); Container container = (Container) sCtx; Container c = container.getParent(); while (c != null && !(c instanceof StandardEngine)) { c = c.getParent(); } if (c != null) { StandardEngine engine = (StandardEngine) c; for (Connector connector : engine.getService().findConnectors()) { if(connector.getProtocol().startsWith("HTTP")) { return connector.getPort(); } } } } catch (Exception e) { logger.error("Could not determine http port", e); } return 0; }
Example 17
Source File: SingleSignOn.java From tomcatsrc 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 18
Source File: MBeanUtils.java From tomcatsrc 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 19
Source File: AuthenticatorBase.java From Tomcat7.0.67 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 { // Look up the SingleSignOn implementation in our request processing // path, if there is one Container parent = context.getParent(); while ((sso == null) && (parent != null)) { Valve valves[] = parent.getPipeline().getValves(); for (int i = 0; i < valves.length; i++) { if (valves[i] instanceof SingleSignOn) { sso = (SingleSignOn) valves[i]; break; } } if (sso == null) parent = parent.getParent(); } if (log.isDebugEnabled()) { if (sso != null) log.debug("Found SingleSignOn Valve at " + sso); else log.debug("No SingleSignOn Valve is present"); } sessionIdGenerator = new StandardSessionIdGenerator(); sessionIdGenerator.setSecureRandomAlgorithm(getSecureRandomAlgorithm()); sessionIdGenerator.setSecureRandomClass(getSecureRandomClass()); sessionIdGenerator.setSecureRandomProvider(getSecureRandomProvider()); super.startInternal(); }
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(); }