当前位置: 首页>>代码示例>>Java>>正文


Java AprLifecycleListener类代码示例

本文整理汇总了Java中org.apache.catalina.core.AprLifecycleListener的典型用法代码示例。如果您正苦于以下问题:Java AprLifecycleListener类的具体用法?Java AprLifecycleListener怎么用?Java AprLifecycleListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AprLifecycleListener类属于org.apache.catalina.core包,在下文中一共展示了AprLifecycleListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setProtocol

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
/**
 * Set the Coyote protocol which will be used by the connector.
 *
 * @param protocol
 *            The Coyote protocol name
 */
public void setProtocol(String protocol) {

	if (AprLifecycleListener.isAprAvailable()) {
		if ("HTTP/1.1".equals(protocol)) {
			setProtocolHandlerClassName("org.apache.coyote.http11.Http11AprProtocol");
		} else if ("AJP/1.3".equals(protocol)) {
			setProtocolHandlerClassName("org.apache.coyote.ajp.AjpAprProtocol");
		} else if (protocol != null) {
			setProtocolHandlerClassName(protocol);
		} else {
			setProtocolHandlerClassName("org.apache.coyote.http11.Http11AprProtocol");
		}
	} else {
		if ("HTTP/1.1".equals(protocol)) {
			setProtocolHandlerClassName("org.apache.coyote.http11.Http11Protocol");
		} else if ("AJP/1.3".equals(protocol)) {
			setProtocolHandlerClassName("org.apache.coyote.ajp.AjpProtocol");
		} else if (protocol != null) {
			setProtocolHandlerClassName(protocol);
		}
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:30,代码来源:Connector.java

示例2: createTomcat

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
private static Tomcat createTomcat(int port, String contextPath, String docBase) throws ServletException {
    String tmpDir = System.getProperty("java.io.tmpdir");
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir(tmpDir);
    tomcat.getHost().setAppBase(tmpDir);
    tomcat.getHost().setAutoDeploy(false);
    tomcat.getEngine().setBackgroundProcessorDelay(-1);
    tomcat.setConnector(newNioConnector());
    tomcat.getConnector().setPort(port);
    tomcat.getService().addConnector(tomcat.getConnector());
    Context context = tomcat.addWebapp(contextPath, docBase);
    StandardServer server = (StandardServer) tomcat.getServer();
    server.addLifecycleListener(new AprLifecycleListener());
    server.addLifecycleListener(new JreMemoryLeakPreventionListener());
    return tomcat;
}
 
开发者ID:kevinKaiF,项目名称:cango,代码行数:17,代码来源:TomcatBootstrap.java

示例3: startTomcat

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
private void startTomcat() throws Exception {
  tomcat = new Tomcat();
  tomcat.setPort(8080);

  File tomcatBaseDir = new File("target/tomcat");
  tomcatBaseDir.mkdirs();
  tomcat.setBaseDir(tomcatBaseDir.getAbsolutePath());

  StandardServer server = (StandardServer) tomcat.getServer();
  server.addLifecycleListener(new AprLifecycleListener());

  String contextPath = "/logging-webapp";
  File warFile = new File("target/wars/logging-webapp.war");
  tomcat.addWebapp(contextPath, warFile.getAbsolutePath());
  tomcat.start();
}
 
开发者ID:kite-sdk,项目名称:kite-examples-integration-tests,代码行数:17,代码来源:ITLoggingWebapp.java

示例4: startTomcat

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
private void startTomcat() throws Exception {
  tomcat = new Tomcat();
  tomcat.setPort(8080);

  File tomcatBaseDir = new File("target/tomcat");
  tomcatBaseDir.mkdirs();
  tomcat.setBaseDir(tomcatBaseDir.getAbsolutePath());

  StandardServer server = (StandardServer) tomcat.getServer();
  server.addLifecycleListener(new AprLifecycleListener());

  String contextPath = "/logging-webapp";
  File[] warFiles = new File("target").listFiles(new FileFilter() {
    @Override
    public boolean accept(File pathname) {
      return pathname.getName().endsWith(".war");
    }
  });
  assertEquals("Not exactly one war file found", 1, warFiles.length);
  tomcat.addWebapp(contextPath, warFiles[0].getAbsolutePath());
  tomcat.start();
}
 
开发者ID:kite-sdk,项目名称:kite-examples,代码行数:23,代码来源:ITLoggingWebapp.java

示例5: startTomcat

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
private void startTomcat() throws Exception {
  String appBase = "target/wars/logging-webapp.war";
  tomcat = new Tomcat();
  tomcat.setPort(8080);

  tomcat.setBaseDir(".");
  tomcat.getHost().setAppBase(".");

  String contextPath = "/logging-webapp";

  StandardServer server = (StandardServer) tomcat.getServer();
  server.addLifecycleListener(new AprLifecycleListener());

  tomcat.addWebapp(contextPath, appBase);
  tomcat.start();
}
 
开发者ID:cloudera,项目名称:cdk-examples-integration-tests,代码行数:17,代码来源:ITLoggingWebapp.java

示例6: setProtocol

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
/**
 * Set the Coyote protocol which will be used by the connector.
 *
 * @param protocol The Coyote protocol name
 */
public void setProtocol(String protocol) {

    if (AprLifecycleListener.isAprAvailable()) {
        if ("HTTP/1.1".equals(protocol)) {
            setProtocolHandlerClassName
                ("org.apache.coyote.http11.Http11AprProtocol");
        } else if ("AJP/1.3".equals(protocol)) {
            setProtocolHandlerClassName
                ("org.apache.coyote.ajp.AjpAprProtocol");
        } else if (protocol != null) {
            setProtocolHandlerClassName(protocol);
        } else {
            setProtocolHandlerClassName
                ("org.apache.coyote.http11.Http11AprProtocol");
        }
    } else {
        if ("HTTP/1.1".equals(protocol)) {
            setProtocolHandlerClassName
                ("org.apache.coyote.http11.Http11Protocol");
        } else if ("AJP/1.3".equals(protocol)) {
            setProtocolHandlerClassName
                ("org.apache.coyote.ajp.AjpProtocol");
        } else if (protocol != null) {
            setProtocolHandlerClassName(protocol);
        }
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:34,代码来源:Connector.java

示例7: initInternal

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
@Override
protected void initInternal() throws LifecycleException {

    super.initInternal();

    // Initialize adapter
    adapter = new CoyoteAdapter(this);
    protocolHandler.setAdapter(adapter);

    // Make sure parseBodyMethodsSet has a default
    if( null == parseBodyMethodsSet ) {
        setParseBodyMethods(getParseBodyMethods());
    }

    if (protocolHandler.isAprRequired() &&
            !AprLifecycleListener.isAprAvailable()) {
        throw new LifecycleException(
                sm.getString("coyoteConnector.protocolHandlerNoApr",
                        getProtocolHandlerClassName()));
    }

    try {
        protocolHandler.init();  //初始化
    } catch (Exception e) {
        throw new LifecycleException
            (sm.getString
             ("coyoteConnector.protocolHandlerInitializationFailed"), e);
    }

    // Initialize mapper listener
    mapperListener.init();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:33,代码来源:Connector.java

示例8: setProtocol

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
/**
 * Set the Coyote protocol which will be used by the connector.
 *
 * @param protocol The Coyote protocol name
 */
public void setProtocol(String protocol) {
    //false
    if (AprLifecycleListener.isAprAvailable()) {
        if ("HTTP/1.1".equals(protocol)) {
            setProtocolHandlerClassName
                ("org.apache.coyote.http11.Http11AprProtocol");
        } else if ("AJP/1.3".equals(protocol)) {
            setProtocolHandlerClassName
                ("org.apache.coyote.ajp.AjpAprProtocol");
        } else if (protocol != null) {
            setProtocolHandlerClassName(protocol);
        } else {
            setProtocolHandlerClassName
                ("org.apache.coyote.http11.Http11AprProtocol");
        }
    } else {
        if ("HTTP/1.1".equals(protocol)) {
            setProtocolHandlerClassName
                ("org.apache.coyote.http11.Http11Protocol");
        } else if ("AJP/1.3".equals(protocol)) {
            setProtocolHandlerClassName
                ("org.apache.coyote.ajp.AjpProtocol");
        } else if (protocol != null) {
            setProtocolHandlerClassName(protocol);
        }
    }

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:34,代码来源:Connector.java

示例9: initInternal

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
@Override
protected void initInternal() throws LifecycleException {

    super.initInternal();

    // Initialize adapter
 /**
  * @see CoyoteAdapter#service(org.apache.coyote.Request, org.apache.coyote.Response)
  */
    adapter = new CoyoteAdapter(this);
    //Http11Protocol
    protocolHandler.setAdapter(adapter);

    // Make sure parseBodyMethodsSet has a default
    // "POST"
    if( null == parseBodyMethodsSet ) {
        setParseBodyMethods(getParseBodyMethods());
    }

    if (protocolHandler.isAprRequired() &&
            !AprLifecycleListener.isAprAvailable()) {
        throw new LifecycleException(
                sm.getString("coyoteConnector.protocolHandlerNoApr",
                        getProtocolHandlerClassName()));
    }

    try {
        // 创建ServerSocket
        protocolHandler.init();
    } catch (Exception e) {
        throw new LifecycleException
            (sm.getString
             ("coyoteConnector.protocolHandlerInitializationFailed"), e);
    }

    // Initialize mapper listener
    // Actually Nothing Done Here
 // 很重要的一个类 init方法只是注册了mbean 后面在`startInternal`方法中会分析到
    mapperListener.init();
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:41,代码来源:Connector.java

示例10: initInternal

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
@Override
protected void initInternal() throws LifecycleException {

	super.initInternal();

	// Initialize adapter
	adapter = new CoyoteAdapter(this);
	protocolHandler.setAdapter(adapter);

	// Make sure parseBodyMethodsSet has a default
	if (null == parseBodyMethodsSet) {
		setParseBodyMethods(getParseBodyMethods());
	}

	if (protocolHandler.isAprRequired() && !AprLifecycleListener.isAprAvailable()) {
		throw new LifecycleException(
				sm.getString("coyoteConnector.protocolHandlerNoApr", getProtocolHandlerClassName()));
	}

	try {
		protocolHandler.init();
	} catch (Exception e) {
		throw new LifecycleException(sm.getString("coyoteConnector.protocolHandlerInitializationFailed"), e);
	}

	// Initialize mapper listener
	mapperListener.init();
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:29,代码来源:Connector.java

示例11: main

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    setupDebugEnv();

    int port = 7070;
    if (args.length >= 1) {
        port = Integer.parseInt(args[0]);
    }

    File webBase = new File("../webapp/app");
    File webInfDir = new File(webBase, "WEB-INF");
    FileUtils.deleteDirectory(webInfDir);
    FileUtils.copyDirectoryToDirectory(new File("../server/src/main/webapp/WEB-INF"), webBase);

    Tomcat tomcat = new Tomcat();
    tomcat.setPort(port);
    tomcat.setBaseDir(".");

    // Add AprLifecycleListener
    StandardServer server = (StandardServer) tomcat.getServer();
    AprLifecycleListener listener = new AprLifecycleListener();
    server.addLifecycleListener(listener);

    Context webContext = tomcat.addWebapp("/kylin", webBase.getAbsolutePath());
    ErrorPage notFound = new ErrorPage();
    notFound.setErrorCode(404);
    notFound.setLocation("/index.html");
    webContext.addErrorPage(notFound);
    webContext.addWelcomeFile("index.html");

    // tomcat start
    tomcat.start();
    tomcat.getServer().await();
}
 
开发者ID:apache,项目名称:kylin,代码行数:34,代码来源:DebugTomcat.java

示例12: initInternal

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
@Override
protected void initInternal() throws LifecycleException {

    super.initInternal();

    // Initialize adapter
    adapter = new CoyoteAdapter(this);
    protocolHandler.setAdapter(adapter);

    // Make sure parseBodyMethodsSet has a default
    if( null == parseBodyMethodsSet ) {
        setParseBodyMethods(getParseBodyMethods());
    }

    if (protocolHandler.isAprRequired() &&
            !AprLifecycleListener.isAprAvailable()) {
        throw new LifecycleException(
                sm.getString("coyoteConnector.protocolHandlerNoApr",
                        getProtocolHandlerClassName()));
    }

    try {
        protocolHandler.init();
    } catch (Exception e) {
        throw new LifecycleException
            (sm.getString
             ("coyoteConnector.protocolHandlerInitializationFailed"), e);
    }

    // Initialize mapper listener
    mapperListener.init();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:33,代码来源:Connector.java

示例13: newStandardServer

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
@Override
public TomcatHostBuilder newStandardServer(int port, File baseDir, int httpPort, int ajpPort) {
    ContextResource memoryDatabase = new ContextResource();
    memoryDatabase.setName("name");
    memoryDatabase.setDescription("desc");

    TomcatServerBuilder serverBuilder = newServer(port);
    if (baseDir != null) {
        serverBuilder.setCatalinaBase(baseDir);
        serverBuilder.setCatalinaHome(baseDir);
    }

    Map<String, String> connConfig = new HashMap<>();
    connConfig.put(Constants.EXECUTOR_NAME_ATTR, DEFAULT_EXECUTOR_NAME);

    return serverBuilder.enableNaming()
    			// .addLifecycleListener(SecurityListener.class)
    			.addLifecycleListener(AprLifecycleListener.class)
    			.addLifecycleListener(JreMemoryLeakPreventionListener.class)
    			.addLifecycleListener(GlobalResourcesLifecycleListener.class)
    			.addLifecycleListener(ThreadLocalLeakPreventionListener.class)
    			.addGlobalResource(memoryDatabase)
            .addService(DEFAULT_SERVICE_NAME)
            // TODO .withDefaultRealm()
            .setBackgroundProcessorDelay(0)
            .setStartStopThreads(0)
            .addExecutor(DEFAULT_EXECUTOR_NAME, "tomcat-exec-", DEFAULT_EXECUTOR_MIN, DEFAULT_EXECUTOR_MAX, EMPTY_MAP)
            .addConnector(Tomcat.PROTOCOL_BIO, httpPort, connConfig)
            .addConnector(Tomcat.PROTOCOL_AJP, ajpPort, connConfig)
            .addHost(LOCALHOST, "webapps");
}
 
开发者ID:pidster-dot-org,项目名称:embed-apache-tomcat,代码行数:32,代码来源:CatalinaBuilderImpl.java

示例14: setUp

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
    super.setUp();

    // Trigger loading of catalina.properties
    CatalinaProperties.getProperty("foo");

    File appBase = new File(getTemporaryDirectory(), "webapps");
    if (!appBase.exists() && !appBase.mkdir()) {
        fail("Unable to create appBase for test");
    }

    tomcat = new TomcatWithFastSessionIDs();

    String protocol = getProtocol();
    Connector connector = new Connector(protocol);
    // Listen only on localhost
    connector.setAttribute("address",
            InetAddress.getByName("localhost").getHostAddress());
    // Use random free port
    connector.setPort(0);
    // Mainly set to reduce timeouts during async tests
    connector.setAttribute("connectionTimeout", "3000");
    tomcat.getService().addConnector(connector);
    tomcat.setConnector(connector);

    // Add AprLifecycleListener if we are using the Apr connector
    if (protocol.contains("Apr")) {
        StandardServer server = (StandardServer) tomcat.getServer();
        AprLifecycleListener listener = new AprLifecycleListener();
        listener.setSSLRandomSeed("/dev/urandom");
        server.addLifecycleListener(listener);
        connector.setAttribute("pollerThreadCount", Integer.valueOf(1));
    }

    File catalinaBase = getTemporaryDirectory();
    tomcat.setBaseDir(catalinaBase.getAbsolutePath());
    tomcat.getHost().setAppBase(appBase.getAbsolutePath());

    accessLogEnabled = Boolean.parseBoolean(
        System.getProperty("tomcat.test.accesslog", "false"));
    if (accessLogEnabled) {
        String accessLogDirectory = System
                .getProperty("tomcat.test.reports");
        if (accessLogDirectory == null) {
            accessLogDirectory = new File(getBuildDirectory(), "logs")
                    .toString();
        }
        AccessLogValve alv = new AccessLogValve();
        alv.setDirectory(accessLogDirectory);
        alv.setPattern("%h %l %u %t \"%r\" %s %b %I %D");
        tomcat.getHost().getPipeline().addValve(alv);
    }

    // Cannot delete the whole tempDir, because logs are there,
    // but delete known subdirectories of it.
    addDeleteOnTearDown(new File(catalinaBase, "webapps"));
    addDeleteOnTearDown(new File(catalinaBase, "work"));
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:61,代码来源:TomcatBaseTest.java

示例15: initialize

import org.apache.catalina.core.AprLifecycleListener; //导入依赖的package包/类
public void initialize() {
		try {
			JFishTomcat tomcat = new JFishTomcat();
			if(serverConfig.getTomcatContextClassName()!=null){
				tomcat.setContextClass((Class<StandardContext>)ReflectUtils.loadClass(serverConfig.getTomcatContextClassName(), true));
			}
			int port = serverConfig.getPort();
			tomcat.setPort(port);
//			tomcat.setBaseDir(webConfig.getServerBaseDir());
			String baseDir = null;
			if(!Utils.isBlank(serverConfig.getServerBaseDir())){
				baseDir = serverConfig.getServerBaseDir();
			}else{
				baseDir = System.getProperty("java.io.tmpdir");
				logger.info("set serverBaseDir as java.io.tmpdir : {} ", baseDir);
			}
			tomcat.setBaseDir(baseDir);
			
			// This magic line makes Tomcat look for WAR files in catalinaHome/webapps
			// and automatically deploy them
//			tomcat.getHost().addLifecycleListener(new HostConfig());
			appBaseFile = new File(baseDir+"/tomcat.webapps."+this.serverConfig.getPort());
			if(!appBaseFile.exists()){
				appBaseFile.mkdirs();
			}
			appBaseFile.deleteOnExit();
			tomcat.getHost().setAppBase(appBaseFile.getAbsolutePath());
			Connector connector = tomcat.getConnector();
			connector.setURIEncoding("UTF-8");
			connector.setRedirectPort(serverConfig.getRedirectPort());
			connector.setMaxPostSize(serverConfig.getMaxPostSize());
			
			ProtocolHandler protocol = connector.getProtocolHandler();
			if(protocol instanceof AbstractHttp11Protocol){
				/*****
				 * <Connector port="8080" protocol="HTTP/1.1" 
					   connectionTimeout="20000" 
   						redirectPort="8181" compression="500" 
  						compressableMimeType="text/html,text/xml,text/plain,application/octet-stream" />
				 */
				AbstractHttp11Protocol<?> hp = (AbstractHttp11Protocol<?>) protocol;
				hp.setCompression("on");
				hp.setCompressableMimeTypes("text/html,text/xml,text/plain,application/octet-stream");
			}
			
			
			StandardServer server = (StandardServer) tomcat.getServer();
			AprLifecycleListener listener = new AprLifecycleListener();
			server.addLifecycleListener(listener);

			/*tomcat.addUser("adminuser", "adminuser");
			tomcat.addRole("adminuser", "admin");
			tomcat.addRole("adminuser", "admin");*/
			
			this.tomcat = tomcat;
		} catch (Exception e) {
			throw new RuntimeException("web server initialize error , check it. " + e.getMessage(), e);
		}
		
		/*Runtime.getRuntime().addShutdownHook(new Thread(){

			@Override
			public void run() {
				appBaseFile.delete();
			}
			
		});*/
	}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:69,代码来源:TomcatServer.java


注:本文中的org.apache.catalina.core.AprLifecycleListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。