org.daisy.pipeline.braille.common.BundledNativePath Maven / Gradle / Ivy
The newest version!
package org.daisy.pipeline.braille.common;
import java.net.URI;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.daisy.common.spi.ActivationException;
import static org.daisy.pipeline.braille.common.util.OS;
public class BundledNativePath extends StandardNativePath {
private static final String OS_FAMILY = "os.family";
private BundledResourcePath resourcePath;
protected ResourcePath delegate() {
return resourcePath;
}
/**
* @throws RuntimeException if the binaries don't work on the current OS
*/
protected void activate(Map,?> properties, Class> context) throws RuntimeException {
if (properties.get(OS_FAMILY) == null
|| properties.get(OS_FAMILY).toString().isEmpty()) {
throw new IllegalArgumentException(OS_FAMILY + " property must not be empty"); }
if (OS.Family.valueOf(properties.get(OS_FAMILY).toString().toUpperCase()) != OS.getFamily()) {
String errorMessage = "does not work on " + OS.getFamily();
try {
SPIHelper.failToActivate(errorMessage);
} catch (NoClassDefFoundError e) {
// we are probably in OSGi context
throw new RuntimeException(errorMessage);
}
}
if (properties.get(BundledResourcePath.UNPACK) != null)
throw new IllegalArgumentException(BundledResourcePath.UNPACK + " property not supported");
Map