Top Description Inners Fields Constructors Methods
org.aspectj.weaver.tools.cache

public Class SimpleCache

extends Object
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .File, .FileInputStream, .FileNotFoundException, .FileOutputStream, .IOException, .ObjectInputStream, .ObjectOutputStream, java.lang.reflect.InvocationTargetException, .Method, java.security.ProtectionDomain, java.util.Arrays, .Collections, .HashMap, .Map, java.util.zip.CRC32, org.aspectj.weaver.Dump, org.aspectj.weaver.tools.Trace, .TraceFactory

Copyright (c) 2012 Contributors. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v 2.0 which accompanies this distribution and is available at https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt Contributors: Abraham Nevado (lucierna) initial implementation

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private Map<String, byte[]>
private Method
private Method
private boolean
private static final String
private static final String
private Map<String, byte[]>
public static final String
private static final byte[]
private static final String

Constructor Summary

AccessConstructor and Description
protected
SimpleCache(String folder, boolean enabled)

Method Summary

Modifier and TypeMethod and Description
public void
addGeneratedClassesNames(String parentClassName, byte[] parentBytes, String generatedClassName)

private void
defineClass(ClassLoader loader, String name, byte[] bytes)

private void
defineClass(ClassLoader loader, String name, byte[] bytes, ProtectionDomain protectionDomain)

private String
generateKey(String classname, byte[] bytes)

private byte[]
get(String classname, byte[] bytes)

public byte[]
getAndInitialize(String classname, byte[] bytes, ClassLoader loader, ProtectionDomain protectionDomain)

private String[]
getGeneratedClassesNames(String className, byte[] bytes)

private void
initializeClass(String className, byte[] bytes, ClassLoader loader, ProtectionDomain protectionDomain)

public void
put(String classname, byte[] origbytes, byte[] wovenbytes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheMapback to summary
private Map<String, byte[]> cacheMap
defineClassMethodback to summary
private Method defineClassMethod
defineClassWithProtectionDomainMethodback to summary
private Method defineClassWithProtectionDomainMethod
enabledback to summary
private boolean enabled
GENERATED_CACHE_SEPARATORback to summary
private static final String GENERATED_CACHE_SEPARATOR
GENERATED_CACHE_SUBFOLDERback to summary
private static final String GENERATED_CACHE_SUBFOLDER
generatedCacheback to summary
private Map<String, byte[]> generatedCache
IMPL_NAMEback to summary
public static final String IMPL_NAME
SAME_BYTESback to summary
private static final byte[] SAME_BYTES
SAME_BYTES_STRINGback to summary
private static final String SAME_BYTES_STRING

Constructor Detail

SimpleCacheback to summary
protected SimpleCache(String folder, boolean enabled)

Method Detail

addGeneratedClassesNamesback to summary
public void addGeneratedClassesNames(String parentClassName, byte[] parentBytes, String generatedClassName)
defineClassback to summary
private void defineClass(ClassLoader loader, String name, byte[] bytes)
defineClassback to summary
private void defineClass(ClassLoader loader, String name, byte[] bytes, ProtectionDomain protectionDomain)
generateKeyback to summary
private String generateKey(String classname, byte[] bytes)
getback to summary
private byte[] get(String classname, byte[] bytes)
getAndInitializeback to summary
public byte[] getAndInitialize(String classname, byte[] bytes, ClassLoader loader, ProtectionDomain protectionDomain)
getGeneratedClassesNamesback to summary
private String[] getGeneratedClassesNames(String className, byte[] bytes)
initializeClassback to summary
private void initializeClass(String className, byte[] bytes, ClassLoader loader, ProtectionDomain protectionDomain)
putback to summary
public void put(String classname, byte[] origbytes, byte[] wovenbytes)
org.aspectj.weaver.tools.cache back to summary

private Class SimpleCache.StoreableCachingMap

extends HashMap
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final String
private static int
private String
private long
private int
private transient Trace

Constructor Summary

AccessConstructor and Description
private
StoreableCachingMap(String folder, int storingTimer)

Method Summary

Modifier and TypeMethod and Description
public Object
get(Object
the key whose associated value is to be returned
obj
)

Overrides java.util.HashMap.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
public static SimpleCache.StoreableCachingMap
init(String folder)

public static SimpleCache.StoreableCachingMap
init(String folder, int storingTimer)

private void
public Object
put(Object
key with which the specified value is to be associated
key
,
Object
value to be associated with the specified key
value
)

Overrides java.util.HashMap.put.

Implements java.util.Map.put.

Associates the specified value with the specified key in this map.
private byte[]
readFromPath(String fullPath)

public void
private String
writeToPath(String key, byte[] bytes)

Inherited from java.util.HashMap:
clearclonecomputecomputeIfAbsentcomputeIfPresentcontainsKeycontainsValueentrySetforEachgetOrDefaultisEmptykeySetmergenewHashMapputAllputIfAbsentremoveremovereplacereplacereplaceAllsizevalues

Field Detail

CACHENAMEIDXback to summary
private static final String CACHENAMEIDX
DEF_STORING_TIMERback to summary
private static int DEF_STORING_TIMER
folderback to summary
private String folder
lastStoredback to summary
private long lastStored
storingTimerback to summary
private int storingTimer
traceback to summary
private transient Trace trace

Constructor Detail

StoreableCachingMapback to summary
private StoreableCachingMap(String folder, int storingTimer)

Method Detail

getback to summary
public Object get(Object obj)

Overrides java.util.HashMap.get.

Implements java.util.Map.get.

Doc from java.util.HashMap.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
obj:Object

Doc from java.util.Map.get.

the key whose associated value is to be returned

Returns:Object

Doc from java.util.Map.get.

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override
initback to summary
public static SimpleCache.StoreableCachingMap init(String folder)
initback to summary
public static SimpleCache.StoreableCachingMap init(String folder, int storingTimer)
initTraceback to summary
private void initTrace()
putback to summary
public Object put(Object key, Object value)

Overrides java.util.HashMap.put.

Implements java.util.Map.put.

Doc from java.util.HashMap.put.

Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.

Parameters
key:Object

key with which the specified value is to be associated

value:Object

value to be associated with the specified key

Returns:Object

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)

Annotations
@Override
readFromPathback to summary
private byte[] readFromPath(String fullPath) throws IOException
storeMapback to summary
public void storeMap()
writeToPathback to summary
private String writeToPath(String key, byte[] bytes) throws IOException