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


Java LifecycleException类代码示例

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


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

示例1: mbeansAvailableAfterBinder

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
@Test
void mbeansAvailableAfterBinder() throws LifecycleException, InterruptedException {
    TomcatMetrics.monitor(registry, null);

    CountDownLatch latch = new CountDownLatch(1);
    registry.config().onMeterAdded(m -> {
        if(m.getId().getName().equals("tomcat.global.received"))
            latch.countDown();
    });

    Tomcat server = new Tomcat();
    try {
        StandardHost host = new StandardHost();
        host.setName("localhost");
        server.setHost(host);
        server.setPort(61000);
        server.start();

        assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();

        assertThat(registry.find("tomcat.global.received").functionCounter()).isNotNull();
    } finally {
        server.stop();
        server.destroy();
    }
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:27,代码来源:TomcatMetricsTest.java

示例2: stopInternal

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    if (log.isDebugEnabled())
        log.debug(sm.getString("deltaManager.stopped", getName()));

    setState(LifecycleState.STOPPING);
    
    // Expire all active sessions
    if (log.isInfoEnabled()) log.info(sm.getString("deltaManager.expireSessions", getName()));
    Session sessions[] = findSessions();
    for (int i = 0; i < sessions.length; i++) {
        DeltaSession session = (DeltaSession) sessions[i];
        if (!session.isValid())
            continue;
        try {
            session.expire(true, isExpireSessionsOnShutdown());
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
        } 
    }

    // Require a new random number generator if we are restarted
    super.stopInternal();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:33,代码来源:DeltaManager.java

示例3: stop

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 * Invoked by tomcat on shutdown. The database connection is closed here.
 * 
 * @exception LifecycleException Can be thrown on lifecycle 
 * inconsistencies or on database errors (as a wrapped SQLException).
 */
public void stop() throws LifecycleException {

    if (!started)
        throw new LifecycleException
            (sm.getString("accessLogValve.notStarted"));
    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    try {
        if (ps != null)
            ps.close();
        if (conn != null)
            conn.close();
	} catch (SQLException e) {
        throw new LifecycleException(e);	
    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:25,代码来源:JDBCAccessLogValve.java

示例4: destroyInternal

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/** Destroy needs to clean up the context completely.
 * 
 * The problem is that undoing all the config in start() and restoring 
 * a 'fresh' state is impossible. After stop()/destroy()/init()/start()
 * we should have the same state as if a fresh start was done - i.e
 * read modified web.xml, etc. This can only be done by completely 
 * removing the context object and remapping a new one, or by cleaning
 * up everything.
 * 
 * XXX Should this be done in stop() ?
 * 
 */ 
@Override
protected void destroyInternal() throws LifecycleException {
    
    // If in state NEW when destroy is called, the object name will never
    // have been set so the notification can't be created
    if (getObjectName() != null) { 
        // Send j2ee.object.deleted notification 
        Notification notification = 
            new Notification("j2ee.object.deleted", this.getObjectName(), 
                             sequenceNumber.getAndIncrement());
        broadcaster.sendNotification(notification);
    }

    if (namingResources != null) {
        namingResources.destroy();
    }

    synchronized (instanceListenersLock) {
        instanceListeners = new String[0];
    }

    super.destroyInternal();
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:36,代码来源:StandardContext.java

示例5: start

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 *
 * Prepare for active use of the public methods of this Component.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents it from being started
 */
public void start() throws LifecycleException {

    // Perform normal superclass initialization
    super.start();

    // Validate that we can open our connection - but let tomcat
    // startup in case the database is temporarily unavailable
    try {
        open();
    } catch (SQLException e) {
        containerLog.error(sm.getString("jdbcRealm.open"), e);
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:JDBCRealm.java

示例6: initInternal

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

	// Kerberos configuration file location
	String krb5Conf = System.getProperty(Constants.KRB5_CONF_PROPERTY);
	if (krb5Conf == null) {
		// System property not set, use the Tomcat default
		File krb5ConfFile = new File(Bootstrap.getCatalinaBase(), Constants.DEFAULT_KRB5_CONF);
		System.setProperty(Constants.KRB5_CONF_PROPERTY, krb5ConfFile.getAbsolutePath());
	}

	// JAAS configuration file location
	String jaasConf = System.getProperty(Constants.JAAS_CONF_PROPERTY);
	if (jaasConf == null) {
		// System property not set, use the Tomcat default
		File jaasConfFile = new File(Bootstrap.getCatalinaBase(), Constants.DEFAULT_JAAS_CONF);
		System.setProperty(Constants.JAAS_CONF_PROPERTY, jaasConfFile.getAbsolutePath());
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:21,代码来源:SpnegoAuthenticator.java

示例7: stop

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 * Gracefully terminate the active use of the public methods of this
 * component.  This method should be the last one called on a given
 * instance of this component.  It should also send a LifecycleEvent
 * of type STOP_EVENT to any registered listeners.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that needs to be reported
 */
public void stop() throws LifecycleException {

    // Validate and update our current component state
    if (!started)
        throw new LifecycleException
            (sm.getString("standardServer.stop.notStarted"));

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, null);

    lifecycle.fireLifecycleEvent(STOP_EVENT, null);
    started = false;

    // Stop our defined Services
    for (int i = 0; i < services.length; i++) {
        if (services[i] instanceof Lifecycle)
            ((Lifecycle) services[i]).stop();
    }

    // Notify our interested LifecycleListeners
    lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:33,代码来源:StandardServer.java

示例8: newProcessor

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 * Create and return a new processor suitable for processing HTTP
 * requests and returning the corresponding responses.
 */
private HttpProcessor newProcessor() {

    //        if (debug >= 2)
    //            log("newProcessor: Creating new processor");
    HttpProcessor processor = new HttpProcessor(this, curProcessors++);
    if (processor instanceof Lifecycle) {
        try {
            ((Lifecycle) processor).start();
        } catch (LifecycleException e) {
            log("newProcessor", e);
            return (null);
        }
    }
    created.addElement(processor);
    return (processor);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:22,代码来源:HttpConnector.java

示例9: testBug57425

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
@Test
public void testBug57425() throws LifecycleException, IOException {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass(ReplicatedContext.class.getName());
    }

    File root = new File("test/webapp-3.0");
    Context context = tomcat.addWebapp(host, "", root.getAbsolutePath());

    Tomcat.addServlet(context, "test", new AccessContextServlet());
    context.addServletMapping("/access", "test");

    tomcat.start();

    ByteChunk result = getUrl("http://localhost:" + getPort() + "/access");

    Assert.assertEquals("OK", result.toString());

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

示例10: stopInternal

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {
    
    super.stopInternal();

    // Close and release everything associated with our db.
    if (dbConnection != null) {
        try {
            dbConnection.commit();
        } catch (SQLException e) {
            // Ignore
        }
        close(dbConnection);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:JDBCStore.java

示例11: startInternal

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 * 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 {
	super.startInternal();
	try {
		CatalinaCluster catclust = (CatalinaCluster) this.getCluster();
		if (catclust != null) {
			ReplicatedMap<String, Object> map = new ReplicatedMap<String, Object>(this, catclust.getChannel(),
					DEFAULT_REPL_TIMEOUT, getName(), getClassLoaders());
			map.setChannelSendOptions(mapSendOptions);
			((ReplApplContext) this.context).setAttributeMap(map);
		}
	} catch (Exception x) {
		log.error("Unable to start ReplicatedContext", x);
		throw new LifecycleException("Failed to start ReplicatedContext", x);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:25,代码来源:ReplicatedContext.java

示例12: addChildInternal

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
private void addChildInternal(Container child) {

		if (log.isDebugEnabled())
			log.debug("Add child " + child + " " + this);
		synchronized (children) {
			if (children.get(child.getName()) != null)
				throw new IllegalArgumentException("addChild:  Child name '" + child.getName() + "' is not unique");
			child.setParent(this); // May throw IAE
			children.put(child.getName(), child);
		}

		// Start child
		// Don't do this inside sync block - start can be a slow process and
		// locking the children object can cause problems elsewhere
		try {
			if ((getState().isAvailable() || LifecycleState.STARTING_PREP.equals(getState())) && startChildren) {
				child.start();
			}
		} catch (LifecycleException e) {
			System.out.println("log:" + log);
			log.error("ContainerBase.addChild: start: ", e);
			throw new IllegalStateException("ContainerBase.addChild: start: " + e);
		} finally {
			fireContainerEvent(ADD_CHILD_EVENT, child);
		}
	}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:ContainerBase.java

示例13: start

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 * Start an existing web application, attached to the specified context
 * path.  Only starts a web application if it is not running.
 *
 * @param contextPath The context path of the application to be started
 *
 * @exception IllegalArgumentException if the specified context path
 *  is malformed (it must be "" or start with a slash)
 * @exception IllegalArgumentException if the specified context path does
 *  not identify a currently installed web application
 * @exception IOException if an input/output error occurs during
 *  startup
 */
public void start(String contextPath) throws IOException {
    // Validate the format and state of our arguments
    if (contextPath == null)
        throw new IllegalArgumentException
            (sm.getString("standardHost.pathRequired"));
    if (!contextPath.equals("") && !contextPath.startsWith("/"))
        throw new IllegalArgumentException
            (sm.getString("standardHost.pathFormat", contextPath));
    Context context = findDeployedApp(contextPath);
    if (context == null)
        throw new IllegalArgumentException
            (sm.getString("standardHost.pathMissing", contextPath));
    host.log("standardHost.start " + contextPath);
    try {
        ((Lifecycle) context).start();
    } catch (LifecycleException e) {
        host.log("standardHost.start " + contextPath + ": ", e);
        throw new IllegalStateException
            ("standardHost.start " + contextPath + ": " + e);
    }
}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:35,代码来源:StandardHostDeployer.java

示例14: start

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 * Prepare for the beginning of active use of the public methods of this
 * component.  This method should be called before any of the public
 * methods of this component are utilized.  It should also send a
 * LifecycleEvent of type START_EVENT to any registered listeners.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
public void start() throws LifecycleException {

    // Validate and update our current component state
    if (started) {
        if(log.isInfoEnabled())
            log.info(sm.getString("realmBase.alreadyStarted"));
        return;
    }
    if( !initialized ) {
        init();
    }
    lifecycle.fireLifecycleEvent(START_EVENT, null);
    started = true;

    // Create a MessageDigest instance for credentials, if desired
    if (digest != null) {
        try {
            md = MessageDigest.getInstance(digest);
        } catch (NoSuchAlgorithmException e) {
            throw new LifecycleException
                (sm.getString("realmBase.algorithm", digest), e);
        }
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:RealmBase.java

示例15: stopInternal

import org.apache.catalina.LifecycleException; //导入依赖的package包/类
/**
 * Stop {@link Valve}s) in this pipeline and implement the requirements
 * of {@link LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    setState(LifecycleState.STOPPING);

    // Stop the Valves in our pipeline (including the basic), if any
    Valve current = first;
    if (current == null) {
        current = basic;
    }
    while (current != null) {
        if (current instanceof Lifecycle)
            ((Lifecycle) current).stop();
        current = current.getNext();
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:24,代码来源:StandardPipeline.java


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