Java ejb3 @PostConstruct

I am experimenting with EJB3 on JBoss, creating a bezelless bean. As a rule, after the module is deployed, I need to perform some actions related to the boot application settings. To do this, I annotated the method as @PostConstruct, which, as far as I know from the API, instructs the container to call it after the bean has been deployed and before it works. (right?) Now I'm confused because from the log this method looks like not just called after it has been deployed, but before calling each exposed method. I only need to call this method once, not every time it receives a call. What would be a better approach?

Thank you in advance

Alessandro Ilardo

+3
source share
5

bean - . , , bean . , PostConstruct , bean.

-, JBoss beans , , , , ( ), , PostConstruct.

+2

PostConstruct , bean . , .

-, PreDestory .

, ?

+1

EJB. , beans , . , bean bean, , .

, @PostConstruct ? @PostConstruct.

0

SLSB ? @PostConstruct , ( JBoss), , . , post-construct , .

post-construct, , , SFSB "" SFSB SLSB .

0

PostConstruct , biz. , bean , bean, , @PostConstruct, biz-.

@PostConstruct , bean . Stateless beans . Stateful beans .

- , Java EE, .

Java EE 6 @Startup @Singleton EJB, @PostConstruct.

Java EE 5 ServletContextListener -. ServletContextListener EJB, .

However, what could be a more important question, where do you want to download these application settings? If you are dealing with a non-clustered JVM configuration with a single cluster, you probably want to load them into a Singleton of some type. In Java EE 5– you will have to implement the singleton design template yourself or use the @Singleton EJB type in EE 6.

0
source

Source: https://habr.com/ru/post/1712284/


All Articles