Projets

Vous regardez une version antérieure (v. /wiki/spaces/PROJ/pages/164462605/3.25+JMX) de cette page.

afficher les différences afficher l'historique de la page

« Afficher la version précédente Vous regardez la version actuelle de cette page. (v. 4) afficher la version suivante »

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

    
    <bean id="cmisFileStorageService"
        lazy-init="true">
        <description>A bean to manage files upload and download to the Nuxeo server.</description>
         ...
        <property name="jmxTestCmis" ref="jmxTestCmis"/>
    </bean>
    
    
    <!--  JMX to control CMIS -->
    <bean id="exporter">
        <property name="beans">
            <map>
                <entry key="bean:name=testCmis" value-ref="jmxTestCmis"/>
            </map>
        </property>
    </bean>
    
    <bean id="jmxTestCmis"
        class="org.esupportail.application.service.fileStorage.JmxTestCmisImpl">
        ...
    </bean>
    
</beans>
public class CmisFileStorageServiceImpl  {
     ....

    /**
     * Bean to test if cmis is ready.
     */
    private JmxTestCmis jmxTestCmis;

    public void afterPropertiesSet() throws Exception {
        ....
        Assert.notNull(this.jmxTestCmis,
                "property jmxTestCmis of class " + this.getClass().getName() + " can not be null");
    }    
    ...
    /**
     * @param jmxTestCmis the jmxTestCmis to set
     */
    public void setJmxTestCmis(final JmxTestCmis jmxTestCmis) {
        this.jmxTestCmis = jmxTestCmis;
    }

    public FileStorage getFile(...) throws IOException {
        FileStorage file = null;
        if (jmxTestCmis.getCmisIsReady()) {
                         file= ...;
            
        }  else {
            System.err.println("--------le service CMIS est indisponible");
        }
        return file;
    }
}
 package org.esupportail.application.services.fileStorage;
public interface JmxTestCmis {
    /**
     * Enable the use of CMIS.
     */
    void enabledCmis();
    
    /**
     * Disable the use of CMIS.
     */
    void disabledCmis();
    
    /**
     * @return the cmisIsReady
     */
    Boolean getCmisIsReady();
}

package org.esupportail.application.services.fileStorage;
import java.io.Serializable;
public class JmxTestCmisImpl implements JmxTestCmis, Serializable {
    /**
     * True if cmis is ready.
     * Default value = true.
     */
    private Boolean cmisIsReady;
    public JmxTestCmisImpl() {
        super();
        cmisIsReady = true;
    }

    @Override
    public void disabledCmis() {
        cmisIsReady = false;
    }

    @Override
    public void enabledCmis() {
        cmisIsReady = true;
    }
    
    public Boolean getCmisIsReady() {
        return cmisIsReady;
    }
}
  • Aucune étiquette