Configuration des plug-in OSGi en utilisant le fichier descripteur XML ObjectGrid

Dans cette tâche, vous ajoutez des services OSGi existants à un fichier XML descripteur pour que les conteneurs WebSphere eXtreme Scale puissent reconnaître et charger correctement les plug-in OSGi.

Avant de commencer

Pour configurer vos plug-in, veillez à :

Pourquoi et quand exécuter cette tâche

Vous avez créé un service OSGi pour encapsuler le plug-in. Maintenant, ces services doivent être définis dans le fichier objectgrid.xml pour que les conteneurs eXtreme Scale puissent charger et configurer le ou les plug-in

Procédure

  1. Les plug-in de grille, tels que TransactionCallback, doivent être définis sous l'élément objectGrid. Voir l'exemple suivant du fichier objectgrid.xml :
    <?xml version="1.0" encoding="UTF-8"?>
    
    <objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
        xmlns="http://ibm.com/ws/objectgrid/config">
    
        <objectGrids>
            <objectGrid name="MyGrid" txTimeout="60">
                <bean id="myTranCallback" osgiService="myTranCallbackFactory"/>
                ...
            </objectGrid>
            ...
        </objectGrids>
        ...
    /objectGridConfig>
    Important : La valeur d'attribut osgiService doit correspondre à la valeur d'attribut ref définie dans le fichier XML blueprint, où le service a été défini pour myTranCallback PluginServiceFactory.
  2. Les plug-in de mappe, tels que les chargeurs ou les sérialiseurs, doivent être définis dans l'élément backingMapPluginCollections et référencés depuis l'élément backingMap. Voir l'exemple suivant du fichier objectgrid.xml :
    <?xml version="1.0" encoding="UTF-8"?>
    
    objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd"
        xmlns="http://ibm.com/ws/objectgrid/config">
        <objectGrids>
            <objectGrid name="MyGrid" txTimeout="60">
                <backingMap name="MyMap1" lockStrategy="PESSIMISTIC"
                    copyMode="COPY_TO_BYTES" nullValuesSupported="false"
                    pluginCollectionRef="myPluginCollectionRef1"/>
                <backingMap name="MyMap2" lockStrategy="PESSIMISTIC"
                    copyMode="COPY_TO_BYTES" nullValuesSupported="false"
                    pluginCollectionRef="myPluginCollectionRef2"/>
                ...
            </objectGrid>
            ...
        </objectGrids>
        ...
        <backingMapPluginCollections>
            <backingMapPluginCollection id="myPluginCollectionRef1">
                <bean id="MapSerializerPlugin" osgiService="mySerializerFactory"/>
            </backingMapPluginCollection>
            <backingMapPluginCollection id="myPluginCollectionRef2">
                <bean id="MapSerializerPlugin" osgiService="myOtherSerializerFactory"/>
                <bean id="Loader" osgiService="myLoader"/>
            </backingMapPluginCollection>
            ...
        </backingMapPluginCollections>
        ...
    </objectGridConfig>

Résultats

Le fichier objectgrid.xml dans cet exemple demande à eXtreme Scale de créer la grille MyGrid avec les deux mappes MyMap1 et MyMap2. La mappe MyMap1 utilise le sérialiseur encapsulé par le service OSGi, mySerializerFactory. La mappe MyMap2 utilise un sérialiseur depuis le service OSGi, myOtherSerializerFactory, et un chargeur depuis le service OSGi, myLoader.