English 中文(简体)
我怎么能够阻止 Java EE的申请?
原标题:How can I make a ServletContextListener stop the Java EE application?

我有一个SerletContextListener,在我的 Java E申请开始时履行一些数据库管理职能。 这在我的申请书上进行,而申请的其他部分则开始/上载。 如果数据库维护工作失败,我就发现错误。 如果数据库维护工作失败,申请将无法正常运作,我希望停止申请。

我怎么能够令人宽慰和正确地阻止SerletContextListener的申请。

维文下面给出的解决办法是接近的,但并非完全。 当我扔下一条龙虾时,玻璃鱼被留在一个前后不一的国家里,那里无法使用其行政专册,但有些程序仍在运行,3700港(IIOP?)仍然开放,因此无法重新开始。

问题回答

In your listener, catch any exceptions and use servlet context attributes to store flags or other useful information about the error. You should probably also log something to indicate that the app is non-functional.

此时,你的选择可能取决于你的准备结构。 如果所有要求都由单一控制器/发送器服务器处理,那么将其<条码>列入/code>的方法检查背景属性并投掷<条码>。 仅知道该例外只适用于扔下它的具体保护措施。 如果贵机构包含许多服务,或允许直接获得其他资源,那么这种做法就不那么可行。

另一种选择是建立一个过滤器,拦截每一项请求,检查背景属性,然后作出例外规定。 其他变化肯定是可能的。

∗ ∗∗∗ 抛出一个例外,网吧打上了正确的车载,申请服务器阻挡其后所有要求(并用500个错误回答)。

这确实妨碍申请的开始,也不妨碍申请的提出,但它防止了任何进一步的使用,而且对你来说可能有用。

在进行适当核查之后,这一行为在具体规定中是强制性的。 服务器可以(而不是must)退回500个错误。 因此,必须仔细利用这一解决办法。

,其中引自Serlet spec。





相关问题
Recommended way to develop using Jetty and Eclipse

I am currently developing a J2EE application and I would like to use Jetty. I would like to have iot integrated with Eclipse, so I could debug the appliaction. I ve tried out couple of plugins (...

Call function periodically in Java

we need run one function periodically in Java web application . How to call function of some class periodically ? Is there any way that call function when some event occured like high load in server ...

Why make an EJB rather than a Web Service?

I would have thought that there is a lot of information out there on this, but I haven t found anything that really answers my question. What are the advantages of making an EJB rather than a web ...

Where should I put this configuration setting?

I m designing a fairly small web application which will run on a Sun application server (v9.1). It only has a few pages, no database of its own, and will retrieve/update data via web services. There s ...

JNDI Names -- Is Prefix "jdbc/" needed?

What s up with JNDI names? I m trying to get a javax.sql.DataSource using the new annotations feature of Java 5. It s not working for me, so I want to ask... I have a in my web.xml, inside of it is ...

hibernate interceptors : afterTransactionCompletion

I wrote a Hibernate interceptor : public class MyInterceptor extends EmptyInterceptor { private boolean isCanal=false; public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[]...

热门标签