如何在SEAM中调用bean初始化链末尾的启动bean

发布于 2024-11-16 13:42:51 字数 1041 浏览 4 评论 0原文

14:00:04,449 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.servlet.characterEncodingFilter
14:00:04,450 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.redirectFilter
14:00:04,451 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.exceptionFilter
14:00:04,452 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.multipartFilter
14:00:04,452 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.identityFilter
14:00:04,453 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.rewriteFilter

这些是 JBoss SEAM 应用程序在 JBoss 6 上启动后打印的最后一组行

@Name("myStartup")
@Startup
@Scope(APPLICATION)
@BypassInterceptors
public class MyStartup {

    @Create
    public void create() {
        System.out.println("SERVER STARTED SUCCESSFULLY");
    }
}

。我的目的是在 SeamFilter 初始化后打印上述消息(在 JBoss 6 控制台上)。我该怎么做?

14:00:04,449 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.servlet.characterEncodingFilter
14:00:04,450 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.redirectFilter
14:00:04,451 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.exceptionFilter
14:00:04,452 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.multipartFilter
14:00:04,452 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.identityFilter
14:00:04,453 INFO  [org.jboss.seam.servlet.SeamFilter] Initializing filter:
 org.jboss.seam.web.rewriteFilter

These are the last set of lines which gets printed post the JBoss SEAM application startup on JBoss 6.

@Name("myStartup")
@Startup
@Scope(APPLICATION)
@BypassInterceptors
public class MyStartup {

    @Create
    public void create() {
        System.out.println("SERVER STARTED SUCCESSFULLY");
    }
}

My intention was to print the above message (on JBoss 6 console) after SeamFilter initializes. How should I do this?

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

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

发布评论

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

评论(2

π浅易 2024-11-23 13:42:51

您可以在普通组件上尝试此注释。删除该组件上的@Startup

@Observer({"org.jboss.seam.postInitialization", "org.jboss.seam.postReInitialization"})
public void create() {
    System.out.println("SERVER STARTED SUCCESSFULLY");
}

You can try this annotation on a normal component. Remove the @Startup on this component.

@Observer({"org.jboss.seam.postInitialization", "org.jboss.seam.postReInitialization"})
public void create() {
    System.out.println("SERVER STARTED SUCCESSFULLY");
}
和影子一齐双人舞 2024-11-23 13:42:51

如果想法只是在所有接缝消息之后显示某些状态,则至少有两种方法:

第一种是使用 Shervin 的解决方案并抑制 org.jboss.seam.servlet.Filter INFO 消息 < code>$JBOSS_HOME/server//conf/jboss-log4j.xml:

<category name="org.jboss.seam.servlet.Filter">
   <priority value="ERROR"/>
</category>

或者实现一个过滤器:

@Scope(APPLICATION)
@Name("com.example.seam.myFilter")
@BypassInterceptors
@Filter(within={"org.jboss.seam.web.rewriteFilter"})
public class MyFilter implements Filter {
    public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
        chain.doFilter(request, response);
    }

    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("SERVER STARTED SUCCESSFULLY");
    }
}

If the idea is only to show some status AFTER all seam messages, there are at least 2 ways:

First is to use a Shervin's solution and suppress org.jboss.seam.servlet.Filter INFO messages in $JBOSS_HOME/server/<your-profile>/conf/jboss-log4j.xml:

<category name="org.jboss.seam.servlet.Filter">
   <priority value="ERROR"/>
</category>

Or implement a filter:

@Scope(APPLICATION)
@Name("com.example.seam.myFilter")
@BypassInterceptors
@Filter(within={"org.jboss.seam.web.rewriteFilter"})
public class MyFilter implements Filter {
    public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
        chain.doFilter(request, response);
    }

    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("SERVER STARTED SUCCESSFULLY");
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文