cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between com.sap.ejb.annotations.AppStartup and @PostConstruct

former_member190457
Contributor
0 Kudos

Hi developers,

In NW 7.3 we have two EJB annotations with identical meaning:

javax.annotation.PostConstruct 

and

com.sap.ejb.annotations.AppStartup

A method annotated like this is invoked by the container right before the EJB is made available to clients.

Can anyone explain the difference between the two annotations?

Thanks, regards

Vincenzo

Accepted Solutions (1)

Accepted Solutions (1)

rolf_paulsen
Active Participant
0 Kudos

Hi

PostConstruct = EJB standard, AppStartup = SAP proprietary.

As far as I understand the descriptions, the AppStartup callback invocation occur for all EJBs immediately when the application is starting (no matter if the EJB is called or not) whereas "The PostConstruct callback invocations occur before the first business method invocation on the bean. This is at a point after which any dependency injection has been performed by the container." (see EJB spec).

So the PostConstruct has nothing to do with application life cycle but with the lifecycle of a single bean instance. PostConstruct may be called later on first client invocation) and in AppStartup, you probably do not have dependency injection performed but have to lookup using java:comp/env.

Regards

Rolf

Answers (0)