mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 02:28:25 +08:00 
			
		
		
		
	🎨 优化部分代码
This commit is contained in:
		| @ -1,6 +1,7 @@ | |||||||
| package cn.binarywang.wx.graal; | package cn.binarywang.wx.graal; | ||||||
|  |  | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
|  | import lombok.extern.slf4j.Slf4j; | ||||||
|  |  | ||||||
| import javax.annotation.processing.AbstractProcessor; | import javax.annotation.processing.AbstractProcessor; | ||||||
| import javax.annotation.processing.RoundEnvironment; | import javax.annotation.processing.RoundEnvironment; | ||||||
| @ -25,7 +26,6 @@ import java.util.TreeSet; | |||||||
|  * |  * | ||||||
|  * @author outersky |  * @author outersky | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| @SupportedAnnotationTypes("lombok.Data") | @SupportedAnnotationTypes("lombok.Data") | ||||||
| @SupportedSourceVersion(SourceVersion.RELEASE_7) | @SupportedSourceVersion(SourceVersion.RELEASE_7) | ||||||
| public class GraalProcessor extends AbstractProcessor { | public class GraalProcessor extends AbstractProcessor { | ||||||
| @ -38,7 +38,6 @@ public class GraalProcessor extends AbstractProcessor { | |||||||
|   @Override |   @Override | ||||||
|   public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |   public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { | ||||||
|     for (TypeElement annotatedClass : ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(Data.class))) { |     for (TypeElement annotatedClass : ElementFilter.typesIn(roundEnv.getElementsAnnotatedWith(Data.class))) { | ||||||
|  |  | ||||||
|       registerClass(annotatedClass.getQualifiedName().toString()); |       registerClass(annotatedClass.getQualifiedName().toString()); | ||||||
|       handleSuperClass(annotatedClass); |       handleSuperClass(annotatedClass); | ||||||
|     } |     } | ||||||
| @ -108,16 +107,16 @@ public class GraalProcessor extends AbstractProcessor { | |||||||
|     String propsFile = path + NATIVE_IMAGE_PROPERTIES; |     String propsFile = path + NATIVE_IMAGE_PROPERTIES; | ||||||
|     try { |     try { | ||||||
|       FileObject fileObject = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", propsFile); |       FileObject fileObject = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", propsFile); | ||||||
|       Writer writer = fileObject.openWriter(); |       try (Writer writer = fileObject.openWriter();) { | ||||||
|         writer.append("Args = -H:ReflectionConfigurationResources=${.}/" + REFLECTION_CONFIG_JSON); |         writer.append("Args = -H:ReflectionConfigurationResources=${.}/" + REFLECTION_CONFIG_JSON); | ||||||
|       writer.close(); |       } | ||||||
|     } catch (IOException e) { |     } catch (IOException e) { | ||||||
|       e.printStackTrace(); |       e.printStackTrace(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     try { |     try { | ||||||
|       FileObject fileObject = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", reflectFile); |       FileObject fileObject = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", reflectFile); | ||||||
|       Writer writer = fileObject.openWriter(); |       try (Writer writer = fileObject.openWriter();) { | ||||||
|         writer.write("[\n"); |         writer.write("[\n"); | ||||||
|         boolean first = true; |         boolean first = true; | ||||||
|         for (String name : classSet) { |         for (String name : classSet) { | ||||||
| @ -130,7 +129,7 @@ public class GraalProcessor extends AbstractProcessor { | |||||||
|           writer.append('\n'); |           writer.append('\n'); | ||||||
|         } |         } | ||||||
|         writer.write("]"); |         writer.write("]"); | ||||||
|       writer.close(); |       } | ||||||
|     } catch (IOException e) { |     } catch (IOException e) { | ||||||
|       e.printStackTrace(); |       e.printStackTrace(); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,21 +1,19 @@ | |||||||
| package me.chanjar.weixin.common.session; | package me.chanjar.weixin.common.session; | ||||||
|  |  | ||||||
|  | import me.chanjar.weixin.common.util.res.StringManager; | ||||||
|  | import org.slf4j.Logger; | ||||||
|  | import org.slf4j.LoggerFactory; | ||||||
|  |  | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| import java.util.concurrent.ConcurrentHashMap; | import java.util.concurrent.ConcurrentHashMap; | ||||||
| import java.util.concurrent.atomic.AtomicBoolean; | import java.util.concurrent.atomic.AtomicBoolean; | ||||||
|  |  | ||||||
| import org.slf4j.Logger; |  | ||||||
| import org.slf4j.LoggerFactory; |  | ||||||
|  |  | ||||||
| import me.chanjar.weixin.common.util.res.StringManager; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 基于内存的session manager. |  * 基于内存的session manager. | ||||||
|  * |  * | ||||||
|  * @author Daniel Qian |  * @author Daniel Qian | ||||||
|  */ |  */ | ||||||
| public class StandardSessionManager implements WxSessionManager, InternalSessionManager { | public class StandardSessionManager implements WxSessionManager, InternalSessionManager { | ||||||
|  |  | ||||||
|   protected static final StringManager SM = StringManager.getManager(Constants.PACKAGE); |   protected static final StringManager SM = StringManager.getManager(Constants.PACKAGE); | ||||||
|   /** |   /** | ||||||
|    * The descriptive name of this Manager implementation (for logging). |    * The descriptive name of this Manager implementation (for logging). | ||||||
| @ -51,7 +49,9 @@ public class StandardSessionManager implements WxSessionManager, InternalSession | |||||||
|    */ |    */ | ||||||
|   protected int maxInactiveInterval = 30 * 60; |   protected int maxInactiveInterval = 30 * 60; | ||||||
|  |  | ||||||
|   // Number of sessions created by this manager |   /** | ||||||
|  |    * Number of sessions created by this manager | ||||||
|  |    */ | ||||||
|   protected long sessionCounter = 0; |   protected long sessionCounter = 0; | ||||||
|  |  | ||||||
|   protected volatile int maxActive = 0; |   protected volatile int maxActive = 0; | ||||||
| @ -154,12 +154,10 @@ public class StandardSessionManager implements WxSessionManager, InternalSession | |||||||
|     session.setValid(true); |     session.setValid(true); | ||||||
|     session.setCreationTime(System.currentTimeMillis()); |     session.setCreationTime(System.currentTimeMillis()); | ||||||
|     session.setMaxInactiveInterval(this.maxInactiveInterval); |     session.setMaxInactiveInterval(this.maxInactiveInterval); | ||||||
|     String id = sessionId; |     session.setId(sessionId); | ||||||
|     session.setId(id); |  | ||||||
|     this.sessionCounter++; |     this.sessionCounter++; | ||||||
|  |  | ||||||
|     return (session); |     return session; | ||||||
|  |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |  | ||||||
| @ -181,10 +179,8 @@ public class StandardSessionManager implements WxSessionManager, InternalSession | |||||||
|     return new StandardSession(this); |     return new StandardSession(this); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public void add(InternalSession session) { |   public void add(InternalSession session) { | ||||||
|  |  | ||||||
|     // 当第一次有session创建的时候,开启session清理线程 |     // 当第一次有session创建的时候,开启session清理线程 | ||||||
|     if (!this.backgroundProcessStarted.getAndSet(true)) { |     if (!this.backgroundProcessStarted.getAndSet(true)) { | ||||||
|       Thread t = new Thread(new Runnable() { |       Thread t = new Thread(new Runnable() { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang