update seata 1.6.1 => 1.7.0
parent
bc2b511f8b
commit
f3125d245c
Binary file not shown.
@ -1,188 +0,0 @@
|
||||
/*
|
||||
* Copyright 1999-2019 Seata.io Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.seata.spring.util;
|
||||
|
||||
import io.seata.common.util.CollectionUtils;
|
||||
import io.seata.rm.tcc.remoting.parser.DubboUtil;
|
||||
import org.springframework.aop.TargetSource;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.aop.framework.AdvisedSupport;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Proxy tools base on spring
|
||||
*
|
||||
* 临时修复 seata 适配 jdk17 反射bug
|
||||
*
|
||||
* @author zhangsen
|
||||
*/
|
||||
public class SpringProxyUtils {
|
||||
private SpringProxyUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find target class class.
|
||||
*
|
||||
* @param proxy the proxy
|
||||
* @return the class
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static Class<?> findTargetClass(Object proxy) throws Exception {
|
||||
if (proxy == null) {
|
||||
return null;
|
||||
}
|
||||
if (AopUtils.isAopProxy(proxy) && proxy instanceof Advised) {
|
||||
// #issue 3709
|
||||
final TargetSource targetSource = ((Advised) proxy).getTargetSource();
|
||||
if (!targetSource.isStatic()) {
|
||||
return targetSource.getTargetClass();
|
||||
}
|
||||
return findTargetClass(targetSource.getTarget());
|
||||
}
|
||||
return proxy.getClass();
|
||||
}
|
||||
|
||||
public static Class<?>[] findInterfaces(Object proxy) throws Exception {
|
||||
if (AopUtils.isJdkDynamicProxy(proxy)) {
|
||||
AdvisedSupport advised = getAdvisedSupport(proxy);
|
||||
return getInterfacesByAdvised(advised);
|
||||
} else {
|
||||
return new Class<?>[]{};
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<?>[] getInterfacesByAdvised(AdvisedSupport advised) {
|
||||
Class<?>[] interfaces = advised.getProxiedInterfaces();
|
||||
if (interfaces.length > 0) {
|
||||
return interfaces;
|
||||
} else {
|
||||
throw new IllegalStateException("Find the jdk dynamic proxy class that does not implement the interface");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets advised support.
|
||||
*
|
||||
* @param proxy the proxy
|
||||
* @return the advised support
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static AdvisedSupport getAdvisedSupport(Object proxy) throws Exception {
|
||||
Object dynamicAdvisedInterceptor;
|
||||
if (AopUtils.isJdkDynamicProxy(proxy)) {
|
||||
dynamicAdvisedInterceptor = Proxy.getInvocationHandler(proxy);
|
||||
} else {
|
||||
Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0");
|
||||
h.setAccessible(true);
|
||||
dynamicAdvisedInterceptor = h.get(proxy);
|
||||
}
|
||||
Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised");
|
||||
advised.setAccessible(true);
|
||||
return (AdvisedSupport)advised.get(dynamicAdvisedInterceptor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is proxy boolean.
|
||||
*
|
||||
* @param bean the bean
|
||||
* @return the boolean
|
||||
*/
|
||||
public static boolean isProxy(Object bean) {
|
||||
if (bean == null) {
|
||||
return false;
|
||||
}
|
||||
//check dubbo proxy ?
|
||||
return DubboUtil.isDubboProxyName(bean.getClass().getName()) || (Proxy.class.isAssignableFrom(bean.getClass())
|
||||
|| AopUtils.isAopProxy(bean));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the target class , get the interface of its agent if it is a Proxy
|
||||
*
|
||||
* @param proxy the proxy
|
||||
* @return target interface
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static Class<?> getTargetInterface(Object proxy) throws Exception {
|
||||
if (proxy == null) {
|
||||
throw new java.lang.IllegalArgumentException("proxy can not be null");
|
||||
}
|
||||
|
||||
//jdk proxy
|
||||
if (Proxy.class.isAssignableFrom(proxy.getClass())) {
|
||||
Proxy p = (Proxy)proxy;
|
||||
return p.getClass().getInterfaces()[0];
|
||||
}
|
||||
|
||||
return getTargetClass(proxy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class type of the proxy target object, if hadn't a target object, return the interface of the proxy
|
||||
*
|
||||
* @param proxy the proxy
|
||||
* @return target interface
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
protected static Class<?> getTargetClass(Object proxy) throws Exception {
|
||||
if (proxy == null) {
|
||||
throw new java.lang.IllegalArgumentException("proxy can not be null");
|
||||
}
|
||||
//not proxy
|
||||
if (!AopUtils.isAopProxy(proxy)) {
|
||||
return proxy.getClass();
|
||||
}
|
||||
AdvisedSupport advisedSupport = getAdvisedSupport(proxy);
|
||||
Object target = advisedSupport.getTargetSource().getTarget();
|
||||
/*
|
||||
* the Proxy of sofa:reference has no target
|
||||
*/
|
||||
if (target == null) {
|
||||
if (CollectionUtils.isNotEmpty(advisedSupport.getProxiedInterfaces())) {
|
||||
return advisedSupport.getProxiedInterfaces()[0];
|
||||
} else {
|
||||
return proxy.getClass();
|
||||
}
|
||||
} else {
|
||||
return getTargetClass(target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the all interfaces of bean, if the bean is null, then return empty array
|
||||
* @param bean the bean
|
||||
* @return target interface
|
||||
*/
|
||||
public static Class<?>[] getAllInterfaces(Object bean) {
|
||||
Set<Class<?>> interfaces = new HashSet<>();
|
||||
if (bean != null) {
|
||||
Class<?> clazz = bean.getClass();
|
||||
while (!Object.class.getName().equalsIgnoreCase(clazz.getName())) {
|
||||
Class<?>[] clazzInterfaces = clazz.getInterfaces();
|
||||
interfaces.addAll(Arrays.asList(clazzInterfaces));
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
}
|
||||
return interfaces.toArray(new Class[0]);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright 1999-2019 Seata.io Group.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.seata.server.spring.listener;
|
||||
|
||||
import io.seata.common.util.CollectionUtils;
|
||||
import io.seata.common.util.StringUtils;
|
||||
import io.seata.config.ConfigurationFactory;
|
||||
import io.seata.config.FileConfiguration;
|
||||
import io.seata.config.file.FileConfig;
|
||||
import io.seata.server.store.StoreConfig;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.core.env.PropertiesPropertySource;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static io.seata.common.ConfigurationKeys.*;
|
||||
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class SeataPropertiesLoader implements ApplicationContextInitializer<ConfigurableApplicationContext> {
|
||||
|
||||
List<String> prefixList = Arrays.asList(FILE_ROOT_PREFIX_CONFIG, FILE_ROOT_PREFIX_REGISTRY, SERVER_PREFIX,
|
||||
STORE_PREFIX, METRICS_PREFIX, TRANSPORT_PREFIX);
|
||||
|
||||
@Override
|
||||
public void initialize(ConfigurableApplicationContext applicationContext) {
|
||||
ConfigurableEnvironment environment = applicationContext.getEnvironment();
|
||||
FileConfiguration configuration = ConfigurationFactory.getOriginFileInstanceRegistry();
|
||||
FileConfig fileConfig = configuration.getFileConfig();
|
||||
Map<String, Object> configs = fileConfig.getAllConfig();
|
||||
if (CollectionUtils.isNotEmpty(configs)) {
|
||||
Optional<FileConfiguration> originFileInstance = ConfigurationFactory.getOriginFileInstance();
|
||||
originFileInstance
|
||||
.ifPresent(fileConfiguration -> configs.putAll(fileConfiguration.getFileConfig().getAllConfig()));
|
||||
Properties properties = new Properties();
|
||||
configs.forEach((k, v) -> {
|
||||
if (v instanceof String) {
|
||||
if (StringUtils.isEmpty((String)v)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Convert the configuration name to the configuration name under Spring Boot
|
||||
if (prefixList.stream().anyMatch(k::startsWith)) {
|
||||
properties.put(SEATA_FILE_PREFIX_ROOT_CONFIG + k, v);
|
||||
}
|
||||
});
|
||||
environment.getPropertySources().addLast(new PropertiesPropertySource("seataOldConfig", properties));
|
||||
}
|
||||
// Load by priority
|
||||
System.setProperty("sessionMode", StoreConfig.getSessionMode().getName());
|
||||
System.setProperty("lockMode", StoreConfig.getLockMode().getName());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,362 @@
|
||||
[
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.core.rpc.RegisterCheckAuthHandler"
|
||||
},
|
||||
"name": "io.seata.server.auth.DefaultCheckAuthHandler",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.core.store.db.DataSourceProvider"
|
||||
},
|
||||
"name": "io.seata.server.store.DbcpDataSourceProvider",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.core.store.db.DataSourceProvider"
|
||||
},
|
||||
"name": "io.seata.server.store.DruidDataSourceProvider",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.core.store.db.DataSourceProvider"
|
||||
},
|
||||
"name": "io.seata.server.store.HikariDataSourceProvider",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.core.store.DistributedLocker"
|
||||
},
|
||||
"name": "io.seata.server.storage.redis.lock.RedisDistributedLocker",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.core.store.DistributedLocker"
|
||||
},
|
||||
"name": "io.seata.server.storage.db.lock.DataBaseDistributedLocker",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.coordinator.AbstractCore"
|
||||
},
|
||||
"name": "io.seata.server.transaction.at.ATCore",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": [
|
||||
"io.seata.core.rpc.RemotingServer"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.coordinator.AbstractCore"
|
||||
},
|
||||
"name": "io.seata.server.transaction.tcc.TccCore",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": [
|
||||
"io.seata.core.rpc.RemotingServer"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.coordinator.AbstractCore"
|
||||
},
|
||||
"name": "io.seata.server.transaction.saga.SagaCore",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": [
|
||||
"io.seata.core.rpc.RemotingServer"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.coordinator.AbstractCore"
|
||||
},
|
||||
"name": "io.seata.server.transaction.xa.XACore",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": [
|
||||
"io.seata.core.rpc.RemotingServer"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.lock.LockManager"
|
||||
},
|
||||
"name": "io.seata.server.storage.db.lock.DataBaseLockManager",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.lock.LockManager"
|
||||
},
|
||||
"name": "io.seata.server.storage.file.lock.FileLockManager",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.lock.LockManager"
|
||||
},
|
||||
"name": "io.seata.server.storage.redis.lock.RedisLockManager",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.session.SessionManager"
|
||||
},
|
||||
"name": "io.seata.server.storage.file.session.FileSessionManager",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": [
|
||||
"java.lang.String",
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.session.SessionManager"
|
||||
},
|
||||
"name": "io.seata.server.storage.db.session.DataBaseSessionManager",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
},
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": [
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.seata.server.session.SessionManager"
|
||||
},
|
||||
"name": "io.seata.server.storage.redis.session.RedisSessionManager",
|
||||
"methods": [
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": []
|
||||
},
|
||||
{
|
||||
"name": "<init>",
|
||||
"parameterTypes": [
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "com.google.inject.internal.TypeConverterBindingProcessor"
|
||||
},
|
||||
"name": "java.lang.Integer",
|
||||
"methods": [
|
||||
{
|
||||
"name": "parseInteger",
|
||||
"parameterTypes": [
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "com.google.inject.internal.TypeConverterBindingProcessor"
|
||||
},
|
||||
"name": "java.lang.Long",
|
||||
"methods": [
|
||||
{
|
||||
"name": "parseLong",
|
||||
"parameterTypes": [
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "com.google.inject.internal.TypeConverterBindingProcessor"
|
||||
},
|
||||
"name": "java.lang.Boolean",
|
||||
"methods": [
|
||||
{
|
||||
"name": "parseBoolean",
|
||||
"parameterTypes": [
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "com.google.inject.internal.TypeConverterBindingProcessor"
|
||||
},
|
||||
"name": "java.lang.Byte",
|
||||
"methods": [
|
||||
{
|
||||
"name": "parseByte",
|
||||
"parameterTypes": [
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "com.google.inject.internal.TypeConverterBindingProcessor"
|
||||
},
|
||||
"name": "java.lang.Short",
|
||||
"methods": [
|
||||
{
|
||||
"name": "parseShort",
|
||||
"parameterTypes": [
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "com.google.inject.internal.TypeConverterBindingProcessor"
|
||||
},
|
||||
"name": "java.lang.Float",
|
||||
"methods": [
|
||||
{
|
||||
"name": "parseFloat",
|
||||
"parameterTypes": [
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "com.google.inject.internal.TypeConverterBindingProcessor"
|
||||
},
|
||||
"name": "java.lang.Double",
|
||||
"methods": [
|
||||
{
|
||||
"name": "parseDouble",
|
||||
"parameterTypes": [
|
||||
"java.lang.String"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.netty.channel.socket.nio.SelectorProviderUtil"
|
||||
},
|
||||
"name": "java.nio.channels.spi.SelectorProvider",
|
||||
"methods": [
|
||||
{
|
||||
"name": "openServerSocketChannel",
|
||||
"parameterTypes": [
|
||||
"java.net.ProtocolFamily"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.netty.channel.DefaultChannelConfig"
|
||||
},
|
||||
"name": "io.netty.buffer.ByteBufAllocator"
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.netty.channel.DefaultChannelConfig"
|
||||
},
|
||||
"name": "io.netty.buffer.ByteBufUtil"
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.netty.util.ResourceLeakDetector"
|
||||
},
|
||||
"name": "io.netty.buffer.AbstractByteBufAllocator",
|
||||
"allDeclaredMethods": true
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.netty.util.ResourceLeakDetector"
|
||||
},
|
||||
"name": "io.netty.buffer.AdvancedLeakAwareByteBuf",
|
||||
"allDeclaredMethods": true
|
||||
},
|
||||
{
|
||||
"condition": {
|
||||
"typeReachable": "io.netty.util.ResourceLeakDetector"
|
||||
},
|
||||
"name": "io.netty.util.ReferenceCountUtil",
|
||||
"allDeclaredMethods": true
|
||||
}
|
||||
]
|
@ -0,0 +1,21 @@
|
||||
{
|
||||
"resources": {
|
||||
"includes": [
|
||||
{
|
||||
"pattern": "\\Qlogback\/\\E.*"
|
||||
},
|
||||
{
|
||||
"pattern": "\\Qlua\/redislocker\/redislock.lua\\E"
|
||||
},
|
||||
{
|
||||
"pattern": "\\Qapplication.yml\\E"
|
||||
},
|
||||
{
|
||||
"pattern": "\\Qbanner.txt\\E"
|
||||
},
|
||||
{
|
||||
"pattern": "\\Qlogback-spring.xml\\E"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -1,2 +1,4 @@
|
||||
org.springframework.context.ApplicationListener=\
|
||||
io.seata.server.ServerApplicationListener
|
||||
io.seata.server.spring.listener.ServerApplicationListener
|
||||
org.springframework.context.ApplicationContextInitializer=\
|
||||
io.seata.server.spring.listener.SeataPropertiesLoader
|
Loading…
Reference in New Issue