org/objectweb/proactive/core/body/proxy/AbstractProxy.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.core.body.proxy;
00032 
00033 //import java.util.HashMap;
00034 
00035 import org.apache.log4j.Logger;
00036 import org.objectweb.proactive.core.exceptions.NonFunctionalException;
00037 import org.objectweb.proactive.core.exceptions.manager.NFEListener;
00038 import org.objectweb.proactive.core.exceptions.manager.NFEListenerList;
00039 import org.objectweb.proactive.core.exceptions.manager.NFEProducer;
00040 import org.objectweb.proactive.core.mop.MethodCall;
00041 import org.objectweb.proactive.core.mop.Proxy;
00042 import org.objectweb.proactive.core.util.log.Loggers;
00043 import org.objectweb.proactive.core.util.log.ProActiveLogger;
00044 
00045 
00046 public abstract class AbstractProxy implements Proxy, java.io.Serializable,
00047     NFEProducer {
00048     // Get logger
00049     protected static Logger logger = ProActiveLogger.getLogger(Loggers.NFE);
00050 
00051     // table of handlers associated to proxy
00052     //private HashMap proxyLevel;
00053 
00054     //
00055     // -- CONSTRUCTORS -----------------------------------------------
00056     //
00057     public AbstractProxy() {
00058     }
00059 
00060     //
00061     // -- METHODS ----------------------------------------------------
00062     //
00063 
00075     protected static boolean isAsynchronousCall(MethodCall mc) {
00076         return mc.isAsynchronousWayCall();
00077     }
00078 
00086     protected static boolean isOneWayCall(MethodCall mc) {
00087         return mc.isOneWayCall();
00088     }
00089 
00090     //  /**
00091     //   * Get information about the handlerizable object
00092     //   * @return information about the handlerizable object
00093     //   */
00094     //  public String getHandlerizableInfo()  throws java.io.IOException {
00095     //          return "PROXY of CLASS ["+ this.getClass()  +"]";
00096     //  }
00097     //  
00098     //    /** Give a reference to a local map of handlers
00099     //    * @return A reference to a map of handlers
00100     //    */
00101     //    public HashMap getHandlersLevel() throws java.io.IOException {
00102     //        return proxyLevel;
00103     //    }
00104     //
00105     //  /** 
00106     //   * Clear the local map of handlers
00107     //   */
00108     //  public void clearHandlersLevel() throws java.io.IOException {
00109     //           proxyLevel.clear();
00110     //  }
00111     //
00112     //    /** Set a new handler within the table of the Handlerizable Object
00113     //     * @param handler A handler associated with a class of non functional exception.
00114     //     * @param exception A class of non functional exception. It is a subclass of <code>NonFunctionalException</code>.
00115     //     */
00116     //    public void setExceptionHandler(Handler handler, Class exception)
00117     //        throws java.io.IOException {
00118     //        // add handler to proxy level
00119     //        if (proxyLevel == null) {
00120     //            proxyLevel = new HashMap();
00121     //        }
00122     //        proxyLevel.put(exception, handler);
00123     //    }
00124     //
00125     //    /** Remove a handler from the table of the Handlerizable Object
00126     //     * @param exception A class of non functional exception. It is a subclass of <code>NonFunctionalException</code>.
00127     //     * @return The removed handler or null
00128     //     */
00129     //    public Handler unsetExceptionHandler(Class exception)
00130     //        throws java.io.IOException {
00131     //        // remove handler from proxy level
00132     //        if (proxyLevel != null) {
00133     //            Handler handler = (Handler) proxyLevel.remove(exception);
00134     //            return handler;
00135     //        } else {
00136     //            if (logger.isDebugEnabled()) {
00137     //                logger.debug("[NFE_WARNING] No handler for [" +
00138     //                    exception.getName() + "] can be removed from PROXY level");
00139     //            }
00140     //            return null;
00141     //        }
00142     //    }
00143     // NFEProducer implementation
00144     private NFEListenerList nfeListeners = null;
00145 
00146     public void addNFEListener(NFEListener listener) {
00147         if (nfeListeners == null) {
00148             nfeListeners = new NFEListenerList();
00149         }
00150         nfeListeners.addNFEListener(listener);
00151     }
00152 
00153     public void removeNFEListener(NFEListener listener) {
00154         if (nfeListeners != null) {
00155             nfeListeners.removeNFEListener(listener);
00156         }
00157     }
00158 
00159     public int fireNFE(NonFunctionalException e) {
00160         if (nfeListeners != null) {
00161             return nfeListeners.fireNFE(e);
00162         }
00163         return 0;
00164     }
00165 }

Generated on Mon Jan 22 15:16:06 2007 for ProActive by  doxygen 1.5.1