org/objectweb/proactive/core/util/SerializableMethod.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.util;
00032 
00033 import java.io.Serializable;
00034 import java.lang.reflect.Method;
00035 
00036 
00037 public class SerializableMethod implements Serializable {
00038     private transient Method m;
00039 
00040     public SerializableMethod(Method m) {
00041         this.m = m;
00042     }
00043 
00044     public Method getMethod() {
00045         return m;
00046     }
00047 
00048     private void writeObject(java.io.ObjectOutputStream out)
00049         throws java.io.IOException {
00050         System.out.println("writing WrappedMethod");
00051         out.writeObject(m.getDeclaringClass());
00052         out.writeObject(m.getName());
00053         out.writeObject(m.getParameterTypes());
00054     }
00055     
00056     
00057 
00058 //    private Class[] fixBugRead(FixWrapper[] para) {
00059 //        Class[] tmp = new Class[para.length];
00060 //        for (int i = 0; i < para.length; i++) {
00061 //            //        System.out.println("fixBugRead for " + i + " value is " +para[i]);
00062 //            tmp[i] = para[i].getWrapped();
00063 //        }
00064 //        return tmp;
00065 //    }
00066 //
00067 //    private FixWrapper[] fixBugWrite(Class[] para) {
00068 //        FixWrapper[] tmp = new FixWrapper[para.length];
00069 //        for (int i = 0; i < para.length; i++) {
00070 //            //        System.out.println("fixBugWrite for " + i + " out of " + para.length + " value is " +para[i] ); 
00071 //            tmp[i] = new MethodCall.FixWrapper(para[i]);
00072 //        }
00073 //        return tmp;
00074 //    }
00075     
00076     private void readObject(java.io.ObjectInputStream in)
00077         throws java.io.IOException, ClassNotFoundException {
00078         System.out.println("reading WrappedMethod");
00079         Class declaringClass = (Class) in.readObject();
00080         String name = (String) in.readObject();
00081         Class[] paramTypes = (Class[])in.readObject();
00082 
00083         try {
00084             m = declaringClass.getMethod(name, paramTypes);
00085         } catch (SecurityException e) {
00086             e.printStackTrace();
00087         } catch (NoSuchMethodException e) {
00088             e.printStackTrace();
00089         }
00090     }
00091 
00092         @Override
00093         public int hashCode() {
00094                 return m.hashCode();
00095         }
00096 
00097         @Override
00098         public String toString() {
00099                 return m.toString();
00100         }
00101 
00102         @Override
00103         public boolean equals(Object obj) {
00104                 if (! (obj instanceof SerializableMethod)) {
00105                         return false;
00106                 }
00107                 return m.equals(((SerializableMethod)obj).getMethod());
00108         }
00109     
00110         
00111     
00112 }

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