AEM是 Adobe 出品的一个CMS管理系统,相比于市面上其他著名的CMS系统,比如Wordpress,织梦等,AEM具有灵活性高,高可复用性,定制化程度高,组件化和运维功能丰富等特点。
所见即所得: 一般的CMS系统都会提供很多预开发好的功能和页面,比如首页,文章详情页,文章列表页等页面,然后用户可以在CMS提供的管理后台添加和维护站点的相关信息,比如创建新的文章,而这些管理后台都只是表单型的提交文章数据到数据库,用户再次进入站点前台页面时,会读取后台配置好的文章数据,按照CMS厂商写死的固定显示样式来渲染文章。一般管理后台长这样:
创建新文章面板:
而AEM则不需要在一个独立的管理后台中进行表单式的提交数据,而是直接在最终页面上进行编辑,编辑完后直接显示
组件化: 不用于一般CMS由开发商一次开发好所有网站功能,一般以页面为单位,用户只能在管理后台编辑数据的模式,AEM的具有一定逻辑代码的最小单元是组件,AEM平台本身提供了很多常用的组件,比如列表(链接,图片均可),富文本编辑,面包屑,图片,轮播图,表格等组件,开发者也可以开发任何自定义组件,比如上面图中,就是酒店房间列表组件,该组件提供一个编辑窗口来收集房间数据,最终按照开发者写好的HTML进行渲染。
下面是OOTB提供的一些组件:
文档型数据库: 不用于一般的CMS系统使用MySql, SqlServer等关系型数据库,AEM采用文档型数据库(JCR)来存储数据。使用该数据库的显著特点是AEM的程序本身,以及用户所添加的数据,上传的图片等全部存储在AEM实例的所在文件夹中,文件夹结构如下:
.
AEM 作为一个企业级的CMS管理系统,主要用户维护,创建和部署大型商业网站及其服务。
一般AEM的应用场景如下:
相较于Eclipse,IntelliJ更加灵活便捷,而且IntelliJ的插件市场也能提供很多丰富的实用插件。
使用IntelliJ进行AEM开发时,请在导入AEM项目时,选择Maven项目,如下:
有三种方式可以部署代码到AEM实例
mvn clean install -PautoInstallPackage,local-author,adobe-public
AEM 是Adobe的面向企业的CMS解决方案,不对个人免费开发,个人开发学习可向公司内部有该文件的同事取得。获得到的quickstart结构如下:
包含一个quickstart jar文件,是AEM的服务主体。
包含一个license文件,必须有这个才能正常启动AEM。
我们可以直接双击运行cq-author-4502.jar这个文件来启动AEM,但这只是快速调试用的临时启动方式,用该方式无法调试代码,以及优化AEM启动参数等。
无论是开发者开发还是生产环境部署,均首选此方式。一般的启动命令如下:
java -XX:MaxPermSize=1028m -Xmx2048M -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=30308,server=y,suspend=n -jar cq-author-4502.jar -r author localdev
首选使用Adobe官方提供的Archetype Project Code。使用该原型项目可以方便快速的获得最可靠,最符合AEM项目规范的基础代码。使用如下Mvn命令获得
mvn archetype:generate \
-DarchetypeGroupId=com.adobe.granite.archetypes \
-DarchetypeArtifactId=aem-project-archetype \
-DarchetypeVersion=XX
XX 是版本号,具体取值参见:https://github.com/adobe/aem-project-archetype/blob/master/VERSIONS.md
Touch UI Manager是AEM的核心控制台
Touch UI控制台主要提供页面的管理(创建新页面,编辑页面),Asset管理(上传,删除图片,视频等素材),另外还提供了一些列工具,比如replication,workflow,template,account等,具体可直接点击Tool按钮查看:
Touch UI控制台是运维人员和AEM管理员的主要控制台
Crx/de控制台可以认为是AEM的数据库管理工具
Crx/de 工具的主要功能是查看JCR的底层数据,包括我们部署到AEM的代码,OOTB的代码,以及用户创建的页面,添加的组件等,可以说,整个AEM的所有数据都可以在Crx/de中查看,以及修改,修改立即生效,因此,在项目中,我们可以在Crx/de中验证我们的功能,或者直接在Crx/de中添加修改数据而不经过代码部署环节,甚至,可以在生产环境的Crx/de中快速开发一个紧急功能而绕过其他环节。
Crx/de的另一个功能是数据导入导出,将用户生产的数据(添加的页面,图片,author的组件)等导入到其他Instance中。
ConfigMgr主要用来查看Bundle级的信息,比如,项目代码的Bundle是否部署和运行成功,组件java代码的Model是否成功运行,最重要的功能是,如果我们在java代码中添加了Property field,那我们可以在这个控制台中进行配置。
explorer 控制台不是很常用,核心功能是配置系统级用户,系统级用户是,在AEM的权限管理中,所有操作JCR数据必须要有一个用户,我们在Java中使用API操作JCR也不例外,因此需要为我们的java代码分配一个用户,而直接在Touch UI中创建用户,安全性低并且还需要密码认证,所以我们一般在该控制台中创建一个为代码使用的系统级用户。
Author instance
Typically, for security, governance, and other reasons, a production site will divide instances of AEM into Author and Publish instances. For more information on deployment architecture (including Author/Publish instances), see documentation about AEM Instances.
Publish instance
For security, governance, and other reasons, a production site will typically divide instances of AEM into Author and Publish instances. For more information on deployment architecture (including Author/Publish instances), see documentation about AEM Instances.
Component
In AEM, a Component is an object type, instances of which can generally be created by dragging and dropping them from, say, the Sidekick. So for example, out-of-the-box components that ship with AEM include the Text, Title, Tag Cloud, Carousel, Image, and List components, all available from the Sidekick at runtime.
Template
In AEM, a Template specifies a particular type of page. It defines the structure of a page (while also typically specifying a thumbnail image, and various properties). For example, you may have separate templates for product pages, sitemaps, and contact information.
Page
组件(模板也是一种特殊的组件)是AEM的最小的代码逻辑单元,但组件本身是无法实例化的,它只是一个代码对用户是不可见的,在AEM中,页面就是一个实例化的容器,组件必须插入到页面中才可以显示并运行给用户,用户和AEM运维人员实际操作的都是页面,用户基于某个模板创建一个页面,然后在页面上插入和编辑某些组件,页面本身不包含任何代码,页面的实际功能由它的模板和插入的组件所决定。
Digital assets
In AEM, Digital Assets are (typically) images and rich media files. For further information, see Working with Digital Assets in DAM.
Workflow
The AEM Workflow system allows for creation of automated processes involving pages or assets.
Replication agents
Replication agents are central to AEM as the mechanism used to Publish (activate) content from an author to a publish environment; flush content from the Dispatcher cache; return user generated content (for example, form input) from the Publish environment to the Author environment.
在AEM中,具有最小代码逻辑单元的是组件。一般我们看到的一个AEM页面,这个页面是由若干个组件来组成的,这个页面本身并不包含任何代码,包括前端HTML,JS,后台的java等,这个页面只是一个容器,由用户确定拖放哪些组件进入这个页面,这个页面的最终渲染效果和其功能以及数据来源,均是有每个组件来决定的。
在AEM开发组件。一般我们可以将AEM组件的开发工作分为三部分:
之前提到过,一般一个页面的代码逻辑是由组件提供的,我们可以在AEM的Touch UI控制台中基于OOTB的通用模板创建页面,再插入组件,我们只开放组件中的代码即可,但在实际项目中,一般我们需要实现一些统一的JS,CSS依赖,统一的HTML布局结构,以及统一的Header,footer等,要实现这些,我们需要开发具有我们自己代码逻辑的自定义模板。
由于很多功能我们可能采用由前端代码Ajax调用后台数据来渲染View的方式,我们就需要使用Sling Servlet来暴露webservice给前端JS使用,一般是在后台用Sling API,JCR API,AEM API来获得用户author的数据发送给前台渲染页面。
也有一种需求是我们暴露给内部author数据给其他外部系统使用。
workflow也是AEM的一大特性,它使得运维人员可以方便的定义和配置工作流,来实现诸如审批流程,自动发布,灾难备份等功能。
一般我们开发workflow,需要根据实际需求,采用OOTB定义好的内置step或者我们自己开发的step定义一个workflow model。这样用户就可以在Touch UI控制台中使用这个workflow。
以IntelliJ为例,首先需要保证是以命令行启动的AEM并配置了相关debug参数,然后,按照如下配置IntelliJ的debug
在创建好的remote debug config中,端口输入AEM启动参数中配置的30308,点击ok保存
配置完成后,在右上角选择我们刚才的debug配置,再点击右边的小虫子debug按钮即可开启debug。
在Crx/de中切换package视图,创建一个新的package,在新的package中添加要打包的节点,组件,页面,asset均可
http://localhost:4502/system/console/slinglog
http://localhost:4502/libs/cq/i18n/translator.html
参考:https://docs.adobe.com/content/help/en/experience-manager-64/developing/components/internationalization/i18n-translator.html
/etc/languages (没有的话,自己创建它,添加languages属性,类型为数组)下定义全局语言例如:sc_cn, zh_tw
代码合适位置,创建自己的i18n定义文件,例如/apps/ns-zh/i18n/zh.json,文件的node属性中包含jcr:language=sc_cn,jcr:mixinTypes=mix:language
创建语言分类页面,例如sc_cn.html,在其jcr:content中添加jcr:language=sc_cn
在组件的HTML中使用 ${‘check-address’ @i18n}
在JS中使用,先全局定义
先引入这个category的JS:granite.utils
Granite.I18n.setLocale('sc_cn');
Granite.I18n.get('upload-time');
curl -# -u admin:admin -O http://localhost:4503/etc/packages/my_packages/image.zip
curl -u admin:admin -F file=@"content.zip" -F name=“Package” -F force=true -F install=false http://localhost:4502/crx/packmgr/service.jsp --progress-bar -o upload.txt
Apache Sling :: Servlet Resolution
https://sling.apache.org/old-stuff/servlet-resolution.html
Apache Sling :: URL decomposition
http://sling.apache.org/documentation/the-sling-engine/url-decomposition.html
Apache Sling :: HTL Scripting
https://sling.apache.org/documentation/bundles/scripting/scripting-htl.html
Apache Sling :: Sling Models
https://sling.apache.org/documentation/bundles/models.html#specifying-an-alternate-adapter-class- since-110
拓展书目:
Continuous Delivery of Apache Sling Applications
Server-side OSGi with Apache Sling
Java JSR-170(JCR)
JCR规范下载
http://download.oracle.com/otndocs/jcp/content_repository-1.0.1-mr-oth-JSpec/index.html
Jackrabbit:
依据JCR规范的一个JCR实现类库
http://jackrabbit.apache.org/jcr/jackrabbit-architecture.html
一个OSGI实现 官网 http://felix.apache.org/
拓展书目: OSGi and Apache Felix 3.0 Beginner’s Guide
HTML Template Language (HTL)是AEM所推荐使用的服务器端动态HTML模板语言
HTL 语法详解
https://github.com/Adobe-Marketing-Cloud/htl-spec/blob/master/SPECIFICATION.md#221-use
HTL Adobe 官方教程
https://helpx.adobe.com/experience-manager/htl/using/getting-started.html
参考书目:Maven权威指南中文版
如无法显示此图片,请浏览器中打开此链接:https://img-blog.csdnimg.cn/20191108104552463.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0NvZGluZ0Jsb2c=,size_16,color_FFFFFF,t_70
https://helpx.adobe.com/support/experience-manager/6-3.html
https://helpx.adobe.com/experience-manager/kt/index/aem-6-3-videos.html
教你一步一步的开发AEM,很实用 附带官方实例源码
https://github.com/Adobe-Marketing-Cloud/aem-guides-wknd
https://helpx.adobe.com/experience-manager/topics/how-to.html
https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part1.html
https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part2.html
https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part3.html
https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part4.html
https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part5.html
https://helpx.adobe.com/experience-manager/kt/sites/using/getting-started-wknd-tutorial-develop/part6.html
https://helpx.adobe.com/experience-manager/using/aem63_slingmodel.html
https://helpx.adobe.com/experience-manager/using/first_htl_WCMUsePojo.html
https://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html
https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/querybuilder-api.html
https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/single-sign-on.html
https://helpx.adobe.com/experience-manager/6-4/mobile/using/content-services.html
https://helpx.adobe.com/experience-manager/6-4/mobile/using/spaces-and-entities.html
https://helpx.adobe.com/experience-manager/kt/sites/using/content-services-tutorial-use.html
https://helpx.adobe.com/experience-manager/kt/platform-repository/using/sling-model-exporter-tutorial-develop.html
https://helpx.adobe.com/experience-manager/6-3/release-notes/json-exporter-dev-fp.html
https://cwiki.apache.org/confluence/display/SLING/Scripting+variables#Scriptingvariables-Commonscriptingvariables
https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/ht-projects-maven.html
https://www.linkedin.com/pulse/granite-datasource-inside-touch-ui-select-object-aem-gonz%C3%A1lez-ramos
https://mkbansal.wordpress.com/2016/01/04/aem-acs-generic-list-dialog-configuration-touch-ui/
https://helpx.adobe.com/experience-manager/using/creating-touchui-validate11.html
https://helpx.adobe.com/experience-manager/6-3/sites/administering/using/rich-text-editor.html#PluginsandtheirFeatures
https://helpx.adobe.com/experience-manager/6-2/sites/authoring/using/editmode.html#Text
https://helpx.adobe.com/experience-manager/kt/sites/using/content-fragments-feature-video-understand.html
https://helpx.adobe.com/experience-manager/using/multifield_aem63.html
https://helpx.adobe.com/experience-manager/using/aem63_htl_repeat_slingmodel.html
https://helpx.adobe.com/experience-manager/using/first_htl_WCMUsePojo.html
https://helpx.adobe.com/experience-manager/using/aem64_coral_resourcetypes.html
https://helpx.adobe.com/experience-manager/using/resourcetypes.html
https://helpx.adobe.com/experience-manager/using/resourcetypes.html#h2Createarendercomponentthatusesthetemplatebrh2
http://www.6dglobal.com/blog/servlets-sling-case-disappearing-servlet-path-2013-01-31
https://sling.apache.org/documentation/the-sling-engine/servlets.html
https://github.com/tobywang11030/mangoCMS/blob/master/SegmentNotFound%20Issue%20and%20AuthenticationSupport%20service%20missing%20issue
Maven settings
http://helpx.adobe.com/experience-manager/kb/SetUpTheAdobeMavenRepository.html
运行时加上
-Padobe-public
官方定义
By definition, the template console and template editor only allow creation and editing of editable templates. Therefore this document focuses exclusively on editable templates.
Topics | Cost(hours) | Details | Reference | Start Date | End Date | Completed? | Questions | Comment |
---|---|---|---|---|---|---|---|---|
Basic AEM knowledge study | ||||||||
Installing and configuring an AEM developer environment | 1. Install AEM on supported operating systems. 2. Install AEM with different run modes (Author and Publish). 3. Start AEM in debug mode for remote debugging. 4. Setup and configure replication agents. 5. Setup and configure a Web server 5. Setup and manage OSGi configurations. 6. Manage users and groups 7. Manage Access Control Level (ACL) permissions. |
|||||||
Building and deploying AEM projects | 1. Configure a source control system to manage files in AEM 2. Build and deploy AEM projects by using Maven |
|||||||
Building AEM components | 1. Create custom components and dialogs 2. Create templates and page components 3. Create client libraries. 4. Extend out-of-the-box AEM components. |
|||||||
Building OSGi services | 1. Create custom OSGi services. 2. Create and manage custom OSGi configurations. 3. Configure and manage OSGi services and bundles by using the Felix web console. 4. Manage Maven dependencies. |
|||||||
Troubleshooting AEM projects | 1. Create custom log files by using the Web console. 2. Configure and manage AEM log levels for specific AEM environments. 3. Given an option for starting AEM, I can select the correct parameter(s) for starting AEM. 4. Troubleshoot caching issues related to the Dispatcher and browsers. 5. Troubleshoot AEM configurations. |
|||||||
AEM使用一段时间之后,因AEM的存储机制问题,AEM的Repository的文件夹的大小会越来越大,会造成极大的系统开销甚至导致数据错误时AEM崩溃无法运行。AEM6.3以后提供两种方式清理AEM的数据仓库以节省磁盘占用。下面为具体步骤,亦可参考Adobe官网https://helpx.adobe.com/experience-manager/6-4/sites/deploying/using/revision-cleanup.html
依次进入Tools-Operations-Maintenance 进入系统维护工具
或者直接访问 http://localhost:4502/libs/granite/operations/content/maintenance.html
AEM提供了两组清理工具,一组为建议Daily执行的,一组为建议Weekly执行的。
点击Daily Maintenance Window,即可发现系统默认提供了两个清理工具
可以直接手动运行这个Revision Clean Up,该工具运行后,可以减少repository\segmentstore文件夹的大小
点击Weekly Maintenance Window,即可发现系统默认提供了两个清理工具
可以直接手动运行这个Data Store Garbage Collection,该工具运行后,可以减少repository\datastore文件夹的大小
备注:如发现运行Online Revision Cleanup中的任何清理工具均无任何效果,则需要用Offline Revision Cleanup进行清理。该问题根据官网介绍,可能是因为清理机制的问题。
如发现Online Revision Cleanup的方式无法清理,需要使用Offline Revision Cleanup
首先访问https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/下载合适版本的 oak-run.jar 工具
然后关掉AEM实例
依次执行如下命令:
Shut down AEM.
执行命令
java -jar oak-run.jar checkpoints install-folder/crx-quickstart/repository/segmentstore
执行命令
java -jar oak-run.jar checkpoints install-folder/crx-quickstart/repository/segmentstore rm-unreferenced
执行命令
java -jar -Dsun.arch.data.model=32 oak-run.jar compact install-folder/crx-quickstart/repository/segmentstore
AEM默认会开启Version生成,当你上传,更新,新建,发布一个页面或者asset时,均会生成一个对应的Version,而这些额外的Version默认设置下是不会被删除的,会造成磁盘占用越来越大,可以通过修改VersionManagerImpl这个类的设置开关闭Version生成,或者开启Version Purgin功能自动清理Version。
AEM有两种形式的数据,一种为Node数据,主要存储的是JCR属性,另一个为二进制数据,主要存储的是上传的图片,视频等。安装并启动一个AEM实例后,在默认情况下,这两种形式的数据均以Tar Storage(一种文件存储系统)的形式储存在本地磁盘中。可参考https://helpx.adobe.com/experience-manager/6-4/sites/deploying/using/storage-elements-in-aem-6.html
AEM的默认数据存储方式,该方式下数据已Tar文件的形式存储,该方式具有比较高的性能,也是AEM建议的存储方式,该方式的缺点是如果用户会上传大量的图片,视频,以及每天会有大量的author和修改的话,会造成repository文件夹很大,甚至几TB,这样一是比较昂贵,而是因为数据文件过多,增加了数据损坏导致系统崩溃的风险。
该模式的几种优化方案:
根据AEM官方介绍,如果符合以下条件,建议使用Mongo Storage存储方式,否则还是应使用默认的file storage
启用该存储方式,可以将Node数据以及二进制数据(可选,二进制数据仍可以已文件形式存在本地磁盘或者S3等第三方云),这样可以借助Mongo Storage的高性能,分布式的特点提高AEM的数据存储性能。具体可参考https://helpx.adobe.com/experience-manager/6-4/sites/deploying/using/aem-with-mongodb.html
Topics | Cost(hours) | Details | Reference | Start Date | End Date | Completed? | Questions | Comment |
---|---|---|---|---|---|---|---|---|
Install and Configure the AEM Environment | 1. Identify the default runmode of the AEM server 2. Identify the default runmode of the AEM server 3. Apply best practices for installation of AEM 6.0 ondifferent operating systems 4. Determine the valid run modes to operate AEM 5. State the configurations required for the installation on application servers 6. Identify the supported operating system for installing AEM on an application |
|||||||
Build and deploy AEM projects | 1. Apply version control management best practices 2. Apply standard procedures to create multi-module Maven projects 3. Apply standard procedures to develop and debug application using IDE |
|||||||
Build AEM Components | 1. Given a scenario, I can analyze and evaluate the usage of forms, metadata and other features 2. Apply best practices to create and use client libraries 3. Apply best practices to create, customize, and configure AEM components and dialogs 4. Given a scenario, I can determine workflow steps and processes 5. Apply standard procedures to create and extend AEM components, templates, and page components |
|||||||
Create and configure OSGI services | 1. Apply standard processes to manage OSGI bundles,services and dependencies 2. Analyze and evaluate the logs to identify discrepancies 3. Given a scenario, I can determine the OSGI configuration 4. Apply a standard process to create OSGI components and services |
|||||||
Setup content structure and taxonomy | 1. Apply best practices to manage user-generated content 2. Given a scenario, I can analyze content structure and evaluate query efficiency 3. Apply standard procedures to manage AEM tagging framework 4. Given a scenario, I can analyze workflows to setup multilingual sites |
|||||||
Create AEM security policies | 1. Evaluate AEM users and group permissions 2. Apply standard processes to set up CUGs 3. Evaluate ACLs and permission level for users/groups |
|||||||
Set-up and configure deployment infrastructure | 1. Analyze and evaluate logs and other artifacts to manage garbage collection and TAR optimization 2. Apply standard procedure for backend data store configuration 3. Apply standard procedures to integrate AEM applications with Marketing Cloud tools and third-party tools 4. Apply standard procedures to integrate AEM applications with LDAP/SSO/OAUTH Providers/Third-Party login authentication mechanisms |
|||||||
Troubleshoot AEM projects | 1. Troubleshoot issues related to performance 2. Troubleshoot functional issues 3. Identify issues related to scalability bottlenecks |