com.liferay.portal.kernel.concurrent.FutureConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.portal.kernel Show documentation
Show all versions of com.liferay.portal.kernel Show documentation
Contains interfaces for the portal services. Interfaces are only loaded by the global class loader and are shared by all plugins.
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.kernel.concurrent;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* @author Shuyang Zhou
*/
public abstract class FutureConverter implements Future {
public FutureConverter(Future future) {
_future = future;
}
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return _future.cancel(mayInterruptIfRunning);
}
@Override
public T get() throws ExecutionException, InterruptedException {
V v = _future.get();
try {
return convert(v);
}
catch (Throwable t) {
throw new ExecutionException(t);
}
}
@Override
public T get(long timeout, TimeUnit timeUnit)
throws ExecutionException, InterruptedException, TimeoutException {
V v = _future.get(timeout, timeUnit);
try {
return convert(v);
}
catch (Throwable t) {
throw new ExecutionException(t);
}
}
@Override
public boolean isCancelled() {
return _future.isCancelled();
}
@Override
public boolean isDone() {
return _future.isDone();
}
protected abstract T convert(V v) throws Throwable;
private final Future _future;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy