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


Java Context.setDocBase方法代碼示例

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


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

示例1: addContext

import org.apache.catalina.Context; //導入方法依賴的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

示例2: addWebapp

import org.apache.catalina.Context; //導入方法依賴的package包/類
/**
 * @see #addWebapp(String, String)
 *
 * @param name Ignored. The contextPath will be used
 *
 * @deprecated Use {@link #addWebapp(Host, String, String)}
 */
@Deprecated
public Context addWebapp(Host host, String contextPath, String name, String docBase) {
    silence(host, contextPath);

    Context ctx = createContext(host, contextPath);
    ctx.setPath(contextPath);
    ctx.setDocBase(docBase);

    ctx.addLifecycleListener(new DefaultWebXmlListener());
    ctx.setConfigFile(getWebappConfigFile(docBase, contextPath));

    ContextConfig ctxCfg = new ContextConfig();
    ctx.addLifecycleListener(ctxCfg);
    
    // prevent it from looking ( if it finds one - it'll have dup error )
    ctxCfg.setDefaultWebXml(noDefaultWebXmlPath());

    if (host == null) {
        getHost().addChild(ctx);
    } else {
        host.addChild(ctx);
    }

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

示例3: reload

import org.apache.catalina.Context; //導入方法依賴的package包/類
private void reload(DeployedApplication app, File fileToRemove, String newDocBase) {
    if(log.isInfoEnabled())
        log.info(sm.getString("hostConfig.reload", app.name));
    Context context = (Context) host.findChild(app.name);
    if (context.getState().isAvailable()) {
        if (fileToRemove != null && newDocBase != null) {
            context.addLifecycleListener(
                    new ExpandedDirectoryRemovalListener(fileToRemove, newDocBase));
        }
        // Reload catches and logs exceptions
        context.reload();
    } else {
        // If the context was not started (for example an error
        // in web.xml) we'll still get to try to start
        if (fileToRemove != null && newDocBase != null) {
            ExpandWar.delete(fileToRemove);
            context.setDocBase(newDocBase);
        }
        try {
            context.start();
        } catch (Exception e) {
            log.warn(sm.getString
                     ("hostConfig.context.restart", app.name), e);
        }
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:27,代碼來源:HostConfig.java

示例4: lifecycleEvent

import org.apache.catalina.Context; //導入方法依賴的package包/類
@Override
public void lifecycleEvent(LifecycleEvent event) {
    if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
        // The context has stopped.
        Context context = (Context) event.getLifecycle();

        // Remove the old expanded WAR.
        ExpandWar.delete(toDelete);

        // Reset the docBase to trigger re-expansion of the WAR.
        context.setDocBase(newDocBase);

        // Remove this listener from the Context else it will run every
        // time the Context is stopped.
        context.removeLifecycleListener(this);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:18,代碼來源:HostConfig.java

示例5: addChild

import org.apache.catalina.Context; //導入方法依賴的package包/類
/**
 * Delegate a request to add a child Context to our associated Host.
 *
 * @param child The child Context to be added
 */
public void addChild(Container child) {

    context = (Context) child;
    String contextPath = context.getPath();
    if (contextPath == null)
        throw new IllegalArgumentException
            (sm.getString("standardHost.pathRequired"));
    else if (!contextPath.equals("") && !contextPath.startsWith("/"))
        throw new IllegalArgumentException
            (sm.getString("standardHost.pathFormat", contextPath));
    if (host.findChild(contextPath) != null)
        throw new IllegalStateException
            (sm.getString("standardHost.pathUsed", contextPath));
    if (this.overrideDocBase != null)
        context.setDocBase(this.overrideDocBase);
    host.fireContainerEvent(PRE_INSTALL_EVENT, context);
    host.addChild(child);
    host.fireContainerEvent(INSTALL_EVENT, context);

}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:26,代碼來源:StandardHostDeployer.java

示例6: reload

import org.apache.catalina.Context; //導入方法依賴的package包/類
private void reload(DeployedApplication app, File fileToRemove, String newDocBase) {
	if (log.isInfoEnabled())
		log.info(sm.getString("hostConfig.reload", app.name));
	Context context = (Context) host.findChild(app.name);
	if (context.getState().isAvailable()) {
		if (fileToRemove != null && newDocBase != null) {
			context.addLifecycleListener(new ExpandedDirectoryRemovalListener(fileToRemove, newDocBase));
		}
		// Reload catches and logs exceptions
		context.reload();
	} else {
		// If the context was not started (for example an error
		// in web.xml) we'll still get to try to start
		if (fileToRemove != null && newDocBase != null) {
			ExpandWar.delete(fileToRemove);
			context.setDocBase(newDocBase);
		}
		try {
			context.start();
		} catch (Exception e) {
			log.warn(sm.getString("hostConfig.context.restart", app.name), e);
		}
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:25,代碼來源:HostConfig.java

示例7: lifecycleEvent

import org.apache.catalina.Context; //導入方法依賴的package包/類
@Override
public void lifecycleEvent(LifecycleEvent event) {
	if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
		// The context has stopped.
		Context context = (Context) event.getLifecycle();

		// Remove the old expanded WAR.
		ExpandWar.delete(toDelete);

		// Reset the docBase to trigger re-expansion of the WAR.
		context.setDocBase(newDocBase);

		// Remove this listener from the Context else it will run every
		// time the Context is stopped.
		context.removeLifecycleListener(this);
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:18,代碼來源:HostConfig.java

示例8: lifecycleEvent

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

    // Identify the context we are associated with
    try {
        context = (Context) event.getLifecycle();
    } catch (ClassCastException e) {
        log.error(sm.getString("contextConfig.cce", event.getLifecycle()), e);
        return;
    }

    // Process the event that has occurred
    if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) {
        configureStart();
    } else if (event.getType().equals(Lifecycle.BEFORE_START_EVENT)) {
        beforeStart();
    } else if (event.getType().equals(Lifecycle.AFTER_START_EVENT)) {
        // Restore docBase for management tools
        if (originalDocBase != null) {
            context.setDocBase(originalDocBase);
        }
    } else if (event.getType().equals(Lifecycle.CONFIGURE_STOP_EVENT)) {
        configureStop();
    } else if (event.getType().equals(Lifecycle.AFTER_INIT_EVENT)) {
        init();
    } else if (event.getType().equals(Lifecycle.AFTER_DESTROY_EVENT)) {
        destroy();
    }

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

示例9: deploy

import org.apache.catalina.Context; //導入方法依賴的package包/類
/**
 * Deploy a web application for the specified user if they have such an
 * application in the defined directory within their home directory.
 *
 * @param user Username owning the application to be deployed
 * @param home Home directory of this user
 */
private void deploy(String user, String home) {

    // Does this user have a web application to be deployed?
    String contextPath = "/~" + user;
    if (host.findChild(contextPath) != null)
        return;
    File app = new File(home, directoryName);
    if (!app.exists() || !app.isDirectory())
        return;
    /*
    File dd = new File(app, "/WEB-INF/web.xml");
    if (!dd.exists() || !dd.isFile() || !dd.canRead())
        return;
    */
    host.getLogger().info(sm.getString("userConfig.deploy", user));

    // Deploy the web application for this user
    try {
        Class<?> clazz = Class.forName(contextClass);
        Context context =
          (Context) clazz.newInstance();
        context.setPath(contextPath);
        context.setDocBase(app.toString());
        clazz = Class.forName(configClass);
        LifecycleListener listener =
            (LifecycleListener) clazz.newInstance();
        context.addLifecycleListener(listener);
        host.addChild(context);
    } catch (Exception e) {
        host.getLogger().error(sm.getString("userConfig.error", user), e);
    }

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

示例10: deploy

import org.apache.catalina.Context; //導入方法依賴的package包/類
/**
 * Deploy a web application for the specified user if they have such an
 * application in the defined directory within their home directory.
 *
 * @param user Username owning the application to be deployed
 * @param home Home directory of this user
 */
private void deploy(String user, String home) {

    // Does this user have a web application to be deployed?
    String contextPath = "/~" + user;
    if (host.findChild(contextPath) != null)
        return;
    File app = new File(home, directoryName);
    if (!app.exists() || !app.isDirectory())
        return;
    /*
    File dd = new File(app, "/WEB-INF/web.xml");
    if (!dd.exists() || !dd.isFile() || !dd.canRead())
        return;
    */
    host.getLogger().info(sm.getString("userConfig.deploy", user));

    // Deploy the web application for this user
    try {
        Class clazz = Class.forName(contextClass);
        Context context =
          (Context) clazz.newInstance();
        context.setPath(contextPath);
        context.setDocBase(app.toString());
        if (context instanceof Lifecycle) {
            clazz = Class.forName(configClass);
            LifecycleListener listener =
              (LifecycleListener) clazz.newInstance();
            ((Lifecycle) context).addLifecycleListener(listener);
        }
        host.addChild(context);
    } catch (Exception e) {
        host.getLogger().error(sm.getString("userConfig.error", user), e);
    }

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

示例11: deploy

import org.apache.catalina.Context; //導入方法依賴的package包/類
/**
 * Deploy a web application for the specified user if they have such an
 * application in the defined directory within their home directory.
 *
 * @param user Username owning the application to be deployed
 * @param home Home directory of this user
 */
private void deploy(String user, String home) {

    // Does this user have a web application to be deployed?
    String contextPath = "/~" + user;
    if (host.findChild(contextPath) != null)
        return;
    File app = new File(home, directoryName);
    if (!app.exists() || !app.isDirectory())
        return;
    /*
    File dd = new File(app, "/WEB-INF/web.xml");
    if (!dd.exists() || !dd.isFile() || !dd.canRead())
        return;
    */
    log(sm.getString("userConfig.deploy", user));

    // Deploy the web application for this user
    try {
        Class clazz = Class.forName(contextClass);
        Context context =
          (Context) clazz.newInstance();
        context.setPath(contextPath);
        context.setDocBase(app.toString());
        if (context instanceof Lifecycle) {
            clazz = Class.forName(configClass);
            LifecycleListener listener =
              (LifecycleListener) clazz.newInstance();
            ((Lifecycle) context).addLifecycleListener(listener);
        }
        host.addChild(context);
    } catch (Exception e) {
        log(sm.getString("userConfig.error", user), e);
    }

}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:43,代碼來源:UserConfig.java

示例12: deploy

import org.apache.catalina.Context; //導入方法依賴的package包/類
/**
 * Deploy a web application for the specified user if they have such an
 * application in the defined directory within their home directory.
 *
 * @param user
 *            Username owning the application to be deployed
 * @param home
 *            Home directory of this user
 */
private void deploy(String user, String home) {

	// Does this user have a web application to be deployed?
	String contextPath = "/~" + user;
	if (host.findChild(contextPath) != null)
		return;
	File app = new File(home, directoryName);
	if (!app.exists() || !app.isDirectory())
		return;
	/*
	 * File dd = new File(app, "/WEB-INF/web.xml"); if (!dd.exists() ||
	 * !dd.isFile() || !dd.canRead()) return;
	 */
	host.getLogger().info(sm.getString("userConfig.deploy", user));

	// Deploy the web application for this user
	try {
		Class<?> clazz = Class.forName(contextClass);
		Context context = (Context) clazz.newInstance();
		context.setPath(contextPath);
		context.setDocBase(app.toString());
		clazz = Class.forName(configClass);
		LifecycleListener listener = (LifecycleListener) clazz.newInstance();
		context.addLifecycleListener(listener);
		host.addChild(context);
	} catch (Exception e) {
		host.getLogger().error(sm.getString("userConfig.error", user), e);
	}

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

示例13: testBug57190

import org.apache.catalina.Context; //導入方法依賴的package包/類
@Test
public void testBug57190() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    Context foo1 = new StandardContext();
    foo1.setName("/foo##1");
    foo1.setPath("/foo");
    foo1.setWebappVersion("1");
    foo1.setDocBase(System.getProperty("java.io.tmpdir"));
    foo1.addLifecycleListener(new FixContextListener());
    foo1.addLifecycleListener(new SetIdListener("foo1"));
    tomcat.getHost().addChild(foo1);

    Context foo2 = new StandardContext();
    foo2.setName("/foo##2");
    foo2.setPath("/foo");
    foo2.setWebappVersion("2");
    foo2.setDocBase(System.getProperty("java.io.tmpdir"));
    foo2.addLifecycleListener(new FixContextListener());
    foo2.addLifecycleListener(new SetIdListener("foo2"));
    tomcat.getHost().addChild(foo2);

    // No file system docBase required
    Context bar = tomcat.addContext("/bar", null);
    bar.addLifecycleListener(new SetIdListener("bar"));

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);
    ctx.addLifecycleListener(new SetIdListener("ROOT"));
    ctx.setCrossContext(true);

    Tomcat.addServlet(ctx, "Bug57190Servlet", new Bug57190Servlet());
    ctx.addServletMapping("/", "Bug57190Servlet");

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() + "/");
    String body = res.toString();

    Assert.assertTrue(body, body.contains("01-bar"));
    Assert.assertTrue(body, body.contains("02-foo2"));
    Assert.assertTrue(body, body.contains("03-foo1"));
    Assert.assertTrue(body, body.contains("04-foo2"));
    Assert.assertTrue(body, body.contains("05-foo2"));
    Assert.assertTrue(body, body.contains("06-ROOT"));
    Assert.assertTrue(body, body.contains("07-ROOT"));
    Assert.assertTrue(body, body.contains("08-foo2"));
    Assert.assertTrue(body, body.contains("09-ROOT"));
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:50,代碼來源:TestApplicationContext.java


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