You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2002/09/04 19:05:56 UTC
cvs commit: xml-axis/java/src/org/apache/axis/components/image ImageIOFactory.java
butek 2002/09/04 10:05:56
Modified: java/src/org/apache/axis/components/image
ImageIOFactory.java
Log:
Changed ImageIOFactory such that there is now a precedence for which
ImageIO implementation to use (see javadoc comments).
Revision Changes Path
1.4 +37 -13 xml-axis/java/src/org/apache/axis/components/image/ImageIOFactory.java
Index: ImageIOFactory.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/components/image/ImageIOFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ImageIOFactory.java 23 Aug 2002 22:22:30 -0000 1.3
+++ ImageIOFactory.java 4 Sep 2002 17:05:56 -0000 1.4
@@ -57,7 +57,6 @@
import org.apache.axis.AxisProperties;
import org.apache.axis.utils.ClassUtils;
-import org.apache.axis.utils.JavaUtils;
import org.apache.commons.discovery.tools.SPInterface;
@@ -74,23 +73,48 @@
protected static Log log =
LogFactory.getLog(ImageIOFactory.class.getName());
+ /**
+ * Get the ImageIO implementation. This method follows a precedence:
+ * 1. Use the class defined by the System property axis.ImageIO.
+ * 2. If that isn't set, try instantiating MerlinIO, the JDK 1.4 ImageIO implementation.
+ * 3. If that fails try JimiIO, the JIMI ImageIO implementation.
+ * 4. If that fails, instantiate the limited JDK13IO implementation.
+ */
public static ImageIO getImageIO() {
- /**
- * JimiIO may/maynot be present, so we don't use
- * hard link to class (JimiIO.class), but instead
- * the fully qualified class name
- */
+ // If the imageIO property is configured, use it.
+ // Note: I wish AxisProperties.newInstance could return null,
+ // but it doesn't seem to; makes the following if check a bit more complex,
+ // and disallows someone explicitly forcing JDK13IO over the others.
ImageIO imageIO =
(ImageIO)AxisProperties.newInstance(
- new SPInterface(ImageIO.class, "axis.ImageIO"),
- "org.apache.axis.components.image.JimiIO");
+ new SPInterface(ImageIO.class, "axis.ImageIO"), "org.apache.axis.components.image.JDK13IO");
- if (imageIO == null) {
- log.info(JavaUtils.getMessage("needImageIO"));
- } else {
- log.debug("axis.ImageIO:" + imageIO.getClass().getName());
+ if (imageIO == null || imageIO.getClass() ==
+ org.apache.axis.components.image.JDK13IO.class) {
+ // If the imageIO is not configured look for the following:
+ // 1. Try the JDK 1.4 classes
+ // 2. Try the JIMI classes
+ // 3. If all else fails, try the JDK 1.3 classes
+ try {
+ ClassUtils.forName("javax.imageio.ImageWriter");
+ imageIO = (ImageIO) ClassUtils.forName(
+ "org.apache.axis.components.image.MerlinIO").
+ newInstance();
+ }
+ catch (Throwable t1) {
+ try {
+ ClassUtils.forName("com.sun.jimi.core.Jimi");
+ imageIO = (ImageIO) ClassUtils.forName(
+ "org.apache.axis.components.image.JimiIO").
+ newInstance();
+ }
+ catch (Throwable t2) {
+ imageIO = new JDK13IO();
+ }
+ }
}
+ log.debug("axis.ImageIO:" + imageIO.getClass().getName());
return imageIO;
}
}