首页 > 代码库 > [Liferay] Liferay 瘦身,Liferay 精简,取消加载 Portlet

[Liferay] Liferay 瘦身,Liferay 精简,取消加载 Portlet

liferay version  :  liferay-portal-6.1.1-ce-ga2

server  : tomcat 7.0.25


Liferay是很庞大,Portal 自带几十个 Portlet, 但是完全可以自己根据需求选择性加载 Portal 自带的 Portlet。


好处就是:

1,启动速度(性能)的提升

2,界面能变得更加简洁,毕竟不需要的 Portlet 都看不到了


看着玄乎其实很简单,就以 Liferay 6.1 版本来说

1. 打开 Portal 的 liferay-portlet.xml

2. 在不需要加载的 Portlet 配置内添加 <include>false</include> 

<portlet>
	<portlet-name>16</portlet-name>
	<icon>/html/icons/currency_converter.png</icon>
	<struts-path>currency_converter</struts-path>
	<preferences-owned-by-group>false</preferences-owned-by-group>
	<use-default-template>false</use-default-template>
	<remoteable>true</remoteable>
	<private-request-attributes>false</private-request-attributes>
	<private-session-attributes>false</private-session-attributes>
	<render-weight>0</render-weight>
	<css-class-wrapper>portlet-currency-converter</css-class-wrapper>
	<include>false</include>
</portlet>


注意 <include>false</include> 在 portlet 里面的得按照规定的顺序,比如上述例子就是在 css-class-wrapper 之后

3. 重启服务看效果吧


有兴趣的可以看看 liferay-portlet.xml 的 dtd 文件 liferay-portlet-app_6_1_0.dtd

里面对 <include> 属性的介绍很详细了。


Set the include value to true to if the portlet is available to the portal. If
set to false, the portlet is not available to the portal. The default value is
true.


Portlets that are not included as part of the portal are never available to the
user to be made active or inactive. As far the user knows, the portlets do not
even exist in the system. This allows the Liferay developers to bundle a lot of
portlets in one core package, and yet allow custom deployments to turn on or off
individual portlets or sets of portlets. This follows the Siebel and Microsoft
model of bundling everything in one core package, but using XML configuration or
registry settings to turn on and off features or sets of features.


We do not recommend that custom deployers modify the core source by removing
specific portlets because this prevents an easy upgrade process in the future.
The best way to turn on and off portlets is to set the include element. The
advantage of this way of doing things is that it becomes very easy to deploy
Liferay. All features are available in one package. The disadvantage is that by
not utilizing all of the portlets, you are wasting disk space and may even take
a small but static memory footprint. However, we feel that the extra disk space
and memory usage is a cheap price to pay in order to provide an easy
installation and upgrade path.


[Liferay] Liferay 瘦身,Liferay 精简,取消加载 Portlet