English 中文(简体)
Java网络应用中未使用的申诉方法
原标题:Call method on undeploy from a Java web-application

我正在开发一个 Java网络应用程序。 申请与卢塞纳指数挂钩。 我创建了一个单一州指数。 该案打开了一些档案。 当我重新调配网上申请时,索引Searcher早期开始的档案继续开放,另一个例子是重新调配的申请。 在进行了几次重新部署之后,该系统开始放弃“许多公开档案”例外。 在重新调配之前,我想结束老的情况,以便关闭旧档案,但我无法说明如何这样做? 是否在网上发布指令,要求进行不爆炸,类似于重荷启动? I m 运行一个小船服务器上的网络应用。

最佳回答

Implement a ServletContextListener.

@WebListener
public class LuceneConfig implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent event) {
        // Do your job here during webapp startup.
    }

    @Override
    public void contextDestroyed(ServletContextEvent event) {
        // Do your job here during webapp shutdown.
    }

}

如果您不再列入3.0(虽然已经删除了2年),那么你需要删除<条码>@WebListener的说明,并在<条码>上人工登记。

<listener>
    <listener-class>com.example.LuceneConfig</listener-class>
</listener>
问题回答

如果你执行<条码>javax.servlet.ServletContextListener,并登记在web.xml中的类别,作为<条码><listener>,则在环境中卸载之前,将使用<条码>contextDestroyed()。





相关问题
Implementing SSO with SAML and JBoss

I want to implement SSO with SAML tokens in JBossAS. The scenario is as follows. I have 2 applications app1 and app2 running on 2 JBoss instances. Login into app1 and enter username / password ...

How do you efficiently repeat an action every x minutes?

I have an application that runs in JBoss. I have an incoming web service request that will update an ArrayList. I want to poll this list from another class every 60 seconds. What would be the most ...

jsp:how to hide folder structure of website from users?

how to hide folder structure of website from users. i have developed a website on jave platform (jsp). website is deployed on jboss. suppose my website s home page url is dummy.com/dummyFolder/...

JBoss Web Services Behind IIS Through HTTPs

This is a tangled web that s woven, I suppose, but it really shouldn t be all that hard. Let me see if I can paint the picture: I have written a web service, starting with a WSDL, which is to run in ...

Flex: image scale stopped working after deploy to server

I have some code to scale an image s width according to its height after the image is being loaded. It works fine on my development PC if I point to the wrapper html using local file system path. ...

How in jboss write traces to separate trace file

How in JBoss to write traces to separate file? I would like to see traces about org.hibernate.SQL and org.hibernate.type in separate trace file. I added next appender and categories to jboss-log4j....

热门标签