Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You 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
  * 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.catalina.util;
Custom subclass of ObjectInputStream that loads from the class loader for this web application. This allows classes defined only with the web application to be found correctly.

Craig R. McClanahan
Bip Thelin
$Revision: 515 $, $Date: 2008-03-17 22:02:23 +0100 (Mon, 17 Mar 2008) $
 public final class CustomObjectInputStream
     extends ObjectInputStream {

The class loader we will use to resolve classes.
     private ClassLoader classLoader = null;

Construct a new instance of CustomObjectInputStream

stream The input stream we will read from
classLoader The class loader used to instantiate objects
Throws: if an input/output error occurs
     public CustomObjectInputStream(InputStream stream,
                                    ClassLoader classLoader)
         throws IOException {
         this. = classLoader;

Load the local class equivalent of the specified stream class description, by using the class loader assigned to this Context.

classDesc Class description from the input stream
java.lang.ClassNotFoundException if this class cannot be found if an input/output error occurs
     public Class resolveClass(ObjectStreamClass classDesc)
         throws ClassNotFoundExceptionIOException {
         try {
             return Class.forName(classDesc.getName(), false);
         } catch (ClassNotFoundException e) {
             // Try also the superclass because of primitive types
             return super.resolveClass(classDesc);

Return a proxy class that implements the interfaces named in a proxy class descriptor. Do this using the class loader assigned to this Context.
     protected Class resolveProxyClass(String[] interfaces)
         throws IOExceptionClassNotFoundException {
         Class[] cinterfaces = new Class[interfaces.length];
         for (int i = 0; i < interfaces.lengthi++)
             cinterfaces[i] = .loadClass(interfaces[i]);
         try {
             return Proxy.getProxyClass(cinterfaces);
         } catch (IllegalArgumentException e) {
             throw new ClassNotFoundException(nulle);
New to GrepCode? Check out our FAQ X