Skip to content

Commit

Permalink
Merge pull request #470 from blacklee123/main
Browse files Browse the repository at this point in the history
refactor: @bean should not return void
  • Loading branch information
ZhouYixun authored Oct 12, 2024
2 parents 5fa2d3e + 83aa608 commit 5d0665a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cloud.sonic.agent.bridge.android;

import jakarta.annotation.PreDestroy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

Expand All @@ -16,7 +17,15 @@ public class AndroidDeviceThreadPool {
public static ExecutorService cachedThreadPool;

@Bean
public void androidThreadPoolInit() {
public ExecutorService androidThreadPoolInit() {
cachedThreadPool = Executors.newCachedThreadPool();
return cachedThreadPool;
}

@PreDestroy
public void shutdownThreadPool() {
if (cachedThreadPool != null) {
cachedThreadPool.shutdown();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.cloud.sonic.agent.bridge.ios;

import jakarta.annotation.PreDestroy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
* @author ZhouYiXun
* @des 所有iOS相关线程都放这个线程池
Expand All @@ -16,7 +16,15 @@ public class IOSDeviceThreadPool {
public static ExecutorService cachedThreadPool;

@Bean
public void iOSThreadPoolInit() {
public ExecutorService iOSThreadPoolInit() {
cachedThreadPool = Executors.newCachedThreadPool();
return cachedThreadPool;
}

@PreDestroy
public void shutdownThreadPool() {
if (cachedThreadPool != null) {
cachedThreadPool.shutdown();
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/org/cloud/sonic/agent/bridge/ios/SibTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import jakarta.annotation.PostConstruct;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.Ordered;
Expand Down Expand Up @@ -83,7 +83,7 @@ public class SibTool implements ApplicationListener<ContextRefreshedEvent> {
private RestTemplate restTemplateBean;
private static Map<String, Integer> webViewMap = new HashMap<>();

@Bean
@PostConstruct
public void setEnv() {
bundleId = getBundleId;
xcodeProjectPath = getXcodeProjectPath;
Expand Down

0 comments on commit 5d0665a

Please sign in to comment.