[Jboss-cvs] JBossAS SVN: r56566 - branches/JBoss_4_0_4_GA_JBAS-3623/system/src/main/org/jboss/system/pm
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Sep 5 10:06:36 EDT 2006
Author: dimitris at jboss.org
Date: 2006-09-05 10:06:34 -0400 (Tue, 05 Sep 2006)
New Revision: 56566
Modified:
branches/JBoss_4_0_4_GA_JBAS-3623/system/src/main/org/jboss/system/pm/XMLAttributePersistenceManager.java
Log:
JBAS-3623, Backport JBAS-3463 to 4.0.4.GA
Modified: branches/JBoss_4_0_4_GA_JBAS-3623/system/src/main/org/jboss/system/pm/XMLAttributePersistenceManager.java
===================================================================
--- branches/JBoss_4_0_4_GA_JBAS-3623/system/src/main/org/jboss/system/pm/XMLAttributePersistenceManager.java 2006-09-05 12:32:11 UTC (rev 56565)
+++ branches/JBoss_4_0_4_GA_JBAS-3623/system/src/main/org/jboss/system/pm/XMLAttributePersistenceManager.java 2006-09-05 14:06:34 UTC (rev 56566)
@@ -1,24 +1,24 @@
/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This 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 (at your option) any later version.
-*
-* This software 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 software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.jboss.system.pm;
import java.beans.PropertyEditor;
@@ -33,6 +33,7 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
import java.io.OutputStream;
import java.io.Serializable;
import java.net.URL;
@@ -57,6 +58,7 @@
import org.jboss.logging.Logger;
import org.jboss.mx.persistence.AttributePersistenceManager;
import org.jboss.system.server.ServerConfigLocator;
+import org.jboss.util.Classes;
import org.jboss.util.file.Files;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
@@ -70,7 +72,7 @@
*
* @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
* @version $Revision$
-**/
+ */
public class XMLAttributePersistenceManager
implements AttributePersistenceManager
{
@@ -730,19 +732,23 @@
}
Serializable retn = null;
-
- try {
+ try
+ {
+ // Use ObjectInputStreamExt that will utilise the
+ // ThreadContextClassLoader to deserialize objects
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bais);
-
+ ObjectInputStream ois = new ObjectInputStreamExt(bais);
retn = (Serializable)ois.readObject();
+ ois.close();
}
- catch (IOException e) {
- log.warn("Cannot deserialize object", e); }
- catch (ClassNotFoundException e) {
+ catch (ClassNotFoundException e)
+ {
log.warn("Cannot deserialize object", e);
+ }
+ catch (IOException e)
+ {
+ log.warn("Cought IOException", e);
}
-
return retn;
}
@@ -947,4 +953,22 @@
return Files.decodeFileName(file);
}
}
+
+ /**
+ * Default implementation ObjectInputStream uses the System
+ * classloader to deserialize classes, by we need to use the
+ * ThreadContextClassLoader, instead.
+ */
+ private class ObjectInputStreamExt extends ObjectInputStream
+ {
+ ObjectInputStreamExt(InputStream is) throws IOException
+ {
+ super(is);
+ }
+
+ protected Class resolveClass(ObjectStreamClass v) throws IOException, ClassNotFoundException
+ {
+ return Classes.loadClass(v.getName());
+ }
+ }
}
More information about the jboss-cvs-commits
mailing list