掲示板

Service/persistence classes of Service Builder injected into LocalService

thumbnail
12年前 に Adam Victor Nazareth Brandizzi によって更新されました。

Service/persistence classes of Service Builder injected into LocalService

Junior Member 投稿: 67 参加年月日: 10/04/30 最新の投稿
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!