留言板

Can we add our custom classes in the service builder generated packages

Sunil Kulkarni,修改在11 年前。

Can we add our custom classes in the service builder generated packages

Junior Member 帖子: 94 加入日期: 11-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
thumbnail
David H Nebinger,修改在11 年前。

RE: Can we add our custom classes in the service builder generated packages

Liferay Legend 帖子: 14915 加入日期: 06-9-2 最近的帖子
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,修改在11 年前。

RE: Can we add our custom classes in the service builder generated packages

Junior Member 帖子: 94 加入日期: 11-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.