本文整理汇总了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);
}
示例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);
}
示例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()));
}
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
}
}
示例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));
}
}
示例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());
}
示例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
}
}
示例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);
}
示例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();
}
示例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();
}
示例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));
}
}
示例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();
}