In my Liferay 6.1.1 installation I have extended (note: not overridden) the UserLocalServiceImpl class in an Ext plugin to provide a more relaxed screen name validation. However, I have been unable to get Liferay to load the new class instead of the default UserLocalServiceImpl class.
As far as I can tell, the “normal” way to replace service classes is to use a hook plugin. Unfortunately, hook plugins cannot access the implementation classes. I would have to extend UserLocalServiceWrapper instead of UserLocalServiceImpl, which would be very cumbersome for this particular use.
Is there a way to get Liferay to use my modified service class from an Ext plugin? Alternatively, is there a way to allow a hook plugin access to the implementation classes?
It is possible to change the service class implementation from an Ext plugin using the following procedure:
Create a new folder named
META-INFunderdocroot/WEB-INF/ext-impl/srcin the Ext folder.Create a new file named
ext-spring.xmlunderdocroot/WEB-INF/ext-impl/src/META-INF.Search the Liferay source distribution for the
portal-spring.xmlfile. In Liferay 6.1.1 it can be found atportal-impl/src/META-INF/portal-spring.xml.Copy the content of
portal-spring.xmlto theext-spring.xmlfile that was created earlier.Remove all bean entries from
ext-spring.xml, except for those that correspond to classes that will be replaced/extended.For each remaining entry, change the
classattribute to point to the replacement class.Re-deploy the Ext plugin and restart the Liferay application server.