geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r157965 - in geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel: ClassLoaderReference.java ObjectInputStreamExt.java StoredObject.java
Date Thu, 17 Mar 2005 19:10:11 GMT
Author: dblevins
Date: Thu Mar 17 11:10:10 2005
New Revision: 157965

URL: http://svn.apache.org/viewcvs?view=rev&rev=157965
Log:
Serialization related classes that are tied to ObjectInputStreamExt

Added:
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoaderReference.java
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/StoredObject.java
Modified:
    geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ObjectInputStreamExt.java

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoaderReference.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoaderReference.java?view=auto&rev=157965
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoaderReference.java
(added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoaderReference.java
Thu Mar 17 11:10:10 2005
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel;
+
+import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectStreamException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ClassLoaderReference extends ClassLoader implements Serializable {
+
+    private ClassLoader classloader;
+
+    public ClassLoaderReference(ClassLoader parent) {
+        super(parent);
+    }
+
+    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException{
+        in.defaultReadObject();
+        ObjectInputStreamExt objectInputStreamExt = (ObjectInputStreamExt)in;
+        classloader = objectInputStreamExt.getClassloader();
+    }
+
+    private Object readResolve() throws ObjectStreamException {
+        return classloader;
+    }
+}

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ObjectInputStreamExt.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ObjectInputStreamExt.java?view=diff&r1=157964&r2=157965
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ObjectInputStreamExt.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ObjectInputStreamExt.java
Thu Mar 17 11:10:10 2005
@@ -20,6 +20,11 @@
 import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectStreamClass;
+import java.io.Serializable;
+import java.io.ObjectStreamException;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
 import java.lang.reflect.Proxy;
 
 import org.apache.geronimo.kernel.ClassLoading;
@@ -51,4 +56,9 @@
             throw new ClassNotFoundException(null, e);
         }
     }
+
+    ClassLoader getClassloader() {
+        return classloader;
+    }
+
 }

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/StoredObject.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/StoredObject.java?view=auto&rev=157965
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/StoredObject.java (added)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/StoredObject.java Thu
Mar 17 11:10:10 2005
@@ -0,0 +1,51 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel;
+
+import java.io.Serializable;
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StoredObject implements Serializable {
+
+    private byte[] content;
+
+    public StoredObject(Serializable object) throws IOException {
+        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream(buffer);
+        out.writeObject(object);
+        out.flush();
+        out.close();
+        this.content = buffer.toByteArray();
+        buffer.close();
+    }
+
+    public Object getObject(ClassLoader classLoader) throws IOException, ClassNotFoundException
{
+        ByteArrayInputStream buffer = new ByteArrayInputStream(this.content);
+        ObjectInputStream in = new ObjectInputStreamExt(buffer, classLoader);
+        Object obj = in.readObject();
+        buffer.close();
+        in.close();
+        return obj;
+    }
+}



Mime
View raw message