de.dnb.oai.harvester.DummyHarvester Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of oaiharvester Show documentation
Show all versions of oaiharvester Show documentation
A Java implementation of OAI-PMH 2.0 specification.
See http://www.openarchives.org/pmh/
The newest version!
/**********************************************************************
* Class DummyHarvester
*
* Copyright (c) 2008-2012, German National Library / Deutsche Nationalbibliothek
* Adickesallee 1, D-60322 Frankfurt am Main, Federal Republic of Germany
*
* This program is free software.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Kadir Karaca Kocer -- German National Library
*
**********************************************************************/
package de.dnb.oai.harvester;
import org.springframework.context.ApplicationContext;
import de.dnb.oai.harvester.task.Request;
import de.dnb.stm.task.TaskConstants;
/**
* Dummy Harvester to functional test of HarvesterManager.
* It does not do anything useful. Do not use it.
*
* @author Kadir Karaca Kocer, German National Library
*/
public class DummyHarvester extends Harvester {
private static int instanceCounter = 0;
private int instanceNumber;
/**
* Constructor
* @param context Application Context
*/
public DummyHarvester(ApplicationContext context) {
synchronized (DummyHarvester.class) {
this.instanceNumber = instanceCounter;
instanceCounter++;
}
}
/**
* @see de.dnb.oai.harvester.Harvester#run()
* @since 20.06.2008
*/
@Override
public void run() {
System.out.println("Harvester is running... " + this.instanceNumber);
Request request = this.getTask().getRequest();
request.setStatus(TaskConstants.TASK_STATUS_RUNNING);
try {
Thread.sleep(14000);
} catch (InterruptedException e) {
request.setStatus(TaskConstants.TASK_STATUS_INTERRUPTED);
System.out.println("Harvester interrupted... " + this.instanceNumber);
}
request.setStatus(TaskConstants.TASK_STATUS_SUCCESSFULL);
System.out.println("Harvester stopped... " + this.instanceNumber);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy