| Bloc de code |
|---|
<?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> |
| Bloc de code |
|---|
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; } } |
| Bloc de code |
|---|
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;
}
}
|