LIFERAY-HOOK 开发指南
Liferay之权限

如何使用Liferay权限配置当前的Liferay权限结构是从4.0版本开始的。
jsr168中基于role的权限设计只解决了开发技术层面,并没有和实际的应用关联起来。
在Liferay中权限设计有很大的扩展,并可在多个层次进行配置。
首先要解释的是Liferay的权限模型。
首先看一下Liferay的定义A permission is defined as an action acting on a resource在Liferay中,权限作用是判断当前用户是否允许在Resource上进行某项操作(action)。
Resource代表着一个个的可操作的实体。
在Portal系统中,最直观的Resource就是一个个的Portlet。
但是由于应用的原因,在Portlet下还可以根据应用的功能再细分,最典型的就是Message Board Portlet下还分Category和Message两类Resource。
这些Resource是很直观的。
此外还存在一些特殊的Resource可以控制,比如每张Page也是Resource。
另外由于在Liferay中可以配置多个Community,每个Community都可以多次放置同一种Portlet作为多个Instance的,所以对于Resource又附加了Scope的概念。
Resource有三种Scope:Enterprise、Community和Individual。
Enterprise代表整个Portal系统中的一类资源,Community需要指明是哪个Community下的一类资源,Individual则是独立的Resource。
举个例子,我们要定义一个PermissionView+Message Board Topic / Enterprise上面的定义说明,“查看当前Portal系统中任一个Message Board的Topic”。
再举个例子Update Message Board Topic / "Developer" Community Scope上面的定义说明,“修改Developer 这个Community 下的任一个Message Board Topic ”。
Liferay 6.1开发学习转载别人的文档

原作者网址:/category/technology-share/li feray/page/2/Liferay是什么?2012年06月11日⁄ Liferay⁄ 评论数1⁄ 被围观497 views+关于LiferayLiferay是一个开源公司,我们一般谈Liferay是指的Liferay Portal。
Liferay Portal始创于2000年的洛杉机,当时是一个非营利性组织。
于2004年建立Liferay公司,今天Liferay的办事处和子公司遍及北美、德国、中国、西班牙和印度等,在全球30多个国家有建立合作伙伴帮助其扩展全球业务。
官方网站(/)Liferay于2011年第三季度发布Liferay 6.1版本,在6.1版本中添加了lifray同步实现文件共享、改善文档库、界面调整、表单和工作流设计器、增强移动设备支持等等诸多功能的完善与修改。
EE版和SE版EE版是企业版,SE版是社区版。
关于企业版和社区版的差异,在Liferay的官方网站上有详细的介绍。
简单的说就是企业版是更稳定、更可靠、有服务支持、收费的版本;社区版是免费的、没有服务支持的、代码是最新的、对稳定必及可靠性不做提供保障的。
社区版可以在Liferay的官方网站上下载到源码和编译后的运行环境等,企业版可以有30天的试用,需要付费后获取源码。
Liferay的市场地位下面对于Liferay的市场地位的评价数据来源于Gartner每年关于垂直门户产品魔力四象限的比较,数据区间为2008年到2011年的。
从以上的数据中可以看到Liferay在近几年的市场地位是逐渐上升,虽然还比不上微软、IBM、Oracle等。
但从2010年开始gartner已经将Liferay列为市场领导者(leaders)的角色里面。
Gartner对于门户产品领导者的定位如下:在此魔力象限的领导者有能力提供全方位的各种门户部署方案,并且已经证明在相当长的时间内能够提供和用户需求相一致的产品,领导者能在为客户提供满意产品的同时提供重要的产品创新,并能够将产品销售给各行业的新客户。
liferay整理文档

Liferay6.2文档作者:张娜日期:2014-01-10目录1 环境搭建 (4)1.1 开发工具 (4)1.2 打开集成Liferay Portal IDE的Eclipse (4)1.3配置Liferay-plugins-sdk (5)1.4 配置ant (6)1.5 配置tomcat (7)1.6 配置jre参数 (7)1.7启动服务 (8)2 配置数据库 (8)3 liferay使用介绍 (9)3.1 访问portal (9)3.2 添加应用 (9)3.3 管理 (10)3.3.1页面 (11)3.3.2 站点设置 (13)3.3.3 站点内容 (13)3.4 门户的基础管理 (14)3.4.1 用户和组织 (14)3.4.2 站点 (14)3.4.3 网站模板 (15)3.4.4 网页模板 (15)3.4.5 用户群组 (16)3.4.6 角色 (16)3.4.7 portal设置 (16)4 Portal架构 (17)4.1 portal和portlet的概念 (17)4.2 portal结构 (18)4.3 portal的组成架构 (19)4.4 portal应用架构 (21)4.5 Portal主要功能 (21)5 Portal标准 (22)6 liferay国际化 (23)6.1属性的国际化 (23)6.2 内容的国际化 (24)7 常用参数配置 (24)7.1 文件存储路径 (24)7.2 去掉公共页和私有页 (24)7.3 去掉用户第一次登录时的密码提示 (24)7.4 让没有权限的portlet隐藏掉 (24)7.5 上传文件大小配置 (24)7.6 liferay的登录认证形式 (25)7.7 liferay默认进入的站点 (25)7.8 event配置 (25)7.9 设置session (25)8 liferay中常用的API (26)8.1 获取HttpServletRequest (26)8.2 获取UserId、groupId、companyId (26)8.3 获取当前页面、导航的名称 (27)8.4 获取当前环境运行类型 (27)8.5 Validator验证 (27)8.6 ParamUtil (27)8.7 password (28)9 创建主题 (28)9.1主题目录 (28)9.2主题样式文件 (28)9.3主题模版文件 (29)9.4在eclipse下创建主题 (29)10 创建Layout Template (32)11 常见问题 (35)1 环境搭建1.1 开发工具1.集成Liferay Portal IDE插件的Eclipse,在线插件安装地址:/tools/ide/eclipse/indigo/stable/2.Liferay-plugins-sdk插件包,开发portlet、theme、layout、ext、hook等插件项目,下载地址:/zh/downloads/liferay-portal/available-releases3.Liferay Portal RunTime Server,本环境使用Tomcat,官方有绑定好的,下载地址:/zh/downloads/liferay-portal/available-releases4.所需软件包1.2 打开集成Liferay Portal IDE的Eclipse从官网上下载右键new项目有Liferay视图则插件安装成功1.3配置Liferay-plugins-sdk1.4 配置antAdd External JARs到liferay-portal-src-6.2.0-ce-ga1\lib\development下找到ecj.jar添加进来即可。
Hook技术入门

Hook技术⼊门参考链接——inline hook⽅式——inline hook,不是完整的代码,但是逻辑很清晰——总结了多种hook⽅式,包括主要原理和各个⽅式的优缺点——打印程序执⾏⽇志以及防⽌程序重复执⾏的应⽤——Andriod界⾯免注册跳转过程的hook,使⽤动态代理⽅式——动态代理⽅式,还有拦截通知栏、剪贴板的demo——fishhook实例1. 什么是Hook?⽤⾃⼰的话说⼀下⾃⼰的理解(不⼀定对,等之后有了更深的理解之后再做更新)Hook钩⼦,和动态插桩以及蹦床机制差不多,主要是为了能在执⾏⽬标函数或指令之前,拦截数据或者执⾏逻辑,先执⾏⾃⼰插⼊的⼀段代码,然后再执⾏原本的⽬标函数。
完成这个任务的⽅法有很多,⽐如可以将要调⽤的函数地址替换为⾃⼰的函数地址,或者在指令流中插⼊跳转指令使执⾏逻辑跳转到⾃⼰插⼊的代码块上,等等。
不过在修改了原本的数据或指令后,还需要还原以执⾏原本正常的功能,也就是说在hook时还需要保存原本的现场数据以及指令信息等。
实际上就是在原本的程序执⾏逻辑中,hook函数获得控制权,并执⾏我们⾃定义的功能,然后再将控制权返回原本的逻辑继续执⾏。
形象化可以理解为⼀条直线在向前⾛,结果⾛到了岔路上,⾛了⼀会⼉⼜回到了原本的直线⽅向继续向前。
2. Hook的应⽤场景。
Hook的应⽤⾮常⼴泛,不仅开发⼈员会⽤到,攻击者也会⽤到。
开发有:对程序的执⾏记录⽇志、防⽌应⽤重复启动等。
攻击有:使⽤hook拦截⽤户输⼊信息,获取键盘数据等。
3. Hook的技术⽅式或框架。
inline hook⽅式:⽬标函数执⾏指令中插⼊Jump跳转指令实现重定向动态代理⽅式:思路应该是类似于设计模式中的代理模式,代理原本的函数的执⾏Method Swizzle⽅式:动态改变SEL(⽅法编号)与IMP(⽅法实现)的对应关系Cydia Substrate⽅式:适⽤于iOS和andriod,定义了⼀系列的函数和宏,底层调⽤了objc的runtime和fishHook来替代⽬标函数或者系统⽅法fishHook⽅式:是Facebook提供⼀种动态修改链接Mach-O⽂件的⼯具。
liferay开发文档别人我来让大家下

liferay开发文档别人我来让大家下部门: xxx时间: xxx制作人:xxx整理范文,仅供参考,可下载自行修改这个是别人地,但是是要收财富值地,哈哈,我来给大家免费纯属个人理解,不确保全部正确,仅供新手参考.一、Liferay地安装与使用目前liferay地最新版本是liferay portal 6.0.5,下载地址:/projects/lportal/ ;这里下载地是liferay与tomcat6绑定地版本,而且自带jdk1.6,下载完后需要做以下几个步骤便可轻松跑起来liferay了.1、下载完后最好找个文件夹专门用来做liferay地工作空间,因为以后好多文件下载,这样方便管理.首先解压liferay-portal-tomcat-6.0.5.zip,解压后其目录结构如下:b5E2RGbCAPliferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/data/目录下放是liferay自带地例子<7coogs)、数据库hsql地脚本及lucene产生地文档.liferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/tomcat-6.0.26/这个就是tomcat地home目录了,里面地结构和一般地tomcat是一样地,在webapps目录中放地就是liferay portal 地应用war包了,其中ROOT是最重要地,你会发现WEB-INF/classes中没有class文件,因为它们被打成jar包放在WEB-INF/lib下了,这样效果也一样.2、liferay中自带hsql数据库,如果你要改其他数据库地话可以在liferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/tomcat-6.0.26/webapps/ROOT/WEB-INF/classes下新建一个portal-ext.properties文件,内容如下(这里用mysql当作例子>: # # MySQL # jdbc.default.driverClassName=com.mysq l.jdbc.Driver jdbc.default.url=jdbc:mysql://localhos t/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false ername=roo t jdbc.default.password=1234其他数据库配置可以参见:/community/wiki/-/wiki/Main/Database+Portal+Properties上面地配置仅仅只是liferay 6.0 之后地方法,与之前地版本还是有不同地,具体地各版本地数据库配置可以参考:/community/wiki/-/wiki/Main/Database+Configuration3、在liferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/tomcat-6.0.26/bin 目录中执行startup.bat,此时就已经启动tomcat了,一般会启动5分钟左右.启动完毕后会自动在浏览器中打开http://localhost:8080,这样你就可以开始访问liferay portal 了.p1EanqFDPw4、登录liferay Portal在打开地浏览器中,点击右上角地login,输入帐号和密码.在这里地输入地帐号密码为email:bruno@password:brunoliferay从5.2之后地版本中都带有一个7cogs.inc公司地示例数据库,所以这里地管理员帐号密码如上.如果删除示例数据库,则账号密码如下:DXDiTa9E3demail:test@password:test5、删除7cogs例子a、在tomcat/webapps下面找到目录sevencogs-hook这个目录,删除掉b、在删除与tomcat平级地data/hsql目录c、重启tomcat,这时地管理员帐号就变为test@/test6、liferay启动地时候日志信息是乱码怎么办?打开liferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/tomcat-6.0.26/conf/ 目录下地logging.properties文件,加上一句java.util.logging.ConsoleHandler.encoding = gbk ,重新启动就行了.RTCrpUDGiT二、搭建liferay地开发环境1、开发方式介绍从6.0 开始提供可eclipse可视化地插件之后就更加地友好,开发一个portlet或者一个hook都只需点点鼠标即可完成,这在官方wiki里面可以找到视频教程.在准备开发之前需要先了解“portlet规范”,然后再看liferay 6 地开发指南,之后再看下面地内容.5PCzVD7HxALiferay 6开发文档下载地址:/view/d8ab5bbd960590c69ec37682.htm ljLBHrnAILgPortlet 规范介绍文档下载地址:/view/e72aeefafab069dc50220181.htm lxHAQX74J0X首先需要下载liferay地sdk<开发环境包)、liferay ide<开发环境地插件).sdk地下载地址:/projects/lportal/files/LiferayPor tal/6.0.5/liferay-plugins-sdk-6.0.5.zip/downloadliferay ide下载地址:/projects/lportal/files/LiferayIDE /1.1.0/liferay-ide-eclipse-updatesite-1.1.0.zip/downloadLDAYtRyKfE安装此插件地时候eclipse要用3.6版本地.在自己地工作目录解压sdk包liferay-plugins-sdk-6.0.5.zip、在eclipse中安装liferay ide.解压sdk后看到其目录结构如下:有ext、hook、portlet等目录中放地是ext、hook、portlet以插件形式开发地文件.要修改一下sdk目录下build.properties文件中运行环境目录,此处使用tomcat,所以修改大约76行修改为类似下地目录地址:app.server.dir=D:/liferay/liferay-portal-6.0.3/tomcat-6.0.26以portlet为例子,里面有build.xml、build-common-portlet.xml、create.bat、create.sh、portlet.zip这5个文件,不用说build.xml、build-common-portlet.xml是ant文件应该都知道,create脚本就是新建一个插件工程,工程目录结构在portlet.zip中.但是现在有了liferay ide后就不用执行脚本创建了,而是直接用eclipse.Zzz6ZB2Ltk这里有liferay ide 地使用方法:/community/wiki/-/wiki/Main/Liferay+IDE+1.1+New+and+Noteworthy.在使用liferay ide地过程中需要配置sdk和与绑定tomcat地目录,这里就不做详细介绍了,就是路径地问题.装完ide后地图示:3、搭建完环境后新建一个liferay plugin project,可以new portlet、Hook<扩展环境)、ext<扩展环境)、theme<主题)、layout<布局)类型地。
plugins开发指南4 (续)

Liferay-plugin 开发指南--(4)简单的MVC分层结构的 portlet----核心代码开发生成好代码后,我们可以进入正是开发阶段。
首先在出版商的服务类PublisherLocalServiceImpl中添加如下的方法/*** 根据groupId查询所有的出版商*/public List<Publisher> findAllInGroup(long groupId)throws SystemException {List<Publisher> list = (List<Publisher>) PublisherUtil.findByGroupId(groupId);return list;}/*** 保存或者更新出版商。
**/public Publisher addPublisher(Publisher validPublisher)throws SystemException {// 创建出版商类Publisher publisher = PublisherUtil.create(CounterLocalServiceUtil.increment(Publisher.class.getName()));// 将具体的值设置到具体的属性中publisher.setName(validPublisher.getName());publisher.setEmailAddress(validPublisher.getEmailAddress());publisher.setWebsite(validPublisher.getWebsite());publisher.setPhoneNumber(validPublisher.getPhoneNumber());publisher.setCompanyId(validPublisher.getCompanyId());publisher.setGroupId(validPublisher.getGroupId());// 保存或更改出版商信息return PublisherUtil.update(publisher, false);}/*** 删除出版商*/public void remove(Publisher publisher) throws SystemException{PublisherUtil.remove(publisher);}增加完这些方法后,再执行一次ant命令“ant build-service” ,以便自动把实现类中新增的方法同步到接口声明中去。
Liferay Portlet指南(环境搭建)

Liferay Portlet指南(环境搭建)Liferay Portlet指南一、Liferay扩展环境搭建环境设置一、JDK 1.6.0, JDK 1.5.0 or JDK 1.4.2 1. 点击下一步安装2. 设置环境变量“JAVA_HOME”指向jikes的目录3. 增加“%JAVA_HOME%\\bin”到Path环境变量中二、Jikes 1.22 or Jikes 1.21 1. 解压缩安装包2. 设置环境变量“JIKES_HOME”指向jikes的目录3. 增加“%JIKES_HOME%\\bin”到Path环境变量中三、Ant 1.7.01. 解压缩安装包2. 设置环境变量“ANT_HOME”指向ant的目录3. 增加“%ANT _HOME%\\bin”到Path环境变量中配置扩展环境本指南所使用的liferay版本为4.2.2Step1:解压源代码将liferay源代码解压到任意目录,我们称之为${PORTAL_HOME}。
本指南中,将liferay源代码存放在目录${PORTAL_HOME}\\src下。
Step2:修改release配置文件在${PORTAL_HOME}\\src目录下找到文件release.properties,将其另存,命名为“release.${username}.properties”。
其中${username}就是当前Windows登陆的用户名,可以通过“开始菜单-》运行-》cmd.exe”后显示的默认路径看到,跟在“Documents and Settings”字样后面的就是当前登陆的用户名。
比如配置文件的名称是release.administrator.properties 。
文件的内容如下:修改lp.source.dir属性,来指定liferay源代码所在目录lp.source.dir=${PORTAL_HOME}/src修改lp.ext.dir属性,来指定liferay扩展环境放置目录lp.ext.dir=${PORTAL_HOME}/ext当然可以在源文件release.properties上修改,不过不建议这样做。
配置liferay开发环境配置说明

配置liferay开发环境说明1.准备文件(假设J2EE环境已配置好)ant部署工具:apache-ant-1.7.0-bin.zip(下面2中用)JIKES工具包:jikes-1.22-1.windows.zip(下面2中用)liferay原码包:liferay-portal-src-4.1.3.zip(下面2中用)liferay运行环境包:liferay-portal-tomcat-jdk5-4.1.3.zip(下面6中用)2.建立目录,并解压以上文件(1).在目录D:\liferay下建立目录文件夹ext和portal,apache-ant-1.7.0 jikes-1.22(2).将“ant部署工具”和“JIKES工具包”解到对应的apache-ant-1.7.0 jikes-1.22目录下(3).将原码文件liferay-portal-src-4.1.3.zip解到portal3.配置环境变量(1).ANT_HOME=D:\D:\liferay\apache-ant-1.7.0(2).JIKES_HOME=D:\liferay\jikes-1.22(3).Path=%JAVA_HOME%\bin;%JIKES_HOME%\bin;%ANT_HOME%\bin4.编译原码文件(1)在运行中用cmd进入D:\liferay\portal目录,执行ant start来编译原码(2)然后在此目录下建release.windows登录用户名.properties文件,并打开该文件写入lp.ext.dir=D:/liferay/ext设置信息后保存(3)然后在当前目录下执行命令:ant build-ext,此时在D:\liferay\ext 目录下生成文件5.进入D:\liferay\ext目录配置(1)将文件app.server.properties名称改为app.server.windows登录用户名.properties,并修改文件中的内容app.server.type=tomcat(2)将文件build.properties名称改为build.windows登录用户名.properties ,并修改内容jsp.precompile=on6.建立tomcat运行环境,并生成部署文件(1)将liferay-portal-tomcat-jdk5-4.1.3.zip运行包解压倒目录D:\liferay\ext\servers\tomcat下,准备好发布运行环境(2)在目录D:\liferay\ext\ext-web下执行ant(3)然后在D:\liferay\ext\ext-ejb下执行ant deploy,此时在该目录生成文件ext-ejb.jar包(4)将该ext-ejb.jar包拷贝到D:\liferay\ext\servers\ tomcat\ webapps\ROOT\WEB-INF\lib下,如存在就覆盖。
Liferay Portal二次开发指南

Liferay Portal二次开发指南(1)Liferay Portal二次开发指南(1)第一部分Liferay Portal架构解析本部分主要内容Portal服务器Portal容器Portlet 第一章 Liferay Portal作为一个开源Portal产品,Liferay Portal提供对多个独立系统的内容集成,帮助多个组织实现更有效的合作。
与其他商业的Portal产品相比,Liferay Portal有着一系列的优良特性,而且不需要付费。
第一节Portal规范随着Portal的兴起,越来越多的公司开始涉足Portal产品开发,并组建各自的Portal组件和基于其的产品,比如IBM、BEA、MicroSoft、SAP、Apache等。
各个厂商的接口互不兼容,给软件开发商以及开发人员带来诸多不便。
1.1.1 JSR168为此,JCP组织发布了JSR168(Java Specification Request),Portlet Specification V1.0,用来提供不同的Portal和Portlet之间的互通性。
只要开发的Portlet遵循JSR168,则就可以在所有遵循JSR168的Portal上部署运行。
JSR168中定义了Portal的实现规范和接口,并对理想的Portlet进行了详细的规划和描述。
1.1.2 WSRPWSRP是OASIS Web Service for Remote Portlet的缩写。
WSRP是Web Service的一种新的商业应用,一种新的标准,主要用来简化Portal对于各种资源或者程序整合的复杂度,可以避免编程带来的整合麻烦和问题。
而且Portal管理员可以从海量的WSRP服务中选择需要的功能用以整合到目前所用的Portal中。
它有三种角色:①、生产者 提供Portlet②、消费者→使用Portlet③、终端用户→最终用户它的特点在于生产者将消费者所需要的信息通过WSRP返回给消费者,这些信息是相对标记片断,例如HTML、XHTML等,可以直接嵌入用户的页面中,而不用像Web Service一样开发用户端接口。
Liferay Portal 4.1.2 – 快速入门指南

Liferay Portal 4.1.2 –快速入门指南Joseph ShumAlexander Chow翻译:呼吸Sohui Gu译者序本文并非完全按照英文原版逐字翻译,其中有部分内容是作者根据英文原版内容进行写作的,以便让读者更好地理解、更好地帮助读者进入Liferay Portal的世界。
希望我们的努力能给你带来帮助。
由于时间仓促,难免出错,欢迎读者给我们提出宝贵的意见,以便我们完善本文档。
另外在没有得到译者与作者允许的前提下,不得用于商用目的。
第一部分. 用户第一章. 准备开始快速入门指南是专门为初次使用Liferay Portal的用户写的,还有那些对Liferay Portal的最新版本感兴趣的人。
它的目的是尽可能快地帮助你让你的Portal启动并运行在你的机器上。
其中包含的内容有Liferay Portal游览、核心功能大纲、关键特性。
另外还有如何使用Liferay Portal 与Apache Tomcat在Microsoft Windows XP和Redhat Enterprise Linux 4上安装与设置Liferay Portal。
在此覆盖的每个主题内容在用户指南和开发者指南中有更加详细的描述。
本指南对于JSR-168 Portals的新用户、评估门户技术与了解Liferay Portal的特性的任何人来讲是一个很好的起点。
在我们开始之前,你必须在你的服务器上安装好下面的组件:1.下载并安装Java JDK1.5⏹从/j2se/1.5.0/download.jsp下载并安装Windows Platform - J2SE(TM)Development Kit 5.0 Update⏹从控制面板,进入系统→高级→环境变量⏹增加一个新的用户环境变量JAVA_HOME,并将其值设置指向你已经安装好的JavaJDK目录。
2.下载并安装Liferay Portal and Tomcat Bundle⏹在此下载并安装Liferay Portal Professional 4.1.2 ( Bundled with Tomcat and JDK5.0)[/web/guest/downloads]。
Liferay 6开发指南

Liferay 6.0开发指南1. 介绍1、已有的应用集成方法:将应用重写为一个Portlet创建一个简单的Portlet整合应用(一般使用Web Service),可以使用iframe或http 代理(可以使用Liferay's WebProxy portlet)。
已有的应用要像部署门户插件一样,把WAR文件部署到应用服务器里,可以使用控制面板或直接复制的方式完成。
Liferay可以自动创建一个Portlet通过iframe集成已有应用。
2、自定义主题风格(Themes)3、自定义布局模板(Layout Templates)4、自定义或扩展门户功能:Hook plugins)Hook plugins可以用来扩展Liferay的核心功能。
5、高级扩展方式:Ext plugins扩展插件可以允许开发人员修改Liferay的核心部分,可以修改任何一个类。
扩展插件部署之后需要重新启动应用服务器。
Liferay 6.0之后用Ext plugins的开发方式替换了原来的Ext Environment开发方式,这样可以简化部署。
之前的扩展环境可以转换为一个独立的插件。
2. 插件开发工具包(THE PLUGINS SDK)2.1 安装Liferay1、下载Liferay Portal bundled with Tomcat;/downloads2、下载Plugins SDK;3、删除liferay-portal-[version]/tomcat-[tomcatversion]/webapps 除ROOT和tunnel-web目录的其他所有文件夹。
4、打开liferayportal-[version]/tomcat-[tomcat-version]/bin目录,运行startup.bat,启动Liferay。
5、http://localhost:8080,默认帐号/密码:test@/test。
6、设置环境变量ANT_HOME,将$ANT_HOME/bin加入到PATH环境变量中。
plugins开发指南4

Liferay-plugin 开发指南--(4)简单的MVC分层结构的 portlet---service代码自动生成做完前面的几个例子后,我们再来做一个稍微复杂些的例子,在这个例子里我们要实现一个MVC结构的portlet。
首先请参考《指南1》生成一个叫mvctest的plugin工程。
建好工程后在/mvctest-portlet/docroot/WEB-INF/ 下建一个叫service.xml的xml文件。
然后把如下的内容写到这个文件中去。
<?xml version="1.0"?><!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.0.0//EN""/dtd/liferay-service-builder_6_0_0.dtd"><service-builder package-path="com.liferay.training.library"><author>Delta.j</author><namespace>MVCDEMO</namespace><!-- Define the entity for the Library_Publisher table --><entity name="Publisher" local-service="true" remote-service="false"><!-- Primary key column --><column name="publisherId" type="long" primary="true" /><!-- Foreign key columns --><column name="companyId" type="long" /><column name="groupId" type="long" /><!-- Other columns --><column name="name" type="String" /><column name="emailAddress" type="String" /><column name="website" type="String" /><column name="phoneNumber" type="String" /><!-- Sort order --><order by="asc"><order-column name="name" /></order><!-- Finder Methods --><finder name="GroupId" return-type="Collection"><finder-column name="groupId" /></finder></entity><!-- Define the entity for the Library_Book table --><entity name="Book" local-service="true" remote-service="false"><!-- Primary key column --><column name="bookId" type="long" primary="true" /><!-- Foreign key columns --><column name="companyId" type="long" /><column name="groupId" type="long" /><column name="publisherId" type="long" /><!-- Other columns --><column name="title" type="String" /><column name="authorName" type="String" /><column name="publicationDate" type="Date" /><!-- Sort order --><order by="asc"><order-column name="title" /></order><!-- Finder Methods --><finder name="GroupId" return-type="Collection"><finder-column name="groupId" /></finder></entity></service-builder>这个文件是自动生成service工程的关键,这里记录了生成service所要的一些关键元素。
c++ 程序 hook 示例

C++程序的Hook是指在程序运行时修改其行为或拦截其功能调用的一种技术。
通过Hook技术,我们可以在不修改程序源代码的情况下,对程序的行为进行动态改变,这对于程序的调试、分析以及功能拓展都具有重要的意义。
下面我们将通过一个具体的示例来讲解在C++程序中如何进行Hook操作。
1. 环境准备在进行C++程序的Hook操作前,我们需要准备好相应的开发环境。
这包括一个能够进行C++编程的集成开发环境(IDE)如Visual Studio、Eclipse等,以及一个用于程序Hook的工具库。
在本示例中,我们将使用MinHook工具库来实现Hook操作。
2. 引入MinHook工具库在你的C++项目中引入MinHook库。
你可以在GitHub上找到MinHook项目,并将其源码下载下来。
在你的项目中引入MinHook 的头文件,并信息MinHook的库文件。
在Visual Studio中,你可以在项目属性中进行相应设置。
3. 找到目标函数在进行Hook操作前,我们首先需要找到我们需要Hook的目标函数。
这可能是程序中的一个库函数,或者是一个自定义函数。
在本示例中,我们将以一个简单的自定义函数为例来进行Hook操作。
假设我们的目标函数如下:```cppint originalFunction(int arg1, int arg2) {// 原始函数的实现return arg1 + arg2;}```我们将使用Hook技术来改变这个函数的行为。
4. 实现Hook函数接下来,我们需要编写我们的Hook函数。
这个Hook函数将会替代原始函数的行为,并在其中进行一些我们自定义的操作。
在本示例中,我们将实现一个简单的Hook函数,将原始函数的返回值加倍后再返回。
```cppint hookedFunction(int arg1, int arg2) {// Hook函数的实现int result = originalFunction(arg1, arg2);return result * 2;}```5. 进行Hook操作现在,我们可以使用MinHook工具库来进行Hook操作。
plugins开发指南1

Liferay-plugin 开发指南--(1)准备工作1.进行liferay-plugin的开发首先要配置好liferay-plugins-sdk的环境。
首先从liferay官方网站上下载liferay-plugins-sdk-6.0.3 。
然后解压到一个目录中例如解压到/home/deltaj/中,进入liferay-plugins-sdk-6.0.3目录中先复制一份build.properties,然后把这份复制build.properties改名为 build.${用户名}.properties。
其中${用户名}是你登录计算机的名称。
打开这个properties文件,然后把其中所有内容清空,然后在其中输入以下2行app.server.type=tomcatapp.server.dir=/opt/liferay6u3/tomcat-6.0.26第一行是设置所使用的中间件服务器类型,第二行设置的是中间件服务器所在的位置。
2.上面的步骤都做好后,接下来要设置JDK 和 ANT 。
设置JDK,先从sun的官方网站上下载jdk的最新版本。
终端下进入你存放jdk-6u21-linux-i586.bin的位置,例如我的位置是:/home/deltaj更改文件权限为可执行$ sudo chmod u+x jdk-6u21-linux-i586.bin$ sudo -s ./jdk-6u21-linux-i586.bin一路回车,直到询问是否安装,输入yes回车ok,安装完毕,下面配置环境变量配置classpath,修改所有用户的环境变量$ sudo gedit /etc/profile在文件最后添加#set java environmentexport JAVA_HOME=/home/liangshihong/jdk1.6.0_12export JRE_HOME=/home/liangshihong/jdk1.6.0_12/jreexport CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH重新启动计算机,用命令测试jdk的版本java -version显示如下信息:成功安装java version "1.6.0_21"Java(TM) SE Runtime Environment (build 1.6.0_12-b04)Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)3.Ant的安装。
LifeRay培训讲义1-LifeRay基础

Portal简介 ----Portal的作用
一是针对跟人(网友)的应用。由于Portal的特色,企业 和网站可以很容易的将自己的服务进行标准封装,插入 Portal系统,提 供跟用户使用。现在很多门户网站和 专业网站有很多服务,但是很多服务用户根本就没有使 用过、发现过,通过Portal的形式给用户一个集中体验 的场所。 二 是针对企业,企业可以将现有的信息系统,资源通过 Portal来进行封装,提供给用户使用。比如:有些公司 有报销系统,考核系统,会议系统,但这些系统都 是彼 此分离的,使用和界面并不统一,通过Portal可以很容 易地将这些系统提供的服务封装并呈给用户使用。
20
Liferay简介 ----功能分类
Liferay具备健壮的功能体系,提供超过60多个 开箱即用的portlet ,主要分为三类:
• 门户、内容管理&WEB发布
• 协作应用(Collaboration)
• 社交应用(Social Networking)
21
Liferay简介 ----内容管理&WEB发 布
14
下图显示了Portal服务器、Portlet容器以及Portlet之间的关系。
15
Portal的组成 ---- Portal逻辑架构
Portal系统一般由Portal服 务器、支持Servlet的Java应 用服务器或Web服务器、数据 库服务器、LDAP服务器组成, 此外还可以加上身份认证和 访问控制服务器(Identity Server或Access Manager) 等。前面所说的Portlet容器 通常是打包在Portal服务器 中的。
Liferay简介 ----社交应用(Social Networking)
liferay6plugin式开发

注:在按照这篇文档的操作前请先按照我上一篇的文档《liferay6.0 plug-in 安装说明》中所介绍的按照liferay plug -in 插件的方法把插件安装到eclipse 中.安装好了插件后我们就可以进行plug in到开发了。
1.首先我们要新建一个plug in 工程。
在eclipse 中点击创建plug in工程的图标。
然后选择其中的liferay portlet plug-in project.2.在创建新的plug-in project页面中填入project name,例如firstPortlet,然后liferay sdk,和liferay runtime 都选择默认的设置,也就是我们上一节里设置的。
Plug-in type 选择plortlet。
然后点击下一步。
3.在下一步中是要选择dynamic web module version 和configuration,这里都选择默认的设置,然后点击finish,这样eclipse会自动的帮我们进行编译工程。
(如果你如果在操作过程中出现什么错误的话,可以试试把dynamic web module version 选择为2.4 )编译完成后我们就可以看到编译了一个项目。
选择new liferay portlet选项。
5.在new liferay protlet 页面中输入portlet class 名称,和java package 名,然后点击next。
6,在设置Portlet部署描述符中指定的细节页面中,可以设置,portlet的名称,显示名称,标题,还有portlet 模式,liferay portlet模式,是否要创建jsp,jsp所在的文件夹6。
设置完portlet的基本信息后就进入了设置portlet页面信息的页面,这里可以设置页面所用的css 和js等。
设置完这些我们就一路点击next,最后点击finish就完成了整个设置的过程。
plugins开发指南2

Liferay-plugin 开发指南--(2)开发一个简单的portlet本例子要做一个简单的portlet,这个portlet所要实现的功能是在edit页面中输入一个字符串并且提交,在view页面中能够显示出这个字符串。
要完成这个portlet的开发,首先要请参考《Liferay-plugin开发指南1》生成一个plugin工程。
然后打开eclipes,新建一个Dynamic web project 工程,项目的名称为hello,在project location 中取消use default location 的选项,然后在location这栏中选取1中所建的工程。
这里注意src所在的位置要改为docroot/WEB-INF/src,如下图最后content directory 中写docroot。
最后将Generate web.xml deployment descriptor 取消。
如下图生成一个名为com.tellhow.portlettest的package ,然后在该包中建一个名为TestPortle的类.这个类继承自MVCPortlet 。
这个类中有2个方法,一个是在edit页面中输入名称后点击确定所调用点方法,另外一个是展示view页面所调用的方法。
代码如下:public class TestPortlet extends MVCPortlet {/**** 点击确定所调用的方法,先从actionRequest中得到传入的参数,* 然后保存到数据库中,最后跳转到view页面。
**/@ProcessAction(name = "Persistence")public void Persistence(ActionRequest actionRequest,ActionResponse actionResponse) throws ReadOnlyException,ValidatorException, IOException, PortletModeException {// 得到portlet实例化类。
liferay-plugins-guide-4.3

L IFERAY P LUGIN D EVELOPMENT G UIDE Extending Liferay with Portlets and ThemesRichard L. Sezov, Jr.Liferay Plugin Development Guideby Richard L. Sezov, Jr.Portions reworked from the Themes document at /index.php/Themes. Please see the History tab there for author credit for this material.Copyright © 2007 by Liferay, Inc. All Rights Reserved.1. Introduction (5)W HAT IS A P ORTLET? (5)W HAT IS A T HEME? (6)2. Initial Setup (9)U SING THE P LUGINS SDK (12)3. Portlets (13)A NATOMY OF A P ORTLET P ROJECT (14)4. Themes (17)T HEME C ONCEPTS (17)A NATOMY OF A T HEME (18)J AVA S CRIPT (18)S ETTINGS (19)C OLOR S CHEMES (20)P ORTAL PREDEFINED SETTINGS (21)portlet-setup-show-borders-default (21)bullet-style-options (21)5. Deployment (23)C ONCLUSION (24)This guide is a quick start plugins development and deployment guide, using Liferay's Plugins Soft-ware Development Kit. Plugins (portlets and themes) are now the preferred way to add functionality to Liferay, as they have several benefits over using the extension environment:●Plugins can be composed of multiple smaller portlet and theme projects. This reduces the com-plexity of individual projects, allowing developers to more easily divide up project functionality●Plugins are completely separate from the Liferay core. Portlet plugins written to the JSR-168 stand-ard are deployable on any portlet container●Plugins can be hot deployed (i.e., deployed while the server is running) and are available immedi-ately. This prevents any server downtime for deploymentsThere are multiple ways to create portlet and theme plugins for Liferay. Many IDEs on the market today support portlet projects natively, and theme projects are nothing more than standard web modules with style sheets, images, and optional JavaScript and Velocity templates in them. Because of this, there are many tools which can be used to create plugins, from text editors to full blown integrated development en-vironments. If you are already familiar with such a tool, you may use that tool to create plugins.Because Liferay makes every effort to remain tool agnostic, we provide a Plugins Software Develop-ment Kit (SDK) which may be used to create both portlet and theme plugins. This SDK may be used with any text editor or IDE to create plugins for Liferay. Though it is not necessary to use this SDK to create plugins, it is the recommended method.This document will show you how to create both portlet and theme plugins using Liferay's plugin SDK. In the process, this will also show you the proper project layout for portlet and theme plugins, allow-ing you to use your own tools to create plugins if you wish to do so.What is a Portlet?Portlets are small web applications that run in a portion of a web page. The heart of any portal im-Introductionplementation is its portlets, because portlets are where the functionality of any portal resides. Liferay's core is a portlet container, and this container is only responsible for aggregating the set of portlets that are to appear on any particular page. This means that all of the features and functionality of your portal applic-ation must be in its portlets.Portlet applications, like servlet applications, have become a Java standard which various portal server vendors have implemented. The JSR-168 standard defines the portlet specification. A JSR-168 stand-ard portlet should be deployable on any JSR-168 portlet container. Portlets are placed on the page in a cer-tain order by the end user and are served up dynamically by the portal server. This means that certain “givens” that apply to servlet-based projects, such as control over URLs or access to the HttpServletRequest object, don’t apply in portlet projects, because the portal server generates these objects dynamically.Portal applications come generally in two flavors: 1) portlets can be written to provide small amounts of functionality and then aggregated by the portal server into a larger application, or 2) whole ap-plications can be written to reside in only one or a few portlet windows. The choice is up to those designing the application. The developer only has to worry about what happens inside of the portlet itself; the portal server handles building out the page as it is presented to the user.Most developers nowadays like to use certain frameworks to develop their applications, because those frameworks provide both functionality and structure to a project. For example, Struts enforces the Model-View-Controller design pattern and provides lots of functionality, such as custom tags and validating functionality, that make it easier for a developer to implement certain standard features. With Liferay, de-velopers are free to use all of the leading frameworks in the JavaEE space, including Struts, Spring, and Java Server Faces. This allows developers familiar with those frameworks to more easily implement portlets, and also facilitates the quick porting of an application using those frameworks over to a portlet implementa-tion.Additionally, Liferay allows for the consuming of PHP and Ruby applications as “portlets,” so you do not need to be a Java developer in order to take advantage of Liferay's built-in features (such as user management, communities, page building and content management). You can use the Plugins SDK to de-ploy your PHP or Ruby application as a portlet, and it will run seamlessly inside of Liferay. We have plenty of examples of this; to see them, check out the Plugins SDK from Liferay's public Subversion repository.What is a Theme?Themes are hot deployable plugins which can completely transform the look and feel of the portal. Theme creators can make themes to provide an interface that is unique to the site that the portal will serve. Themes make it possible to change the user interface so completely that it would be difficult or im-possible to tell that the site is running on Liferay.Liferay provides a well organized, modular structure to its themes. This allows the theme de-veloper to be able to quickly modify everything from the border around a portlet window to every object on the page, because all of the objects are easy to find. Additionally, theme developers do not have to custom-ize every aspect of their themes: if the plugin SDK is used, themes become only a list of differences from the6What is a Theme?Introduction default theme. This allows themes to be smaller and less cluttered with extraneous data that already exists in the default theme (such as graphics for emoticons for the message boards portlet).What is a Theme? 7Setting up the Plugins SDK is pretty straightforward. Download the archive from Liferay's Addition-al Files download page,in the section for developers here: /web/guest/downloads/additional. Unzip the file to the location in which you will be doing your work. You will see that it has the following directory structure:letsand theme plugin projects.maketheme projects in the plugins SDK requires that you have Ant 1.7.0or higher installed on your machine. Download the latest version ofAnt fromappropriate folder of your choosing.points to the folder to which you installed Ant. Use this variable toadd the binaries for Ant to your PATH by adding ANT_HOME/bin toyour PATH environment variable. Set another environment variablecalled ANT_OPTS with the proper memory settings for building pro-jects.file as follows (assuming you installed Ant inIllustration 1:Plugins SDK folderInitial SetupYou can do this on Windows by going to Start -> Control Panel, and double-clicking the System icon. Go to Advanced, and then click the Environment Variables button. Under System Variables, select New. Make the Variable Name ANT_HOME and the Variable Value the path to which you installed Ant (e.g., c:\java\apache-ant-1.7.0, and click OK.Select New again.Make the Variable Name ANT_OPTS and the Variable Value"-Xms256M -Xmx512M" and click OK.Scroll down until you find the PATH environment variable.Select it and select Edit.Add %ANT_HOME%\bin to the end or beginning of the Path. Select OK, and then select OK again. Open a com-mand prompt and type ant and press Enter. If you get a build file not found error, you have correctly in-stalled Ant. If not, check your environment variable settings and make sure they are pointing to the direct-ory to which you unzipped Ant.You will need a Liferay runtime on which to deploy your plugins to test them. We recommend us-ing the Liferay-Tomcat bundle which is available from Liferay's web site, as Tomcat is small, fast, and takes up less resources than most other containers. Download the latest Liferay-Tomcat bundle and unzip it to a folder on your machine. You can start Tomcat by navigating to the <Tomcat Home>/bin folder and running the startup command (i.e., startup.bat for Windows or ./startup.sh for Linux or Mac).You will notice that the plugins SDK contains a file called build.properties. Open this file in the text editor or IDE you will be using to create portlets and themes. At the top of the file is a message, “DO NOT EDIT THIS FILE.” This file contains the settings for where you have Liferay installed and where your deploy-ment folder is going to be, but you don't want to customize this file. Instead, create a new file in the same folder called ername.properties, where username is your user ID on your machine. For example, if your user name is jsmith (for John Smith), you would create a file called build.jsmith.properties.You will likely need to customize the following properties:10Initial SetupInitial Setup Illustration 2: The build.properties fileLiferay.auto.deploy.dir: This is the folder into which plugins should be placed in order for them tobe hot deployed to Liferay. By default, this folder is in $HOME/liferay/deploy.app.server.lib.portal.dir: This folder is where Liferay's libraries are installed. If you are us-ing the Liferay-Tomcat bundle,for example,you would set this to$ Initial Setup 11Initial Setup{app.server.dir}/webapps/ROOT/WEB-INF/lib.app.server.portal.dir: This folder is the folder to which Liferay is installed inside of your ap-plication server. For the Liferay-Tomcat bundle, set this to ${app.server.dir}/webapps/ROOT.piler: The default value for this is the Eclipse compiler, ECJ. ECJ is an alternate Javacompiler which performs very fast. If you do not have ECJ installed, the ant script will installit for you by copying ecj.jar to your Ant folder. If you do not wish to use ECJ to compile yourcode, you can set this to modern. This will cause the ant scripts in the plugins SDK to use thedefault Java compiler from your JDK.Save the file. You are now ready to start using the plugins SDK.Using the Plugins SDKThe plugins SDK can be used to house all of your portlet and theme projects enterprise-wide, or you can have separate plugins SDK projects for each of your portal projects. For example, if you have an in-ternal Intranet which uses Liferay and which has some custom written portlets for internal use, you could keep those portlets and themes in their own plugins SDK project in your source code repository. If you also have an external instance of Liferay running for your public Internet web site, you could have a separate plugins SDK with those projects (portlet and theme) in your source code repository. Or you could further separate your projects by having a different plugins SDK project for each portlet or theme project. It's really up to you.You could also use the plugins SDK as a simple cross-platform new project generator. You can gen-erate the project using the ant scripts in the plugins SDK and then copy the resulting project from the port-lets or themes folder to your IDE of choice. You would need to customize the ant script if you wish to do that, but this allows organizations which have strict standards for their Java projects to adhere to those stand-ards.12Using the Plugins SDKCreating portlets with the plugins SDK is a straightforward process. As noted before, there is a portlets folder inside of the plugins SDK folder. This is where your portlet projects will reside. To create a new portlet, first decide what its name is going to be. You need both a project name (without spaces) and a display name (which can have spaces). When you have decided on your portlet's name, you are ready to create the project. On Linux and Mac, from the portlets directory,enter the following command:type:portlets folder in your plugins SDK. This folder is your new portlet project. This is where you will be imple-menting your own functionality. At this point, if you wish, you can check your Plugins SDK into a source code repository in order to share your project with others.Alternatively, if you will not be using the Plugins SDK to house your portlet projects, you can copy your newly created portlet project into your IDE of choice and work with it there. If you do this, you may need to make sure the project references some .jar files from your Liferay installation, or you may get com-pile errors. Since the ant scripts in the Plugins SDK do this for you automatically, you don't get these errors when working with the Plugins SDK.To resolve the dependencies for portlet projects, see the class path entries in the build-common.xml file in the Plugins SDK project. You will be able to determine from the plugin.classpath and portal.classpath entries which .jar files are necessary to build your newly created portlet project.PortletsAnatomy of a Portlet Project1.Java Source2.Configuration files3.Client-side files (*.jsp, *.css, *.js, graphics, etc.)These files are stored in a standard directory structure whichdeploy ant task.The default portlet is configured as a standard JSR-168 portletIllustration 3:Portlet projectThe Java Source is stored in the docroot/WEB-INF/src folder. You necessary to implement your functionality.The Configuration Files are stored in the docroot/WEB-INF folder. The two standard JSR-168 port-let configuration files, web.xml and portlet.xml are here, as well as three Liferay-specific configuration files. These files are completely optional, but are important if your portlets are going to be deployed on a Liferay Portal server.liferay-display.xml: This file describes for Liferay what category the portlet should appear under in the Add Content window.liferay-portlet.xml: This file describes some optional Liferay-specific enhancements for JSR-168 port-lets that are installed on a Liferay Portal server. For example, you can set whether a portlet is instanceable, which means that you can place more than one instance on a page, and each portlet will have its own data. Please see the DTD for this file for further details, as there are too many settings to list here. The DTD may be found in the definitions folder in the Liferay source code.liferay-plugin-package.properties: This file describes the plugin to Liferay's hot deployer. One of the things that can be configured in this file is dependency .jars. If a portlet plugin has dependencies on partic-ular .jar files that already come with Liferay, you can specify them in this file and the hot deployer will modify the .war file on deployment so that those .jars are on the class path.Client Side Files are the .jsp, .css, and JavaScript files that you write to implement your portlet's user interface. These files should go in the docroot folder somewhere—either in the root of the folder or in a folder structure of their own. Remember that with portlets you are only dealing with a portion of the HTML document that is getting returned to the browser. Any HTML code you have in your client side files should14Anatomy of a Portlet ProjectPortletsbe free of global tags such as <html> or <head>.The default portlet project that is created is a simple JSR-168 portlet, with no bells and whistles. You can use this framework to write your code to the JSR-168 portlet API and implement all the functional-ity that you need. There are many portlets that are implemented this way. The standard portlet API is easy to use and straightforward.Many developers, however, prefer to use a particular framework when developing web applica-tions. Several frameworks, such as Struts, Spring, or Java Server Faces, make the development of web ap-plications more straightforward and easier to follow than a standard servlet implementation would be. All three of the frameworks mentioned can also be used to create portlets. Liferay has many examples of how these frameworks would be used in our public Subversion repository at SourceForge. You can grab them by checking them out of the repository or by accessing our Official Plugins page at /web/guest/downloads/official_plugins.You can also check out our Portlet Development Guide, which you can find in the same location you found this document. That guide gives you step-by-step instructions for creating portlets.Anatomy of a Portlet Project 15Creation of themes is done in a similar manner to the creation of portlets. There is a themes folder inside the plugins SDK where all new themes reside. To create a new theme, you run a command in this folder similar to the one you used to create a new portlet. For Linux and Mac, type:type:Theme ConceptsCustom themes are based on differences between the custom code and the default Liferay theme, called Classic. You will notice that there is a _diffs folder inside of your custom theme folder. This is where you will place your theme code. You only need to customize the parts of your theme that will differ from what is already displayed in the Classic theme. To do this, you mirror the directory structure of the Classic theme inside of the _diffs folder, placing only the folders and files you need to customize there.For example, to customize the Dock (a necessary component of all themes), you would copy just the dock.vm file from your Liferay installation(the Classic theme is in<Tomcat Home/webapps/ROOT/html/themes/classic) into your theme's _diffs/templates folder. You can then open this file and customize it to your liking. For example, you might want to change the welcome message to something else, like “Quick Links.”For custom styles, we recommend you create a css folder and place a single file there called custom-.css. This is where you would put all of your new styles and all of your overrides to the default Liferay styles.ThemesIt is best to do it this way because of the order in which the .css files are loaded. Custom.css is loaded last, and so anything inside this file will be guaranteed to override any styles that are in any of the other style sheets.Anatomy of a ThemeThe folders in themes are designed to be easy to navigate and understand. Currently, this is what the new directory structure looks like:/THEME_NAME//css/base.csscustom.cssmain.cssnavigation.cssforms.cssportlet.cssdeprecated.csstabs.csslayout.css/images/(many directories)/javascript/javascript.js/templates/dock.vmnavigation.vmportal_normal.vmportal_popup.vmportlet.vm/WEB-INF/META-INFtomize that portion of the theme.JavaScriptLiferay now includes the jQuery JavaScript library, and theme developers can include any plugins that jQuery supports. The $ variable, however, is not supported (for better compliance with different port-lets). Inside of the javascript.js file, you will find three different function calls, like this:jQuery(document).ready(function() {//Custom javascript goes here});Liferay.Portlet.ready(function(portletId, jQueryObj) {//Custom javascript goes here});jQuery(document).last(function() {//Custom javascript goes here});18JavaScriptThemes jQuery(document).ready(fn);When this gets passed a function (it can be a defined function, or an anonymous one like above), the function gets executed as soon as the HTML in the page has finished loading (minus any portlets loaded via ajax).Liferay.Portlet.ready(fn);When this gets passed a function (it can be a defined function, or an anonymous one like above), the function gets executed after each portlet has loaded. The function that gets executed receives two variables,portletId and jQueryObj.portletId is the id of the current portlet that has loaded, and jQueryObj is the jQuery object of the current portlet element.jQuery(document).last(fn);When this gets passed a function (it can be a defined function, or an anonymous one like above), the function gets executed after everything—including AJAX portlets—gets loaded onto the page.Besides theme-wide JavaScript there is also support for page specific JavaScript. The Page Settings form provides three separate JavaScript pieces that you can insert anywhere in your theme. Use the follow-ing to include the code from these settings:means that each field can only have one line of text. For multi-line scripts, the newlines should be escaped using \, just as in a normal .properties file.SettingsEach theme can define a set of settings to make it configurable.The settings are defined in the liferay-look-and-feel.xml using the following syntax:in the header. One of the themes has more details while the other is smaller (and takes less screen real es-tate). Instead of creating two different themes, we are going to create only one and use a setting to choose which header we want.While developing the theme we get to the header. In the portal_normal.vm template we write:Settings 19Themessame theme but have a different value for the header-type setting:<theme id="beauty1" name="Beauty 1"><root-path>/html/themes/beauty</root-path><templates-path>${root-path}/templates</templates-path><images-path>${root-path}/images</images-path><template-extension>vm</template-extension><settings><setting key="header-type" value="detailed" /></settings><color-scheme id="01" name="Blue"><css-class>blue</css-class><color-scheme-images-path>${images-path}/color_schemes/${css-class}</color-scheme-im-ages-path></color-scheme>...</theme><theme id="beauty2" name="Beauty 2"><root-path>/html/themes/beauty</root-path><templates-path>${root-path}/templates</templates-path><images-path>${root-path}/images</images-path><template-extension>vm</template-extension><settings><setting key="header-type" value="brief" /></settings><color-scheme id="01" name="Blue"><css-class>blue</css-class><color-scheme-images-path>${images-path}/color_schemes/${css-class}</color-scheme-im-ages-path></color-scheme>...</theme>Color SchemesColor schemes are specified using a CSS class name, with which you can not only change colors, but also choose different background images, different border colors, and so on.In your liferay-look-and-feel.xml (located in WEB-INF), you would specify the class names like so:<theme id="my_theme" name="My Theme"><root-path>/my_theme</root-path><templates-path>${root-path}/templates</templates-path><images-path>${root-path}/images</images-path><template-extension>vm</template-extension><color-scheme id="01" name="Blue"><css-class>blue</css-class><color-scheme-images-path>${images-path}/color_schemes/${css-class}</color-scheme-images-path></color-scheme><color-scheme id="02" name="Green"><css-class>green</css-class></color-scheme></theme>20Color SchemesThemes for each of your color schemes. In the case above, we would could either have just one called green.css and let the default styling handle the first color scheme, or you could have both blue.css and green.css.Now, inside of your custom.css, you would place the following lines:css styles like this:Portal predefined settingsThe portal defines some settings that allow the theme to determine certain behaviors. So far there are only two predefined settings but this number may grow in the future.portlet-setup-show-borders-defaultIf set to false, the portal will turn off borders by default for all the portlets.The default is true.Example:•liferay-portlet.xml•Portlet CSS popup settingbullet-style-optionsThe value must be a comma separated list of valid bullet styles to be used. The default is an empty list. The navigation portlet will not show any option in the portlet configuration screen.Example:this pattern:Portal predefined settings 21Themescase the bullet style option is cool:type of menu.For further information about themes, please see .22bullet-style-optionsYou will notice that when your project was created in the Plugins SDK, an ant script was also cre-ated for it. To deploy a plugin, you run the deploy ant task in your project. This task will compile your plu-gin (theme or portlet), store it in a dist folder, and deploy your plugin to your local Liferay installation.This is done by copying the plugin .war file to your Liferay hot deploy folder. If your local installa-tion of Liferay is running, your plugin will be automatically picked up by the server and deployed. Watch your Liferay console for messages. When you seeIf your plugin is a portlet, you can add it to a page by hovering over the Dock and clicking Add Con-tent. Find your portlet in the category you specified in your liferay-display.xml file. If you have not yet cus-tomized the file, your portlet will be in the Samples category. Simply click the Add button next to it to add it to the page you are currently viewing.If your Liferay installation is running in debug mode inside of your IDE, you can set breakpoints in your code and your debugger will stop the execution of the portlet in the specified place so you can step through the code. If you find a problem, fix the problem and then run the deploy ant task again to redeploy your portlet to the server for further testing.If your plugin is a theme, you can choose it for the page you are viewing by hovering over the Dock and clicking Page Settings. Go to the Look and Feel tab and your theme should be in the list. Select it and it will be applied to the page you are viewing. You can then click the Go back to full view link and see your theme applied to the full page.When you are finished implementing your features and debugging your code, create a final build for it by running the deploy ant task again. The plugin will reside in a dist folder in the project folder. You can then take the .war file stored there and deploy it to any running Liferay portal. All that is necessary for this is to copy the file into the hot deploy folder defined for the Liferay portal server. The file can also beDeploymentuploaded to a server housing a Liferay Software Catalog. Your portal administrator can then point the Plu-gin Installer portlet to this software catalog and through a simple point and click interface install any plu-gins that the development team makes available on their Software Catalog. For more information on how to configure this, please see the Liferay Administration Guide.ConclusionYou can see that the Plugins SDK provides a full development lifecycle for both portlet projects and theme projects. It is tool-agnostic, so developers are free to use the tools of their choice to create port-let projects and theme projects. It provides a method to create and deploy theme projects and portlet pro-jects with little effort and which supports the majority of application server platforms. And finally, it provides a structure to group the portlets and themes that go together with an overall portal project. We hope that you will enjoy using the Plugins SDK and that it will be a useful tool for you to create your port-lets and your themes.And remember, if you create open source portlets and themes, you can make them available on Liferay's community Software Catalog (/web/guest/community/community_plu-gins).Happy coding!24Conclusion。
installguide

Liferay Portal-Installation andConfigurationLiferay Portal-Installation and ConfigurationTable of Contents1.Application Servers (1)Geronimo1.1with Tomcat (1)JBoss4.04with Jetty (2)JBoss4.04with Tomcat (5)Jetty5.1.1 (8)Tomcat5.5.17 (10)Resin3.0.19 (13)Websphere6.0.2.5 (14)Installation (14)Set Up Database Service (15)Mail Configuration (19)Install Liferay (23)Start Liferay Portal (28)2.Special Cases (30)Using Oracle9and10Database (30)List of Tables1.1 (18)Chapter1.Application ServersThis document is the expert installation and configuration guide to install Liferay Portal4.x on top of supported ap-plication servers.For easy installation with Liferay bundled with an application server,please refer to Chapter1: Getting Started[/4.0.0/docs/quickstart/ch01.html]of the Quick Start Guide.Please note that this documentation will be using MySQL as the database.To use other databases,please subsitute that database JDBC driver and configure accordingly.Consult the Database section of the developers guide or your Database Ad-ministrator for more details.Geronimo1.1with Tomcat1.Download and install Geronimo/Tomcat[/downloads.html]into your preferred dir-ectory.From now on,the directory where you installed Gernonimo will be referred to as$GERONIMO_HOME.2.Download and install JDK5[/javaee/downloads/index.jsp].Set an environment variablecalled%JAVA_HOME%to point to your JDK directory.3.Download MySQL from []and install.4.Download liferay-portal-4.1.x.war[/web/guest/downloads].5.Download portal-kernal.jar from liferay Portal4.1.x Dependencies[/web/guest/downloads].6.Populate your database with the portal schema and default data.a.Download script create-mysql.sql from Liferay Portal4.1.0SQL Scripts[/web/guest/downloads].b.In command prompt,run mysql script by entering mysql<create-mysql.sql.7.Edit$GERONIMO_HOME\bin\geronimo.batinsert at line219:set JAVA_OPTS=-Xms128m-Xmx512m-Dfile.encoding=UTF8-Duser.timezone=GMT 8.Point browser to localhost:8080/console to enter Administration Console.•Login in as User:system and Password:manager9.Click Common Libs under Services.•Click Browse,find portal-kernal.jar and add•Group:Liferay•Artifact:Portal-kernel•Version:enter version number of jar•Type:Jar•Click Install???10.Click Database Pools under Services•Click Using the Geronimo database pool wizard•Name of Database Pool:LiferayPool•Database Type:MySql•Click Next•Driver Jar:click Download a Driver and select MySQL Connector/J3.0.17•Click Next•DB User Name:<none>•DB Password:<none>•Port:3306(default)•Host:localhost•Database:lportal•Click Next•Click Test Connection•Click Deploy11.Click Deploy New under Applications•Archive:Browse for lieray-portal-4.x.war•Click Install12.Click Web App WARs•Uninstall geronimo/welcome-tomcat/1.1/car•Start-default/liferayportal/xxxxxxx.../war13.Open your browser to http://localhost:8080.Click on My Liferay at the upper right hand corner to enter the lo-gin screen.Your login is test@ and your password is test.JBoss4.04with Jetty1.Download and install JBoss AS[/portal/jbossas]into your preferred directory.From nowon,the directory where you installed Tomcat will be referred to as$JBOSS_HOME.2.Download and install JDK5[/javaee/downloads/index.jsp].Set an environment variablecalled%JAVA_HOME%to point to your JDK directory.3.Download MySQL from []and install.4.Download liferay-portal-4.x.ear[/web/guest/downloads].5.Edit$JBOSS_HOME/server/default/conf/jboss-service.xml:<classpath codebase="${jboss.server.lib.url:lib}/ext"archives="*"/>6.Create directory$JBOSS_HOME/directory/server/default/deploy/jbossweb-jetty.sar.Download jetty-5.1.4-jboss-4.0.2.sar[/project/showfiles.php?group_id=7322&package_id=132 252]and unzip to directory.7.Remove$JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar.8.Remove$JBOSS_HOME/server/default/deploy/management.9.Create file$JBOSS_HOME/server/default/deploy/liferay-ds.xml with following content:<?xml version="1.0"?><datasources><local-tx-datasource><jndi-name>jdbc/LiferayPool</jndi-name><connection-url>jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8 </connection-url><driver-class>com.mysql.jdbc.Driver</driver-class><user-name></user-name><password></password><min-pool-size>0</min-pool-size></local-tx-datasource></datasources>10.Go to$JBOSS_HOME/server/default/lib/and create new directory ext.Download mysql-con-nector-java-{$version}-bin.jar[/products/connector/j/]and copy to this directory.(This is the JDBC connector for MySQL,for other databases,go to appropriate website to download.)11.Populate your database with the portal schema and default data.a.Download script create-mysql.sql from Liferay Portal4.1.0SQL Scripts[/web/guest/downloads].b.In command prompt,run mysql script by entering mysql<create-mysql.sql.12.Download portlet.jar and portal-kernel.jar from liferay Portal4.1.0Dependencies[/web/guest/downloads].a.Copy to$JBOSS_HOME/server/default/lib/ext.13.Set mail properties by replacing the contents of$JBOSS_HOME/server/default/deploy/mail-service.xml with:<?xml version="1.0"?><server><mbean code="org.jboss.mail.MailService"name="jboss:service=MailSession"><attribute name="JNDIName">mail/MailSession</attribute><attribute name="User">nobody</attribute><attribute name="Password">password</attribute><attribute name="Configuration"><configuration><property name="mail.store.protocol"value="imap"/><property name="mail.transport.protocol"value="smtp"/><property name="mail.imap.host"value="localhost"/><property name="mail.pop3.host"value="localhost"/><property name="mail.smtp.host"value="localhost"/></configuration></attribute></mbean></server>14.Configure JAAS.Edit$JBOSS_HOME/server/default/conf/login-config.xml and commentout the entire XML for policy'other'in lines140-156.<!--<application-policy name="other">-->...<!--<authentication><login-module code="ersRolesLoginModule"flag="required"/></authentication></application-policy>-->15.Deploy liferay-portal-4.x.ear.a.Create directory$JBOSS_HOME/server/default/deploy/liferay-portal.earb.Unzip liferay-portal-4.x.ear to directoryc.Go to JBOSS_HOME/server/default/deploy/liferay-portal.ear/libi.Move dom4j.jar,jaxen.jar to JBOSS_HOME/libii.Move commons-collections.jar to JBOSS_HOME/server/default/libiii.Remove hibernate3.jar,jboss-hibernate.jar fromJBOSS_HOME/server/default/lib16.Edit$JBOSS_HOME/server/default/deploy/jbossjca-service.xml:Change Debug attribute in line63from true to false:<attribute name="Debug">false</attribute>17.In$JBOSS/server/default/deploy/jbossws14.sar/META-INF/jboss-service.xmlComment out deployer service for JSE and EJB2.1endpointsline36-40<!--<mbean name="jboss.ws:service=WebServiceDeployerJSE"code="org.jboss.ws.server.WebServiceDeployerJSE"><depends-list optional-attribute-name="Interceptables"> <depends-list-element>jboss.web:service=WebServer</depends-list-element></depends-list></mbean>-->lines45-49<!--<mbean name="jboss.ws:service=WebServiceDeployerEJB21"code="org.jboss.ws.server.WebServiceDeployerEJB21"><depends-list optional-attribute-name="Interceptables"> <depends-list-element>jboss.ejb:service=EJBDeployer</depends-list-element> </depends-list></mbean>-->lines72-75<!--<mbean name="jboss.ws:service=WebServiceDeployerNestedJSE"code="org.jboss.ws.server.WebServiceDeployerNestedJSE"><depends optional-attribute-name="MainDeployer"proxy-type="attribute">jboss.system:service=MainDeployer</depends> <depends>jboss.ws:service=WebServiceDeployerJSE</depends> </mbean>-->18.Edit$JBOSS_HOME/server/default/deploy/jms/jbossmq-destinations-service.xml.Clear out text between server tags:<?xml version="1.0"?><server></server>19.Start JBoss.Open your browser to http://localhost:8080.Click on My Liferay at the upper right hand corner toenter the login screen.Your login is test@ and your password is test.JBoss4.04with Tomcat1.Download and install JBoss AS[/portal/]into your preferred directory.From now on,thedirectory where you installed Tomcat will be referred to as$JBOSS_HOME.2.Download and install JDK5[/javaee/downloads/index.jsp].Set an environment variablecalled%JAVA_HOME%to point to your JDK directory.3.Download MySQL from []and install.4.Download liferay-portal-4.x.ear[/web/guest/downloads].5.Edit$JBOSS_HOME/server/default/conf/jboss-service.xml:<classpath codebase="${jboss.server.lib.url:lib}/ext"archives="*"/>6.Delete$JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/ROOT.war.7.Edit$JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/conf/web.xml:replace default servlet(lines79-91):<servlet><servlet-name>default</servlet-name><servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> <init-param><param-name>debug</param-name><param-value>0</param-value></init-param><init-param><param-name>listings</param-name><param-value>true</param-value></init-param><load-on-startup>1</load-on-startup></servlet>with:<servlet><servlet-name>default</servlet-name><servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class> <init-param><param-name>debug</param-name><param-value>0</param-value></init-param><init-param><param-name>listings</param-name><param-value>false</param-value></init-param><init-param><param-name>input</param-name><param-value>4096</param-value></init-param><init-param><param-name>output</param-name><param-value>4096</param-value></init-param><load-on-startup>1</load-on-startup></servlet>8.Create$JBOSS_HOME/server/default/deploy/liferay-ds.xml with following con-tent:<datasources><local-tx-datasource><jndi-name>jdbc/LiferayPool</jndi-name><connection-url>jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8 </connection-url><driver-class>com.mysql.jdbc.Driver</driver-class><user-name></user-name><password></password><min-pool-size>0</min-pool-size></local-tx-datasource></datasources>9.Go to$JBOSS_HOME/server/default/lib/and create new directory ext.Download mysql-con-nector-java-{$version}-bin.jar[/products/connector/j/]and copy to this directory.(This is the JDBC connector for MySQL,for other databases,go to appropriate website to download.)10.Populate your database with the portal schema and defult data.a.Download script create-mysql.sql from Liferay Portal4.x SQL Scripts[/web/guest/downloads].b.In command prompt,run mysql script by entering mysql<create-mysql.sql.11.Download portlet.jar and portal-kernel.jar from liferay Portal4.x Dependencies[/web/guest/downloads].a.Copy to$JBOSS_HOME/server/default/lib/ext.12.Set mail properties by replacing the contents of$JBOSS_HOME/server/default/deploy/mail-service.xml with:<?xml version="1.0"?><server><mbean code="org.jboss.mail.MailService"name="jboss:service=MailSession"><attribute name="JNDIName">mail/MailSession</attribute><attribute name="User">nobody</attribute><attribute name="Password">password</attribute><attribute name="Configuration"><configuration><property name="mail.store.protocol"value="imap"/><property name="mail.transport.protocol"value="smtp"/><property name="mail.imap.host"value="localhost"/><property name="mail.pop3.host"value="localhost"/><property name="mail.smtp.host"value="localhost"/></configuration></attribute></mbean></server>13.Configure JAAS.Edit$JBOSS_HOME/server/default/conf/login-config.xml and commentout the entire XML for policy other in lines140-156.<!--<application-policy name="other">-->...<!--<authentication><login-module code="ersRolesLoginModule"flag="required"/></authentication></application-policy>-->14.Deploy liferay-portal-4.x.ear.a.create new directory$JBOSS_HOME/server/default/deploy/liferay-portal.earb.unzip liferay-portal-4.x.ear to directoryc.go into$JBOSS_HOME/server/default/deploy/liferay-portal.ear/lib•move dom4j.jar,jaxen.jar to JBOSS_HOME/lib•move commons-collections.jar goes to JBOSS_HOME/server/default/lib•remove hibernate3.jar,jboss-hibernate.jar from JBOSS_HOME/server/default/lib15.Edit JBOSS_HOME/server/default/deploy/jbossjca-service.xml:change Debug attribute in line63from true to false:<attribute name="Debug">false</attribute>16.Edit JBOSS_HOME/server/default/deploy/jms/jbossmq-destinations-service.xml.Clear out text between servertags:<?xml version="1.0"?><server></server>17.Start JBoss.Open your browser to http://localhost:8080.Click on My Liferay at the upper right hand corner toenter the login screen.Your login is test@ and your password is test.Jetty5.1.11.Download and install JDK1.4or1.5[/javaee/].Set an environment variable called%JAVA_HOME%to point to your JDK directory.2.Download MySQL from []and install.3.Download and install Jetty5.1.11[/jetty/index.html].Note:Only this version of Jetty issupported by Liferay.Others may work but will not be covered in this documentation.From now on the home directory where you installed Jetty will be called$JETTY_HOME.4.Download liferay-portal-pro-4.1.0.war[/web/guest/downloads].5.Download portlet.jar and portal-kernel.jar from liferay Portal4.x Dependencies[/web/guest/downloads].a.Create a$JETTY_HOME/lib/ext directory and copy these two files there.If the files do not extract to thisdirectory,make sure they are in the correct directory by moving them there.6.Populate your database with the portal schema and default data.a.Download script create-mysql.sql from Liferay Portal4.x SQL Scripts[/web/guest/downloads]b.In command prompt,run mysql script by entering mysql<create-mysql.sql7.Edit$JETTY_HOME/extra/etc/start-plus.config.$(jetty.home)/lib/ext/$(jetty.home)/lib/ext/*8.Create a data source bound to jdbc/LiferayPool by editing$JETTY_HOME/etc/jetty.xml.<Call name="addService"><Arg><New class="org.mortbay.jetty.plus.JotmService"><Set name="Name">TransactionMgr</Set><Call name="addDataSource"><Arg>jdbc/LiferayPool</Arg><Arg><Newclass="org.enhydra.jdbc.standard.StandardXADataSource"><Set name="DriverName">com.mysql.jdbc.Driver</Set><Setname="Url">jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8</<Set name="User"></Set><Set name="Password"></Set></New></Arg><Arg><Newclass="org.enhydra.jdbc.pool.StandardXAPoolDataSource"><Arg type="Integer">4</Arg><Set name="MinSize">4</Set><Set name="MaxSize">15</Set></New></Arg></Call></New></Arg></Call>9.Download mysql-connector-java-{$version}-bin.jar[/products/connector/j/]and copy toto$JETTY_HOME/lib/ext..(This is the JDBC connector for MySQL,for other databases,go to appropri-ate website to download.)10.Create a mail session bound to mail/MailSession.a.Edit$JETTY_HOME/etc/jetty.xml and configure a mail session.<Call name="addService"><Arg><Newclass="org.mortbay.jetty.plus.MailService"><Set name="Name">MailService</Set><Set name="JNDI">mail/MailSession</Set><Putname="mail.smtp.host">localhost</Put></New></Arg></Call>11.Create$JETTY_HOME/etc/jaas.config.PortalRealm{com.liferay.portal.kernel.security.jaas.PortalLoginModulerequired;};12.Create directory$JETTY_HOME/webapps/root and unpack liferay-portal-pro-4.x.war.13.Go to$JETTY_HOME/webapps/root/WEB-INF/lib and delete xercesImpl.jar andxml-apis.jar.14.Copy$JETTY_HOME/webapps/root/WEB-INF/lib/commons-logging.jar toJETTY_HOME/ext(overwriting existing one).15.Create batch file.a.Create a directory$JETTY_HOME/binb.Create run.bat(Note,this is for Windows platform.For other platforms,configure accordingly)@echo offif""=="%JAVA_HOME%"goto errorJavaHome%JAVA_HOME%/bin/java-Xmx512m-Dfile.encoding=UTF8-Duser.timezone=GMT-Djava.security.auth.login.config=../etc/jaas.config-DSTART=../extra/etc/start-plus.config-jar../start.jar../etc/jetty.xml goto end:errorJavaHomeecho JAVA_HOME not defined.goto end:endNote:If you get a ng.OutOfMemoryError exception while starting up Jetty,give your JVM morememory by setting-Xmx512m.16.Start Liferay by running run.bat.Open your browser to http://localhost:8080.Click on My Liferay at the upperright hand corner to enter the login screen.Your login is test@ and your password is test. Tomcat5.5.171.Download and install Tomcat5.5.17[/]into your preferred directory.From now on,thedirectory where you installed Tomcat will be referred to as$TOMCAT_HOME.2.Download and install JDK5[/javaee/downloads/index.jsp].Set an environment variablecalled%JAVA_HOME%to point to your JDK directory.Note:If you are using JDK1.4,you must download and install the JDK1.4Compatability Package at tom-cat.apache.For JDK1.4users:delete$TOMCAT_HOME/webapps/ROOT/WEB-INF/lib/xercesImpl.jar.For JDK5users:move$TOMCAT_HOME/webapps/ROOT/WEB-INF/lib/xercesImpl.jar to TOM-CAT_HOME/common/endorsed.3.Download MySQL from []and install.4.Create and edit$TOMCAT_HOME/conf/Catalina/localhost/ROOT.xml to set up the portal web ap-plication.<Context path=""></Context>5.Download liferay-portal-pro-4.x.war[/web/guest/downloads].6.Download portlet.jar and portal-kernel.jar from liferay Portal4.x Dependencies[/web/guest/downloads].a.Create a$TOMCAT_HOME/common/lib/ext directory and copy these two files there.If the files donot extract to this directory,make sure they are in the correct directory by moving them there.7.Edit$TOMCAT_HOME/conf/catalina.properties.common.loader=${catalina.home}/common/classes,\...\${catalina.home}/common/lib/ext/*.jar8.Configure data sources for your database.Make sure the JDBC driver for your database is accessible by Tom-cat.a.Download mysql-connector-java-{$version}-bin.jar[/products/connector/j/].(Thisis the JDBC connector for MySQL,for other databases,go to appropriate website to download.)b.Copy to$TOMCAT_HOME/common/lib/ext.9.Edit$TOMCAT_HOME/conf/Catalina/localhost/ROOT.xml.<Context...><Resourcename="jdbc/LiferayPool"auth="Container"type="javax.sql.DataSource"driverClassName="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8"username=""password=""maxActive="100"maxIdle="30"maxWait="10000"/></Context>10.Populate your database with the portal schema and default data.a.Download script create-mysql.sql from Liferay Portal4.x SQL Scripts[/web/guest/downloads].b.In command prompt,run mysql script by entering mysql<create-mysql.sql11.Create a mail session bound to mail/MailSession.Edit$TOMCAT_HOME/conf/Catalina/localhost/ROOT.xml and configure a mail session.<Context...><Resourcename="mail/MailSession"auth="Container"type="javax.mail.Session"mail.transport.protocol="smtp"mail.smtp.host="localhost"/></Context>12.Configure JAAS.Edit$TOMCAT_HOME/conf/Catalina/localhost/ROOT.xml and configure a security realm.<Context...><RealmclassName="org.apache.catalina.realm.JAASRealm"appName="PortalRealm"userClassNames="com.liferay.portal.security.jaas.PortalPrincipal"roleClassNames="com.liferay.portal.security.jaas.PortalRole"debug="99"useContextClassLoader="false"/></Context>13.Repeat this step for a file called$TOMCAT_HOME/conf/Catalina/localhost/tunnel.xml if youwant to enable Liferay's HTTP tunneling.14.Create$TOMCAT_HOME/conf/jaas.config.PortalRealm{com.liferay.portal.kernel.security.jaas.PortalLoginModule required;};15.Edit$TOMCAT_HOME/bin/catalina.bat so that Tomcat can reference the login module.rem-----Execute...set JAVA_OPTS=-Xms128m-Xmx512m-Dfile.encoding=UTF8-Duser.timezone=GMT -Djava.security.auth.login.config=%CATALINA_HOME%/conf/jaas.config16.Delete contents$TOMCAT_HOME/webapps/ROOT directory.17.Unpack liferay-portal-pro-4.x.war to$TOMCAT_HOME/webapps/ROOT.18.For supporting UTF-8UIRIEncoding,edit$TOMCAT_HOME/conf/server.xml.<!--Define a non-SSL HTTP/1.1Connector on port8080--><Connector port="8080"maxHttpHeaderSize="8192"maxThreads="150"minSpareThreads="25"maxSpareThreads="75"enableLookups="false"redirectPort="8443"acceptCount="100"connectionTimeout="20000"disableUploadTimeout="true"URIEncoding="UTF-8"/>19.Run Tomcat,point browser to http://localhost:8080.Sign in as test@ and password testResin3.0.191.Download and install Resin[/]into your preferred directory.From now on,the direct-ory where you installed Resin will be referred to as$JBOSS_HOME.2.Download and install JDK5[/javaee/downloads/index.jsp].Set an environment variablecalled%JAVA_HOME%to point to your JDK directory.3.Download MySQL from []and install.4.Edit$RESIN_HOME/conf/resin.conf.replace lines60-64<class-loader><tree-loader path="${resin.home}/lib"/><tree-loader path="${server.root}/lib"/></class-loader>with<class-loader><tree-loader path="${resin.home}/lib"/><tree-loader path="${server.root}/lib"/><compiling-loader path="${server.rootDir}/common/classes"/><library-loader path="${server.rootDir}/common/lib"/></class-loader>add:<database><jndi-name>jdbc/LiferayPool</jndi-name><driver type="com.mysql.jdbc.Driver"><url>jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8</url><user></user><password></password></driver><prepared-statement-cache-size>8</prepared-statement-cache-size><max-connections>20</max-connections><max-idle-time>30s</max-idle-time></database><resource jndi-name="mail/MailSession"type="javax.mail.Session"><init><mail.store.protocol>imap</mail.store.protocol> <mail.transport.protocol>smtp</mail.transport.protocol><mail.imap.host>localhost</mail.imap.host><mail.pop3.host>localhost</mail.pop3.host><mail.smtp.host>localhost</mail.smtp.host></init></resource><system-propertyjavax.xml.parsers.DocumentBuilderFactory="org.apache.xerces.jaxp.DocumentBuilderFactory /><system-propertyjavax.xml.parsers.SAXParserFactory="org.apache.xerces.jaxp.SAXParserFactoryImpl"/><system-propertyjavax.xml.transform.TransformerFactory="org.apache.xalan.processor.TransformerFactoryIm /><system-propertyorg.xml.sax.driver="org.apache.xerces.parsers.SAXParser"/>5.Go to$RESIN_HOME and create new directory common\lib.Download mysql-connect-or-java-{$version}-bin[/products/connector/j/].jar and copy to this direct-ory.(This is the JDBC connector for MySQL,for other databases,go to appropriate website to download.)6.Populate your database with the portal schema and default data.a.Download script create-mysql.sql from Liferay Portal4.1SQL Scripts[/web/guest/downloads].b.In command prompt,run mysql script by entering mysql<create-mysql.sql.7.Download portlet.jar and portal-kernel.jar from Liferay Portal4.1Dependencies[/web/guest/downloads]and copy to$RESIN_HOME\common\lib.8.Delete contents of$RESIN_HOME\webapps\ROOT.9.Unzip liferay-portal-pro-4.x.war to$RESIN_HOME\webapps\ROOT.10.Download liferay-portal-ent-4.0.0-src.zip.a.Go to$\lib\development\and copy activation.jar and mail.jar to$RESIN_HOME\common\lib,saxpath.jar and xalan.jar to$RESIN_HOME\libb.Go to$\lib\portal and copy xercesImpl.jar and xml-apis.jar to$RESIN_HOME\lib11.Go to$RESIN_HOME\bin and create run.bat...\httpd.exe-Xmx512m-Dfile.encoding=UTF-8-Duser.timezone=GMT12.Start Resin.Open your browser to http://localhost:8080.Click on My Liferay at the upper right hand corner toenter the login screen.Your login is test@ and your password is test.Websphere6.0.2.5Note:Throughout this installation and configuration process,Websphere will prompt you to Click Save to applychanges to Master Configuration.Do so intermittently to save your changes.Installation1.Download Liferay Portal Professional4.1.0WAR,unzip and compile.2.Install IBM Websphere.3.Install MySql.4.Download and extract these liferay jars to websphere\appserver\lib\ext.。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
LIFERAY HOOK 开发步骤备注:适用版本号完全相同的IDE,SDK,否则会报错。
一、Liferay提供hook的目的是减少二次开发的代码与liferay核心工程的耦合,通过hook我们主要可以主要做以下六件事情:1、覆盖事件处理程序:如程序启动事件(application.startup.events)、登录注销事件(login.events.pre、login.events.post)、session的创建销毁事件等。
2、语言包:比如对liferay的某些翻译不满意,需要自定义,则可以使用hook 覆盖liferay的语言包。
3、liferay工程的portlet JSP内容:比如想在顶部的top_bar里面添加内容、想修改liferay的用户编辑界面、想修改用户登录界面等等。
4、覆盖portal.properties里面的属性配置:可以在hook工程里面覆盖一些liferay的portal.properties 里面属性配置,但是请注意,在hook工程里面只能覆盖部分的属性设置。
不能覆盖的如果需要可以在root/WEB-INF/classes 里面添加 portal-ext.properties,这个同可以覆盖所有的。
5、覆盖liferay的services里面的方法,如UserLocalService、GroupLocalService、OrganizationLocalService等等。
6、Liferay的Model监听程序,比如user、group、blog等的创建、更新、查看;插件的部署;集群的消息传递等等监听程序。
二、创建一个HOOK 工程1、在liferay IDE中,New Liferay Project-->选择hook-->输入project Name,点击完成,即可创建一个hook工程。
2、在IDE的工具条中,选择New Liferay hook,选择我们要创建的hook类型,如下图:三、重写或者覆盖JSP 页面1、在liferay IDE中,New Liferay Project-->选择hook-->输入project Name,点击完成,即可创建一个hook工程。
2、在IDE的工具条中,选择New Liferay hook,选择我们要创建的hook类型,如下图:custom JSp:为自定义的JSP文件portal properties:覆盖portal属性Services:这个可以可以做两件事情一是覆盖事件处理程序;二是覆盖service 类Lanuage properties:这个覆盖或者新增国际化的语言文件。
3、点击下一步,进入Create Custom JSPs 页面,在这个页面,可以通过add from liferay按钮来选择需要重写的JSP 文件如图这里选择terms_of_use.jsp 文件,该文件是用户协议界面可以在该文件中做想要的内容修改4、修改完成后重新发布一下,使用一个新创建的账号登陆,在用户协议界面就可以看到刚刚修改的效果了5、此时可以在源文件liferay-portal-[version]/tomcat-[tomcat-version]/webapps/ROOT/html/portal 目录下看到2 个文件,一个是terms_of_use.jsp ,另一个是terms_of_use.properties.jsp 文件,后者是修改之前的文件,前者是修改之后的文件6、如果想要修改后的文件包含修改之前的文件,可以在terms_of_use.jsp中添加<liferay-util:buffer var="html"><liferay-util:include page="/html/portlet/blogs/search.portal.jsp" />//此处的路径为源文件的路径</liferay-util:buffer><!--以下是新添加的内容--><%html = StringUtil.add(html,"Didn't find what you were looking for? Refine your search and " +"try again!","\n");%><%= html %>即可。
四、创建国际化文档1、在docroot/WEB-INF 目录下的liferay-hook.xml 中添加如下内容<language-properties>content/Language_zh_CN.properties</language-properties>注意放置的位置,如果不对的话,有时会报错,具体可以参看下面目录的文档liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\webapps\ROOT\dtd\liferay-hook_6_1_0.dtd2、“content/Language_zh_CN.properties”是国际化文件的目录,放在src 根目录下,如果没有,可以自己创建只有知道需要变换的参数值(value)才可以修改。
3、IDE 提供的图形界面方法也是这样实现的。
五、Application Adapters 定制站点1、liferay-hook.xml中添加<hook><custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir><custom-jsp-global>false</custom-jsp-global></hook>当部署hook 时,liferay 会自动安装Application adapter 到实例当中去2、创建一个新的view.jsp 目录为:/META-INF/custom_jsps/html/portlet/navigationJSP 内容为:<%@ taglib uri="/tld/util" prefix="liferay-util" %><liferay-util:includepage="/html/portlet/navigation/view.jsp"useCustomPage="false"/><!--useCustomPage="false" 的作用是使得当前JSP 包含被覆盖的original view.jsp 文档--> <p>This was modified by the Example Application Adapter.</p>当前文件同样可以在ROOT 文件夹中找到。
3、发布应用后登陆,在管理-->站点设置中的Application Adapter 下拉列表中可以找到刚刚创建的应用,名字是创建的HOOK 的工程名。
4、返回到导航的portlet 即可以看见view.jsp 中的文本。
如果没有导航,可以自行添加步骤:添加---->导航六:定制动作1、在目录example-hook/docroot/WEB-INF/src/com/liferay/sample/hook下创建一个LoginAction.java 文件package com.liferay.sample.hook;import com.liferay.portal.kernel.events.Action;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class LoginAction extends Action {public void run(HttpServletRequest req, HttpServletResponse res) {System.out.println("## My custom login action");}}2、src 根目录下创建一个portal.properties 配置文件添加 login.events.pre=com.liferay.sample.hook.LoginAction3、在liferay-hook.xml 文件中添加上面的配置文件的路径信息<portal-properties>portal.properties</portal-properties>4、重新发布,并重新登录,即可在后台看见字符串“## My custom login action”5、2,3 步骤也可以直接在 liferay-hook.xml 中配置<event><event-class>com.liferay.sample.hook.LoginAction</event-class> <event-type>login.events.pre</event-type></event>七、portal.properties该配置文件中有些属性的值是可以有多个的,例如:login.events.pre但是有些属性的值是唯一的,例如:e.required该配置文件中具体有哪些属性可以定义,可以参看文件liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\webapps\ROOT\dtd\liferay-hook_6_1_0.dtd八、Struts Actions使用效果类似servlet,Struts Actions是接口,分为2个:com.liferay.portal.kernel.struts.StrutsActioncom.liferay.portal.kernel.struts.StrutsPortletAction该StrutsAction接口用于portal正规的Struts动作,如/ C/portal/ update_email_address。
该StrutsPortletAction接口用于类似Struts动作,但是用于portlet。
系统自带的struts action 在liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\webapps\ROOT\dtd\struts-config.dtd的文件中有定义1、在struts-config.xml 中可以看到<action path="/login/login"type="com.liferay.portlet.login.action.LoginAction"><forwardname="portlet.login.login"path="portlet.login.login"/><forwardname="portlet.login.login_redirect"path="portlet.login.login_redirect"/></action>2、在liferay-hook.xml中添加如下代码,放在</hook> 之前<struts-action><!--自定义的action,当发生“/portal/sample”请求时触发--><struts-action-path>/portal/sample</struts-action-path><struts-action-impl>com.liferay.sample.hook.action.ExampleStrutsAction</struts-action-impl></struts-action><struts-action><!--重写的action,当发生“/login/login”请求时触发--><struts-action-path>/login/login</struts-action-path><struts-action-impl>com.liferay.sample.hook.action.ExampleStrutsPortletAction</struts-action-impl></struts-action>3、根目录下创建包com.liferay.sample.hook.action创建ExampleStrutsPortletAction类内容如下:package com.liferay.sample.hook.action;import com.liferay.portal.kernel.struts.BaseStrutsPortletAction;import com.liferay.portal.kernel.struts.StrutsPortletAction;import com.liferay.portal.theme.ThemeDisplay;import com.liferay.portal.kernel.util.WebKeys;import javax.portlet.ActionRequest;import javax.portlet.ActionResponse;import javax.portlet.PortletConfig;import javax.portlet.RenderRequest;import javax.portlet.RenderResponse;import javax.portlet.ResourceRequest;import javax.portlet.ResourceResponse;public class ExampleStrutsPortletAction extends BaseStrutsPortletAction {public void processAction(StrutsPortletAction originalStrutsPortletAction,PortletConfig portletConfig, ActionRequest actionRequest,ActionResponse actionResponse)throws Exception {ThemeDisplay themeDisplay =(ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);Long currentuser = themeDisplay.getUserId();if (currentuser != null) {System.out.println("Wrapped /login/ action2");}originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, actionRequest,actionResponse);}public String render(StrutsPortletAction originalStrutsPortletAction,PortletConfig portletConfig, RenderRequest renderRequest,RenderResponse renderResponse)throws Exception {System.out.println("Wrapped /login/ action");return originalStrutsPortletAction.render(null, portletConfig, renderRequest, renderResponse);}public void serveResource(StrutsPortletAction originalStrutsPortletAction,PortletConfig portletConfig, ResourceRequest resourceRequest,ResourceResponse resourceResponse)throws Exception {originalStrutsPortletAction.serveResource(originalStrutsPortletAction, portletConfig, resourceRequest,resourceResponse);}}在创建ExampleStrutsAction类package com.liferay.sample.hook.action;import com.liferay.portal.kernel.struts.BaseStrutsAction;import com.liferay.portal.kernel.util.ParamUtil;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class ExampleStrutsAction extends BaseStrutsAction {public String execute(HttpServletRequest request, HttpServletResponse response)throws Exception {String name = ParamUtil.get(request, "name", "World");request.setAttribute("name", name);return "/portal/sample.jsp";}}4、在/custom_jsps/html/portal目录下创建sample.jsp 页面,添加代码<%String name = (String)request.getAttribute("name");%>Hello <%= name %>!5、在src 根目录下创建portal.properties,如果没有的话添加属性参数Auth.public.paths=/portal/sample6、重启服务器,就可以在后台看见Wrapped /login/ action登陆后:Wrapped /login/ action2Wrapped /login/ action7、输入地址:http://localhost:8080/c/portal/sample显示如下内容,则自定义的action 及相应的JSP 发布成功(此处注意地址,如果404报错,则说明发布失败)九、Services这个demo是对登陆事件响应的一个重写。