Forums de discussion

Service/persistence classes of Service Builder injected into LocalService

thumbnail
Adam Victor Nazareth Brandizzi, modifié il y a 12 années.

Service/persistence classes of Service Builder injected into LocalService

Junior Member Publications: 67 Date d'inscription: 30/04/10 Publications récentes
Looking at the Liferay source code, I noted that the UserLocalServiceBaseImpl is injected with both the local service instances and the persistence instances of the entities it will need to deal with. (For example, the cited class has both a reference to AccountLocalService and AccountPersistence:
@BeanReference(type = AccountLocalService.class)
protected AccountLocalService accountLocalService;
@BeanReference(type = AccountService.class)
protected AccountService accountService;

UserServiceImpl is even more dependent: it has instances of UserService, UserLocalService and UserPersistence! I studied services generated by Service Builder for some portlets I have created and it happens on them, too.

My questions are:
  • Why do local service objects have both a reference to a local service instance and a persistence instance?
  • Why do service objects have a reference for service, local service and persistence instances?
  • Which injected dependency should I preferably use? Should I use the persistence instances in methods I add to local services? Should I prefer to use the local service instances in services?

Thanks in advance!