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

Modified Files:
        Factory.java ImageConversionRequestProcessor.java 
Log Message:
for testing purposes, made it possible to shutdown (and reinit) the image 
conversion threads


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.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Factory.java        3 Sep 2008 17:20:35 -0000       1.3
+++ Factory.java        23 Sep 2008 07:38:51 -0000      1.4
@@ -23,6 +23,7 @@
  *
  * @author Michiel Meeuwissen
  * @since MMBase-1.8
+ * @version $Id: Factory.java,v 1.4 2008/09/23 07:38:51 michiel Exp $
  */
 
 public class Factory {
@@ -81,6 +82,12 @@
             ireqprocessors[i] = new 
ImageConversionRequestProcessor(imageConverter, imageRequestQueue, 
imageRequestTable);
         }
     }
+    public static void shutdown() {
+        for (ImageConversionRequestProcessor icrp : ireqprocessors) {
+            log.service("Shutting down " + icrp);
+            icrp.shutdown();
+        }
+    }
 
     public static String getDefaultImageFormat() {
         return defaultImageFormat;
@@ -109,17 +116,13 @@
             ici = (ImageConverter) cl.newInstance();
             log.service("loaded '" + className+"' for image Factory");
         } catch (ClassNotFoundException e) {
-            log.error("is classname in " + params.get("configfile") + " 
correct? ('not found class " + className + "')");
-            log.error(Logging.stackTrace(e));
+            log.error("is classname in " + params.get("configfile") + " 
correct? ('not found class " + className + "')", e);
         } catch (InstantiationException e) {
-            log.error("something went wrong ('could not instantiate class " + 
className + "')");
-            log.error(Logging.stackTrace(e));
+            log.error("something went wrong ('could not instantiate class " + 
className + "')", e);
         } catch (java.lang.IllegalAccessException e) {
-            log.error("something went wrong ('illegal access class " + 
className + "')");
-            log.error(Logging.stackTrace(e));
+            log.error("something went wrong ('illegal access class " + 
className + "')", e);
         } catch (NoClassDefFoundError e) {
-            log.error("are all lib's available? ('missing class used by class" 
+ className + "')");
-            log.error(Logging.stackTrace(e));
+            log.error("are all lib's available? ('missing class used by class" 
+ className + "')", e);
         }
         return ici;
     }


Index: ImageConversionRequestProcessor.java
===================================================================
RCS file: 
/var/cvs/applications/resources/src/org/mmbase/util/images/ImageConversionRequestProcessor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- ImageConversionRequestProcessor.java        13 Jun 2007 18:54:55 -0000      
1.2
+++ ImageConversionRequestProcessor.java        23 Sep 2008 07:38:51 -0000      
1.3
@@ -25,7 +25,7 @@
  *
  * @author Rico Jansen
  * @author Michiel Meeuwissen
- * @version $Id: ImageConversionRequestProcessor.java,v 1.2 2007/06/13 
18:54:55 nklasens Exp $
+ * @version $Id: ImageConversionRequestProcessor.java,v 1.3 2008/09/23 
07:38:51 michiel Exp $
  * @see    ImageConversionRequest
  */
 public class ImageConversionRequestProcessor implements Runnable {
@@ -33,11 +33,13 @@
     private static final Logger log = 
Logging.getLoggerInstance(ImageConversionRequestProcessor.class);
     private static int idCounter =0;
     private final int processorId;
+    private Thread thread;
 
     private final ImageConverter convert;
     private final BlockingQueue<ImageConversionRequest> queue;
     private final Map<ImageConversionReceiver, ImageConversionRequest> table;
 
+
     /**
      * @javadoc
      */
@@ -54,7 +56,10 @@
      * Starts the thread for this ImageRequestProcessor.
      */
     protected void start() {
-        MMBaseContext.startThread(this, "ImageConvert[" + processorId +"]");
+        thread = MMBaseContext.startThread(this, "ImageConvert[" + processorId 
+"]");
+    }
+    protected void shutdown() {
+        thread.interrupt();
     }
 
     // javadoc inherited (from Runnable)
@@ -69,7 +74,7 @@
                 log.debug("Done with request");
             } catch (InterruptedException ie) {
                 log.debug(Thread.currentThread().getName() +" was 
interrupted.");
-                continue;
+                break;
             } catch (Exception e) {
                 log.error(e.getMessage(), e);
             }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to