Sometimes we have to know which liferay version we are using, so how can we know? We can know the liferay version in different ways. 1. Liferay has provided some utility methods to know the which liferay version we are using , Here is the utility method ReleaseInfo.getReleaseInfo() It prints this statement " Liferay Portal Community Edition 6.2 CE GA2 (Newton / Build 6201 / March 20, 2014) " as i am using community version it shoes as CE. 2. Also we can also identify by response headers as below screenshot. If your using the chrome, right click on the browser and click inscept element , and navigate to the network . you will see the URLS , click on the any url. 3. Also we can see during server startup as below statement Liferay Portal Community Edition 6.2 CE GA2 (Newton / Build 6201 / March 20, 2014)
Sometimes we have to know SQL query hiting in DB to retrieve the list. Suppose When we are writing the DynamicQuery , Some times we have to know SQL query it is generating to hit DB. So generally it is useful when we are debugging the Query it is generated. In hibernate we used the write the property in XML file as hibernate.show.sql to view the query. In Liferay also we can also set the below property to true in the portal-ext.properties to view the SQL query at the console. hibernate.show_sql=true. By adding the above property it will just reterive the parameters. What if we want to display the parameters. Add the below properties in log4j.properties it will display the paramters also. # logs the SQL statements #log4j.logger.org.hibernate.SQL=debug # Logs the JDBC parameters passed to a query #log4j.logger.org.hibernate.type=trace In Liferay log4j is located in the below location tomcat-7.0.42\webapps\ROOT\WEB-INF\classes Also we want to see hibernate ses
In Liferay we can exceute the background task asynchrously. The Background Task framework allows the developers to create and manage any kind of tasks that need to be run in a separated thread without the need of knowing anything about JAVA threading or concurrency Here the code ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Map taskContextMap = null; String taskName = null; String servletContextNames [] = new String[1] ; Portlet portlet = PortletLocalServiceUtil.getPortletById(request.getAttribute(WebKeys.PORTLET_ID).toString()); servletContextNames[0] = portlet.getContextName(); try { BackgroundTaskLocalServiceUtil.addBackgroundTask(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), taskName, servletContextNames,TestBackgroundTaskExecutor.class, taskContextMap,new ServiceContext()); } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); }
Comments
Post a Comment