掲示板

Creating Utility classes in Liferay 7

7年前 に Zak Thompson によって更新されました。

Creating Utility classes in Liferay 7

Junior Member 投稿: 70 参加年月日: 16/06/13 最新の投稿
I've been messing around with Liferay 7 CE, and one of the things I'd like to do is make some utility methods for come common functionality. What is the best way to do that in Liferay 7? I know exactly what I want my methods to do, I'm just not sure if they should be put in a portlet, module, osgi service, etc.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Creating Utility classes in Liferay 7

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Well the answer really kind of depends on what you're building.

  • If it's a data-based service, I'd use Service Builder.
  • If it's a generic sort of service, I'd use a DS service (an OSGi-based service which exposes an API of interfaces and provides hidden implementations of the APIs).
  • If it is just some kind of jar with basic methods, you could make them global or you could just include them in the modules where they are accessed.





Come meet me at the LSNA!
7年前 に Zak Thompson によって更新されました。

RE: Creating Utility classes in Liferay 7

Junior Member 投稿: 70 参加年月日: 16/06/13 最新の投稿
It will just be a JAR with basic methods, nothing data-based or related to services. Mainly just some common functions that will be used in multiple places, so I want to have a central place to store/access them.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Creating Utility classes in Liferay 7

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Even these can be implemented as a DS service layer so it can be shared within an OSGi container. So when you say "what is the best way for LR7", a simple jar is not really the right answer.





Come meet me at the LSNA!
7年前 に Zak Thompson によって更新されました。

RE: Creating Utility classes in Liferay 7

Junior Member 投稿: 70 参加年月日: 16/06/13 最新の投稿
If there is going to only be one implementation of the methods though, is it necessary to put into an OSGI service? I thought the whole benefit of OSGI services is that it allows you to have multiple implementations of the same interface.
thumbnail
7年前 に Richard Sezov によって更新されました。

RE: Creating Utility classes in Liferay 7

Regular Member 投稿: 220 参加年月日: 07/02/07 最新の投稿
Dependency resolution is the other benefit. If your applications are dependent on these utilities, the container can then make them available only when the dependencies are satisfied. This prevents users from seeing errors.
7年前 に Zak Thompson によって更新されました。

RE: Creating Utility classes in Liferay 7

Junior Member 投稿: 70 参加年月日: 16/06/13 最新の投稿
Oh ok that makes sense. Thanks for the explanation