457696 - JMX implementation should not be overridden by WebApp classes

+ Marking org.eclipse.jetty.util.annotation. for hole punching
+ Making ContextHandler parsing of "org.eclipse.jetty.server.context.ManagedAttributes"
  more lenient to whitespace around delimitors
+ Making ObjectMBean take in account the .jmx.{name}MBean for
  annotation influences too.
This commit is contained in:
Joakim Erdfelt 2015-01-16 15:15:44 -07:00
parent aea4713d27
commit 3f08e54a23
3 changed files with 17 additions and 23 deletions

View File

@ -241,7 +241,9 @@ public class ObjectMBean implements DynamicMBean
// Find list of classes that can influence the mbean
Class<?> o_class=_managed.getClass();
List<Class<?>> influences = findInfluences(new ArrayList<Class<?>>(), _managed.getClass());
List<Class<?>> influences = new ArrayList<Class<?>>();
influences.add(this.getClass()); // always add MBean itself
influences = findInfluences(influences, _managed.getClass());
if (LOG.isDebugEnabled())
LOG.debug("Influence Count: {}", influences.size() );
@ -560,35 +562,23 @@ public class ObjectMBean implements DynamicMBean
private static List<Class<?>> findInfluences(List<Class<?>> influences, Class<?> aClass)
{
if (aClass!=null)
if (aClass != null)
{
// This class is an influence
influences.add(aClass);
String pName = aClass.getPackage().getName();
String cName = aClass.getName().substring(pName.length() + 1);
String mName = pName + ".jmx." + cName + "MBean";
try
if (!influences.contains(aClass))
{
Class<?> mbeanClazz = Class.forName(mName);
if (LOG.isDebugEnabled())
LOG.debug("MBean Influence found for " + aClass.getSimpleName());
influences.add(mbeanClazz);
}
catch (ClassNotFoundException cnfe)
{
if (LOG.isDebugEnabled())
LOG.debug("No MBean Influence for " + aClass.getSimpleName());
// This class is a new influence
influences.add(aClass);
}
// So are the super classes
influences=findInfluences(influences,aClass.getSuperclass());
influences = findInfluences(influences,aClass.getSuperclass());
// So are the interfaces
Class<?>[] ifs = aClass.getInterfaces();
for (int i=0;ifs!=null && i<ifs.length;i++)
influences=findInfluences(influences,ifs[i]);
for (int i = 0; ifs != null && i < ifs.length; i++)
{
influences = findInfluences(influences,ifs[i]);
}
}
return influences;

View File

@ -768,7 +768,9 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
_managedAttributes = new HashMap<String, Object>();
String[] attributes = managedAttributes.split(",");
for (String attribute : attributes)
_managedAttributes.put(attribute,null);
{
_managedAttributes.put(attribute.trim(),null);
}
Enumeration<String> e = _scontext.getAttributeNames();
while (e.hasMoreElements())

View File

@ -112,6 +112,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
"org.xml.", // needed by javax.xml
"org.w3c.", // needed by javax.xml
"org.eclipse.jetty.jmx.", // webapp cannot change jmx classes
"org.eclipse.jetty.util.annotation.", // webapp cannot change jmx annotations
"org.eclipse.jetty.continuation.", // webapp cannot change continuation classes
"org.eclipse.jetty.jndi.", // webapp cannot change naming classes
"org.eclipse.jetty.jaas.", // webapp cannot change jaas classes
@ -130,6 +131,7 @@ public class WebAppContext extends ServletContextHandler implements WebAppClassL
public final static String[] __dftServerClasses =
{
"-org.eclipse.jetty.jmx.", // don't hide jmx classes
"-org.eclipse.jetty.util.annotation.", // don't hide jmx annotation
"-org.eclipse.jetty.continuation.", // don't hide continuation classes
"-org.eclipse.jetty.jndi.", // don't hide naming classes
"-org.eclipse.jetty.jaas.", // don't hide jaas classes