*
* @see org.ejbca.core.model.services.IWorker#work()
*/
public void work(Map<Class<?>, Object> ejbs) throws ServiceExecutionFailedException {
log.trace(">work");
final PublisherSessionLocal publisherSession = ((PublisherSessionLocal)ejbs.get(PublisherSessionLocal.class));
final PublisherQueueSessionLocal publisherQueueSession = ((PublisherQueueSessionLocal)ejbs.get(PublisherQueueSessionLocal.class));
// A semaphore used to not run parallel processing jobs
boolean running = false;
synchronized (runmap) {
Boolean b = runmap.get(this.serviceName);
if (b != null) {
running = b.booleanValue();
}
}
if (!running) {
try {
synchronized (runmap) {
runmap.put(this.serviceName, Boolean.valueOf(true));
}
Object o = properties.get(PROP_PUBLISHER_IDS);
if (o != null) {
String idstr = (String) o;
log.debug("Ids: " + idstr);
// Loop through all handled publisher ids and process
// anything in the queue
String[] ids = StringUtils.split(idstr, ';');
for (int i = 0; i < ids.length; i++) {
int publisherId = Integer.valueOf(ids[i]).intValue();
// Get everything from the queue for this publisher id
BasePublisher publisher = publisherSession.getPublisher(getAdmin(), publisherId);
publisherQueueSession.plainFifoTryAlwaysLimit100EntriesOrderByTimeCreated(getAdmin(), publisherId, publisher);
}
} else {
log.debug("No publisher ids configured for worker.");
}