-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from nkevins/develop
Increment 2 Development Code
- Loading branch information
Showing
269 changed files
with
17,648 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/com/chlorocode/tendertracker/LongProcessConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.chlorocode.tendertracker; | ||
|
||
import com.chlorocode.tendertracker.api.LongProcess; | ||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; | ||
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.AsyncConfigurer; | ||
import org.springframework.scheduling.annotation.EnableAsync; | ||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
|
||
import java.util.concurrent.Executor; | ||
|
||
/** | ||
* Created by Kyaw Min Thu on 5/1/2017. | ||
* This class is used to control the long background process of the application. | ||
*/ | ||
@Configuration | ||
@EnableAsync | ||
public class LongProcessConfiguration implements AsyncConfigurer { | ||
|
||
/** | ||
* This method is used to generate the LongProcess bean. | ||
* | ||
* @return LongProcess | ||
* @see LongProcess | ||
*/ | ||
@Bean | ||
public LongProcess longProcessBean() { | ||
return new LongProcess(); | ||
} | ||
|
||
/** | ||
* This method is used to get the executor of async tasks. | ||
* | ||
* @return Executor | ||
*/ | ||
@Override | ||
public Executor getAsyncExecutor() { | ||
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); | ||
taskExecutor.setMaxPoolSize(10); | ||
taskExecutor.setThreadNamePrefix("LULExecutor-"); | ||
taskExecutor.initialize(); | ||
return taskExecutor; | ||
} | ||
|
||
/** | ||
* This method is used to create the AsyncUncaughtExceptionHandler. | ||
* | ||
* @return AsyncUncaughtExceptionHandler | ||
*/ | ||
@Override | ||
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { | ||
return new SimpleAsyncUncaughtExceptionHandler(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/chlorocode/tendertracker/api/LongProcess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.chlorocode.tendertracker.api; | ||
|
||
import com.chlorocode.tendertracker.dao.entity.ExternalTender; | ||
import com.chlorocode.tendertracker.service.ExternalTenderService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.scheduling.annotation.AsyncResult; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.Future; | ||
|
||
/** | ||
* This class is used to handle long process threading during external tender saving process. | ||
*/ | ||
public class LongProcess { | ||
|
||
@Autowired | ||
private ExternalTenderService tenderWCService; | ||
|
||
/** | ||
* This method is used to save external tender asynchronously. | ||
* | ||
* @param tenders list of external tender to be saved | ||
* @return String | ||
*/ | ||
@Async | ||
public Future<String> createExternalTenderList(List<ExternalTender> tenders) { | ||
tenderWCService.createTenderWCList(tenders); | ||
return new AsyncResult<>("success"); | ||
} | ||
|
||
} |
Oops, something went wrong.