1.3.3. External plugin

Warning

You are looking at documentation for an older release. Not what you want? See the current release documentation.

The external plugin allows you to add configuration on the fly.

As stated in Service configuration for beginners, the newer configurations normally replace previous configurations. An external plugin allows you to add configuration without replacing previous configurations.

That can be interesting if you adapt a service configuration for your project-specific needs (country, language, branch, project, and more).

Let's have a look at the TaxonomyPlugin configuration of the CategoriesService:


<external-component-plugins>
    <target-component>org.exoplatform.services.cms.categories.CategoriesService</target-component>    
        <component-plugin>
        <name>predefinedTaxonomyPlugin</name>
        <set-method>addTaxonomyPlugin</set-method>
        <type>org.exoplatform.services.cms.categories.impl.TaxonomyPlugin</type>
        <init-params>
            <value-param>
                <name>autoCreateInNewRepository</name>
                <value>true</value>
            </value-param>         
            <value-param>
                <name>repository</name>
                <value>repository</value>
            </value-param>         
            <object-param>
                <name>taxonomy.configuration</name>
                <description>configuration predefined taxonomies to inject in jcr</description>
                <object type="org.exoplatform.services.cms.categories.impl.TaxonomyConfig">            
                    <field  name="taxonomies">
                        <collection type="java.util.ArrayList">
                            <!-- cms taxonomy -->
                            <value>
                                <object type="org.exoplatform.services.cms.categories.impl.TaxonomyConfig$Taxonomy">
                                    <field  name="name"><string>cmsTaxonomy</string></field>                              
                                    <field  name="path"><string>/cms</string></field>                                              
                                </object>
                            </value>
                            <value> 
                                <object type="org.exoplatform.services.cms.categories.impl.TaxonomyConfig$Taxonomy">
                                    <field  name="name"><string>newsTaxonomy</string></field>                              
                                    <field  name="path"><string>/cms/news</string></field>                                              
                                </object>
                            </value>
                        </collection>
                    </field>                     
                </object>
            </object-param>
        </init-params>
    </component-plugin>
<external-component-plugins>

The <target-component> defines the service for which the plugin is defined. The configuration is injected by the container using a method that is defined in <set-method>. The method has exactly one argument of the org.exoplatform.services.cms.categories.impl.TaxonomyPlugin type:

addTaxonomyPlugin(org.exoplatform.services.cms.categories.impl.TaxonomyPlugin plugin)

The content of <init-params> corresponds to the structure of the TaxonomyPlugin object.

Note

You can configure the CategoriesService component using the addTaxonomyPlugin as often as you wish. You can also call addTaxonomyPlugin in different configuration files. The addTaxonomyPlugin method is then called for several times, everything else that depends on the implementation of the method.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus