cancel
Showing results for 
Search instead for 
Did you mean: 

Module dependent custom-slingshot-application-context.xml

itzamna
Confirmed Champ
Confirmed Champ
Hi all,

I've developed some extensions (evaluator + indicator to provide some icons and a new document action for documents of our content types) that requires changes in the custom-slingshot-application-context.xml[1][2] in combination with changes in the share-config-custom.xml.
All works fine so, far but as we deliver our module as an AMP file I'm looking for a way to include the custom-slingshot-application-context.xml file also in our distribution, so that it will be automatically deployed. At this point I need some help. What is the correct place for a module dependent version of this file? We have already a module dependent share-config-custom.xml file that we place into the META-DATA folder of the JAR file. So my first shoot from hips was to place the custom-slingshot-application-context.xml also in that folder of the JAR file. But it won't be considered. Any hints what I'm doing wrong? Is the custom-slingshot-application-context.xml the right location to provide beans at all? The content[3] of the file below.

Thanks,
Itzamna

[1] http://ecmstuff.blogspot.de/2012/04/adding-document-library-actions-in.html
[2] http://docs.alfresco.com/4.2/topic/com.alfresco.enterprise.doc/concepts/doclib-override-extension-ex...
[3] Content of custom-slingshot-application-context.xml

<beans>
    <bean id="myCompany.product.doclib.action.openInExternalProgram" class="myCompany.product.share.CheckIfDocHasExternalProgramAspectsEvaluator" >
        <property name="aspects">
            <list>
                <value>myProductAL:ExternalProgramREAspect</value>
            </list>
        </property>
        <property name="appliesTo">
                <list>
                    <value>cm:content</value>
                    <value>cm:folder</value>
                </list>
        </property>
    </bean>

    <bean id="myCompany.product.doclib.icon.openInExternalProgram.documents" class="myCompany.product.share.CheckIfDocHasExternalProgramAspectsEvaluator" >
        <property name="aspects">
            <list>
                <value>myProductAL:ExternalProgramALAspect</value>
                <value>myProductRE:ExternalProgramREAspect</value>
            </list>
        </property>
        <property name="appliesTo">
            <list>
                <value>cm:content</value>
            </list>
        </property>
    </bean>
</beans>
3 REPLIES 3

kaynezhang
World-Class Innovator
World-Class Innovator
First you need to create a Spring configuration file and place it in the package alfresco.module.<moduleId> and the file should be called module-context.xml.
Then you have two options :
option 1, paste you content of custom-slingshot-application-context.xml in to module-context.xml.
option 2 ,place custom-slingshot-application-context.xml in module package and import it into module-context.xml,like following

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
   
    <import resource="classpath:alfresco/module/<moduleId>/custom-slingshot-application-context.xml" />
   
</beans>

itzamna
Confirmed Champ
Confirmed Champ
Thank you for the both approches. I think I'll prefer option 1 as with this, there is one file less.
One question I have for the location of the module-context.xml: Where do I have to place it or otherwise where should this file be placed after the deployment in the exploded web-app?

I do have a module-context.xml already in my Alfresco Explorer project that is in folder "/src/main/config" (IDE) and will be deployed to "webapps/alfresco/WEB-INF/classes/alfresco/module/myModule". But for Alfresco Share, I have currently less experience, so I don't know how to place the file there? I tried it similar, so with copying the file manually to "webapps/share/WEB-INF/classes/alfresco/module/myModuleShare" but it won't work and I get the error "
[org.alfresco.web.scripts.ActionEvaluatorHelper] Evaluator 'myCompany.product.doclib.icon.openInExternalProgram.folders' not found.
" in logs.

Thanks for any further hint.

I'm still glad of any further advice. Thanks!

I've placed the file now in folder:
..\Git\myShareProject\src\main\resources\alfresco\web-extension

I've renamed it from "custom-slingshot-application-context.xml" into "custom-slingshot-myModuleName-context.xml". It seems to be working right now.

BUT: Is this a convenient approach?