With Service Wrappers, you can override default service methods to add extra functionality. For example, you may want the value of a field you’ve added to Liferay’s User object to be saved whenever the Liferay API’s addUser or updateUser methods are called. Liferay’s service wrappers provide easy-to-use extension points for customizing Liferay’s services.
docker run -it -m 8g -p 8080:8080 liferay/portal:7.4.3.132-ga132
Sign in to Liferay at http://localhost:8080. Use the email address test@liferay.com and the password test. When prompted, change the password to learn.
Then, follow these steps to deploy the example:
Download and unzip the liferay-j1c2.zip example project.
Open the J1C2UserLocalServiceWrapper class in your text editor or IDE.
Inside the class, create a public method called getUser. This overrides UserLocalService’s getUser method. As such, it must pass a long as an argument and return a User. This method should also throw a PortalException. Make sure to add the @Override annotation.
@Override
public User getUser(long userId) throws PortalException {
}
Since this method returns the User object, import it at the top of the file.
import com.liferay.portal.kernel.model.User;
Create a similar method to the one in the example so that every time the getUser method is called, it prints a message to the console.
if (_log.isInfoEnabled()) {
_log.info(
"Invoking #getUser(long)");
}
You still want getUser to be called, so make the method return the results of calling getUser’s super method.
return super.getUser(userId);
In the end, your method should look like this:
@Override
public User getUser(long userId) throws PortalException {
if (_log.isInfoEnabled()) {
_log.info(
"Invoking #getUser(long)");
}
return super.getUser(userId);
}
This website uses cookies and similar tools, some of which are provided by third parties (together “tools”). These tools enable us and the third parties to access and record certain user-related and activity data and to track your interactions with this website. These tools and the informationcollected are used to operate and secure this website, enhance performance, enable certain website features and functionality, analyze and improve website performance, and personalize user experience.
If you click “Accept All”, you allow the deployment of all these tools and collection of the information by us and the third parties for all these purposes.
If you click “Decline All” your IP address and other information may still be collected but only by tools (including third party tools) that are necessary to operate, secure and enable default website features and functionalities. Review and change your preferences by clicking the “Configurations” at any time.
Visite nossa Política de privacidade