瓦丁入口点

发布于 2024-09-10 05:35:15 字数 141 浏览 1 评论 0原文

我想知道是否/在哪里可以放置一些代码来在 Vaadin 服务器第一次初始化时运行? (不是用户第一次访问该网站)

(例如从文件加载代理设置、启动 rss 爬虫等)

很可能我在这里错过了 JavaEE 内容的技巧,我对这些内容还很陌生。

I am wondering if/where I can put some code to run the VERY first time the Vaadin server is initialized? (Not the first time a user hits the site)

(For example for loading proxy settings from files, starting rss crawlers etc.)

It's quite possible I'm missing a trick with the JavaEE stuff here, I'm pretty new to this stuff.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜灵血窟げ 2024-09-17 05:35:15

使用 ServletContextListener。这是一个接口,每次服务器启动时都会调用 contextInitialized 方法。它们使用起来非常简单,只需实现接口并将上下文侦听器添加到 web-xml 中,请参阅 此示例

Use ServletContextListeners. It's an interface whose contextInitialized method is called everytime the server is started. They are really simple to use, just implement the interface and add your context listener to the web-xml, see this example.

与往事干杯 2024-09-17 05:35:15

另一种方法是扩展 ApplicationServlet 并覆盖init() 方法。
然后,您必须修改 .xml 文件以指向此 servlet,而不是 Vaadin 的默认值。
一旦容器启动 servlet,就会调用此方法。

Another way would be to extend ApplicationServlet and override the init() method.
Then you have to modify your .xml file to point to this servlet instead of Vaadin's default one.
This method is called once the servlet is brought up by the container.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文