论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Sunil Kulkarni
Can we add our custom classes in the service builder generated packages
2013年3月8日 上午4:23
答复

Sunil Kulkarni

等级: Junior Member

帖子: 94

加入日期: 2011年6月24日

最近的帖子

Hello All,

I am using LR6.1.1.
I have created the books portlet and generate the service using service builder.
Service builder generate service folder under which there are interfaces and utils which are exposed to others and there is implementation classes present in the src folder where the actual implementation is present.

Now, I want to implement the similar to that where I can store the custom interface and util in the service folder and them actual implementation will be present in the src (project source) package.

I have added the interfaces, utils and implementaion classes as per mentioned in the above.
I have created following in the service package
BooksTest (interface)
BooksTestUtil (Util clas)

I have created following in the service package
BooksTestImpl (class) which implements BookTest interface.

However, I am getting an error while compiling the project saying that .

BooksTest cannot be resolved to a type
David H Nebinger
RE: Can we add our custom classes in the service builder generated packages
2013年3月8日 上午5:46
答复

David H Nebinger

Community Moderator

等级: Liferay Legend

帖子: 8426

加入日期: 2006年9月1日

最近的帖子

Unless you really know what you're doing, no you cannot put classes in the service folder.

There are other options, though:

1. Create a columnless entity in your service.xml file and rebuild services. This will then give you a XxxLocalServiceImpl class where you can add methods for shared functionality, but the methods can only pass/return entities from the service.xml, primitives, their object counterparts, or collections of these items.

2. To use your own classes, you would need to define them as entities. There are ideas here to define entities that would not be persisted but allow you to use SB to build and share them.
Sunil Kulkarni
RE: Can we add our custom classes in the service builder generated packages
2013年3月10日 下午11:38
答复

Sunil Kulkarni

等级: Junior Member

帖子: 94

加入日期: 2011年6月24日

最近的帖子

Thanks for the reply David.

In both approaches, we cannot extends or implements any service builder generated classes with custom classes/interface which are generated manually.

I want funcationality, just like UsersAdmin (interface), UsersAdminImpl(Class) and UsersAdminUtil(Class), these interface and classes are already present in the liferay source code where UsersAdmin , UsersAdminUtil is present in portal-service and UsersAdminImpl is present in portal-impl. I have also found the entries of these classes and interfaces in util-spring.xml file.

Can we implement such functionality in our hook so that we can use this as wrapper over the service builder generated classes and interfaces and also returns the custom model classes.