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
   * 
   *      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.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.

Author(s):
Craig R. McClanahan
Bip Thelin
Version:
$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

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


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

Parameters:
classDesc Class description from the input stream
Throws:
java.lang.ClassNotFoundException if this class cannot be found
java.io.IOException 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