sxiao3 / jsmpp

Automatically exported from code.google.com/p/jsmpp
Apache License 2.0
0 stars 0 forks source link

please support specifying a custom ExecutorService (or, even better, a plain Executor) #94

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
SMPPSession.java uses 

private ExecutorService executorService = 
Executors.newFixedThreadPool(getPduProcessorDegree());

it would be ideal for some of our use cases if there was a template method that 
provided the Executor for you so that a subclass could simply override it as 
appropriate. this is important because some environments don't allow native 
threads, but do support other abstractions through an Executor interface, like 
the WorkManager API (which is a standard that was never finished, but which 
remains partially supported on numerous platforms), which Spring also supports. 

perhaps you could have the following inside of SMPSession (NOT PDUReaderWorker, 
since there's no way to override that):

 protected java.util.concurrent.Executor buildExecutor(int numberOfThreads){ 
   // default implementation:
   return Executors.newFixedThreadPool(getPduProcessorDegree()); 
 }

I don't think I saw any other places in the code base where you instantiate a 
thread or threadpool or executor directly, but if there are such places, please 
also make those configurable.  

the API is fantastic, thanks very much. 

Original issue reported on code.google.com by starbux...@gmail.com on 28 Feb 2011 at 7:28