Issue #70 has been updated by Pablo Ojanguren.

Implemented initial version following these steps:

1) Create MBean interface for class to manage

KunePropertiesDefaultMBean


package cc.kune.core.server.properties;

/**
 * MBean interface for JMX management of server properties
 *
 */
public interface KunePropertiesDefaultMBean {

    String reload();
    String getProperty(String key);
    void setProperty(String key, String value);

}

2) Implement mbean interface new methods

KunePropertiesDefault

diff --git a/src/main/java/cc/kune/core/server/properties/KunePropertiesDefault.java b/src/main/java/cc/kune/core/server/properties/KunePropertiesDefault.java
index aa8639f..ed79f6d 100644
--- a/src/main/java/cc/kune/core/server/properties/KunePropertiesDefault.java
+++ b/src/main/java/cc/kune/core/server/properties/KunePropertiesDefault.java
@@ -1,6 +1,6 @@
 /*
  *
- * Copyright (C) 2007-2012 The kune development team (see CREDITS for details)
+ * Copyright (C) 2007-2013 The kune development team (see CREDITS for details)
  * This file is part of kune.
  *
  * This program is free software: you can redistribute it and/or modify
@@ -35,7 +35,7 @@
 import com.google.inject.Singleton;

 @Singleton
-public class KunePropertiesDefault implements KuneProperties {
+public class KunePropertiesDefault implements KuneProperties, KunePropertiesDefaultMBean {
   public static final Log LOG = LogFactory.getLog(KunePropertiesDefault.class);
   private CompositeConfiguration config;
   private final String fileName;
@@ -124,4 +124,33 @@
     }
   }

+  @Override
+  public String reload() {
+     
+      String resultInfoStr = "OK";
+      
+      try {
+          
+          loadConfiguration();
+          
+      } catch (final ServerException e) {
+          
+          resultInfoStr = e.getMessage();
+      }
+     
+      return resultInfoStr;
+  }
+
+  @Override
+  public String getProperty(String key) {
+      
+      return this.get(key);
+  }
+
+  @Override
+  public void setProperty(String key, String value) {
+      
+      this.setProperty(key, value);
+  }
+
 }

3) Add mbean activation just after KuneProperties object is created

DataSourceKunePersistModule

diff --git a/src/main/java/cc/kune/core/server/persist/DataSourceKunePersistModule.java b/src/main/java/cc/kune/core/server/persist/DataSourceKunePersistModule.java
index 5b097bf..2ae371b 100644
--- a/src/main/java/cc/kune/core/server/persist/DataSourceKunePersistModule.java
+++ b/src/main/java/cc/kune/core/server/persist/DataSourceKunePersistModule.java
@@ -21,8 +21,15 @@

 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.management.ManagementFactory;
 import java.util.Properties;

+import javax.management.InstanceAlreadyExistsException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
 import javax.persistence.EntityManager;

 import org.apache.commons.configuration.SystemConfiguration;
@@ -220,6 +227,33 @@
     final SystemConfiguration sysConf = new SystemConfiguration();
     kuneConfig = settedProperties != null ? settedProperties : sysConf.getString("kune.server.config");
     kuneProperties = new KunePropertiesDefault(kuneConfig);
+    
+    /* #70 Reload Configuration Properties via JMX */
+    MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); 
+    ObjectName mbeanName = null;
+    try {
+    
+        mbeanName = new ObjectName("cc.kune.mbeans:type=KuneProperties");
+    
+    } catch (MalformedObjectNameException e) {
+        e.printStackTrace();        
+    } catch (NullPointerException e) {        
+        e.printStackTrace();
+    } 
+    
+    try {
+    
+        mbeanServer.registerMBean(kuneProperties, mbeanName);
+    
+    } catch (InstanceAlreadyExistsException e) {
+        e.printStackTrace();
+    } catch (MBeanRegistrationException e) {
+        e.printStackTrace();
+    } catch (NotCompliantMBeanException e) {
+        e.printStackTrace();
+    }
+    
+    
     log4Conf = sysConf.getString("log4j.configuration");
   }
 

4) Tested successfully using jconsole through local jetty-java process (see attached picture)

Next steps


Enhancement #70: Implement some kind of "/etc/init.d/kune reload" to reload configuration

Related
http://ykyuen.wordpress.com/2010/07/26/jetty-stop-a-jetty-server-by-command/
http://wiki.eclipse.org/Jetty/Howto/Secure_Termination
http://irc.codehaus.org/display/JETTY/How+to+gracefully+shutdown
http://ptrthomas.wordpress.com/2009/01/24/how-to-start-and-stop-jetty-revisited/
http://eureka.ykyuen.info/2010/07/26/jetty-stop-a-jetty-server-by-command/


You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://redmine.ourproject.org/my/account