當前位置: 首頁>>代碼示例>>Java>>正文


Java Host類代碼示例

本文整理匯總了Java中org.apache.catalina.Host的典型用法代碼示例。如果您正苦於以下問題:Java Host類的具體用法?Java Host怎麽用?Java Host使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Host類屬於org.apache.catalina包,在下文中一共展示了Host類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: invoke

import org.apache.catalina.Host; //導入依賴的package包/類
/**
 * Select the appropriate child Host to process this request,
 * based on the requested server name.  If no matching Host can
 * be found, return an appropriate HTTP error.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 *
 * @exception IOException if an input/output error occurred
 * @exception ServletException if a servlet error occurred
 */
@Override
public final void invoke(Request request, Response response)
    throws IOException, ServletException {

    // Select the Host to be used for this Request
    Host host = request.getHost();
    if (host == null) {
        response.sendError
            (HttpServletResponse.SC_BAD_REQUEST,
             sm.getString("standardEngine.noHost", 
                          request.getServerName()));
        return;
    }
    if (request.isAsyncSupported()) {
        request.setAsyncSupported(host.getPipeline().isAsyncSupported());
    }

    // Ask this Host to process this request
    host.getPipeline().getFirst().invoke(request, response);

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:33,代碼來源:StandardEngineValve.java

示例2: invoke

import org.apache.catalina.Host; //導入依賴的package包/類
/**
 * Select the appropriate child Host to process this request,
 * based on the requested server name.  If no matching Host can
 * be found, return an appropriate HTTP error.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 * @param valveContext Valve context used to forward to the next Valve
 *
 * @exception IOException if an input/output error occurred
 * @exception ServletException if a servlet error occurred
 */
public final void invoke(Request request, Response response)
    throws IOException, ServletException {

    // Select the Host to be used for this Request
    Host host = request.getHost();
    if (host == null) {
        response.sendError
            (HttpServletResponse.SC_BAD_REQUEST,
             sm.getString("standardEngine.noHost", 
                          request.getServerName()));
        return;
    }

    // Ask this Host to process this request
    host.getPipeline().getFirst().invoke(request, response);

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:StandardEngineValve.java

示例3: list

import org.apache.catalina.Host; //導入依賴的package包/類
/**
 * Render a list of the currently active Contexts in our virtual host.
 *
 * @param writer Writer to render to
 */
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();
        StringBuilder buf = new StringBuilder();
        if (aliases.length > 0) {
            buf.append(aliases[0]);
            for (int j = 1; j < aliases.length; j++) {
                buf.append(',').append(aliases[j]);
            }
        }
        writer.println(smClient.getString("hostManagerServlet.listitem",
                                    name, buf.toString()));
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:30,代碼來源:HostManagerServlet.java

示例4: addContext

import org.apache.catalina.Host; //導入依賴的package包/類
public Context addContext(Host host, String contextPath, String contextName,
        String dir) {
    silence(host, contextName);
    Context ctx = createContext(host, contextPath);
    ctx.setName(contextName);
    ctx.setPath(contextPath);
    ctx.setDocBase(dir);
    ctx.addLifecycleListener(new FixContextListener());
    
    if (host == null) {
        getHost().addChild(ctx);
    } else {
        host.addChild(ctx);
    }
    return ctx;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:17,代碼來源:Tomcat.java

示例5: getLoggerName

import org.apache.catalina.Host; //導入依賴的package包/類
private String getLoggerName(Host host, String contextName) {
    if (host == null) {
        host = getHost();
    }
    StringBuilder loggerName = new StringBuilder();
    loggerName.append(ContainerBase.class.getName());
    loggerName.append(".[");
    // Engine name
    loggerName.append(host.getParent().getName());
    loggerName.append("].[");
    // Host name
    loggerName.append(host.getName());
    loggerName.append("].[");
    // Context name
    if (contextName == null || contextName.equals("")) {
        loggerName.append("/");
    } else if (contextName.startsWith("##")) {
        loggerName.append("/");
        loggerName.append(contextName);
    }
    loggerName.append(']');

    return loggerName.toString();
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:25,代碼來源:Tomcat.java

示例6: lifecycleEvent

import org.apache.catalina.Host; //導入依賴的package包/類
/**
 * Process the START event for an associated Host.
 *
 * @param event The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("hostConfig.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();

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:24,代碼來源:UserConfig.java

示例7: startInternal

import org.apache.catalina.Host; //導入依賴的package包/類
@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);
        }
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:23,代碼來源:MapperListener.java

示例8: registerHost

import org.apache.catalina.Host; //導入依賴的package包/類
/**
 * Register host.
 */
private void registerHost(Host host) {

    String[] aliases = host.findAliases();
    mapper.addHost(host.getName(), aliases, host);

    for (Container container : host.findChildren()) {
        if (container.getState().isAvailable()) {
            registerContext((Context) container);
        }
    }
    if(log.isDebugEnabled()) {
        log.debug(sm.getString("mapperListener.registerHost",
                host.getName(), domain, connector));
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:19,代碼來源:MapperListener.java

示例9: testGetCustomContextPerAddWebappWithHost

import org.apache.catalina.Host; //導入依賴的package包/類
@Test
public void testGetCustomContextPerAddWebappWithHost() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass(ReplicatedContext.class
                .getName());
    }

    File appFile = new File("test/deployment/context.war");
    Context context = tomcat.addWebapp(host, "/test",
            appFile.getAbsolutePath());

    assertEquals(ReplicatedContext.class.getName(), context.getClass()
            .getName());
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:17,代碼來源:TestTomcat.java

示例10: testGetBrokenContextPerAddContext

import org.apache.catalina.Host; //導入依賴的package包/類
@Test
public void testGetBrokenContextPerAddContext() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass("InvalidContextClassName");
    }

    // No file system docBase required
    try {
        tomcat.addContext(null, "", null);
        fail();
    } catch (IllegalArgumentException e) {
        // OK
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:17,代碼來源:TestTomcat.java

示例11: getConfigBaseFile

import org.apache.catalina.Host; //導入依賴的package包/類
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);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:19,代碼來源:TestHostConfigAutomaticDeployment.java

示例12: getHostConfigPath

import org.apache.catalina.Host; //導入依賴的package包/類
protected String getHostConfigPath(String resourceName) {
    StringBuffer result = new StringBuffer();
    Container container = context;
    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();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:ContextConfig.java

示例13: lifecycleEvent

import org.apache.catalina.Host; //導入依賴的package包/類
/**
 * Process the START event for an associated Host.
 *
 * @param event The lifecycle event that has occurred
 */
public void lifecycleEvent(LifecycleEvent event) {

    // Identify the host we are associated with
    try {
        host = (Host) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("hostConfig.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();

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:UserConfig.java

示例14: registerHost

import org.apache.catalina.Host; //導入依賴的package包/類
/**
 * Register host.
 */
private void registerHost(ObjectName objectName)
    throws Exception {
    String name=objectName.getKeyProperty("host");
    if( name != null ) {        
        Host host = (Host) ServerFactory.getServer().findService(
                domain).getContainer().findChild(name);
        String[] aliases = host.findAliases();
        mapper.addHost(name, aliases, objectName);
        host.addContainerListener(this);
        if(log.isDebugEnabled())
            log.debug(sm.getString
                 ("mapperListener.registerHost", name, domain));

    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:MapperListener.java

示例15: lifecycleEvent

import org.apache.catalina.Host; //導入依賴的package包/類
/**
 * Process the START event for an associated Host.
 *
 * @param event
 *            The lifecycle event that has occurred
 */
@Override
public void lifecycleEvent(LifecycleEvent event) {

	// Identify the host we are associated with
	try {
		host = (Host) event.getLifecycle();
	} catch (ClassCastException e) {
		log.error(sm.getString("hostConfig.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();

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:25,代碼來源:UserConfig.java


注:本文中的org.apache.catalina.Host類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。