Fórum

Correct steps for ext plugin development

thumbnail
Pete Helgren, modificado 9 Anos atrás.

Correct steps for ext plugin development

Regular Member Postagens: 225 Data de Entrada: 07/04/11 Postagens Recentes
As it applies to 6.0 the online development guide says this:
-----------------------------------------------------------------------
If you really need to change core portal-impl class and this class that cannot be replaced in any configuration file, then best way to avoid conflicts and easily merge with a new portal version is to:

Rename original class (e.g. DeployUtil → MyDeployUtil)
Create new subclass with old name (e.g DeployUtil extends MyDeployUtil)
Override methods you need to change
Delegate static methods
Use logger with appropriate class name for both classes (e.g. DeployUtil)

Seems like some things are missing...

1. Rename the original class *where* exactly? Should the source be copied to the ext plugin project ext-impl/src folder (if you are changing a portal-impl class) and THEN renamed? Then THAT class is extended? If the class will be deployed with the same name anyway, why not just copy it, modify it and deploy it?

2. Delegate static methods, how?

After some research I have determined that I want to override a few methods in com.liferay.portal.service.impl.RoleLocalServiceImpl but that is as far as I have gotten. I *could* make the changes directly to the class and deploy the change but I have read where it is recommended NOT to change a class but instead extend that class and then make a change to a spring xml file (which one is uncertain).

So, does anyone have a step by step that clearly identifies what, exactly, needs to happen to change a class that is in the portal-impl jar? I have read through multiple examples: PortalLDAPImporterImpl, PermissionChecker both of which seem to be special uses cases. How about an example of a class, any class, in LR 6.0.6 that would be "generic" ?
thumbnail
Andew Jardine, modificado 9 Anos atrás.

RE: Correct steps for ext plugin development

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hey Pete,

This is a bit of a grey area for me having only read about it and not done it yet, but the Role stuff is done using Service Builder. You could possibly extend the RoleLocalServiceWrapper class to do what you are looking for? This is for 6.1 but I think it still applies in 6.0 --

https://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/overriding-a-portal-servi-4
thumbnail
Pete Helgren, modificado 9 Anos atrás.

RE: Correct steps for ext plugin development

Regular Member Postagens: 225 Data de Entrada: 07/04/11 Postagens Recentes
Thanks. The whole .Base, .Impl, .Util, .Wrapper thing for classes in LR is a bit mind blowing. Yeah, most of it is just FreeMarker template generated "DON'T modify this!" code, so I am always at a bit of a loss of where, exactly, to begin to dig in (I usually look for classes that DON'T have the modification warnings....) The thing that left me scratching my head on this was that the Utility class has this: "Add custom service methods to com.liferay.portal.service.impl.RoleLocalServiceImpl" with the additional instruction " and rerun ServiceBuilder to regenerate this class". So I was a bit stumped as to what to do since I don't think I want to run SB on the whole of LR portal-impl (do I?)

Anyway, your suggestion makes some sense and there is a reference to doing something like that here for 6.0 as well (almost the same doc):
https://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/overriding-a-portal-service

But again, I am a little mystified because I thought that portal services had to be modified using an ext plugin rather than a hook but this example shows modifying the behavior in a hook....I wish that the LR team would stop developing for a while and write up more complete documentation with a broader range of clarifying examples.....awesome product...confusing documentation...

I am going head down the wrapper class rabbit hole for a while and do some testing....
thumbnail
Pete Helgren, modificado 9 Anos atrás.

RE: Correct steps for ext plugin development

Regular Member Postagens: 225 Data de Entrada: 07/04/11 Postagens Recentes
So, that works! That is what I needed. Simply built a hook that extends the wrapper class. Thanks!!

Much simpler and easier to manage than an ext plugin.
thumbnail
Andew Jardine, modificado 9 Anos atrás.

RE: Correct steps for ext plugin development

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hey Pete,

Glad that worked out for you. There are still some cases where you need to go to an EXT plugin but Liferay is doing an awesome job at making that list really small. With the additional of StrutsAction overrides in 6.1 there are very few instances now where you need to do an EXT. If you do get to something like that again though, definitely drop a note in here and I am sure the community will help.

As for the ServiceBuilder stuff -- for your own new ServiceBuilder projects you basically modify the XXXLocalServiceImpl class adding whatever methods you want to be included in the XXXXLocalServiceUtil class. Re-run the build-service target and you should see them, with the logic you specified in the Impl class there.

Any existing XXXService stuff, do what you did here and hook it with a Wrapper inheritted alternative.