Dear All
We have developed the portal service which registers for KM event capturer. Previously we tried for repository service which stopped whole km, so now we have switched to portal service.
We want init() method of service to be get called after each j2ee server restart.
Though the service status is shown started in portal, i guess the init method is not getting called.Because as soon as I restart the service manually the desired funtion is achieved.
Please suggest the solution::
The codes are as below :
IRegisterKMEvents::
import com.sapportals.portal.prt.service.IService;
public interface IRegisterKMEvents extends IService
{
public static final String KEY = "RegisterKMEvents";
}
RegisterKMEvents::
public class RegisterKMEvents implements IRegisterKMEvents{
private IServiceContext mm_serviceContext;
/**
Generic init method of the service. Will be called by the portal runtime.
@param serviceContext
*/
public void init(IServiceContext serviceContext)
{
mm_serviceContext = serviceContext;
try {
IUser ep5User = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
IResourceFactory factory;
factory = ResourceFactory.getInstance();
IResourceContext context = new ResourceContext(ep5User);
// Now get the RId of /documents folder as we have to register Event Handler for /documents only
RID fileRID2 = RID.getRID("/documents");
IResource resource = factory.getResource(fileRID2, context);
MyEventReceiver aReceiver = new MyEventReceiver();
aReceiver.register(resource);
} catch (Exception e) {
// TODO Auto-generated catch block
}
}
/**
This method is called after all services in the portal runtime
have already been initialized.
*/
public void afterInit()
{
}
/**
configure the service
@param configuration
@deprecated
*/
public void configure(com.sapportals.portal.prt.service.IServiceConfiguration configuration)
{
}
/**
This method is called by the portal runtime
when the service is destroyed.
*/
public void destroy()
{
}
/**
This method is called by the portal runtime
when the service is released.
@deprecated
*/
public void release()
{
}
/**
@return the context of the service, which was previously set
by the portal runtime
*/
public IServiceContext getContext()
{
return mm_serviceContext;
}
/**
This method should return a string that is unique to this service amongst all
other services deployed in the portal runtime.
@return a unique key of the service
*/
public String getKey()
{
return KEY;
}
}