Wednesday 10 August 2016

Using Liferay Service Builder with liferay7


Using service Builder in Liferay 7-:

In liferay 7 we can create services using the liferay service builder as we used to do in the previous version of liferay.

First we need to create a new project with the template servicebuilder. Once you have filled the name of the project click on next and fill in the package name.


You will see that there are 3 projects created.
1) student-services
2) student-services-api-> will contain the Interfaces and the model classes.
3)student-services-service ->will contain the Impl classes

Open up the service.xml from the student-services-service project and enter the entities that you want to insert. Once you are done click on the buildService from the Gradel Tasks.
Once the services are created you can see that classes are generated in the *-services and the *-api projects.
Now we need to deploy this service in order to use this in some portlet. Deploy this by clicking on the deploy task in the Gradel Task. Once done you can see in the GOGO shell that *.service are installed. In this case that will be student.services.service
Now we will have to deploy generated services. So goto the Gradel Task of student-services and execute the deploy task.

This will generate the required JARs deploy and start them. You can verify the same in tomcat logs.
17:35:43,969 INFO  [fileinstall-F:/LR7/liferay-ce-portal-7.0-ga2/osgi/modules][BundleStartStopLogger:35] STARTED student.services-api_1.0.0 [489]
17:35:44,581 INFO  [fileinstall-F:/LR7/liferay-ce-portal-7.0-ga2/osgi/modules][BundleStartStopLogger:35] STARTED student.services-service_1.0.0 [490]

Our services are deployed and ready for use. Now we need to write a consumer, In this case it will be a new portlet. You can refer to my previous tutorials for process of how to create a new portlet.
Create a new portlet named Student-Portlet. Now we have to inform this portlet that it will needs to  consume the above generated services. To do that open the build.gradel file of Student-Portlet and give the dependency of the above services as follows.
compile  project(':modules:student-services:student-services-api')
compile  project(':modules:student-services:student-services-service')
If you are going to use these services now in your portlet you will be getting a compile time error. To remove those errors we will have to do a gradel refresh like this.
Once done you can use the services in your portlet.


http://liferaytutorials4u.blogspot.com/2016/08/how-to-create-and-deploy-portlet-in.html
http://liferaytutorials4u.blogspot.com/2016/08/how-to-create-liferay-workspace-using.html



j\

0 comments:

Post a Comment

 

Copyright @ 2016 LiferayRevisited.