public class CrossrefClient
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.ExecutorService |
executorService |
protected java.util.Map<java.lang.Long,java.util.List<java.util.concurrent.Future<?>>> |
futures |
protected static CrossrefClient |
instance |
protected static boolean |
limitAuto |
static Logger |
logger |
protected TimedSemaphore |
timedSemaphore |
Modifier | Constructor and Description |
---|---|
protected |
CrossrefClient()
Hidden constructor
|
Modifier and Type | Method and Description |
---|---|
void |
checkLimits() |
void |
close() |
void |
finish(long threadId)
Wait for all request from a specific thread to be completed
|
static CrossrefClient |
getInstance() |
static void |
printLog(CrossrefRequest<?> request,
java.lang.String message) |
<T> void |
pushRequest(CrossrefRequest<T> request,
CrossrefRequestListener<T> listener,
long threadId)
Push a request in pool to be executed as soon as possible, then wait a response through the listener.
|
<T> void |
pushRequest(java.lang.String model,
java.util.Map<java.lang.String,java.lang.String> params,
CrossrefDeserializer<T> deserializer,
long threadId,
CrossrefRequestListener<T> listener)
Push a request in pool to be executed soon as possible, then wait a response through the listener.
|
void |
setLimits(int iterations,
int interval) |
void |
updateLimits(int iterations,
int interval) |
public static final Logger logger
protected static volatile CrossrefClient instance
protected volatile java.util.concurrent.ExecutorService executorService
protected static boolean limitAuto
protected volatile TimedSemaphore timedSemaphore
protected volatile java.util.Map<java.lang.Long,java.util.List<java.util.concurrent.Future<?>>> futures
public static CrossrefClient getInstance()
public static void printLog(CrossrefRequest<?> request, java.lang.String message)
public void setLimits(int iterations, int interval)
public void updateLimits(int iterations, int interval)
public void checkLimits() throws java.lang.InterruptedException
java.lang.InterruptedException
public <T> void pushRequest(CrossrefRequest<T> request, CrossrefRequestListener<T> listener, long threadId) throws java.net.URISyntaxException, ClientProtocolException, java.io.IOException
java.net.URISyntaxException
ClientProtocolException
java.io.IOException
public <T> void pushRequest(java.lang.String model, java.util.Map<java.lang.String,java.lang.String> params, CrossrefDeserializer<T> deserializer, long threadId, CrossrefRequestListener<T> listener) throws java.net.URISyntaxException, ClientProtocolException, java.io.IOException
params
- query parameters, can be null, ex: ?query.title=[title]&query.author=[author]deserializer
- json response deserializer, ex: WorkDeserializer to convert Work to BiblioItemthreadId
- the java identifier of the thread providing the request (e.g. via Thread.currentThread().getId())listener
- catch response from requestjava.net.URISyntaxException
ClientProtocolException
java.io.IOException
public void finish(long threadId)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException