Foros de discusión

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

Sunil Kulkarni, modificado hace 11 años.

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

Junior Member Mensajes: 94 Fecha de incorporación: 24/06/11 Mensajes recientes
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, modificado hace 11 años.

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

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
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, modificado hace 11 años.

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

Junior Member Mensajes: 94 Fecha de incorporación: 24/06/11 Mensajes recientes
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.