天天看點

Alfresco 2.0 解讀

alfresco 2.0 解讀

一、介紹

<a href="http://www.alfresco.com/">http://www.alfresco.com</a>

alfresco is the open source alternative for enterprise content management (ecm), providing document management, collaboration, records management, knowledge management, web content management and imaging.

采用的技術

java

spring aspect-oriented framework

acegi – aspect-oriented security framework

myfaces jsf implementation

hibernate orm persistence

lucene text search engine

jlan

poi file format conversion

pdfbox – pdf conversion

openoffice

jbpm

rhino javascript engine

支援的接口

cifs/smb microsoft file share protocol

jsr-168 portlet specification

jsr-127 java server faces

ftp

webdav

web services

rest

二、配置解讀

1、從web.xml開始入手

其它的略過,在 web.xml 中可以看到加載了如下 spring 配置檔案

&lt;context-param&gt;

            &lt;param-name&gt;contextconfiglocation&lt;/param-name&gt;

            &lt;param-value&gt;

     classpath:alfresco/web-client-application-context.xml

     classpath:web-services-application-context.xml

     classpath:alfresco/web-api-application-context.xml

     classpath:alfresco/application-context.xml

 &lt;/param-value&gt;

            &lt;description&gt;spring config file locations&lt;/description&gt;

&lt;/context-param&gt;

web client 層

alfresco/web-client-application-context.xml

打開它可以看到它引入了所有的 alfresco/web-client*.xml &amp; alfresco/extension/web-client*.xml &amp; jar:*!/meta-inf/web-client*.xml

web api 層

alfresco/web-api-application-context.xml

打開它可以看到它引入了 alfresco/web-api-config.xml &amp; alfresco/extension/web-api-config-custom.xml

web service 層

web-services-application-context.xml

剛開始找這個檔案時,居然沒有找到,怪事!not exist???why?

于是後來才發現這個檔案是在 remote-api.jar 包裡,暈,不是很好的做法啊。

bean 配置定義關鍵的檔案

alfresco/application-context.xml

    &lt;import resource="classpath:alfresco/core-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/public-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/model-specific-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/action-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/rule-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/node-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/scheduled-jobs-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/network-protocol-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/content-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/hibernate-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/ownable-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/template-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/script-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/index-recovery-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/authority-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/authentication-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/policy-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/import-export-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/bootstrap-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/workflow-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/jcr-api-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/avm-services-context.xml"/&gt;

    &lt;import resource="classpath:alfresco/audit-services-context.xml"/&gt;

    &lt;import resource="classpath*:alfresco/patch/*-context.xml"/&gt;

    &lt;import resource="classpath*:alfresco/domain/*-context.xml"/&gt;

    &lt;!--

         import all modules and related components.

         extensions are explicitly imported after this so that the default

         mechanism can still be used to override module-specific beans.

    --&gt;

    &lt;import resource="classpath*:alfresco/module-context.xml"/&gt;

         import of general extensions and bean overrides.

         to give developers final control over the tuning

         of their own local build, the dev-context.xml file

         is processed last (note: dev-context.xml isn't

         part of the source tree itself). 

         for details, see:

         http://wiki.alfresco.com/wiki/developer_runtime_configuration

    &lt;import resource="classpath*:alfresco/extension/*-context.xml"/&gt;

    &lt;import resource="classpath*:alfresco/extension/dev-context.xml"/&gt;

可以看到分層次地進行加載不同的 bean ,并且在後面提供可擴充的 bean 定義的引入,友善進行擴充,而不需要更變這個配置檔案

繼續一個個往下看,并把一些重要的 bean 配置拿出來:

core-services-context.xml 核心 bean 的配置

看到配置了 jmx 的服務

&lt;!-- custom mbeanserver --&gt;

&lt;bean id="alfrescombeanserver" class="org.springframework.jmx.support.mbeanserverfactorybean"/&gt;

&lt;bean id="registry"   class="org.springframework.remoting.rmi.rmiregistryfactorybean"&gt;

    &lt;property name="port" value="${avm.remote.port}"/&gt;

&lt;/bean&gt;

&lt;!-- mbeanserver connector (registers itself with custom alfrescombeanserver) --&gt;

&lt;bean id="serverconnector"

      class="org.springframework.jmx.support.connectorserverfactorybean"

      depends-on="registry"&gt;

    &lt;property name="server"      ref="alfrescombeanserver"/&gt;

    &lt;property name="objectname" value="connector:name=rmi"/&gt;

    &lt;property name="serviceurl" value="service:jmx:rmi://localhost/jndi/rmi://localhost:${avm.remote.port}/alfresco/jmxrmi"/&gt;

    &lt;property name="environment"&gt;

        &lt;map&gt;

            &lt;!-- the following keys are only valid when sun jmx is used --&gt;

            &lt;entry key="jmx.remote.x.password.file" value="${alfresco.jmx.dir}/alfresco-jmxrmi.password"/&gt;

            &lt;entry key="jmx.remote.x.access.file"   value="${alfresco.jmx.dir}/alfresco-jmxrmi.access"/&gt;

        &lt;/map&gt;

    &lt;/property&gt;

&lt;!-- mbeans registered with alfrescombeanserver --&gt;

&lt;bean id="virtserverregistry"

      class="org.alfresco.mbeans.virtserverregistry"

      init-method="initialize"&gt;

jmx 服務暴露

&lt;bean id="exporter" class="org.springframework.jmx.export.mbeanexporter"&gt;

  &lt;property name="server" ref="alfrescombeanserver"/&gt;

   &lt;property name="beans"&gt;

     &lt;map&gt;

       &lt;!-- mbeans to register with alfrescombeanserver --&gt;

       &lt;entry key="alfresco:name=virtserverregistry,type=virtserverregistry" value-ref="virtserverregistry"/&gt;

       &lt;entry key="alfresco:name=fileserverconfig,type=fileserverconfig" value-ref="fileserverconfig"/&gt;

     &lt;/map&gt;

   &lt;/property&gt;

同時暴露了 rmi 的服務

rmi

&lt;!-- the rmi export of the repo remote transport. --&gt;

&lt;bean id="reporemotetransportrmi" class="org.springframework.remoting.rmi.rmiserviceexporter"&gt;

            &lt;property name="service"&gt;

                        &lt;ref bean="reporemotetransport"/&gt;

            &lt;/property&gt;

            &lt;property name="serviceinterface"&gt;

                        &lt;value&gt;org.alfresco.service.cmr.remote.reporemotetransport&lt;/value&gt;

            &lt;property name="servicename"&gt;

                        &lt;value&gt;repo&lt;/value&gt;

            &lt;property name="registryport"&gt;

                        &lt;value&gt;${avm.remote.port}&lt;/value&gt;

驗證 bean 配置,也是同時暴露了 rmi 的服務

authentication-services-context.xml

&lt;!-- here for now. probably want remote-context.xml file. --&gt;

&lt;!-- the authenticationservice exported as an rmi service. --&gt;

&lt;bean id="rmiauthenticationservice" class="org.springframework.remoting.rmi.rmiserviceexporter"&gt;

                        &lt;ref bean="authenticationservice"/&gt;

                        &lt;value&gt;org.alfresco.service.cmr.security.authenticationservice&lt;/value&gt;

                        &lt;value&gt;authentication&lt;/value&gt;

avm 裡也暴露了 rmi 的服務

avm-services-context.xml

&lt;!-- the rmi wrapper around the avm remote interface. --&gt;

&lt;bean id="avmremoteservice" class="org.springframework.remoting.rmi.rmiserviceexporter"&gt;

                        &lt;ref bean="avmremotetransport"/&gt;

                        &lt;value&gt;org.alfresco.service.cmr.remote.avmremotetransport&lt;/value&gt;

                        &lt;value&gt;avm&lt;/value&gt;

&lt;bean id="avmsyncservicetransport" class="org.alfresco.repo.avm.avmsyncservicetransportimpl"&gt;

    &lt;property name="authenticationservice"&gt;

        &lt;ref bean="authenticationservice"/&gt;

    &lt;property name="avmsyncservice"&gt;

        &lt;ref bean="avmsyncservice"/&gt;

&lt;bean id="avmsyncservicetransportrmi" class="org.springframework.remoting.rmi.rmiserviceexporter"&gt;

    &lt;property name="service"&gt;

        &lt;ref bean="avmsyncservicetransport"/&gt;

    &lt;property name="serviceinterface"&gt;

        &lt;value&gt;org.alfresco.service.cmr.remote.avmsyncservicetransport&lt;/value&gt;

    &lt;property name="servicename"&gt;

        &lt;value&gt;avmsync&lt;/value&gt;

    &lt;property name="registryport"&gt;

        &lt;value&gt;${avm.remote.port}&lt;/value&gt;

通過上面的 jmx 與 rmi 暴露在不同的配置檔案裡可以看到,如果我要去掉 jmx 或 rmi 服務的話,需要修改 n 個的配置檔案,實在是麻煩。

建議要二次開發時根據需要進行整理,合并到一個檔案裡進行暴露即可,或者沒有需要的話就直接 delete 掉這些:)

而且這個 jmx rmi 服務的暴露,導緻你不能僅重新開機應用就可以,而非得重新開機整個應用伺服器才行,要不然會報服務已啟動,即預設的端口50500被占用了,而整個應用啟動不了,麻煩。除非你在重新開機應用之前再去修改一下配置檔案裡的端口号,呵呵。

不過,最終的解決辦法是象我在 jmx4log4j 裡那樣自己去再封裝一個擷取端口号的類,發現有人用了,就找下一個:)這樣就OK了。

core-services-context.xml

&lt;!-- datasource bean --&gt;

資料庫連接配接池用的居然是 org.apache.commons.dbcp.basicdatasource ,大家自己改吧 c3p0 等等

郵件

&lt;!-- mail service           --&gt;

&lt;bean id="mailservice" class="org.springframework.mail.javamail.javamailsenderimpl"&gt;

lucene 索引和搜尋 api

     &lt;!-- indexing and search api --&gt;

    &lt;bean id="indexercomponent" class="org.alfresco.repo.search.indexercomponent"&gt;

    &lt;bean id="searchservice" class="org.alfresco.repo.search.searchercomponent"&gt;

    &lt;!-- indexer and searchers for lucene --&gt;

    &lt;bean id="luceneindexerandsearcherfactory"

        class="org.alfresco.repo.search.impl.lucene.luceneindexerandsearcherfactory2"&gt;

    &lt;bean id="lucenecategoryservice" class="org.alfresco.repo.search.impl.lucene.lucenecategoryserviceimpl"&gt;

    &lt;!-- lock service           --&gt;

    &lt;bean id="lockservice" class="org.alfresco.repo.lock.lockserviceimpl" init-method="initialise"&gt;

版本控制

    &lt;!-- version service   --&gt;

    &lt;bean id="versionservice" class="org.alfresco.repo.version.versionserviceimpl" init-method="initialise"&gt;

資料庫

    &lt;!-- data dictionary --&gt;

    &lt;bean id="dictionarybootstrap" parent="dictionarymodelbootstrap" depends-on="resourcebundles"&gt;

        &lt;property name="models"&gt;

            &lt;list&gt;

                &lt;!-- system models --&gt;

                &lt;value&gt;alfresco/model/dictionarymodel.xml&lt;/value&gt;

                &lt;value&gt;alfresco/model/systemmodel.xml&lt;/value&gt;

                &lt;value&gt;org/alfresco/repo/security/authentication/usermodel.xml&lt;/value&gt;

                &lt;!-- content models --&gt;

                &lt;value&gt;alfresco/model/contentmodel.xml&lt;/value&gt;

                &lt;value&gt;alfresco/model/bpmmodel.xml&lt;/value&gt;

                &lt;value&gt;alfresco/model/wcmmodel.xml&lt;/value&gt;

                &lt;value&gt;alfresco/model/forummodel.xml&lt;/value&gt;

                &lt;!-- content models --&gt;

                &lt;value&gt;alfresco/model/applicationmodel.xml&lt;/value&gt;

                &lt;value&gt;alfresco/model/wcmappmodel.xml&lt;/value&gt;

                &lt;!-- implementation models --&gt;

                &lt;value&gt;org/alfresco/repo/action/actionmodel.xml&lt;/value&gt;

                &lt;value&gt;org/alfresco/repo/rule/rulemodel.xml&lt;/value&gt;

                &lt;value&gt;org/alfresco/repo/version/version_model.xml&lt;/value&gt;

                &lt;!-- deprecated types --&gt;

                &lt;value&gt;alfresco/model/deprecated/deprecated_contentmodel.xml&lt;/value&gt;

            &lt;/list&gt;

        &lt;/property&gt;

        &lt;property name="labels"&gt;

                &lt;value&gt;alfresco/model/datatypeanalyzers&lt;/value&gt;

                &lt;value&gt;alfresco/messages/system-model&lt;/value&gt;

                &lt;value&gt;alfresco/messages/dictionary-model&lt;/value&gt;

                &lt;value&gt;alfresco/messages/content-model&lt;/value&gt;

                &lt;value&gt;alfresco/messages/bpm-messages&lt;/value&gt;

                &lt;value&gt;alfresco/messages/application-model&lt;/value&gt;

                &lt;value&gt;alfresco/messages/forum-model&lt;/value&gt;

    &lt;/bean&gt;

拷貝

    &lt;!-- copy service    --&gt;

    &lt;!-- note this uses the node service that enforces permissions so you can only copy what you can see --&gt;

    &lt;bean id="copyservice" class="org.alfresco.repo.copy.copyserviceimpl" init-method="init"&gt;

檢出 / 檢入

    &lt;!-- checkout/checkin service --&gt;

    &lt;bean id="checkoutcheckinservice" class="org.alfresco.repo.coci.checkoutcheckinserviceimpl"&gt;

全文搜尋

    &lt;!-- bean to support full text search --&gt;

    &lt;bean id="lucenefulltextsearchindexer"

        class="org.springframework.transaction.interceptor.transactionproxyfactorybean"&gt;

lucene 索引檔案備份

    &lt;!-- bean to backup lucene indexes --&gt;

   &lt;bean id="luceneindexbackupcomponent"

          class="org.alfresco.repo.search.impl.lucene.luceneindexerandsearcherfactory2$luceneindexbackupcomponent"&gt;

    &lt;!-- registry service --&gt;

    &lt;bean id="registryservice" class="org.alfresco.repo.admin.registry.registryserviceimpl" init-method="init"&gt;

    &lt;!-- a simple filesystem like api for the repo implementation.

                 unfinished, experimental, and probably ephemeral. --&gt;

    &lt;bean id="reporemoteservice" class="org.alfresco.repo.remote.reporemoteservice"&gt;

            &lt;!-- transactionally wrapped version of above. --&gt;

    &lt;bean id="reporemoteservice" class="org.springframework.transaction.interceptor.transactionproxyfactorybean"&gt;

public-services-context.xml

當中引入了

    &lt;import resource="classpath:alfresco/public-services-security-context.xml"/&gt;

public-services-security-context.xml 安全認證相關

使用的是 acegi 元件,當中引入了

    &lt;import resource="classpath:alfresco/cache-context.xml" /&gt;

cache-context.xml cache 相關的,使用的是 ehcache

   &lt;bean name="transactionalehcachemanager" class="org.alfresco.repo.cache.ehcachemanagerfactorybean"&gt;

      &lt;property name="configlocation"&gt;

         &lt;value&gt;classpath:alfresco/ehcache-transactional.xml&lt;/value&gt;

      &lt;/property&gt;

   &lt;/bean&gt;

    &lt;!-- service registry --&gt;

    &lt;bean id="serviceregistry" class="org.alfresco.repo.service.servicedescriptorregistry"/&gt;

基本上服務都從這裡注入并從中擷取,樹結構,當中有spring bean factory

model-specific-services-context.xml

   &lt;!-- file/folder specific service --&gt;

   &lt;bean name="filefolderservice" class="org.alfresco.repo.model.filefolder.filefolderserviceimpl" init-method="init"&gt;

   &lt;bean name="tempfilemarkerinterceptor" class="org.alfresco.repo.model.filefolder.tempfilemarkerinterceptor"&gt;

   &lt;!-- multilingual specific service --&gt;

   &lt;bean name="multilingualcontentservice" class="org.alfresco.repo.model.ml.multilingualcontentserviceimpl"&gt;

action-services-context.xml action 相關的

用 thread local containing the current action chain

    &lt;!-- action service --&gt;

    &lt;bean id="actionservice" class="org.alfresco.repo.action.actionserviceimpl"&gt;

rule-services-context.xml 規則、觸發規則服務

&lt;!-- rules service --&gt;

&lt;bean id="ruleservice" class="org.alfresco.repo.rule.ruleserviceimpl"&gt;

&lt;!-- rules aspect --&gt;

&lt;bean id="rulesaspect" class="org.alfresco.repo.rule.rulesaspect" init-method="init"&gt;

&lt;!-- rule triggers --&gt;

&lt;bean id="rule-trigger-base" abstract="true" init-method="registerruletrigger"&gt;

node-services-context.xml 節點相關服務

&lt;!-- beans pertinent to node persistence and services --&gt;

scheduled-jobs-context.xml 定時任務

&lt;!-- task scheduler --&gt;

&lt;!-- triggers should not appear here - the scheduler should be injected into the trigger definition --&gt;

&lt;!-- this bean should not need to apear else where in extension configuration --&gt;

&lt;bean id="schedulerfactory" class="org.springframework.scheduling.quartz.schedulerfactorybean"&gt;

    &lt;property name="waitforjobstocompleteonshutdown"&gt;

        &lt;value&gt;true&lt;/value&gt;

    &lt;property name="configlocation"&gt;

        &lt;value&gt;classpath:alfresco/domain/quartz.properties&lt;/value&gt;

    &lt;property name="schedulername"&gt;

        &lt;value&gt;defaultscheduler&lt;/value&gt;

# quartz thread settings 預設的線程優先級為 3

org.quartz.threadpool.threadpriority=3

network-protocol-context.xml 網絡相關的服務

需要相關的檔案配置資訊在 file-servers.xml 中

content-services-context.xml 内容相關的服務

mime openoffice pdf mail mp3 ...

hibernate-context.xml hibernate 的映射配置檔案

&lt;!-- load hibernate configuration properties --&gt;   

&lt;bean id="hibernateconfigproperties" class="org.springframework.beans.factory.config.propertiesfactorybean"&gt;

    &lt;property name="locations"&gt;

        &lt;list&gt;

            &lt;value&gt;classpath:alfresco/domain/hibernate-cfg.properties&lt;/value&gt;

        &lt;/list&gt;

&lt;!-- load hibernate entity cache strategies --&gt;   

&lt;bean id="cachestrategiesplaceholderconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"&gt;

    &lt;property name="ignoreunresolvableplaceholders"&gt;

            &lt;value&gt;classpath:alfresco/domain/cache-strategies.properties&lt;/value&gt;

&lt;!-- hibernate session factory --&gt;

&lt;bean id="sessionfactory" class="org.springframework.orm.hibernate3.localsessionfactorybean" parent="sessionfactorybase"&gt;

    &lt;property name="datasource"&gt;

        &lt;ref bean="datasource"/&gt;

&lt;bean id="sessionfactorybase" abstract="true"&gt;

    &lt;property name="hibernateproperties" ref="hibernateconfigproperties"/&gt;

    不同的cache政策

    &lt;property name="entitycachestrategies"&gt;

    &lt;property name="collectioncachestrategies"&gt;

ownable-services-context.xml

ownership service support. use in permissions framework as dynamic authority.

&lt;bean id="ownableservice" class="org.alfresco.repo.ownable.impl.ownableserviceimpl"&gt;

template-services-context.xml 模闆引擎 freemarker

script-services-context.xml 腳本引擎 rhino javascript engine.

index-recovery-context.xml 索引校驗與恢複

&lt;!-- index recovery and validation --&gt;

&lt;!--

 recovery types are:

     none:     ignore

     validate: checks that the last transaction for each store is represented in the indexes

     auto:     validates and auto-recovers if validation fails

     full:     full index rebuild, processing all transactions in order. the server is temporarily suspended.

--&gt;

&lt;bean

     id="indexrecoverycomponent"

     class="org.alfresco.repo.node.index.fullindexrecoverycomponent"

     parent="indexrecoverycomponentbase"&gt;

 &lt;property name="recoverymode"&gt;

      &lt;value&gt;${index.recovery.mode}&lt;/value&gt;

 &lt;/property&gt;

&lt;!-- bean that attempts to index content that was previously missing --&gt;

     id="missingcontentreindexcomponent"

     class="org.alfresco.repo.node.index.missingcontentreindexcomponent"

authority-services-context.xml 授權服務

&lt;!-- the configuration of the authority service implementation --&gt;

&lt;!-- this implementation supports the identification of users as admin users. --&gt;

&lt;!-- it also supports groups and allows groups and users to be arranged into --&gt;

&lt;!-- hierarchies.                                                             --&gt;

&lt;bean id="authorityservice" class="org.alfresco.repo.security.authority.authorityserviceimpl"&gt;

    &lt;!-- a list of users with admin rights.                               --&gt;

    &lt;!--                                                                  --&gt;

    &lt;!-- if the security framework is case sensitive these values should --&gt;

    &lt;!-- be case sensitive user names. if the security framework is not   --&gt;

    &lt;!-- case sensitive these values should be the lower-case user names. --&gt;

    &lt;!--                                                                  --&gt;

    &lt;!-- by default this includes:                                        --&gt;

    &lt;!--    admin (the user name of default alfresco admin user)          --&gt;

    &lt;!--    administrator (the windows default admin user)                --&gt;

    &lt;!-- this assumes that user names are not case sensitive.             --&gt;

    &lt;property name="adminusers"&gt;

        &lt;set&gt;

                                    &lt;value&gt;admin&lt;/value&gt;

                                    &lt;value&gt;administrator&lt;/value&gt;

                        &lt;/set&gt;

&lt;!-- authority dao that stores group information along with user information, --&gt;

&lt;!-- in the repository.                                                       --&gt;

&lt;!--                                                                          --&gt;

&lt;!-- this bean uses the usertoauthoritycache configured in cache-context.xml --&gt;

&lt;bean id="authoritydao" class="org.alfresco.repo.security.authority.authoritydaoimpl"&gt;  

authentication-services-context.xml 驗證 acegi

&lt;!-- this file contains the bean definitions that support authentication --&gt;

policy-context.xml 政策服務

&lt;!-- policy support --&gt;

import-export-context.xml 導入導出服務

bootstrap-context.xml 系統啟動的初始化工作

如:資料庫、avm、檔案伺服器、ftp、nfs、cifs等等。。。

repository bootstrap sequence.

&lt;!-- ensure that the schema is bootstrapped --&gt;

&lt;bean id="schemabootstrap" class="org.alfresco.repo.domain.schema.schemabootstrap"&gt;

 &lt;property name="localsessionfactory"&gt;

     &lt;ref bean="&amp;amp;sessionfactory"&gt;&lt;/ref&gt; &lt;!-- inject the actual factory, not a session --&gt;

workflow-context.xml 工作流相關的服務,jbpm

&lt;!-- workflow service implementation --&gt;

jcr-api-context.xml 實作jcr 170相關的api,即1.0版本的api

alfresco implementation of a jcr repository

avm-services-context.xml avm相關服務,以及一堆的dao

&lt;!-- id issuers. --&gt;

&lt;!-- daos for persistent data types --&gt;

&lt;!-- issuers are not actual entities. more like pseudo entities. --&gt;

avm-console-context.xml

&lt;!-- use substitution values in this config. --&gt;

avm-console.properties 預設配置為本地mysql的資料庫

# database specifics.

db.driver=org.gjt.mm.mysql.driver

db.url=jdbc:mysql://127.0.0.1/avm

db.username=root

db.password=

db.pool.initial=4

db.pool.max=32

# hibernate properties

hibernate.dialect=org.hibernate.dialect.mysqlinnodbdialect

hibernate.current_session_context_class=thread

hibernate.connection.isolation=2

hibernate.default_batch_fetch_size=16

hibernate.jdbc.batch_versioned_data=true

hibernate.cache.use_second_level_cache=true

hibernate.hbm2ddl.auto=update

# avm specific properties.

    &lt;import resource="file:config/alfresco/avm-base-context.xml"/&gt;

audit-services-context.xml

&lt;!-- base audit service - non tx --&gt;

&lt;bean id="auditservice" class="org.alfresco.repo.audit.auditserviceimpl"&gt;

    &lt;property name="auditcomponent"&gt;

        &lt;ref bean="auditcomponent"/&gt;

&lt;!-- audit component --&gt;

&lt;bean id="auditcomponent" class="org.alfresco.repo.audit.auditcomponentimpl"&gt;

其後在 application-context.xml 還加載了

&lt;import resource="classpath*:alfresco/patch/*-context.xml"/&gt;一堆patch,呵呵

patch-services-context.xml

&lt;import resource="classpath*:alfresco/domain/*-context.xml"/&gt;其它的。。。

&lt;import resource="classpath*:alfresco/module-context.xml"/&gt;

module-context.xml 加載其它的子產品bean

最後加載一些擴充與二次開發的bean

&lt;import resource="classpath*:alfresco/extension/*-context.xml"/&gt;

&lt;import resource="classpath*:alfresco/extension/dev-context.xml"/&gt;

同時覆寫掉想覆寫的bean,後面覆寫前面的,map嘛。比如: custom-repository-context.xml 裡的屬性配置、資源配置、事務配置等

三、配置安裝時的注意事項

1、要将 alfresco 預設安裝使用的資料庫hsql轉換為mqsql的話,隻需要删掉三個 hsql 使用的檔案:

這三個檔案分别是 tomcat/shared/classes/alfresco/extension 目錄下的

            custom-db-and-data-context.xml

            custom-db-connection.properties

            custom-hibernate-dialect.properties

為了産生一個mysql資料庫,執行 &lt;alfresco_installation_folder&gt;/extra/database/mysql ,運作 db_setup.bat 檔案,或者打開檔案,手工輸入指令也一樣。

就會産生一個與一個使用者一起命名 alfresco 的 mysql 資料庫帳戶和一個 alfresco 的密碼。

2、國際化

alfresco的檔案路徑為: web-inf/classes/alfresco/messages 下面包含了一堆檔案,一個個去國際化吧,當然用插件、native2ascii或配合ant都可以。

eclipse 的 propertieseditor 插件不錯。

3、無論從一種資料庫切換到另一種資料庫,都要記得把 repository.properties 配置檔案裡 dir.root 所在的目錄下的檔案删除幹淨,要不然會出問題。

比如:caused by: org.alfresco.repo.search.searcherexception: more than one root node in index: 2

#dir.root=./alf_data

4、将 win32netbios.dll 拷貝到 %java_home%/jre/bin/ 目錄下 或者 %tomcat_home%/bin 目錄下

5、不要 scriptservice 的話,可以在 public-services-context.xml 中

注釋掉 scriptservice 和 scriptservice_transaction

&lt;!-- script service --&gt;

&lt;bean id="scriptservice" class="org.springframework.aop.framework.proxyfactorybean"&gt;

...

&lt;bean id="scriptservice_transaction" class="org.springframework.transaction.interceptor.transactioninterceptor"&gt;

6、檢視 hibernate 的 sql

            修改 log4j.properties

            在 log4j.logger.org.hibernate 下增加一行,即可

            log4j.logger.org.hibernate.sql=debug

7、發現啟動報 "ensure that the 'dir.root' property is pointing to the correct data location." ... 之類的錯誤時可以在 repository.properties 配置檔案裡将 strict 設定為 false

# change the failure behaviour of the configuration checker

system.bootstrap.config_check.strict=false

不過,設定後很有可能可以啟動,但是仍是登入不了之類的,要小心。

如果用的是hsql的話,最好把 alf_data/hsql_data 下面的 alfresco.properties 和 alfresco.script 恢複成原來的,并删除其它的檔案,再重新開機就可以了。

8、第 7 條,仍報錯 error [repo.admin.configurationchecker] content integrity error: indexes not found for 5 stores. 的話,設定為全部索引,并按第 3 條所說的删除檔案,或者直接就換個檔案夾,不要用預設的檔案夾名稱,并删除資料庫的内容(所有的表以及hibernate_sequence),并重新開機即可。

在 repository.properties 中設定

index.recovery.mode=full

9、如果是強行關閉掉tomcat之類後,馬上啟動tomcat的話,有可能會報錯

ioexception while loading persisted sessions: java.io.writeabortedexception: writing aborted; java.io.notserializableexception: org.alfresco.web.ui.common.component.uilistitem

過一會兒再啟動就沒有問題了。

10、alfresco 2.0 需要 jdk 1.5_07 以上的版本,這個也要注意。

11、使用者名大小字問題,可以在 repository.properties 進行設定

# are user names case sensitive?

user.name.casesensitive=true

設定為 true ,大小寫敏感,預設為 false

12、關閉ftp服務,在 bootstrap-context.xml 配置中注釋掉它就可以了。file-servers.xml裡儲存相關的配置資訊

&lt;!-- ftp server --&gt;

&lt;bean id="ftpserver" class="org.alfresco.filesys.ftpserver" destroy-method="stopserver"&gt;

    &lt;constructor-arg&gt;

       &lt;ref local="fileserverconfiguration"/&gt;

    &lt;/constructor-arg&gt;

或者也可以在 file-servers.xml 檔案中設定 &lt;serverenable enabled="false"/&gt;

13、關閉cifs服務

在 file-servers.xml 檔案中設定 &lt;serverenable enabled="false"/&gt; 即可。

四、資料庫模型

可以看附件,有包含jbpm的與不包含jbmp的兩個資料庫

五、相關資料

java content repository api 簡介 學習 jsr-170 如何使建構 cma 變得輕而易舉

<a href="http://www.ibm.com/developerworks/cn/java/j-jcr/">http://www.ibm.com/developerworks/cn/java/j-jcr/</a>

國外廠商紛紛投入開源界 自述其中原因,此文重點介紹 alfresco 的相關資訊。

<a href="http://dotnet.csdn.net/n/20060206/86350.html">http://dotnet.csdn.net/n/20060206/86350.html</a>

六、開發與代碼分析

1、換 web services 的實作方式由 axis 換到 xfire

  codehaus xfire is a next-generation java soap framework. codehaus xfire makes service oriented development approachable through its easy to use api and support for standards. it is also highly performant since it is built on a low memory stax based model.

==============================================================

代碼分析有時間再繼續整理上來

category由id,title,description組成

            public category(org.alfresco.webservice.types.reference id,java.lang.string title,java.lang.string description)

classification

            public classification(java.lang.string classification,org.alfresco.webservice.types.category rootcategory,java.lang.string title,java.lang.string description)

reference

            public reference(org.alfresco.webservice.types.store store,java.lang.string uuid,java.lang.string path)

appliedcategory

            public appliedcategory(java.lang.string classification,org.alfresco.webservice.types.reference[] categories)

classdefinition

            public classdefinition(java.lang.string name,java.lang.string title,java.lang.string description,java.lang.string superclass,boolean isaspect,org.alfresco.webservice.types.propertydefinition[] properties,org.alfresco.webservice.types.associationdefinition[] associations)

 附件下載下傳: