[jboss-dev-forums] [Design of POJO Server] - Re: ManagedProperty serialization issue
alesj
do-not-reply at jboss.com
Fri Oct 5 07:44:43 EDT 2007
"alesj" wrote : I guess this should be added (or is this even part of what I was changing with implementing serialization to ClassInfo?), although it looks like an ugly implementation is about to come out of this. :-)
|
I added this to ReflectMethodInfoImpl (+ similar code to other ReflectX classes):
| private void readObject(ObjectInputStream oistream)
| throws IOException, ClassNotFoundException, NoSuchMethodException
| {
| oistream.defaultReadObject();
| int length = parameterTypes != null ? parameterTypes.length : 0;
| Class<?>[] classes = new Class<?>[length];
| for(int j = 0; j < length; j++)
| classes[j] = parameterTypes[j].getType();
| method = ReflectionUtils.findExactMethod(getDeclaringClass().getType(), name, classes);
| }
|
Utils code:
|
| public static Method findMethod(Class clazz, String name, Class<?>... parameterTypes)
| {
| if (clazz == null)
| return null;
|
| try
| {
| return clazz.getDeclaredMethod(name, parameterTypes);
| }
| catch(Exception ignored)
| {
| }
| return findMethod(clazz.getSuperclass(), name, parameterTypes);
| }
|
| public static Method findExactMethod(Class clazz, String name, Class<?>... parameterTypes)
| throws NoSuchMethodException
| {
| Method method = findMethod(clazz, name, parameterTypes);
| if (method == null)
| throw new NoSuchMethodException(clazz + "." + name + " - " + Arrays.asList(parameterTypes));
| return method;
| }
|
Which makes ReflectX classes know their Member instance after deserialization.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4091946#4091946
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4091946
More information about the jboss-dev-forums
mailing list