
cc.protea.foundation.util.ThreadUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of foundation Show documentation
Show all versions of foundation Show documentation
Integrate compatible versions of many external systems to create a REST/HTTP server foundation
The newest version!
package cc.protea.foundation.util;
import java.io.IOException;
import javax.ws.rs.core.Response.Status;
import org.glassfish.jersey.server.ChunkedOutput;
import cc.protea.foundation.model.ProteaException;
public class ThreadUtil {
public static abstract class ChunkedThread extends Thread {
protected final ChunkedOutput output;
public ChunkedThread(final String title) {
super(title);
output = new ChunkedOutput(String.class);
}
public abstract void process() throws IOException;
public void run() {
try {
process();
} catch (IOException e) {
throw new ProteaException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
} finally {
try {
output.close();
} catch (IOException e) {
throw new ProteaException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
}
}
}
public ChunkedOutput go() {
super.start();
return output;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy