<?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;
}
}
L'application écoute le port jmx 9656 (par exemple)
Au lancement de l'application, on aura les options suivantes:
\-Dcom.sun.management.jmxremote \-Dcom.sun.management.jmxremote.port=9656 \-Dcom.sun.management.jmxremote.authenticate=false \-Dcom.sun.management.jmxremote.ssl=false
Application "surveillée" : activation/désactivation de la surveillance
activationJMX.sh
#!/bin/csh
set cmdLineJMXJar=/opt/admin-java/jmx/cmdline-jmxclient.jar
set jmxHost=host.etablissement.fr
set jmXPort=9656
#No User and password so pass '-'
echo "active l'utilisation de CMIS pour les applications en ecoute sur le port 9656"
/opt/jdk1.6.0/bin/java -jar ${cmdLineJMXJar} - ${jmxHost}:${port} bean:name=testCmis enabled
desactivationJMX.sh
#!/bin/csh
set cmdLineJMXJar=/opt/admin-java/jmx/cmdline-jmxclient.jar
set port=9656
set jmxHost=host.etablissement.fr
#No User and password so pass '-'
echo "désactive l'utilisation de CMIS pour les applications en ecoute sur le port 9656"
/opt/jdk1.6.0/bin/java -jar ${cmdLineJMXJar} - ${jmxHost}:${port} bean:name=testCmis disabled