Update of /var/cvs/applications/resources/src/org/mmbase/util/images
In directory james.mmbase.org:/tmp/cvs-serv7985

Modified Files:
        Factory.java 
Log Message:
added an 'isInited' method which can be used to avoid that the thing is inited 
twice


See also: 
http://cvs.mmbase.org/viewcvs/applications/resources/src/org/mmbase/util/images


Index: Factory.java
===================================================================
RCS file: 
/var/cvs/applications/resources/src/org/mmbase/util/images/Factory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- Factory.java        24 Sep 2008 05:54:30 -0000      1.6
+++ Factory.java        22 Apr 2009 06:55:15 -0000      1.7
@@ -23,7 +23,7 @@
  *
  * @author Michiel Meeuwissen
  * @since MMBase-1.8
- * @version $Id: Factory.java,v 1.6 2008/09/24 05:54:30 michiel Exp $
+ * @version $Id: Factory.java,v 1.7 2009/04/22 06:55:15 michiel Exp $
  */
 
 public class Factory {
@@ -41,10 +41,10 @@
     protected static int maxConcurrentRequests = 2;
 
     protected static final int maxRequests = 32;
-    protected static BlockingQueue<ImageConversionRequest> imageRequestQueue = 
new ArrayBlockingQueue<ImageConversionRequest>(maxRequests);
-    protected static Map<ImageConversionReceiver, ImageConversionRequest> 
imageRequestTable
+    private static final BlockingQueue<ImageConversionRequest> 
imageRequestQueue = new ArrayBlockingQueue<ImageConversionRequest>(maxRequests);
+    private static final Map<ImageConversionReceiver, ImageConversionRequest> 
imageRequestTable
         = new ConcurrentHashMap<ImageConversionReceiver, 
ImageConversionRequest>(maxRequests);
-    protected static ImageConversionRequestProcessor ireqprocessors[];
+    private static ImageConversionRequestProcessor ireqprocessors[];
 
     /**
      * The default image format.
@@ -52,6 +52,10 @@
     protected static String defaultImageFormat = "jpeg";
 
     public static void init(Map<String, String> properties) {
+        if (isInited()) {
+            log.warn("Initing while not shut down!", new Exception());
+            shutdown();
+        }
         params.clear();
         params.putAll(properties);
 
@@ -84,6 +88,14 @@
         }
     }
 
+
+    /**
+     * @since MMBase-1.9.1
+     */
+    public static boolean isInited() {
+        return ireqprocessors != null;
+    }
+
     /**
      * @since MMBase-1.9
      */
@@ -92,6 +104,7 @@
             log.service("Shutting down " + icrp);
             icrp.shutdown();
         }
+        ireqprocessors = null;
     }
 
     /**
@@ -126,7 +139,7 @@
         try {
             Class<?> cl = Class.forName(className);
             ici = (ImageConverter) cl.newInstance();
-            log.service("loaded '" + className+"' for image Factory");
+            log.service("loaded '" + className+"' " + ici + " for image 
Factory");
         } catch (ClassNotFoundException e) {
             log.error("is classname in " + params.get("configfile") + " 
correct? ('not found class " + className + "')", e);
         } catch (InstantiationException e) {
@@ -205,4 +218,5 @@
         return new Imaging.CKey(nodeNumber, template);
     }
 
+
 }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to