|
| 1 | +/** |
| 2 | + * MemCached Java client |
| 3 | + * Copyright (c) 2005 |
| 4 | + * |
| 5 | + * This library is free software; you can redistribute it and/or |
| 6 | + * modify it under the terms of the GNU Lesser General Public |
| 7 | + * License as published by the Free Software Foundation; either |
| 8 | + * version 2.1 of the License, or (at your option) any later |
| 9 | + * version. |
| 10 | + * |
| 11 | + * This library is distributed in the hope that it will be |
| 12 | + * useful, but WITHOUT ANY WARRANTY; without even the implied |
| 13 | + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | + * PURPOSE. See the GNU Lesser General Public License for more |
| 15 | + * details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU Lesser General Public |
| 18 | + * License along with this library; if not, write to the Free Software |
| 19 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | + * |
| 21 | + * |
| 22 | + * Adds the ability for the MemCached client to be initialized |
| 23 | + * with a custom class loader. This will allow for the |
| 24 | + * deserialization of classes that are not visible to the system |
| 25 | + * class loader. |
| 26 | + * |
| 27 | + * @author Vin Chawla <[email protected]> |
| 28 | + */ |
| 29 | +package com.danga.MemCached; |
| 30 | + |
| 31 | +import java.util.*; |
| 32 | +import java.util.zip.*; |
| 33 | +import java.io.*; |
| 34 | + |
| 35 | +public class ContextObjectInputStream extends ObjectInputStream { |
| 36 | + |
| 37 | + ClassLoader mLoader; |
| 38 | + |
| 39 | + public ContextObjectInputStream( InputStream in, ClassLoader loader ) throws IOException, SecurityException { |
| 40 | + super( in ); |
| 41 | + mLoader = loader; |
| 42 | + } |
| 43 | + |
| 44 | + protected Class resolveClass( ObjectStreamClass v ) throws IOException, ClassNotFoundException { |
| 45 | + if ( mLoader == null ) |
| 46 | + return super.resolveClass( v ); |
| 47 | + else |
| 48 | + return mLoader.loadClass( v.getName() ); |
| 49 | + } |
| 50 | +} |
0 commit comments