Foren

Service Builder - custom type argument

thumbnail
Roman Novikov, geändert vor 6 Jahren.

Service Builder - custom type argument

Junior Member Beiträge: 39 Beitrittsdatum: 07.01.17 Neueste Beiträge
Hello! Tell me please any one - Is it possible to pass an object of a custom class into a function under *LocalServiceImpl class as argument?
So, I do:
...
import com.xxx.My_Class;
...

public class CatalogMapperItemLocalServiceImpl extends...
...

public CatalogMapperItem addCatalogMapperItem(long userId, My_Class myClass, ServiceContext serviceContext) ...

After I build the service, I get the following error: com.xxx.My_Class cannot be resolved to a type ...
thumbnail
David H Nebinger, geändert vor 6 Jahren.

RE: Service Builder - custom type argument

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Normally you can only use primitives, their object counterparts, entitles or Liferay classes (because they are in portal-kernel).

Now that we're doing a modular approach, you actually have an API module that you can actually add stuff to and manage dependencies on, so things have loosened up a bit.

When using outside classes, you will have to add the dependency to both modules for everything to resolve corectly.










Come meet me at the 2017 LSNA!
thumbnail
Roman Novikov, geändert vor 6 Jahren.

RE: Service Builder - custom type argument

Junior Member Beiträge: 39 Beitrittsdatum: 07.01.17 Neueste Beiträge
Thank you, David!
That's a good idea to give some liberty to developers which use Service Builder... Now I'm working over a project based on 6.2.. And it sounds to me like "leave all hopes and try it in another way"...
So, I was inspired by this post https://web.liferay.com/community/forums/-/message_boards/message/30908469 where were discussed a similar problem... But it was about 6.1.. It seems that way (with ext-spring.xml) doesn't work in 6.2... emoticon
thumbnail
David H Nebinger, geändert vor 6 Jahren.

RE: Service Builder - custom type argument (Antwort)

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
For 6.x, I would skip the object idea and just pass a bunch of primitives (unless, of course, you want to build a fake entity).









Come meet me at the 2017 LSNA!
thumbnail
Roman Novikov, geändert vor 6 Jahren.

RE: Service Builder - custom type argument

Junior Member Beiträge: 39 Beitrittsdatum: 07.01.17 Neueste Beiträge
I've realized so... I have already redone my code. I created a holder class that contains a static variable of my type and function init(...) for initialization... On the request processing I'm going to put this init in the very beginning, and invoke the getter from under the *LocalServiceImpl... But at the first case I'd have to instantiate my custom class either... Actually, the same work...