You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2016/05/06 00:39:57 UTC

[08/11] incubator-mnemonic git commit: MNEMONIC-40 - Clean up assembled source package for release MNEMONIC-41 - Create a script for preparing a release of a single package with signing and hashing MNEMONIC-42 - Normalize the names of project submodules

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/AnnotatedDurableEntityClass.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/AnnotatedDurableEntityClass.java b/core/src/main/java/org/apache/mnemonic/AnnotatedDurableEntityClass.java
deleted file mode 100644
index 7f25b33..0000000
--- a/core/src/main/java/org/apache/mnemonic/AnnotatedDurableEntityClass.java
+++ /dev/null
@@ -1,943 +0,0 @@
-/*
- * 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.mnemonic;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.Messager;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.element.TypeParameterElement;
-import javax.lang.model.element.VariableElement;
-import javax.lang.model.type.TypeKind;
-import javax.lang.model.type.TypeMirror;
-import javax.lang.model.type.TypeVariable;
-import javax.lang.model.util.Elements;
-import javax.lang.model.util.Types;
-
-import com.squareup.javapoet.AnnotationSpec;
-import com.squareup.javapoet.ArrayTypeName;
-import com.squareup.javapoet.ClassName;
-import com.squareup.javapoet.CodeBlock;
-import com.squareup.javapoet.FieldSpec;
-import com.squareup.javapoet.JavaFile;
-import com.squareup.javapoet.MethodSpec;
-import com.squareup.javapoet.MethodSpec.Builder;
-import com.squareup.javapoet.ParameterSpec;
-import com.squareup.javapoet.ParameterizedTypeName;
-import com.squareup.javapoet.TypeName;
-import com.squareup.javapoet.TypeSpec;
-import com.squareup.javapoet.TypeVariableName;
-
-import sun.misc.Unsafe;
-
-/**
- * this class managed to generate generic non-volatile concrete object and their
- * corresponding factory.
- *
- */
-@SuppressWarnings("restriction")
-public class AnnotatedDurableEntityClass {
-  protected class MethodInfo {
-    public ExecutableElement elem;
-    public MethodSpec.Builder specbuilder;
-    public TypeName rettype;
-  }
-
-  protected class FieldInfo {
-    public FieldSpec.Builder specbuilder;
-    public TypeName type;
-    public long id;
-    public String name;
-    public String efproxiesname;
-    public String gftypesname;
-    public long fieldoff;
-    public long fieldsize;
-  }
-
-  protected final String cFACTORYNAMESUFFIX = "Factory";
-  protected final String cPMEMNAMEPREFIX = "Durable_";
-  protected final String cFIELDNAMESUFFIX = String.format("_field_%s", Utils.genRandomString());
-  protected final String cALLOCATORFIELDNAME = String.format("alloc_%s", Utils.genRandomString());
-  protected final String cAUTORECLAIMFIELDNAME = String.format("autoreclaim_%s", Utils.genRandomString());
-  protected final String cUNSAFEFIELDNAME = String.format("unsafe_%s", Utils.genRandomString());
-  protected final String cHOLDERFIELDNAME = String.format("holder_%s", Utils.genRandomString());
-  protected final String cALLOCTYPENAME = String.format("ALLOC_PMem3C93D24F59");
-
-  private Types m_typeutils;
-  private Elements m_elemutils;
-  private TypeElement m_elem;
-
-  private String m_factoryname;
-  private String m_entityname;
-
-  private long m_holdersize;
-
-  private String m_packagename;
-
-  private TypeName m_alloctypename = TypeVariableName.get(cALLOCTYPENAME);
-  private TypeName m_factoryproxystypename = TypeName.get(EntityFactoryProxy[].class);
-  private TypeName m_gfieldstypename = TypeName.get(GenericField.GType[].class);
-  private TypeVariableName m_alloctypevarname = TypeVariableName.get(cALLOCTYPENAME,
-      ParameterizedTypeName.get(ClassName.get(CommonDurableAllocator.class), TypeVariableName.get(cALLOCTYPENAME)));
-
-  private Map<String, MethodInfo> m_gettersinfo = new HashMap<String, MethodInfo>();
-  private Map<String, MethodInfo> m_settersinfo = new HashMap<String, MethodInfo>();
-  private Map<String, FieldInfo> m_dynfieldsinfo = new HashMap<String, FieldInfo>();
-  private Map<String, FieldInfo> m_fieldsinfo = new HashMap<String, FieldInfo>();
-
-  private Map<String, MethodInfo> m_durablemtdinfo = new HashMap<String, MethodInfo>();
-  private Map<String, MethodInfo> m_entitymtdinfo = new HashMap<String, MethodInfo>();
-
-  private long computeTypeSize(TypeMirror type) {
-    long ret;
-    switch (type.getKind()) {
-    case BYTE:
-      ret = 1L;
-      break;
-    case BOOLEAN:
-      ret = 1L;
-      break;
-    case CHAR:
-      ret = 2L;
-      break;
-    case DOUBLE:
-      ret = 8L;
-      break;
-    case FLOAT:
-      ret = 4L;
-      break;
-    case SHORT:
-      ret = 2L;
-      break;
-    case INT:
-      ret = 4L;
-      break;
-    case LONG:
-      ret = 8L;
-      break;
-    default:
-      ret = 8L;
-    }
-    return ret;
-  }
-
-  private boolean isUnboxPrimitive(TypeName tn) {
-    TypeName n = tn;
-    try {
-      n = tn.unbox();
-    } catch (UnsupportedOperationException ex) {
-    }
-    return n.isPrimitive();
-  }
-
-  private TypeName unboxTypeName(TypeName tn) {
-    TypeName n = tn;
-    try {
-      n = tn.unbox();
-    } catch (UnsupportedOperationException ex) {
-    }
-    return n;
-  }
-
-  public AnnotatedDurableEntityClass(TypeElement classElement, Types typeUtils, Elements elementUtils,
-      Messager messager) {
-    m_elem = classElement;
-    m_typeutils = typeUtils;
-    m_elemutils = elementUtils;
-
-    m_packagename = m_elemutils.getPackageOf(m_elem).getQualifiedName().toString();
-
-    m_factoryname = String.format("%s%s", m_elem.getSimpleName(), cFACTORYNAMESUFFIX);
-    m_entityname = String.format("%s%s_%s", cPMEMNAMEPREFIX, m_elem.getSimpleName(), Utils.genRandomString());
-
-    m_durablemtdinfo.put("cancelAutoReclaim", new MethodInfo());
-    m_durablemtdinfo.put("registerAutoReclaim", new MethodInfo());
-    m_durablemtdinfo.put("getHandler", new MethodInfo());
-    m_durablemtdinfo.put("autoReclaim", new MethodInfo());
-    m_durablemtdinfo.put("destroy", new MethodInfo());
-    m_durablemtdinfo.put("getNativeFieldInfo", new MethodInfo());
-
-    m_entitymtdinfo.put("initializeDurableEntity", new MethodInfo());
-    m_entitymtdinfo.put("createDurableEntity", new MethodInfo());
-    m_entitymtdinfo.put("restoreDurableEntity", new MethodInfo());
-
-  }
-
-  public void prepareProcessing() throws AnnotationProcessingException {
-    MethodInfo methodinfo = null;
-    FieldInfo fieldinfo;
-    String methodname;
-    long fieldoff = 0;
-    TypeElement intf_durable = m_elemutils.getTypeElement(Durable.class.getCanonicalName());
-    TypeElement intf_entity = m_elemutils.getTypeElement(MemoryDurableEntity.class.getCanonicalName());
-    // System.err.printf("<><><><><> %s ======\n", intf_entity.toString());
-
-    boolean valid = false;
-    for (TypeMirror tm : m_elem.getInterfaces()) {
-      if (tm.toString().equals(Durable.class.getCanonicalName())) {
-        valid = true;
-        break;
-      }
-    }
-    if (!valid) {
-      throw new AnnotationProcessingException(m_elem, "Not implemented Durable Interface by %s.",
-          m_elem.getSimpleName().toString());
-    }
-
-    fieldinfo = new FieldInfo();
-    fieldinfo.name = String.format("m_unsafe_%s", Utils.genRandomString());
-    fieldinfo.type = TypeName.get(m_elemutils.getTypeElement(Unsafe.class.getCanonicalName()).asType());
-    fieldinfo.specbuilder = FieldSpec.builder(fieldinfo.type, fieldinfo.name, Modifier.PRIVATE);
-    m_fieldsinfo.put("unsafe", fieldinfo);
-
-    fieldinfo = new FieldInfo();
-    fieldinfo.name = String.format("m_holder_%s", Utils.genRandomString());
-    fieldinfo.type = ParameterizedTypeName.get(ClassName.get(MemChunkHolder.class), m_alloctypename);
-    fieldinfo.specbuilder = FieldSpec.builder(fieldinfo.type, fieldinfo.name, Modifier.PRIVATE);
-    m_fieldsinfo.put("holder", fieldinfo);
-
-    fieldinfo = new FieldInfo();
-    fieldinfo.name = String.format("m_autoreclaim_%s", Utils.genRandomString());
-    fieldinfo.type = TypeName.get(m_typeutils.getPrimitiveType(TypeKind.BOOLEAN));
-    fieldinfo.specbuilder = FieldSpec.builder(fieldinfo.type, fieldinfo.name, Modifier.PRIVATE, Modifier.VOLATILE);
-    m_fieldsinfo.put("autoreclaim", fieldinfo);
-
-    fieldinfo = new FieldInfo();
-    fieldinfo.name = String.format("m_allocator_%s", Utils.genRandomString());
-    fieldinfo.type = m_alloctypename;
-    fieldinfo.specbuilder = FieldSpec.builder(fieldinfo.type, fieldinfo.name, Modifier.PRIVATE);
-    m_fieldsinfo.put("allocator", fieldinfo);
-
-    fieldinfo = new FieldInfo();
-    fieldinfo.name = String.format("m_factoryproxy_%s", Utils.genRandomString());
-    fieldinfo.type = m_factoryproxystypename;
-    fieldinfo.specbuilder = FieldSpec.builder(fieldinfo.type, fieldinfo.name, Modifier.PRIVATE);
-    m_fieldsinfo.put("factoryproxy", fieldinfo);
-
-    fieldinfo = new FieldInfo();
-    fieldinfo.name = String.format("m_genericfield_%s", Utils.genRandomString());
-    fieldinfo.type = m_gfieldstypename;
-    fieldinfo.specbuilder = FieldSpec.builder(fieldinfo.type, fieldinfo.name, Modifier.PRIVATE);
-    m_fieldsinfo.put("genericfield", fieldinfo);
-
-    for (Element elem : m_elem.getEnclosedElements()) {
-      if (elem.getKind() == ElementKind.METHOD) {
-        methodname = elem.getSimpleName().toString();
-        // System.err.printf("=========== %s ======\n", methodname);
-        DurableGetter pgetter = elem.getAnnotation(DurableGetter.class);
-        if (pgetter != null) {
-          if (!elem.getModifiers().contains(Modifier.ABSTRACT)) {
-            throw new AnnotationProcessingException(elem, "%s annotated with DurableGetter is not abstract.",
-                methodname);
-          }
-          if (null != elem.getAnnotation(DurableSetter.class)) {
-            throw new AnnotationProcessingException(elem, "%s is annotated with DurableSetter as well.",
-                methodname);
-          }
-          if (!methodname.startsWith("get")) {
-            throw new AnnotationProcessingException(elem, "%s does not comply name convention of getter.", methodname);
-          }
-          methodinfo = new MethodInfo();
-          methodinfo.elem = (ExecutableElement) elem;
-          methodinfo.specbuilder = MethodSpec.overriding(methodinfo.elem);
-          methodinfo.rettype = TypeName.get(methodinfo.elem.getReturnType());
-          m_gettersinfo.put(methodname.substring(3), methodinfo);
-          fieldinfo = new FieldInfo();
-          fieldinfo.type = methodinfo.rettype;
-          if (fieldinfo.type.toString().equals(String.class.getCanonicalName())) {
-            fieldinfo.type = ParameterizedTypeName.get(ClassName.get(MemBufferHolder.class), m_alloctypename);
-          }
-          if (fieldinfo.type instanceof TypeVariableName) {
-            fieldinfo.type = ParameterizedTypeName.get(ClassName.get(GenericField.class), m_alloctypename,
-                fieldinfo.type);
-          }
-          fieldinfo.name = String.format("m_%s_%s", methodname.substring(3).toLowerCase(), Utils.genRandomString());
-          fieldinfo.specbuilder = FieldSpec.builder(fieldinfo.type, fieldinfo.name, Modifier.PRIVATE);
-          fieldinfo.fieldsize = computeTypeSize(methodinfo.elem.getReturnType());
-          fieldinfo.fieldoff = fieldoff;
-          fieldoff += fieldinfo.fieldsize;
-          fieldinfo.efproxiesname = pgetter.EntityFactoryProxies();
-          fieldinfo.gftypesname = pgetter.GenericFieldTypes();
-          fieldinfo.id = pgetter.Id();
-          m_dynfieldsinfo.put(methodname.substring(3), fieldinfo);
-
-        }
-        if (null != elem.getAnnotation(DurableSetter.class)) {
-          if (!elem.getModifiers().contains(Modifier.ABSTRACT)) {
-            throw new AnnotationProcessingException(elem, "%s annotated with DurableSetter is not abstract.",
-                methodname);
-          }
-          if (!methodname.startsWith("set")) {
-            throw new AnnotationProcessingException(elem, "%s does not comply name convention of setter.", methodname);
-          }
-          methodinfo = new MethodInfo();
-          methodinfo.elem = (ExecutableElement) elem;
-          methodinfo.specbuilder = MethodSpec.overriding(methodinfo.elem);
-          m_settersinfo.put(methodname.substring(3), methodinfo);
-        }
-      }
-    }
-
-    m_holdersize = fieldoff;
-
-    // MethodInfo minfo = null;
-    for (String name : m_settersinfo.keySet()) {
-      if (!m_gettersinfo.containsKey(name)) {
-        throw new AnnotationProcessingException(null, "%s has no getter.", name);
-      }
-    }
-
-    for (Element elem : intf_durable.getEnclosedElements()) {
-      if (elem.getKind() == ElementKind.METHOD) {
-        methodname = elem.getSimpleName().toString();
-        if (m_durablemtdinfo.containsKey(methodname)) {
-          // System.err.printf("**++++++++++ %s ======\n", methodname);
-          methodinfo = m_durablemtdinfo.get(methodname);
-          methodinfo.elem = (ExecutableElement) elem;
-          methodinfo.specbuilder = MethodSpec.overriding(methodinfo.elem);
-        }
-      }
-    }
-
-    for (Element elem : intf_entity.getEnclosedElements()) {
-      if (elem.getKind() == ElementKind.METHOD) {
-        methodname = elem.getSimpleName().toString();
-        if (m_entitymtdinfo.containsKey(methodname)) {
-          // System.err.printf("**------- %s ======\n", elem.toString());
-          methodinfo = m_entitymtdinfo.get(methodname);
-          methodinfo.elem = (ExecutableElement) elem;
-          methodinfo.specbuilder = overriding(methodinfo.elem, cALLOCTYPENAME);
-
-        }
-      }
-    }
-    genNFieldInfo();
-  }
-
-  protected String transTypeToUnsafeMethod(TypeName tname, boolean isget) throws AnnotationProcessingException {
-    String ret = null;
-    if (isUnboxPrimitive(tname)) {
-      TypeName tn = unboxTypeName(tname);
-      if (tn.equals(TypeName.BOOLEAN)) {
-        ret = isget ? "getByte" : "putByte";
-      }
-      if (tn.equals(TypeName.BYTE)) {
-        ret = isget ? "getByte" : "putByte";
-      }
-      if (tn.equals(TypeName.CHAR)) {
-        ret = isget ? "getChar" : "putChar";
-      }
-      if (tn.equals(TypeName.DOUBLE)) {
-        ret = isget ? "getDouble" : "putDouble";
-      }
-      if (tn.equals(TypeName.FLOAT)) {
-        ret = isget ? "getFloat" : "putFloat";
-      }
-      if (tn.equals(TypeName.INT)) {
-        ret = isget ? "getInt" : "putInt";
-      }
-      if (tn.equals(TypeName.LONG)) {
-        ret = isget ? "getLong" : "putLong";
-      }
-      if (tn.equals(TypeName.SHORT)) {
-        ret = isget ? "getShort" : "putShort";
-      }
-    } else {
-      ret = isget ? "getAddress" : "putAddress";
-    }
-    if (null == ret) {
-      throw new AnnotationProcessingException(null, "%s is not supported by getters or setters.", tname.toString());
-    }
-    return ret;
-  }
-
-  protected String getIntialValueLiteral(TypeName tname) throws AnnotationProcessingException {
-    String ret = null;
-    if (isUnboxPrimitive(tname)) {
-      TypeName tn = unboxTypeName(tname);
-      if (tn.equals(TypeName.BOOLEAN)) {
-        ret = "false";
-      }
-      if (tn.equals(TypeName.BYTE)) {
-        ret = "(byte)0";
-      }
-      if (tn.equals(TypeName.CHAR)) {
-        ret = "(char)0";
-      }
-      if (tn.equals(TypeName.DOUBLE)) {
-        ret = "(double)0.0";
-      }
-      if (tn.equals(TypeName.FLOAT)) {
-        ret = "(float)0.0";
-      }
-      if (tn.equals(TypeName.INT)) {
-        ret = "(int)0";
-      }
-      if (tn.equals(TypeName.LONG)) {
-        ret = "(long)0";
-      }
-      if (tn.equals(TypeName.SHORT)) {
-        ret = "(short)0";
-      }
-    } else {
-      ret = null;
-    }
-    if (null == ret) {
-      throw new AnnotationProcessingException(null, "%s is not supported to determine the inital value.",
-          tname.toString());
-    }
-    return ret;
-  }
-
-  private int getFactoryProxyIndex(TypeName gtname) throws AnnotationProcessingException {
-    int ret = -1;
-    boolean found = false;
-    if (gtname instanceof TypeVariableName) {
-      for (TypeParameterElement tpe : m_elem.getTypeParameters()) {
-        ++ret;
-        if (tpe.toString().equals(gtname.toString())) {
-          found = true;
-          break;
-        }
-      }
-      if (!found) {
-        throw new AnnotationProcessingException(null, "%s type is not found during factory proxy query.",
-            gtname.toString());
-      }
-    } else {
-      throw new AnnotationProcessingException(null, "%s type is not generic type for factory proxy query.",
-          gtname.toString());
-    }
-    return ret;
-  }
-
-  protected void genNFieldInfo() {
-    FieldInfo dynfieldinfo, fieldinfo;
-    List<long[]> finfo = new ArrayList<long[]>();
-    for (String name : m_gettersinfo.keySet()) {
-      dynfieldinfo = m_dynfieldsinfo.get(name);
-      if (dynfieldinfo.id > 0) {
-        finfo.add(new long[]{dynfieldinfo.id, dynfieldinfo.fieldoff, dynfieldinfo.fieldsize});
-      }
-    }
-
-    fieldinfo = new FieldInfo();
-    fieldinfo.name = String.format("m_nfieldinfo_%s", Utils.genRandomString());
-    fieldinfo.type = ArrayTypeName.of(ArrayTypeName.of(TypeName.LONG));
-    String initlstr = Utils.toInitLiteral(finfo);
-    fieldinfo.specbuilder = FieldSpec.builder(fieldinfo.type, fieldinfo.name, Modifier.PRIVATE, Modifier.STATIC)
-        .initializer("$1L", initlstr);
-    m_fieldsinfo.put("nfieldinfo", fieldinfo);
-  }
-
-  protected void buildGettersSpecs(TypeSpec.Builder typespecbuilder) throws AnnotationProcessingException {
-    MethodInfo methodinfo;
-    TypeName ftname;
-    String unsafename = m_fieldsinfo.get("unsafe").name;
-    String holdername = m_fieldsinfo.get("holder").name;
-    String allocname = m_fieldsinfo.get("allocator").name;
-    String autoreclaimname = m_fieldsinfo.get("autoreclaim").name;
-    String factoryproxyname = m_fieldsinfo.get("factoryproxy").name;
-    String genericfieldname = m_fieldsinfo.get("genericfield").name;
-    FieldInfo dynfieldinfo;
-    CodeBlock.Builder code;
-    String codefmt;
-    for (String name : m_gettersinfo.keySet()) {
-      code = CodeBlock.builder();
-      methodinfo = m_gettersinfo.get(name);
-      dynfieldinfo = m_dynfieldsinfo.get(name);
-      ftname = m_dynfieldsinfo.get(name).type;
-      if (isUnboxPrimitive(ftname)) {
-        if (unboxTypeName(ftname).equals(TypeName.BOOLEAN)) {
-          codefmt = "return 1 == $1N.$4L($2N.get() + $3L)";
-        } else {
-          codefmt = "return $1N.$4L($2N.get() + $3L)";
-        }
-        code.addStatement(codefmt, unsafename, holdername, dynfieldinfo.fieldoff,
-            transTypeToUnsafeMethod(ftname, true));
-      } else {
-        if (methodinfo.rettype.toString().equals(String.class.getCanonicalName())) {
-          code.beginControlFlow("if (null == $1N)", dynfieldinfo.name);
-          code.addStatement("long phandler = $1N.getAddress($2N.get() + $3L)", unsafename, holdername,
-              dynfieldinfo.fieldoff);
-          code.beginControlFlow("if (0L != phandler)");
-          code.addStatement("$1N = $2N.retrieveBuffer(phandler, $3N)", dynfieldinfo.name, allocname, autoreclaimname);
-          code.beginControlFlow("if (null == $1N)", dynfieldinfo.name);
-          code.addStatement("throw new RetrieveDurableEntityError(\"Retrieve String Buffer Failure.\")");
-          code.endControlFlow();
-          code.endControlFlow();
-          code.endControlFlow();
-          code.addStatement("return null == $1N ? null : $1N.get().asCharBuffer().toString()", dynfieldinfo.name);
-        } else if (dynfieldinfo.type.toString().startsWith(GenericField.class.getCanonicalName())) {
-          code.beginControlFlow("if (null == $1N)", dynfieldinfo.name);
-          code.addStatement("$1T proxy = null", TypeName.get(EntityFactoryProxy.class));
-          code.addStatement("$1T gftype = null", TypeName.get(GenericField.GType.class));
-          code.addStatement("int gfpidx = $1L", getFactoryProxyIndex(methodinfo.rettype));
-          code.beginControlFlow("if (null != $1N && $1N.length > gfpidx)", factoryproxyname);
-          code.addStatement("proxy = $1L[gfpidx]", factoryproxyname);
-          code.endControlFlow();
-          code.beginControlFlow("if (null != $1N && $1N.length > gfpidx)", genericfieldname);
-          code.addStatement("gftype = $1L[gfpidx]", genericfieldname);
-          code.nextControlFlow("else");
-          code.addStatement("throw new RetrieveDurableEntityError(\"No Generic Field Type Info.\")");
-          code.endControlFlow();
-          code.addStatement("$1N = new $2T(proxy, gftype, $8L, $9L, $3N, $4N, $5N, $6N.get() + $7L)", dynfieldinfo.name,
-              dynfieldinfo.type, allocname, unsafename, autoreclaimname, holdername, dynfieldinfo.fieldoff,
-              dynfieldinfo.efproxiesname, dynfieldinfo.gftypesname);
-          code.endControlFlow();
-          code.addStatement("return $1N.get()", dynfieldinfo.name);
-        } else {
-          code.beginControlFlow("if (null == $1N)", dynfieldinfo.name);
-          code.addStatement("long phandler = $1N.getAddress($2N.get() + $3L)", unsafename, holdername,
-              dynfieldinfo.fieldoff);
-          code.beginControlFlow("if (0L != phandler)");
-          code.addStatement("$1N = $4N.restore($2N, $5L, $6L, phandler, $3N)", dynfieldinfo.name, allocname,
-              autoreclaimname, String.format("%s%s",
-                  m_typeutils.asElement(methodinfo.elem.getReturnType()).getSimpleName(), cFACTORYNAMESUFFIX),
-              dynfieldinfo.efproxiesname, dynfieldinfo.gftypesname);
-          code.endControlFlow();
-          code.endControlFlow();
-          code.addStatement("return $1N", dynfieldinfo.name);
-        }
-      }
-      typespecbuilder.addMethod(methodinfo.specbuilder.addCode(code.build()).build());
-    }
-  }
-
-  protected String gsetterName(String name, boolean isget) {
-    return String.format("%s%s", isget ? "get" : "set", name); // Character.toUpperCase(name.charAt(0))
-                                                               // +
-                                                               // name.substring(1));
-  }
-
-  protected void buildSettersSpecs(TypeSpec.Builder typespecbuilder) throws AnnotationProcessingException {
-    MethodInfo methodinfo;
-    TypeName ftname, valtname;
-    String unsafename = m_fieldsinfo.get("unsafe").name;
-    String holdername = m_fieldsinfo.get("holder").name;
-    String allocname = m_fieldsinfo.get("allocator").name;
-    String autoreclaimname = m_fieldsinfo.get("autoreclaim").name;
-    String factoryproxyname = m_fieldsinfo.get("factoryproxy").name;
-    String genericfieldname = m_fieldsinfo.get("genericfield").name;
-    FieldInfo dynfieldinfo;
-    CodeBlock.Builder code;
-    VariableElement arg0;
-    VariableElement arg1;
-    String codefmt;
-    for (String name : m_settersinfo.keySet()) {
-      code = CodeBlock.builder();
-      methodinfo = m_settersinfo.get(name);
-      dynfieldinfo = m_dynfieldsinfo.get(name);
-      ftname = m_dynfieldsinfo.get(name).type;
-      valtname = m_gettersinfo.get(name).rettype;
-      arg0 = methodinfo.elem.getParameters().get(0);
-      if (!TypeName.get(arg0.asType()).equals(valtname)) {
-        throw new AnnotationProcessingException(null, "%s has inconsistent value type with its getter/setter.", name);
-      }
-      if (isUnboxPrimitive(ftname)) {
-        if (unboxTypeName(ftname).equals(TypeName.BOOLEAN)) {
-          codefmt = "$1N.$4L($2N.get() + $3L, $5L?1:0)";
-        } else {
-          codefmt = "$1N.$4L($2N.get() + $3L, $5L)";
-        }
-        code.addStatement(codefmt, unsafename, holdername, dynfieldinfo.fieldoff,
-            transTypeToUnsafeMethod(ftname, false), arg0);
-      } else {
-        try {
-          arg1 = methodinfo.elem.getParameters().get(1);
-          if (!TypeName.BOOLEAN.equals(TypeName.get(arg1.asType()))) {
-            throw new AnnotationProcessingException(null, "the second parameter of %s's setter is not boolean type.",
-                name);
-          }
-        } catch (IndexOutOfBoundsException ex) {
-          throw new AnnotationProcessingException(null, "%s's setter has no second parameters for non primitive type.",
-              name);
-        }
-        if (valtname.toString().equals(String.class.getCanonicalName())) {
-          code.beginControlFlow("if ($1L && null != $2L())", arg1, gsetterName(name, true));
-          code.addStatement("$1N.destroy()", dynfieldinfo.name);
-          code.addStatement("$1N = null", dynfieldinfo.name);
-          code.addStatement("$1N.putAddress($2N.get() + $3L, 0L)", unsafename, holdername, dynfieldinfo.fieldoff);
-          code.endControlFlow();
-          code.beginControlFlow("if (null == $1L)", arg0);
-          code.addStatement("$1N.putLong($2N.get() + $3L, 0L)", unsafename, holdername, dynfieldinfo.fieldoff);
-          code.nextControlFlow("else");
-          code.addStatement("$1N = $2N.createBuffer($3L.length() * 2, $4N)", dynfieldinfo.name, allocname, arg0,
-              autoreclaimname);
-          code.beginControlFlow("if (null == $1N)", dynfieldinfo.name);
-          code.addStatement("throw new OutOfHybridMemory(\"Create Non-Volatile String Error!\")");
-          code.endControlFlow();
-          code.addStatement("$1N.get().asCharBuffer().put($2L)", dynfieldinfo.name, arg0);
-          code.addStatement("$1N.putLong($2N.get() + $3L, $4N.getBufferHandler($5N))", unsafename, holdername,
-              dynfieldinfo.fieldoff, allocname, dynfieldinfo.name);
-          code.endControlFlow();
-        } else if (dynfieldinfo.type.toString().startsWith(GenericField.class.getCanonicalName())) {
-          code.beginControlFlow("if (null == $1N)", dynfieldinfo.name);
-          code.addStatement("$1T proxy = null", TypeName.get(EntityFactoryProxy.class));
-          code.addStatement("$1T gftype = null", TypeName.get(GenericField.GType.class));
-          code.addStatement("int gfpidx = $1L", getFactoryProxyIndex(valtname));
-          code.beginControlFlow("if (null != $1N && $1N.length > gfpidx)", factoryproxyname);
-          code.addStatement("proxy = $1L[gfpidx]", factoryproxyname);
-          code.endControlFlow();
-          code.beginControlFlow("if (null != $1N && $1N.length > gfpidx)", genericfieldname);
-          code.addStatement("gftype = $1L[gfpidx]", genericfieldname);
-          code.nextControlFlow("else");
-          code.addStatement("throw new RetrieveDurableEntityError(\"No Generic Field Type Info.\")");
-          code.endControlFlow();
-          code.addStatement("$1N = new $2T(proxy, gftype, $8L, $9L, $3N, $4N, $5N, $6N.get() + $7L)", dynfieldinfo.name,
-              dynfieldinfo.type, allocname, unsafename, autoreclaimname, holdername, dynfieldinfo.fieldoff,
-              dynfieldinfo.efproxiesname, dynfieldinfo.gftypesname);
-          code.endControlFlow();
-          code.beginControlFlow("if (null != $1L)", dynfieldinfo.name);
-          code.addStatement("$1N.set($2L, $3L)", dynfieldinfo.name, arg0, arg1);
-          code.nextControlFlow("else");
-          code.addStatement("throw new RetrieveDurableEntityError(\"GenericField is null!\")");
-          code.endControlFlow();
-        } else {
-          code.beginControlFlow("if ($1L && null != $2L())", arg1, gsetterName(name, true));
-          code.addStatement("$1N.destroy()", dynfieldinfo.name);
-          code.addStatement("$1N = null", dynfieldinfo.name);
-          code.addStatement("$1N.putAddress($2N.get() + $3L, 0L)", unsafename, holdername, dynfieldinfo.fieldoff);
-          code.endControlFlow();
-          code.addStatement("$1N = $2L", dynfieldinfo.name, arg0);
-          code.addStatement("$1N.putLong($2N.get() + $3L, null == $4N ? 0L : $4N.getHandler())", unsafename,
-              holdername, dynfieldinfo.fieldoff, dynfieldinfo.name);
-        }
-      }
-      typespecbuilder.addMethod(methodinfo.specbuilder.addCode(code.build()).build());
-    }
-  }
-
-  protected void buildDurableMethodSpecs(TypeSpec.Builder typespecbuilder) throws AnnotationProcessingException {
-    MethodInfo methodinfo;
-    CodeBlock.Builder code;
-    FieldInfo dynfieldinfo;
-    String holdername = m_fieldsinfo.get("holder").name;
-    String allocname = m_fieldsinfo.get("allocator").name;
-    String autoreclaimname = m_fieldsinfo.get("autoreclaim").name;
-    for (String name : m_durablemtdinfo.keySet()) {
-      methodinfo = m_durablemtdinfo.get(name);
-      code = CodeBlock.builder();
-      switch (name) {
-      case "cancelAutoReclaim":
-        code.addStatement("$1N.cancelAutoReclaim()", holdername);
-        for (String fname : m_dynfieldsinfo.keySet()) {
-          dynfieldinfo = m_dynfieldsinfo.get(fname);
-          if (!isUnboxPrimitive(dynfieldinfo.type)) {
-            code.beginControlFlow("if (null != $1N)", dynfieldinfo.name);
-            code.addStatement("$1N.cancelAutoReclaim()", dynfieldinfo.name);
-            code.endControlFlow();
-          }
-        }
-        code.addStatement("$1N = false", autoreclaimname);
-        break;
-      case "registerAutoReclaim":
-        code.addStatement("$1N.registerAutoReclaim()", holdername);
-        for (String fname : m_dynfieldsinfo.keySet()) {
-          dynfieldinfo = m_dynfieldsinfo.get(fname);
-          if (!isUnboxPrimitive(dynfieldinfo.type)) {
-            code.beginControlFlow("if (null != $1N)", dynfieldinfo.name);
-            code.addStatement("$1N.registerAutoReclaim()", dynfieldinfo.name);
-            code.endControlFlow();
-          }
-        }
-        code.addStatement("$1N = true", autoreclaimname);
-        break;
-      case "getHandler":
-        code.addStatement("return $1N.getChunkHandler($2N)", allocname, holdername);
-        break;
-      case "autoReclaim":
-        code.addStatement("return $1N", autoreclaimname);
-        break;
-      case "destroy":
-        code.addStatement("$1N.destroy()", holdername);
-        for (String fname : m_dynfieldsinfo.keySet()) {
-          dynfieldinfo = m_dynfieldsinfo.get(fname);
-          if (!isUnboxPrimitive(dynfieldinfo.type)) {
-            code.beginControlFlow("if (null != $1N)", dynfieldinfo.name);
-            code.addStatement("$1N.destroy()", dynfieldinfo.name);
-            code.addStatement("$1N = null", dynfieldinfo.name);
-            code.endControlFlow();
-          }
-        }
-        break;
-      case "getNativeFieldInfo":
-        code.addStatement("return $1N", m_fieldsinfo.get("nfieldinfo").name);
-        break;
-      default:
-        throw new AnnotationProcessingException(null, "Method %s is not supported.", name);
-      }
-      typespecbuilder.addMethod(methodinfo.specbuilder.addCode(code.build()).build());
-    }
-  }
-
-  protected void buildEntityMethodSpecs(TypeSpec.Builder typespecbuilder) throws AnnotationProcessingException {
-    MethodInfo methodinfo;
-    CodeBlock.Builder code;
-    VariableElement arg0, arg1, arg2, arg3, arg4;
-    String unsafename = m_fieldsinfo.get("unsafe").name;
-    String holdername = m_fieldsinfo.get("holder").name;
-    String allocname = m_fieldsinfo.get("allocator").name;
-    String autoreclaimname = m_fieldsinfo.get("autoreclaim").name;
-    String factoryproxyname = m_fieldsinfo.get("factoryproxy").name;
-    String genericfieldname = m_fieldsinfo.get("genericfield").name;
-    for (String name : m_entitymtdinfo.keySet()) {
-      methodinfo = m_entitymtdinfo.get(name);
-      code = CodeBlock.builder();
-      arg0 = methodinfo.elem.getParameters().get(0);
-      arg1 = methodinfo.elem.getParameters().get(1);
-      arg2 = methodinfo.elem.getParameters().get(2);
-      switch (name) {
-      case "initializeDurableEntity":
-        arg3 = methodinfo.elem.getParameters().get(3);
-        code.addStatement("$1N = $2L", allocname, arg0);
-        code.addStatement("$1N = $2L", factoryproxyname, arg1);
-        code.addStatement("$1N = $2L", genericfieldname, arg2);
-        code.addStatement("$1N = $2L", autoreclaimname, arg3);
-        code.beginControlFlow("try");
-        code.addStatement("$1N = $2T.getUnsafe()", unsafename, Utils.class);
-        code.nextControlFlow("catch (Exception e)");
-        code.addStatement("e.printStackTrace()");
-        code.endControlFlow();
-        break;
-      case "createDurableEntity":
-        arg3 = methodinfo.elem.getParameters().get(3);
-        code.addStatement("initializeDurableEntity($1L, $2L, $3L, $4L)", arg0, arg1, arg2, arg3);
-        code.addStatement("$1N = $2N.createChunk($3L, $4N)", holdername, allocname, m_holdersize, autoreclaimname);
-        code.beginControlFlow("if (null == $1N)", holdername);
-        code.addStatement("throw new OutOfHybridMemory(\"Create Non-Volatile Entity Error!\")");
-        code.endControlFlow();
-        // code.beginControlFlow("try");
-        // for (String fname : m_dynfieldsinfo.keySet()) {
-        // dynfieldinfo = m_dynfieldsinfo.get(fname);
-        // if (isUnboxPrimitive(dynfieldinfo.type)) {
-        // code.addStatement("$1N($2L)", gsetterName(fname, false),
-        // getIntialValueLiteral(dynfieldinfo.type));
-        // } else {
-        // code.addStatement("$1N(null, false)", gsetterName(fname, false));
-        // }
-        // }
-        // code.nextControlFlow("catch(RetrieveDurableEntityError ex)");
-        // code.endControlFlow();
-        code.addStatement("initializeAfterCreate()");
-        break;
-      case "restoreDurableEntity":
-        arg3 = methodinfo.elem.getParameters().get(3);
-        arg4 = methodinfo.elem.getParameters().get(4);
-        code.addStatement("initializeDurableEntity($1L, $2L, $3L, $4L)", arg0, arg1, arg2, arg4);
-        code.beginControlFlow("if (0L == $1L)", arg3);
-        code.addStatement("throw new RetrieveDurableEntityError(\"Input handler is null on $1N.\")", name);
-        code.endControlFlow();
-        code.addStatement("$1N = $2N.retrieveChunk($3L, $4N)", holdername, allocname, arg3, autoreclaimname);
-        code.beginControlFlow("if (null == $1N)", holdername);
-        code.addStatement("throw new RetrieveDurableEntityError(\"Retrieve Entity Failure!\")");
-        code.endControlFlow();
-        code.addStatement("initializeAfterRestore()");
-        break;
-      default:
-        throw new AnnotationProcessingException(null, "Method %s is not supported.", name);
-      }
-      typespecbuilder.addMethod(methodinfo.specbuilder.addCode(code.build()).build());
-    }
-  }
-
-  protected void buildFieldSpecs(TypeSpec.Builder typespecbuilder, Map<String, FieldInfo> fieldinfos) {
-    FieldInfo fieldinfo;
-    for (String name : fieldinfos.keySet()) {
-      fieldinfo = fieldinfos.get(name);
-      if (null != fieldinfo.specbuilder) {
-        typespecbuilder.addField(fieldinfo.specbuilder.build());
-      }
-    }
-  }
-
-  protected void buildFactoryMethodSpecs(TypeSpec entityspec, TypeSpec.Builder typespecbuilder)
-      throws AnnotationProcessingException {
-    MethodSpec methodspec;
-    CodeBlock code;
-
-    TypeName entitytn = ParameterizedTypeName.get(ClassName.get(m_packagename, m_entityname),
-        entityspec.typeVariables.toArray(new TypeVariableName[0]));
-
-    ParameterSpec allocparam = ParameterSpec.builder(m_alloctypename, "allocator").build();
-    code = CodeBlock.builder().addStatement("return create($1L, false)", allocparam.name).build();
-    methodspec = MethodSpec.methodBuilder("create").addTypeVariables(entityspec.typeVariables)
-        .addException(OutOfHybridMemory.class).addModifiers(Modifier.PUBLIC, Modifier.STATIC)
-        .returns(TypeName.get(m_elem.asType())).addParameter(allocparam).addCode(code).build();
-    typespecbuilder.addMethod(methodspec);
-
-    ParameterSpec autoreclaimparam = ParameterSpec.builder(TypeName.BOOLEAN, "autoreclaim").build();
-    code = CodeBlock.builder()
-        .addStatement("return create($1L, null, null, $2L)", allocparam.name, autoreclaimparam.name).build();
-    methodspec = MethodSpec.methodBuilder("create").addTypeVariables(entityspec.typeVariables)
-        .addException(OutOfHybridMemory.class).addModifiers(Modifier.PUBLIC, Modifier.STATIC)
-        .returns(TypeName.get(m_elem.asType())).addParameter(allocparam).addParameter(autoreclaimparam).addCode(code)
-        .build();
-    typespecbuilder.addMethod(methodspec);
-
-    ParameterSpec factoryproxysparam = ParameterSpec.builder(m_factoryproxystypename, "factoryproxys").build();
-    ParameterSpec gfieldsparam = ParameterSpec.builder(m_gfieldstypename, "gfields").build();
-    code = CodeBlock.builder().addStatement("$1T entity = new $1T()", entitytn)
-        .addStatement("entity.setupGenericInfo($1N, $2N)", factoryproxysparam.name, gfieldsparam.name)
-        .addStatement("entity.createDurableEntity($1L, $2L, $3L, $4L)", allocparam.name, factoryproxysparam.name,
-            gfieldsparam.name, autoreclaimparam.name)
-        .addStatement("return entity").build();
-    methodspec = MethodSpec.methodBuilder("create").addTypeVariables(entityspec.typeVariables)
-        .addException(OutOfHybridMemory.class).addModifiers(Modifier.PUBLIC, Modifier.STATIC)
-        .returns(TypeName.get(m_elem.asType())).addParameter(allocparam).addParameter(factoryproxysparam)
-        .addParameter(gfieldsparam).addParameter(autoreclaimparam).addCode(code).build();
-    typespecbuilder.addMethod(methodspec);
-
-    ParameterSpec phandlerparam = ParameterSpec.builder(TypeName.LONG, "phandler").build();
-    code = CodeBlock.builder().addStatement("return restore($1L, $2L, false)", allocparam.name, phandlerparam.name)
-        .build();
-    methodspec = MethodSpec.methodBuilder("restore").addTypeVariables(entityspec.typeVariables)
-        .addException(RetrieveDurableEntityError.class).addModifiers(Modifier.PUBLIC, Modifier.STATIC)
-        .returns(TypeName.get(m_elem.asType())).addParameter(allocparam).addParameter(phandlerparam).addCode(code)
-        .build();
-    typespecbuilder.addMethod(methodspec);
-
-    code = CodeBlock.builder().addStatement("return restore($1L, null, null, $2L, $3L)", allocparam.name,
-        phandlerparam.name, autoreclaimparam.name).build();
-    methodspec = MethodSpec.methodBuilder("restore").addTypeVariables(entityspec.typeVariables)
-        .addException(RetrieveDurableEntityError.class).addModifiers(Modifier.PUBLIC, Modifier.STATIC)
-        .returns(TypeName.get(m_elem.asType())).addParameter(allocparam).addParameter(phandlerparam)
-        .addParameter(autoreclaimparam).addCode(code).build();
-    typespecbuilder.addMethod(methodspec);
-
-    code = CodeBlock.builder().addStatement("$1T entity = new $1T()", entitytn)
-        .addStatement("entity.setupGenericInfo($1N, $2N)", factoryproxysparam.name, gfieldsparam.name)
-        .addStatement("entity.restoreDurableEntity($1L, $2L, $3L, $4L, $5L)", allocparam.name,
-            factoryproxysparam.name, gfieldsparam.name, phandlerparam.name, autoreclaimparam.name)
-        .addStatement("return entity").build();
-    methodspec = MethodSpec.methodBuilder("restore").addTypeVariables(entityspec.typeVariables)
-        .addException(RetrieveDurableEntityError.class).addModifiers(Modifier.PUBLIC, Modifier.STATIC)
-        .returns(TypeName.get(m_elem.asType())).addParameter(allocparam).addParameter(factoryproxysparam)
-        .addParameter(gfieldsparam).addParameter(phandlerparam).addParameter(autoreclaimparam).addCode(code).build();
-    typespecbuilder.addMethod(methodspec);
-  }
-
-  public void generateCode(Filer filer) throws IOException, AnnotationProcessingException {
-    AnnotationSpec classannotation = AnnotationSpec.builder(SuppressWarnings.class)
-        .addMember("value", "$S", "restriction").build();
-
-    TypeSpec.Builder entitybuilder = TypeSpec.classBuilder(m_entityname).superclass(TypeName.get(m_elem.asType()))
-        .addModifiers(Modifier.PUBLIC).addAnnotation(classannotation)
-        .addSuperinterface(ParameterizedTypeName.get(ClassName.get(MemoryDurableEntity.class), m_alloctypevarname))
-        .addTypeVariable(m_alloctypevarname);
-
-    for (TypeParameterElement tpe : m_elem.getTypeParameters()) {
-      entitybuilder.addTypeVariable(TypeVariableName.get(tpe));
-    }
-
-    buildFieldSpecs(entitybuilder, m_dynfieldsinfo);
-    buildFieldSpecs(entitybuilder, m_fieldsinfo);
-
-    buildGettersSpecs(entitybuilder);
-    buildSettersSpecs(entitybuilder);
-
-    buildDurableMethodSpecs(entitybuilder);
-    buildEntityMethodSpecs(entitybuilder);
-
-    TypeSpec entityspec = entitybuilder.build();
-
-    JavaFile entityFile = JavaFile.builder(m_packagename, entityspec).build();
-
-    entityFile.writeTo(filer);
-
-    TypeSpec.Builder factorybuilder = TypeSpec.classBuilder(m_factoryname).addModifiers(Modifier.PUBLIC);
-
-    buildFactoryMethodSpecs(entityspec, factorybuilder);
-
-    JavaFile factoryFile = JavaFile.builder(m_packagename, factorybuilder.build()).build();
-
-    factoryFile.writeTo(filer);
-
-  }
-
-  public static Builder overriding(ExecutableElement method, String varname) {
-
-    Set<Modifier> modifiers = method.getModifiers();
-    if (modifiers.contains(Modifier.PRIVATE) || modifiers.contains(Modifier.FINAL)
-        || modifiers.contains(Modifier.STATIC)) {
-      throw new IllegalArgumentException("cannot override method with modifiers: " + modifiers);
-    }
-
-    String methodName = method.getSimpleName().toString();
-    MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(methodName);
-
-    methodBuilder.addAnnotation(Override.class);
-    for (AnnotationMirror mirror : method.getAnnotationMirrors()) {
-      AnnotationSpec annotationSpec = AnnotationSpec.get(mirror);
-      if (annotationSpec.type.equals(Override.class)) {
-        continue;
-      }
-      methodBuilder.addAnnotation(annotationSpec);
-    }
-
-    modifiers = new LinkedHashSet<>(modifiers);
-    modifiers.remove(Modifier.ABSTRACT);
-    methodBuilder.addModifiers(modifiers);
-
-    for (TypeParameterElement typeParameterElement : method.getTypeParameters()) {
-      TypeVariable var = (TypeVariable) typeParameterElement.asType();
-      methodBuilder.addTypeVariable(TypeVariableName.get(var));
-    }
-
-    methodBuilder.returns(TypeName.get(method.getReturnType()));
-
-    List<? extends VariableElement> parameters = method.getParameters();
-    TypeName type;
-    for (VariableElement parameter : parameters) {
-      if (parameter.asType().getKind() == TypeKind.TYPEVAR && parameter.asType().toString().equals(varname)) {
-        type = TypeVariableName.get(varname);
-      } else {
-        type = TypeName.get(parameter.asType());
-      }
-
-      String name = parameter.getSimpleName().toString();
-      Set<Modifier> parameterModifiers = parameter.getModifiers();
-      ParameterSpec.Builder parameterBuilder = ParameterSpec.builder(type, name)
-          .addModifiers(parameterModifiers.toArray(new Modifier[parameterModifiers.size()]));
-      for (AnnotationMirror mirror : parameter.getAnnotationMirrors()) {
-        parameterBuilder.addAnnotation(AnnotationSpec.get(mirror));
-      }
-      methodBuilder.addParameter(parameterBuilder.build());
-    }
-    methodBuilder.varargs(method.isVarArgs());
-
-    for (TypeMirror thrownType : method.getThrownTypes()) {
-      methodBuilder.addException(TypeName.get(thrownType));
-    }
-
-    return methodBuilder;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/AnnotationProcessingException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/AnnotationProcessingException.java b/core/src/main/java/org/apache/mnemonic/AnnotationProcessingException.java
deleted file mode 100644
index d454b22..0000000
--- a/core/src/main/java/org/apache/mnemonic/AnnotationProcessingException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.mnemonic;
-
-import javax.lang.model.element.Element;
-
-/**
- * this exception is used for non-volatile annotation processing
- *
- */
-public class AnnotationProcessingException extends Exception {
-
-  private static final long serialVersionUID = 6911141027622831646L;
-
-  private Element element;
-
-  public AnnotationProcessingException(Element element, String msg, Object... args) {
-    super(String.format(msg, args));
-    this.element = element;
-  }
-
-  public Element getElement() {
-    return element;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/ByteBufferBackedInputStream.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/ByteBufferBackedInputStream.java b/core/src/main/java/org/apache/mnemonic/ByteBufferBackedInputStream.java
deleted file mode 100644
index 7a554dd..0000000
--- a/core/src/main/java/org/apache/mnemonic/ByteBufferBackedInputStream.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.mnemonic;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-
-/**
- * an input Stream that is backed by a in-memory ByteBuffer.
- * 
- *
- */
-public class ByteBufferBackedInputStream extends InputStream {
-
-  private ByteBuffer buf;
-
-  /**
-   * accept a ByteBuffer as backed object for inputStream.
-   * 
-   * @param buf
-   *          specify a bytebuffer that is where any data is from
-   */
-  public ByteBufferBackedInputStream(ByteBuffer buf) {
-    this.buf = buf;
-  }
-
-  /**
-   * read an integer value from backed ByteBuffer.
-   * 
-   * @return a integer value from stream input
-   */
-  public int read() throws IOException {
-    if (!buf.hasRemaining()) {
-      return -1;
-    }
-    return buf.get() & 0xFF;
-  }
-
-  /**
-   * read a specified range of byte array from backed ByteBuffer.
-   * 
-   * @param bytes
-   *          specify a output byte array to store data
-   * 
-   * @param off
-   *          specify the offset from ByteBuffer to read
-   * 
-   * @param len
-   *          specify the length of bytes to read
-   * 
-   * @return the number of bytes has been read
-   */
-  public int read(byte[] bytes, int off, int len) throws IOException {
-    if (!buf.hasRemaining()) {
-      return -1;
-    }
-
-    len = Math.min(len, buf.remaining());
-    buf.get(bytes, off, len);
-    return len;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/ByteBufferBackedOutputStream.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/ByteBufferBackedOutputStream.java b/core/src/main/java/org/apache/mnemonic/ByteBufferBackedOutputStream.java
deleted file mode 100644
index 2a1792d..0000000
--- a/core/src/main/java/org/apache/mnemonic/ByteBufferBackedOutputStream.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.mnemonic;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-
-/**
- * an output Stream that is backed by a in-memory ByteBuffer.
- * 
- *
- */
-public class ByteBufferBackedOutputStream extends OutputStream {
-
-  private ByteBuffer buf;
-
-  /**
-   * accept a ByteBuffer to store external data, the capacity of it could be
-   * extended at will.
-   * 
-   * @param buf
-   *          specify a ByteBuffer object that is used to store external data to
-   *          its backed buffer
-   * 
-   */
-  public ByteBufferBackedOutputStream(ByteBuffer buf) {
-    this.buf = buf;
-  }
-
-  /**
-   * write an integer value to backed buffer.
-   * 
-   * @param b
-   *          specify an integer value to be written
-   */
-  public void write(int b) throws IOException {
-    buf.put((byte) b);
-  }
-
-  /**
-   * write an array of bytes to a specified range of backed buffer
-   * 
-   * @param bytes
-   *          specify a byte array to write
-   * 
-   * @param off
-   *          specify the offset of backed buffer where is start point to be
-   *          written
-   * 
-   * @param len
-   *          specify the length of bytes to be written
-   */
-  public void write(byte[] bytes, int off, int len) throws IOException {
-    buf.put(bytes, off, len);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/ByteBufferSerializer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/ByteBufferSerializer.java b/core/src/main/java/org/apache/mnemonic/ByteBufferSerializer.java
deleted file mode 100644
index b6371d5..0000000
--- a/core/src/main/java/org/apache/mnemonic/ByteBufferSerializer.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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.mnemonic;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.nio.ByteBuffer;
-import java.io.InputStream;
-
-/**
- * a serializer class that manages to serialize any serilizable objects from/to
- * ByteBuffer.
- * 
- */
-
-public class ByteBufferSerializer {
-
-  /**
-   * serialize object to a ByteBuffer object.
-   * 
-   * @param <ValueT>
-   *          the type of object
-   * 
-   * @param obj
-   *          specify a object that is serializable
-   * 
-   * @throws IOException
-   *           the exception of serialization
-   * 
-   * @return a ByteBuffer object contained serialized object
-   */
-  public static <ValueT> ByteBuffer toByteBuffer(ValueT obj) throws IOException {
-    byte[] bytes = null;
-    ByteArrayOutputStream bos = null;
-    ObjectOutputStream oos = null;
-    try {
-      bos = new ByteArrayOutputStream();
-      oos = new ObjectOutputStream(bos);
-      oos.writeObject(obj);
-      oos.flush();
-      bytes = bos.toByteArray();
-    } finally {
-      if (oos != null) {
-        oos.close();
-      }
-      if (bos != null) {
-        bos.close();
-      }
-    }
-    return ByteBuffer.wrap(bytes);
-  }
-
-  /**
-   * de-serialize an object from a ByteBuffer object.
-   * 
-   * @param <ValueT>
-   *          the type of object
-   * 
-   * @param bf
-   *          specify an ByteBuffer contains data that can be de-serialized
-   * 
-   * @throws IOException
-   *           the exception of deserialization
-   * 
-   * @throws ClassNotFoundException
-   *           Not found class of de-serialized object
-   * 
-   * @return a de-serialized object
-   */
-  @SuppressWarnings("unchecked")
-  public static <ValueT> ValueT toObject(ByteBuffer bf) throws IOException, ClassNotFoundException {
-    Object obj = null;
-    InputStream is = null;
-    ObjectInputStream ois = null;
-    try {
-      is = new ByteBufferBackedInputStream(bf);
-      ois = new ObjectInputStream(is);
-      obj = ois.readObject();
-    } finally {
-      if (is != null) {
-        is.close();
-      }
-      if (ois != null) {
-        ois.close();
-      }
-    }
-    return (ValueT) obj;
-  }
-
-  /**
-   * serialize object to a MemBufferHolder object.
-   * 
-   * @param <A>
-   *          the type of bound allocator
-   * 
-   * @param <ValueT>
-   *          the type of object
-   * 
-   * @param ar
-   *          specify an Allocator that is used to generate MemBufferHolder
-   *          which is backed by a native memory block
-   * 
-   * @param obj
-   *          specify a object that is serializable
-   * 
-   * @throws IOException
-   *           the exception of serialization
-   * 
-   * @return a MemBufferHolder object contained serialized object
-   */
-  public static <A extends CommonAllocator<A>, ValueT> MemBufferHolder<A> toMemBufferHolder(A ar, ValueT obj)
-      throws IOException {
-    MemBufferHolder<A> ret = null;
-    ByteBuffer bb = toByteBuffer(obj);
-    if (null != bb && bb.remaining() > 0) {
-      ret = ar.createBuffer(bb.remaining());
-      ret.get().put(bb);
-      ret.get().flip();
-    }
-    return ret;
-  }
-
-  /**
-   * de-serialize an object from a MemBufferHolder object.
-   * 
-   * @param <A>
-   *          the type of bound allocator
-   * 
-   * @param <ValueT>
-   *          the type of object
-   * 
-   * @param mbh
-   *          specify an MemBufferHolder who contains data that can be
-   *          de-serialized
-   * 
-   * @throws IOException
-   *           the exception of deserialization
-   * 
-   * @throws ClassNotFoundException
-   *           Not found class of de-serialized object
-   * 
-   * @return a de-serialized object
-   */
-  public static <A extends CommonAllocator<A>, ValueT> ValueT fromMemBufferHolder(MemBufferHolder<A> mbh)
-      throws IOException, ClassNotFoundException {
-    return toObject(mbh.get());
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/CachePool.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/CachePool.java b/core/src/main/java/org/apache/mnemonic/CachePool.java
deleted file mode 100644
index 37a87ee..0000000
--- a/core/src/main/java/org/apache/mnemonic/CachePool.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.mnemonic;
-
-import java.util.Set;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * This is a abstract CachePool class that is inherited from LinedHashMap class,
- * it extends functionalities of its parent class to support some new features
- * that is usually requried in data caching usage scenario.
- * 
- * 
- */
-public abstract class CachePool<KeyT, ValueT> extends LinkedHashMap<KeyT, ValueT> {
-
-  /**
-   * 
-   */
-  private static final long serialVersionUID = 1L;
-
-  public CachePool(int initialCapacity, float loadFactor) {
-    super(initialCapacity, loadFactor);
-  }
-
-  /**
-   * Return available capacity for new entries.
-   * 
-   * @return available capacity in this cache pool
-   */
-  public abstract long freeCapacity();
-
-  /**
-   * Return the used capacity of cached entries.
-   * 
-   * @return the used size of this cache pool
-   */
-  public abstract long usedCapacity();
-
-  /**
-   * Put an entry in this cache pool and evict eldest entries if necessary that
-   * will free enough space to hold new entry, which entry could be evicted that
-   * can be customized by ({@link EvictFilter}), regarding how to post-process
-   * the eldest entry that can be customized by ( {@link DropEvent}). If this
-   * cache pool previously contained an entry for the key, the old value will be
-   * replaced by the specified value
-   * 
-   * @param k
-   *          the key whoes associated value is to be put
-   * 
-   * @param v
-   *          the value to be put
-   * 
-   * @param fsop
-   *          the customized operations to free space to hold new entry
-   * 
-   * @param dfilter
-   *          the filter of entries for deletion
-   * 
-   * @return <tt>true</tt> if the entry has been put into this container
-   * 
-   */
-  public abstract ValueT put(KeyT k, ValueT v, DropEvent<KeyT, ValueT> fsop, EvictFilter<KeyT, ValueT> dfilter);
-
-  /**
-   * Put all entries into this cache pool and evict eldes entries if necessary.
-   * 
-   * @param m
-   *          the Map object that contains entries to be put
-   * 
-   * @param fsop
-   *          the customized operations to free space to hold new entry
-   * 
-   * @param dfilter
-   *          the filter of entries for deletion
-   * 
-   */
-  public abstract void putAll(Map<? extends KeyT, ? extends ValueT> m, DropEvent<KeyT, ValueT> fsop,
-      EvictFilter<KeyT, ValueT> dfilter);
-
-  /**
-   * Returns a new {@link Set} view of the keys of this cache pool, It contains
-   * the most recently visited keys
-   * 
-   * @param n
-   *          the number of keys to retrieve
-   * 
-   * @return a set of hot keys
-   */
-  public abstract Set<KeyT> hotKeySet(int n);
-
-  /**
-   * Ensure the free capacity is greater than the specified size
-   * 
-   * @param freesz
-   *          the size of free capacity that needs to be secured
-   * 
-   * @return <tt>true</tt> if the size of free capacity is greater than the
-   *         specified size after evacuation
-   * 
-   * @see #ensureFreeSpace(long, DropEvent, EvictFilter)
-   */
-  public abstract boolean ensureFreeSpace(long freesz);
-
-  /**
-   * Removes a first qualified entry in this cache pool
-   * 
-   * @param fsop
-   *          the customized callback to post-process its evicted entry
-   * 
-   * @param dfilter
-   *          the filter for entry deletion
-   * 
-   * @return <tt>true</tt> if there is one qualified entry that has been dropped
-   */
-  public abstract boolean removeFirstEntry(DropEvent<KeyT, ValueT> fsop, EvictFilter<KeyT, ValueT> dfilter);
-
-  /**
-   * Ensure the size of free capacity is greater than the specified size, the
-   * entries will be filtered by {@link EvictFilter} before dropping, the
-   * {@link DropEvent} is used for post-processing
-   * 
-   * @param freesz
-   *          the size of free capacity that needs to be secured
-   * 
-   * @param fsop
-   *          the customized operations to free space to hold new entry
-   * 
-   * @param dfilter
-   *          the filter of entries for deletion
-   * 
-   * @return <tt>true</tt> if the size of free capacity is greater than the
-   *         specified size after evication if necessary
-   */
-  public abstract boolean ensureFreeSpace(long freesz, DropEvent<KeyT, ValueT> fsop, EvictFilter<KeyT, ValueT> dfilter);
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/CommonAllocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/CommonAllocator.java b/core/src/main/java/org/apache/mnemonic/CommonAllocator.java
deleted file mode 100644
index 643704c..0000000
--- a/core/src/main/java/org/apache/mnemonic/CommonAllocator.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.mnemonic;
-
-import java.nio.ByteBuffer;
-
-import org.flowcomputing.commons.resgc.ResCollector;
-
-/**
- * an abstract common class for memory allocator to provide common
- * functionalities.
- * 
- */
-public abstract class CommonAllocator<A extends CommonAllocator<A>> implements Allocator<A> {
-
-  protected Reclaim<Long> m_chunkreclaimer = null;
-  protected Reclaim<ByteBuffer> m_bufferreclaimer = null;
-
-  protected ResCollector<MemChunkHolder<A>, Long> m_chunkcollector = null;
-  protected ResCollector<MemBufferHolder<A>, ByteBuffer> m_bufcollector = null;
-
-  /**
-   * set a reclaimer to reclaim memory buffer
-   * 
-   * @param reclaimer
-   *          specify a reclaimer to accept reclaim request
-   */
-  public void setBufferReclaimer(Reclaim<ByteBuffer> reclaimer) {
-    m_bufferreclaimer = reclaimer;
-  }
-
-  /**
-   * set a reclaimer to reclaim memory chunk
-   * 
-   * @param reclaimer
-   *          specify a reclaimer to accept reclaim request
-   */
-  public void setChunkReclaimer(Reclaim<Long> reclaimer) {
-    m_chunkreclaimer = reclaimer;
-  }
-
-  /**
-   * create a memory chunk that is managed by its holder.
-   * 
-   * @param size
-   *          specify the size of memory chunk
-   * 
-   * @return a holder contains a memory chunk
-   */
-  @Override
-  public MemChunkHolder<A> createChunk(long size) {
-    return createChunk(size, true);
-  }
-
-  /**
-   * create a memory buffer that is managed by its holder.
-   * 
-   * @param size
-   *          specify the size of memory buffer
-   * 
-   * @return a holder contains a memory buffer
-   */
-  @Override
-  public MemBufferHolder<A> createBuffer(long size) {
-    return createBuffer(size, true);
-  }
-
-  /**
-   * register a memory chunk for auto-reclaim
-   *
-   * @param mholder
-   *          specify a chunk holder to register
-   */
-  @Override
-  public void registerChunkAutoReclaim(MemChunkHolder<A> mholder) {
-    m_chunkcollector.register(mholder);
-  }
-
-  /**
-   * register a memory buffer for auto-reclaim
-   *
-   * @param mholder
-   *          specify a buffer holder to register
-   */
-  @Override
-  public void registerBufferAutoReclaim(MemBufferHolder<A> mholder) {
-    m_bufcollector.register(mholder);
-  }
-
-  /**
-   * close both of resource collectors for this allocator
-   *
-   */
-  @Override
-  public void close() {
-    if (null != m_chunkcollector) {
-      m_chunkcollector.close();
-      m_chunkcollector = null;
-    }
-    if (null != m_bufcollector) {
-      m_bufcollector.close();
-      m_bufcollector = null;
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/CommonDurableAllocator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/CommonDurableAllocator.java b/core/src/main/java/org/apache/mnemonic/CommonDurableAllocator.java
deleted file mode 100644
index af27f22..0000000
--- a/core/src/main/java/org/apache/mnemonic/CommonDurableAllocator.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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.mnemonic;
-
-/**
- * an abstract common class for persistent memory allocator to provide common
- * functionalities.
- *
- */
-public abstract class CommonDurableAllocator<A extends CommonAllocator<A>> extends CommonAllocator<A> {
-
-  /**
-   * determine whether the allocator supports transaction feature or not
-   *
-   * @return true if supported
-   */
-  public boolean supportTransaction() {
-    return false;
-  }
-
-  /**
-   * determine whether the allocator does atomic operations on memory pool
-   *
-   * @return true if it is
-   *
-   */
-  public boolean isAtomicOperation() {
-    return false;
-  }
-
-  /**
-   * determine whether this allocator supports to store durable handler or
-   * not
-   *
-   * @return true if there is
-   */
-  public boolean hasDurableHandlerStore() {
-    return false;
-  }
-
-  /**
-   * retrieve a memory buffer from its backed memory allocator.
-   * 
-   * @param phandler
-   *          specify the handler of memory buffer to retrieve
-   *
-   * @return a holder contains the retrieved memory buffer
-   */
-  public MemBufferHolder<A> retrieveBuffer(long phandler) {
-    return retrieveBuffer(phandler, true);
-  }
-
-  /**
-   * retrieve a memory chunk from its backed memory allocator.
-   * 
-   * @param phandler
-   *          specify the handler of memory chunk to retrieve
-   *
-   * @return a holder contains the retrieved memory chunk
-   */
-  public MemChunkHolder<A> retrieveChunk(long phandler) {
-    return retrieveChunk(phandler, true);
-  }
-
-  /**
-   * retrieve a memory buffer from its backed memory allocator.
-   * 
-   * @param phandler
-   *          specify the handler of memory buffer to retrieve
-   *
-   * @param autoreclaim
-   *          specify whether this retrieved memory buffer can be reclaimed
-   *          automatically or not
-   * 
-   * @return a holder contains the retrieved memory buffer
-   */
-  public abstract MemBufferHolder<A> retrieveBuffer(long phandler, boolean autoreclaim);
-
-  /**
-   * retrieve a memory chunk from its backed memory allocator.
-   * 
-   * @param phandler
-   *          specify the handler of memory chunk to retrieve
-   *
-   * @param autoreclaim
-   *          specify whether this retrieved memory chunk can be reclaimed
-   *          automatically or not
-   * 
-   * @return a holder contains the retrieved memory chunk
-   */
-  public abstract MemChunkHolder<A> retrieveChunk(long phandler, boolean autoreclaim);
-
-  /**
-   * get the handler from a memory buffer holder.
-   * 
-   * @param mbuf
-   *          specify the memory buffer holder
-   *
-   * @return a handler that could be used to retrieve its memory buffer
-   */
-  public abstract long getBufferHandler(MemBufferHolder<A> mbuf);
-
-  /**
-   * get the handler from a memory chunk holder.
-   * 
-   * @param mchunk
-   *          specify the memory chunk holder
-   *
-   * @return a handler that could be used to retrieve its memory chunk
-   */
-  public abstract long getChunkHandler(MemChunkHolder<A> mchunk);
-
-  /**
-   * start a application level transaction on this allocator.
-   *
-   */
-  public abstract void beginTransaction();
-
-  /**
-   * end a application level transaction on this allocator.
-   *
-   */
-  public abstract void endTransaction();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/ContainerOverflowException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/ContainerOverflowException.java b/core/src/main/java/org/apache/mnemonic/ContainerOverflowException.java
deleted file mode 100644
index 1791602..0000000
--- a/core/src/main/java/org/apache/mnemonic/ContainerOverflowException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.mnemonic;
-
-/**
- * this Exception will be thrown once cache pool has been out of space.
- * 
- */
-public class ContainerOverflowException extends RuntimeException {
-
-  private static final long serialVersionUID = -8515518456414990004L;
-
-  /**
-   * accept a exception message to describe specific condition.
-   * 
-   * @param message
-   *          exception message
-   */
-  public ContainerOverflowException(String message) {
-    super(message);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/DropEvent.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/DropEvent.java b/core/src/main/java/org/apache/mnemonic/DropEvent.java
deleted file mode 100644
index d1f369a..0000000
--- a/core/src/main/java/org/apache/mnemonic/DropEvent.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.mnemonic;
-
-/**
- * A event listener to monitor and post-process an entry's evacuation.
- * 
- * 
- */
-public interface DropEvent<KeyT, ValueT> {
-  /**
-   * A call-back actor when an entry has been evicted. a customized drop action
-   * can be implemented on this interface's method e.g. spill this entry to disk
-   * or release associated resources etc.
-   * 
-   * @param pool
-   *          the pool which an entry has been evicted from
-   * 
-   * @param k
-   *          the key of an entry that has been evicted
-   * 
-   * @param v
-   *          the value of an entry that has been evicted
-   */
-  void drop(CachePool<KeyT, ValueT> pool, KeyT k, ValueT v);
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/Durable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/Durable.java b/core/src/main/java/org/apache/mnemonic/Durable.java
deleted file mode 100644
index 56f9ac1..0000000
--- a/core/src/main/java/org/apache/mnemonic/Durable.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.mnemonic;
-
-/**
- * this interface defines the interactive functionalities with Mnenomic core
- * part.
- *
- */
-
-public interface Durable {
-
-  /**
-   * this function will be invoked after this non-volatile object is created
-   * brandly new
-   *
-   */
-  void initializeAfterCreate();
-
-  /**
-   * this function will be invoked after this non-volatile object is restored
-   * from its allocator
-   *
-   */
-  void initializeAfterRestore();
-
-  /**
-   * this function will be invoked by its factory to setup generic related info
-   * to avoid expensive operations from reflection
-   *
-   * @param efproxies
-   *          specify a array of factory to proxy the restoring of its generic
-   *          field objects
-   *
-   * @param gftypes
-   *          specify a array of types corresponding to efproxies
-   */
-  void setupGenericInfo(EntityFactoryProxy[] efproxies, GenericField.GType[] gftypes);
-
-  /**
-   * this function could be called by user code to disable auto-reclaim for this
-   * non-volatile object
-   *
-   */
-  void cancelAutoReclaim();
-
-  /**
-   * this function could be called by user code to register this object for
-   * auto-reclaim
-   *
-   */
-  void registerAutoReclaim();
-
-  /**
-   * this function returns its bound handler for this object
-   *
-   * @return the handler of this object
-   */
-  long getHandler();
-
-  /**
-   * return the setting for auto-reclaim
-   *
-   * @return the status of the auto-reclaim setting
-   */
-  boolean autoReclaim();
-
-  /**
-   * manually destroy this object and release its memory resource
-   *
-   */
-  void destroy() throws RetrieveDurableEntityError;
-
-  /**
-   * return the native field map info for native processing.
-   *
-   * @return the native field map info
-   *
-   */
-  long[][] getNativeFieldInfo();
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/DurableEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/DurableEntity.java b/core/src/main/java/org/apache/mnemonic/DurableEntity.java
deleted file mode 100644
index 66e3137..0000000
--- a/core/src/main/java/org/apache/mnemonic/DurableEntity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.mnemonic;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * this class defines a annotation for non-volatile entity
- *
- */
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS)
-public @interface DurableEntity {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/DurableEntityProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/DurableEntityProcessor.java b/core/src/main/java/org/apache/mnemonic/DurableEntityProcessor.java
deleted file mode 100644
index 7610001..0000000
--- a/core/src/main/java/org/apache/mnemonic/DurableEntityProcessor.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.mnemonic;
-
-/**
- * a non-volatile annotation processor
- *
- */
-
-import java.io.IOException;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.Elements;
-import javax.lang.model.util.Types;
-
-import javax.tools.Diagnostic;
-
-public class DurableEntityProcessor extends AbstractProcessor {
-  private Types typeUtils;
-  private Elements elementUtils;
-  private Filer filer;
-  private Messager messager;
-  // private Map<String, FactoryGroupedClasses> factoryClasses = new
-  // LinkedHashMap<String, FactoryGroupedClasses>();
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public synchronized void init(ProcessingEnvironment processingEnv) {
-    super.init(processingEnv);
-    typeUtils = processingEnv.getTypeUtils();
-    elementUtils = processingEnv.getElementUtils();
-    filer = processingEnv.getFiler();
-    messager = processingEnv.getMessager();
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public Set<String> getSupportedAnnotationTypes() {
-    Set<String> annotataions = new LinkedHashSet<String>();
-    annotataions.add(DurableEntity.class.getCanonicalName());
-    return annotataions;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public SourceVersion getSupportedSourceVersion() {
-    return SourceVersion.latestSupported();
-  }
-
-  /**
-   * triggered if an error issued during processing
-   *
-   * @param e
-   *          the element in question
-   *
-   * @param msg
-   *          the message issued
-   */
-  public void error(Element e, String msg) {
-    messager.printMessage(Diagnostic.Kind.ERROR, msg, e);
-  }
-
-  /**
-   * triggered if a note issued during processing
-   *
-   * @param e
-   *          the element in question
-   *
-   * @param msg
-   *          the message issued
-   */
-  public void note(Element e, String msg) {
-    messager.printMessage(Diagnostic.Kind.NOTE, msg, e);
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
-
-    try {
-
-      for (Element annotatedElement : roundEnv.getElementsAnnotatedWith(DurableEntity.class)) {
-
-        String outputstr = String.format("++++++++++%s+++++++++++", annotatedElement.getSimpleName());
-        note(annotatedElement, outputstr);
-        // System.err.println(outputstr);
-
-        if (annotatedElement.getKind() != ElementKind.CLASS) {
-          throw new AnnotationProcessingException(annotatedElement, "Only classes can be annotated with @%s",
-              DurableEntity.class.getSimpleName());
-        }
-
-        // We can cast it, because we know that it of ElementKind.CLASS
-        TypeElement typeelem = (TypeElement) annotatedElement;
-
-        AnnotatedDurableEntityClass annotatedClass = new AnnotatedDurableEntityClass(typeelem, typeUtils,
-            elementUtils, messager);
-
-        annotatedClass.prepareProcessing();
-
-        annotatedClass.generateCode(filer);
-
-      }
-
-    } catch (AnnotationProcessingException e) {
-      error(e.getElement(), e.getMessage());
-    } catch (IOException e) {
-      error(null, e.getMessage());
-    }
-
-    return true;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/DurableGetter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/DurableGetter.java b/core/src/main/java/org/apache/mnemonic/DurableGetter.java
deleted file mode 100644
index 5a11af1..0000000
--- a/core/src/main/java/org/apache/mnemonic/DurableGetter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.mnemonic;
-
-/**
- * this class defines an annotation for getter methods of non-volatile entity
- *
- */
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.CLASS)
-public @interface DurableGetter {
-  String EntityFactoryProxies() default "null";
-
-  String GenericFieldTypes() default "null";
-
-  long Id() default -1L;
-}

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/30836536/core/src/main/java/org/apache/mnemonic/DurableSetter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/mnemonic/DurableSetter.java b/core/src/main/java/org/apache/mnemonic/DurableSetter.java
deleted file mode 100644
index 01021b9..0000000
--- a/core/src/main/java/org/apache/mnemonic/DurableSetter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.mnemonic;
-
-/**
- * this class defines an annotation for setter methods of non-volatile entity
- *
- */
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.CLASS)
-public @interface DurableSetter {
-
-}