This is an automated email from the ASF dual-hosted git repository.
svenmeier pushed a commit to branch jmx-standardmbean-instead-proxy
in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 7b3b938c065a224d3762179d42fc5cd5d3be7084
Author: Sven Meier
AuthorDate: Fri Aug 20 19:34:33 2021 +0200
WICKET-6913 replace proxies with StandardMBean
---
wicket-jmx/pom.xml | 8 --
wicket-jmx/src/main/java/module-info.java | 1 -
.../java/org/apache/wicket/jmx/Initializer.java| 160 +++--
3 files changed, 54 insertions(+), 115 deletions(-)
diff --git a/wicket-jmx/pom.xml b/wicket-jmx/pom.xml
index 67303ae..5fa7d4b 100644
--- a/wicket-jmx/pom.xml
+++ b/wicket-jmx/pom.xml
@@ -30,16 +30,8 @@
- net.bytebuddy
- byte-buddy
-
-
org.apache.wicket
wicket-core
-
- org.ow2.asm
- asm
-
diff --git a/wicket-jmx/src/main/java/module-info.java
b/wicket-jmx/src/main/java/module-info.java
index a0366f8..b646aaf 100644
--- a/wicket-jmx/src/main/java/module-info.java
+++ b/wicket-jmx/src/main/java/module-info.java
@@ -20,7 +20,6 @@ module org.apache.wicket.jmx {
requires org.apache.wicket.util;
requires org.apache.wicket.core;
requires org.slf4j;
-requires net.bytebuddy;
provides org.apache.wicket.IInitializer with
org.apache.wicket.jmx.Initializer;
exports org.apache.wicket.jmx;
diff --git a/wicket-jmx/src/main/java/org/apache/wicket/jmx/Initializer.java
b/wicket-jmx/src/main/java/org/apache/wicket/jmx/Initializer.java
index 181f293..bb89f78 100644
--- a/wicket-jmx/src/main/java/org/apache/wicket/jmx/Initializer.java
+++ b/wicket-jmx/src/main/java/org/apache/wicket/jmx/Initializer.java
@@ -17,11 +17,11 @@
package org.apache.wicket.jmx;
import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
+import javax.management.Attribute;
+import javax.management.AttributeList;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanRegistrationException;
@@ -30,17 +30,7 @@ import javax.management.MBeanServerFactory;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
-
-import net.bytebuddy.ByteBuddy;
-import net.bytebuddy.NamingStrategy;
-import net.bytebuddy.TypeCache;
-import net.bytebuddy.description.type.TypeDescription;
-import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
-import net.bytebuddy.implementation.MethodDelegation;
-import net.bytebuddy.implementation.bind.annotation.AllArguments;
-import net.bytebuddy.implementation.bind.annotation.Origin;
-import net.bytebuddy.implementation.bind.annotation.RuntimeType;
-import net.bytebuddy.matcher.ElementMatchers;
+import javax.management.StandardMBean;
import org.apache.wicket.IInitializer;
import org.apache.wicket.ThreadContext;
@@ -78,15 +68,6 @@ public class Initializer implements IInitializer
{
private static final Logger LOG =
LoggerFactory.getLogger(Initializer.class);
- /**
-* A cache used to store the dynamically generated classes by ByteBuddy.
-* Without this cache a new class will be generated for each proxy
creation
-* and this will fill up the metaspace
-*/
- private static final TypeCache DYNAMIC_CLASS_CACHE
= new TypeCache.WithInlineExpunction<>(TypeCache.Sort.SOFT);
-
- private static final ByteBuddy BYTE_BUDDY = new ByteBuddy();
-
// It's best to store a reference to the MBeanServer rather than
getting it
// over and over
private MBeanServer mbeanServer = null;
@@ -246,102 +227,69 @@ public class Initializer implements IInitializer
* @throws MBeanRegistrationException
* @throws InstanceAlreadyExistsException
*/
- private void register(final org.apache.wicket.Application application,
final Object o,
+ private void register(final org.apache.wicket.Application
application, final T o,
final ObjectName objectName) throws
InstanceAlreadyExistsException,
MBeanRegistrationException, NotCompliantMBeanException
{
- Object proxy = createProxy(application, o);
- mbeanServer.registerMBean(proxy, objectName);
- registered.add(objectName);
- }
-
- // must be public to prevent JMX Server throwing:
- // failed to access class org.apache.wicket.jmx.Initializer$Interceptor
from class org.apache.wicket.jmx.Application
- public static class Interceptor
- {
-