mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 20:15:28 -04:00
#405 SVG OSGi issue
This commit is contained in:
parent
9b871322f7
commit
0c66ad82dd
@ -29,7 +29,7 @@
|
|||||||
package com.twelvemonkeys.imageio.plugins.svg;
|
package com.twelvemonkeys.imageio.plugins.svg;
|
||||||
|
|
||||||
import com.twelvemonkeys.imageio.spi.ImageReaderSpiBase;
|
import com.twelvemonkeys.imageio.spi.ImageReaderSpiBase;
|
||||||
import com.twelvemonkeys.imageio.util.IIOUtil;
|
import com.twelvemonkeys.lang.SystemUtil;
|
||||||
|
|
||||||
import javax.imageio.ImageReader;
|
import javax.imageio.ImageReader;
|
||||||
import javax.imageio.spi.ServiceRegistry;
|
import javax.imageio.spi.ServiceRegistry;
|
||||||
@ -38,8 +38,7 @@ import java.io.EOFException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static com.twelvemonkeys.imageio.plugins.svg.SVGProviderInfo.SVG_READER_AVAILABLE;
|
import static com.twelvemonkeys.imageio.util.IIOUtil.deregisterProvider;
|
||||||
import static com.twelvemonkeys.imageio.util.IIOUtil.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SVGImageReaderSpi
|
* SVGImageReaderSpi
|
||||||
@ -50,6 +49,8 @@ import static com.twelvemonkeys.imageio.util.IIOUtil.*;
|
|||||||
*/
|
*/
|
||||||
public final class SVGImageReaderSpi extends ImageReaderSpiBase {
|
public final class SVGImageReaderSpi extends ImageReaderSpiBase {
|
||||||
|
|
||||||
|
final static boolean SVG_READER_AVAILABLE = SystemUtil.isClassAvailable("com.twelvemonkeys.imageio.plugins.svg.SVGImageReader", SVGImageReaderSpi.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an {@code SVGImageReaderSpi}.
|
* Creates an {@code SVGImageReaderSpi}.
|
||||||
*/
|
*/
|
||||||
@ -59,7 +60,7 @@ public final class SVGImageReaderSpi extends ImageReaderSpiBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDecodeInput(final Object pSource) throws IOException {
|
public boolean canDecodeInput(final Object pSource) throws IOException {
|
||||||
return pSource instanceof ImageInputStream && SVG_READER_AVAILABLE && canDecode((ImageInputStream) pSource);
|
return pSource instanceof ImageInputStream && canDecode((ImageInputStream) pSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("StatementWithEmptyBody")
|
@SuppressWarnings("StatementWithEmptyBody")
|
||||||
@ -166,13 +167,15 @@ public final class SVGImageReaderSpi extends ImageReaderSpiBase {
|
|||||||
@SuppressWarnings({"deprecation"})
|
@SuppressWarnings({"deprecation"})
|
||||||
@Override
|
@Override
|
||||||
public void onRegistration(final ServiceRegistry registry, final Class<?> category) {
|
public void onRegistration(final ServiceRegistry registry, final Class<?> category) {
|
||||||
|
// TODO: Perhaps just try to create an instance, and de-register if we fail?
|
||||||
if (!SVG_READER_AVAILABLE) {
|
if (!SVG_READER_AVAILABLE) {
|
||||||
|
System.err.println("Could not instantiate SVGImageReader (missing support classes).");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// NOTE: This will break, but it gives us some useful debug info
|
// NOTE: This will break, but it gives us some useful debug info
|
||||||
new SVGImageReader(this);
|
new SVGImageReader(this);
|
||||||
}
|
}
|
||||||
catch (Throwable t) {
|
catch (Throwable t) {
|
||||||
System.err.println("Could not instantiate SVGImageReader (missing support classes).");
|
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
package com.twelvemonkeys.imageio.plugins.svg;
|
package com.twelvemonkeys.imageio.plugins.svg;
|
||||||
|
|
||||||
import com.twelvemonkeys.imageio.spi.ReaderWriterProviderInfo;
|
import com.twelvemonkeys.imageio.spi.ReaderWriterProviderInfo;
|
||||||
import com.twelvemonkeys.lang.SystemUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SVGProviderInfo.
|
* SVGProviderInfo.
|
||||||
@ -39,14 +38,12 @@ import com.twelvemonkeys.lang.SystemUtil;
|
|||||||
* @version $Id: SVGProviderInfo.java,v 1.0 20/03/15 harald.kuhr Exp$
|
* @version $Id: SVGProviderInfo.java,v 1.0 20/03/15 harald.kuhr Exp$
|
||||||
*/
|
*/
|
||||||
final class SVGProviderInfo extends ReaderWriterProviderInfo {
|
final class SVGProviderInfo extends ReaderWriterProviderInfo {
|
||||||
final static boolean SVG_READER_AVAILABLE = SystemUtil.isClassAvailable("com.twelvemonkeys.imageio.plugins.svg.SVGImageReader");
|
SVGProviderInfo() {
|
||||||
|
|
||||||
protected SVGProviderInfo() {
|
|
||||||
super(
|
super(
|
||||||
SVGProviderInfo.class,
|
SVGProviderInfo.class,
|
||||||
SVG_READER_AVAILABLE ? new String[]{"svg", "SVG"} : new String[]{""}, // Names
|
new String[]{"svg", "SVG"}, // Names
|
||||||
SVG_READER_AVAILABLE ? new String[]{"svg"} : null, // Suffixes
|
new String[]{"svg"}, // Suffixes
|
||||||
SVG_READER_AVAILABLE ? new String[]{"image/svg", "image/x-svg", "image/svg+xml", "image/svg-xml"} : null, // Mime-types
|
new String[]{"image/svg", "image/x-svg", "image/svg+xml", "image/svg-xml"}, // Mime-types
|
||||||
"com.twelvemonkeys.imageio.plugins.svg.SVGImageReader", // Reader class name
|
"com.twelvemonkeys.imageio.plugins.svg.SVGImageReader", // Reader class name
|
||||||
new String[] {"com.twelvemonkeys.imageio.plugins.svg.SVGImageReaderSpi"},
|
new String[] {"com.twelvemonkeys.imageio.plugins.svg.SVGImageReaderSpi"},
|
||||||
null,
|
null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user