User: mulder
Date: 00/10/04 18:36:33
Modified: src/main/org/jboss/configuration ConfigurationService.java
Log:
Changed configuration service so it doesn't use the JMX call to determine
whether a parameter is writeable.
Changed Minerva so the old "shrinking" is now "idle timeout".
- An object is guaranteed to be released when it has surpassed the idle
timeout (well, the next time GC is run, anyway)
- There's a new parameter MaxIdleTimeoutShrinkPercent that you can use
to force the server to replace some objects that hit the idle timeout
so the pool doesn't shrink too rapidly.
- The pool now prepopulates objects up to the minimum size, so the pool
is never below the minimum size
Updated jboss.jcml to reflect the new Minerva parameters.
Revision Changes Path
1.6 +45 -4 jboss/src/main/org/jboss/configuration/ConfigurationService.java
Index: ConfigurationService.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/configuration/ConfigurationService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ConfigurationService.java 2000/10/03 22:24:01 1.5
+++ ConfigurationService.java 2000/10/05 01:36:33 1.6
@@ -9,6 +9,8 @@
import java.io.*;
import java.beans.*;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.net.URL;
import java.util.Hashtable;
import java.util.Iterator;
@@ -27,7 +29,7 @@
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class ConfigurationService
extends ServiceMBeanSupport
@@ -98,7 +100,7 @@
String name = mbeanElement.getAttribute("name");
ObjectName objectName = new ObjectName(name);
-
+
MBeanInfo info;
try {
info = server.getMBeanInfo(objectName);
@@ -174,8 +176,10 @@
boolean hasAttributes = false;
for (int i = 0; i < attributes.length; i++)
{
- if (attributes[i].isReadable() &&
attributes[i].isWritable())
+ if (attributes[i].isReadable() &&
isAttributeWriteable(server.getObjectInstance(name).getClassName(),
attributes[i].getName(), attributes[i].getType()))
{
+ if(!attributes[i].isWritable())
+ log.error("Detected JMX Bug: Server reports attribute
'"+attributes[i].getName()+"' is not writeable for MBean
'"+name.getCanonicalName()+"'");
Element attributeElement =
doc.createElement("attribute");
Object value = server.getAttribute(name,
attributes[i].getName());
@@ -204,6 +208,43 @@
return out.toString();
}
- // Protected -----------------------------------------------------
+ // Protected -----------------------------------------------------
+ private boolean isAttributeWriteable(String className, String attribute, String
type) {
+ Class arg = null;
+ Class cls = null;
+ try {
+ if(type.equals("int"))
+ arg = Integer.TYPE;
+ else if(type.equals("boolean"))
+ arg = Boolean.TYPE;
+ else if(type.equals("float"))
+ arg = Float.TYPE;
+ else if(type.equals("byte"))
+ arg = Byte.TYPE;
+ else if(type.equals("short"))
+ arg = Short.TYPE;
+ else if(type.equals("char"))
+ arg = Character.TYPE;
+ else if(type.equals("long"))
+ arg = Long.TYPE;
+ else if(type.equals("double"))
+ arg = Double.TYPE;
+ else arg = Class.forName(type);
+ } catch(ClassNotFoundException e) {
+ log.error("Unable to check parameter of type '"+type+"'");
+ return false;
+ }
+ try {
+ cls = Class.forName(className);
+ } catch(ClassNotFoundException e) {
+ log.error("Unable to check MBean of type '"+className+"'");
+ return false;
+ }
+ try {
+ Method m = cls.getMethod("set"+attribute, new Class[]{arg});
+ return m != null && Modifier.isPublic(m.getModifiers()) &&
!Modifier.isStatic(m.getModifiers()) && m.getReturnType().equals(Void.TYPE);
+ } catch(NoSuchMethodException e) {}
+ return false;
+ }
}