/*
* ################################################################
*
* ProActive: The Java(TM) library for Parallel, Distributed,
*            Concurrent computing with Security and Mobility
*
* Copyright (C) 1997-2002 INRIA/University of Nice-Sophia Antipolis
* Contact: proactive-support@inria.fr
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
* USA
*
*  Initial developer(s):               The ProActive Team
*                        http://www.inria.fr/oasis/ProActive/contacts.html
*  Contributor(s):
*
* ################################################################
*/
package org.objectweb.proactive.core.exceptions.handler;

import org.apache.log4j.Logger;
import org.objectweb.proactive.core.body.ActiveBody;
import org.objectweb.proactive.core.exceptions.NonFunctionalException;


/**
 * Handle ProActive exceptions
 *
 * @author  ProActive Team
 * @version 1.0,  2002/07/08
 * @since   ProActive 0.9.3
 *
 */
public class HandlerNonFunctionalException implements Handler {

	// Logger
	protected static Logger logger = Logger.getLogger(ActiveBody.class.getName());
	
    /**
     * Contains a suggestion to resolve the problem
     */
    private String suggestion;

    /**
     * Construct a handler with a suggestion to handle the problem more properly
     */
    public HandlerNonFunctionalException() {
        suggestion = "=> (solution 1) UPDATE HANDLER [" +
            this.getClass().getName() + "]";
    }

    /**
     * Construct a handler with a suggestion to handle the problem more properly
     */
    public HandlerNonFunctionalException(String suggestion) {
        this.suggestion = suggestion;
    }

    /**
    * @return Suggestion to handle the problem more properly
    */
    public String getSuggestion() {
        return suggestion;
    }

    /**
     * @param string Set suggestion to handle the problem more properly
     */
    public void setSuggestion(String string) {
        suggestion = string;
    }

    /**
     * Is the exception reliable for the handler ?
     * @param e The exception checked for handler reliability
     */
    public boolean isHandling(NonFunctionalException e) {
        return (e instanceof NonFunctionalException);
    }

    /**
     * Provide a treatment for the handled exception(s)
     * @param e The exception to be handled
     */ 
    public void handle(NonFunctionalException e) {
        System.out.println("EXCEPTION [" + e.getDescription() +
            "] HANDLED WITH [" + this.getClass().getName() + "]");
        System.out.println(suggestion);
        System.out.println(
            "=> (solution 2) SET HANDLER FOR EXCEPTION [" +
            e.getClass().getName() + "]");
            e.printStackTrace();
    }

    /**
     * Provide a treatment for the handled exception(s)
     * @param e The exception to be handled
     */
    public void handle(NonFunctionalException nfe, Exception e)
        throws Exception {
        logger.info("EXCEPTION [" + nfe.getDescription() +
            "] HANDLED WITH [" + this.getClass().getName() + "]");
        logger.info(suggestion);
        logger.info(
            "=> (solution 2) SET HANDLER FOR EXCEPTION [" +
            nfe.getClass().getName() + "]");
        throw e;
    }
}

@@ -3030,34 +3030,28 @@
         
-System.out.println
+logger.debug
 (%22EXCEPT
@@ -3155,34 +3155,28 @@
         
-System.out.println
+logger.debug
 (suggest
@@ -3193,26 +3193,20 @@
     
-System.out.println
+logger.debug
 (%0A  
@@ -3322,26 +3322,28 @@
     
-e.printStackTrace(
+logger.error(%22NFE%22,e
 );%0A 
@@ -3570,20 +3570,21 @@
  logger.
-info
+debug
 (%22EXCEPT
@@ -3697,20 +3697,21 @@
  logger.
-info
+debug
 (suggest
@@ -3735,12 +3735,13 @@
 ger.
-info
+debug
 (%0A  

Remove nasty System.out.println