protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException { Class<?> resolvedClass = _context.getResolvedClass(classDesc);// check if already resolved boolean containsAnnotation = _context.containsAnnotation(classDesc); String annotation = null; if (containsAnnotation) annotation = _context.getAnnotation(classDesc); resolvedClass = super.resolveClass(classDesc, !containsAnnotation, annotation); _context.putResolvedClass(classDesc, resolvedClass); // save resolved class
public synchronized void putResolvedClass(ObjectStreamClass classDesc, Class<?> cl) { ClassLoaderContext classLoaderContext = getClassLoaderContext(true); classLoaderContext.putResolvedClass(classDesc, cl); if (_logger.isLoggable(Level.FINEST)) logFinest("Adding new resolved class to incoming context [" + cl.getName() + "] for ObjectStreamClass " + classDesc.getName() + ", context class loader key " + classLoaderContext.getClassLoaderCacheKey()); }
NamesWrapper names = new NamesWrapper(interfaceNames); Class<?> cl = _context.getClassFromAnnotateInterfaceNameMap(names); if (cl != null) return cl; _context.putAnnotateInterfaceNamesMap(names, cl); return cl;
/** * Reads a repetitive object which was written by {@link MarshalOutputStream#writeRepetitiveObject}. */ public Object readRepetitiveObject() throws IOException, ClassNotFoundException { // Read object code: int code = readInt(); // If null return: if (code == CODE_NULL) return null; // If repetitive optimization was disabled: if (code == CODE_DISABLED) return readObject(); // Look for cached object by code: Object value = _context.getRepetitiveObjectsCache().get(code); if (value != null) return value; // If object is not cached, read it from the stream and cache it: value = readObject(); // If object is string, intern it: if (value instanceof String) value = ((String) value).intern(); _context.getRepetitiveObjectsCache().put(code, value); return value; }
/** * Overrides the super method and tries to get the class descriptor from a local map. If not * found read from the stream and save to local map. * * @return class descriptor */ @Override protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { ObjectStreamClass cl = null; int index = readInt(); if (index != -1) cl = _context.getObjectStreamClass(index); if (cl == null) { if (_logger.isLoggable(Level.FINEST)) { Long classLoaderKey = ClassLoaderCache.getCache().getClassLoaderKey(ClassLoaderHelper.getContextClassLoader()); logFinest("Received new incoming ObjectStreamClass with key " + index + ", context class loader key " + classLoaderKey + ", reading it from stream"); } cl = super.readClassDescriptor(); if (index != -1) _context.addObjectStreamClass(index, cl); } return cl; }
public void closeContext() { _context.close(); }
public static Context createContext() { return new Context(); }
public synchronized Class<?> getClassFromAnnotateInterfaceNameMap(NamesWrapper names) { ClassLoaderContext classLoaderContext = getClassLoaderContext(false); if (classLoaderContext == null) return null; return classLoaderContext.getClassFromAnnotateInterfaceNameMap(names); }
public synchronized void putAnnotateInterfaceNamesMap(NamesWrapper names, Class<?> cl) { ClassLoaderContext classLoaderContext = getClassLoaderContext(true); classLoaderContext.putAnnotateInterfaceNamesMap(names, cl); if (_logger.isLoggable(Level.FINEST)) logFinest("Adding new NamesWrapper to incoming context [" + names + "] for class " + cl.getName() + ", context class loader key " + classLoaderContext.getClassLoaderCacheKey()); }
/** * @param in input stream to wrap. */ public MarshalInputStream(InputStream in) throws IOException { this(in, new Context()); }
public synchronized Class<?> getResolvedClass(ObjectStreamClass classDesc) { ClassLoaderContext classLoaderContext = getClassLoaderContext(false); if (classLoaderContext == null) return null; return classLoaderContext.getResolvedClass(classDesc); }