Friday, May 29, 2009

SAP Portal - Why afterInit()

During the life cycle of a Portal Service, the Portal Runtime calls the init(IServiceContext) when the service is loaded in memory, the afterInit() when the init returns, the destroy() when the service is stopped.

So is the afterInit() something unnecessary? Can we merge afterInit() into init()?

No. Actually the afterInit() is called after all services in the portal runtime have already been initialized. Suppose you need to call another service to initialize this service, you can't do it in the init() since you have no promise from the Portal Runtime that certain service will be up before others. You will have to do it in the afterInit().

No comments: