@Cacheable(className = CachedClass.class, primaryKeyAttributeName = "txt") public class CachedClass {
/** * Adds the speciafied cacheable to the cache * * @param cacheable cacheable to be added */ @Override public void fillCache(final T cacheable) throws IllegalAccessException, InvocationTargetException { final boolean annotationPresent = cacheable.getClass().isAnnotationPresent(Cacheable.class); if (annotationPresent) { final Cacheable annotation = cacheable.getClass().getAnnotation(Cacheable.class); primaryKeyAttributeName = annotation.primaryKeyAttributeName(); for (final Map.Entry<String, Method> attribute : attribName2Method.entrySet()) { final String attribName = attribute.getKey(); Index<T> index = attribName2Index.get(attribName); if (index == null) { index = new Index<>(); attribName2Index.put(attribName, index); } final Method readMethod = attribute.getValue(); final Object key = readMethod.invoke(cacheable); index.putSingleOrMultiple(key, cacheable); } } else { if (logger.isDebugEnabled()) { logger.debug("Class has no Annotation Cacheable"); } } }
final String className = t.getClass().getAnnotation(Cacheable.class).className().getName(); if (logger.isDebugEnabled()) { logger.debug("classname " + className);
@Cacheable(primaryKeyAttributeName = "txNumber", className = CDITransaction.class) public class CDITransaction { private String txNumber = System.nanoTime() + "";
@Named @Cacheable(primaryKeyAttributeName = "version", className = DemoClassA.class) @CDITransactionScope public class DemoClassA { private String version = System.nanoTime() + ""; public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } @Override public String toString() { final StringBuilder sb = new StringBuilder("DemoClassA{"); sb.append("version='").append(version).append('\''); sb.append('}'); return sb.toString(); } }