16
16
*/
17
17
package org .apache .seata .config ;
18
18
19
+ import java .lang .reflect .Proxy ;
19
20
import java .util .HashMap ;
20
21
import java .util .HashSet ;
21
22
import java .util .Map ;
24
25
import org .apache .seata .common .util .CollectionUtils ;
25
26
import org .apache .seata .common .util .DurationUtil ;
26
27
import org .apache .seata .common .util .StringUtils ;
27
- import net .bytebuddy .ByteBuddy ;
28
- import net .bytebuddy .implementation .InvocationHandlerAdapter ;
29
- import net .bytebuddy .matcher .ElementMatchers ;
30
28
29
+ /**
30
+ * @author funkye
31
+ */
31
32
public class ConfigurationCache implements ConfigurationChangeListener {
32
33
33
34
private static final String METHOD_PREFIX = "get" ;
@@ -99,8 +100,8 @@ public void onChangeEvent(ConfigurationChangeEvent event) {
99
100
}
100
101
101
102
public Configuration proxy (Configuration originalConfiguration ) throws Exception {
102
- return new ByteBuddy (). subclass ( Configuration . class ). method ( ElementMatchers . any ())
103
- . intercept ( InvocationHandlerAdapter . of ( (proxy , method , args ) -> {
103
+ return ( Configuration ) Proxy . newProxyInstance ( this . getClass (). getClassLoader (), new Class []{ Configuration . class }
104
+ , (proxy , method , args ) -> {
104
105
String methodName = method .getName ();
105
106
if (methodName .startsWith (METHOD_PREFIX ) && !methodName .equalsIgnoreCase (METHOD_LATEST_CONFIG )) {
106
107
String rawDataId = (String )args [0 ];
@@ -124,8 +125,8 @@ public Configuration proxy(Configuration originalConfiguration) throws Exception
124
125
return wrapper == null ? null : wrapper .convertData (type );
125
126
}
126
127
return method .invoke (originalConfiguration , args );
127
- })). make (). load ( originalConfiguration . getClass (). getClassLoader ()). getLoaded (). getDeclaredConstructor ()
128
- . newInstance ( );
128
+ }
129
+ );
129
130
}
130
131
131
132
private static class ConfigurationCacheInstance {
0 commit comments