Package com.erudika.para.annotations

Examples of com.erudika.para.annotations.Cached


  public Object invoke(MethodInvocation mi) throws Throwable {
    Object result = null;
    Method m = mi.getMethod();
    Method superMethod = null;
    Indexed indexedAnno = null;
    Cached cachedAnno = null;
    String cn = getClass().getSimpleName();

    try {
      superMethod = DAO.class.getMethod(m.getName(), m.getParameterTypes());
      indexedAnno = Config.SEARCH_ENABLED ? superMethod.getAnnotation(Indexed.class) : null;
      cachedAnno = Config.CACHE_ENABLED ? superMethod.getAnnotation(Cached.class) : null;
    } catch (Exception e) {
      logger.error(null, e);
    }

    Object[] args = mi.getArguments();
    String appid = AOPUtils.getFirstArgOfString(args);

    if (indexedAnno != null) {
      switch (indexedAnno.action()) {
        case ADD:
          ParaObject addMe = AOPUtils.getArgOfParaObject(args);
          if (Utils.isValidObject(addMe)) {
            result = mi.proceed();
            search.index(appid, addMe);
            logger.debug("{}: Indexed {}->{}", cn, appid, addMe.getId());
          } else {
            logger.debug("{}: Invalid object {}->{}", cn, appid, addMe);
          }
          break;
        case REMOVE:
          result = mi.proceed();
          ParaObject removeMe = AOPUtils.getArgOfParaObject(args);
          search.unindex(appid, removeMe);
          logger.debug("{}: Unindexed {}->{}", cn, appid, (removeMe == null) ? null : removeMe.getId());
          break;
        case ADD_ALL:
          List<ParaObject> addUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
          removeSpecialClasses(addUs);
          result = mi.proceed();
          search.indexAll(appid, addUs);
          logger.debug("{}: Indexed all {}->#{}", cn, appid, (addUs == null) ? null : addUs.size());
          break;
        case REMOVE_ALL:
          List<ParaObject> removeUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
          removeSpecialClasses(removeUs);
          result = mi.proceed();
          search.unindexAll(appid, removeUs);
          logger.debug("{}: Unindexed all {}->#{}", cn, appid, (removeUs == null) ? null : removeUs.size());
          break;
        default:
          break;
      }
    }
    if (cachedAnno != null) {
      switch (cachedAnno.action()) {
        case GET:
          String getMeId = (String) args[1];
          if (cache.contains(appid, getMeId)) {
            result = cache.get(appid, getMeId);
            logger.debug("{}: Cache hit: {}->{}", cn, appid, getMeId);
View Full Code Here


  public Object invoke(MethodInvocation mi) throws Throwable {
    Object result = null;
    Method m = mi.getMethod();
    Method superMethod = null;
    Indexed indexedAnno = null;
    Cached cachedAnno = null;
    String cn = getClass().getSimpleName();

    try {
      superMethod = DAO.class.getMethod(m.getName(), m.getParameterTypes());
      indexedAnno = Config.SEARCH_ENABLED ? superMethod.getAnnotation(Indexed.class) : null;
      cachedAnno = Config.CACHE_ENABLED ? superMethod.getAnnotation(Cached.class) : null;
    } catch (Exception e) {
      logger.error(null, e);
    }

    Object[] args = mi.getArguments();
    String appid = AOPUtils.getFirstArgOfString(args);

    if (indexedAnno != null) {
      switch (indexedAnno.action()) {
        case ADD:
          ParaObject addMe = AOPUtils.getArgOfParaObject(args);
          if (Utils.isValidObject(addMe)) {
            result = mi.proceed();
            search.index(appid, addMe);
            logger.debug("{}: Indexed {}->{}", cn, appid, addMe.getId());
          } else {
            logger.debug("{}: Invalid object {}->{}", cn, appid, addMe);
          }
          break;
        case REMOVE:
          result = mi.proceed();
          ParaObject removeMe = AOPUtils.getArgOfParaObject(args);
          search.unindex(appid, removeMe);
          logger.debug("{}: Unindexed {}->{}", cn, appid, removeMe.getId());
          break;
        case ADD_ALL:
          List<ParaObject> addUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
          removeSpecialClasses(addUs);
          result = mi.proceed();
          search.indexAll(appid, addUs);
          logger.debug("{}: Indexed all {}->#{}", cn, appid, addUs.size());
          break;
        case REMOVE_ALL:
          List<ParaObject> removeUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
          removeSpecialClasses(removeUs);
          result = mi.proceed();
          search.unindexAll(appid, removeUs);
          logger.debug("{}: Unindexed all {}->#{}", cn, appid, removeUs.size());
          break;
        default:
          break;
      }
    }
    if (cachedAnno != null) {
      switch (cachedAnno.action()) {
        case GET:
          String getMeId = (String) args[1];
          if (cache.contains(appid, getMeId)) {
            result = cache.get(appid, getMeId);
            logger.debug("{}: Cache hit: {}->{}", cn, appid, getMeId);
View Full Code Here

  public Object invoke(MethodInvocation mi) throws Throwable {
    Object result = null;
    Method m = mi.getMethod();
    Method superMethod = null;
    Indexed indexedAnno = null;
    Cached cachedAnno = null;
    String cn = getClass().getSimpleName();

    try {
      superMethod = DAO.class.getMethod(m.getName(), m.getParameterTypes());
      indexedAnno = Config.SEARCH_ENABLED ? superMethod.getAnnotation(Indexed.class) : null;
      cachedAnno = Config.CACHE_ENABLED ? superMethod.getAnnotation(Cached.class) : null;
    } catch (Exception e) {
      logger.error(null, e);
    }

    Object[] args = mi.getArguments();
    String appid = AOPUtils.getFirstArgOfString(args);

    if (indexedAnno != null) {
      switch (indexedAnno.action()) {
        case ADD:
          ParaObject addMe = AOPUtils.getArgOfParaObject(args);
          if (Utils.isValidObject(addMe)) {
            result = mi.proceed();
            search.index(appid, addMe);
            logger.debug("{}: Indexed {}->{}", cn, appid, addMe.getId());
          } else {
            logger.debug("{}: Invalid object {}->{}", cn, appid, addMe);
          }
          break;
        case REMOVE:
          result = mi.proceed();
          ParaObject removeMe = AOPUtils.getArgOfParaObject(args);
          search.unindex(appid, removeMe);
          logger.debug("{}: Unindexed {}->{}", cn, appid, (removeMe == null) ? null : removeMe.getId());
          break;
        case ADD_ALL:
          List<ParaObject> addUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
          removeSpecialClasses(addUs);
          result = mi.proceed();
          search.indexAll(appid, addUs);
          logger.debug("{}: Indexed all {}->#{}", cn, appid, (addUs == null) ? null : addUs.size());
          break;
        case REMOVE_ALL:
          List<ParaObject> removeUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
          removeSpecialClasses(removeUs);
          result = mi.proceed();
          search.unindexAll(appid, removeUs);
          logger.debug("{}: Unindexed all {}->#{}", cn, appid, (removeUs == null) ? null : removeUs.size());
          break;
        default:
          break;
      }
    }
    if (cachedAnno != null) {
      switch (cachedAnno.action()) {
        case GET:
          String getMeId = (String) args[1];
          if (cache.contains(appid, getMeId)) {
            result = cache.get(appid, getMeId);
            logger.debug("{}: Cache hit: {}->{}", cn, appid, getMeId);
View Full Code Here

  public Object invoke(MethodInvocation mi) throws Throwable {
    Object result = null;
    Method m = mi.getMethod();
    Method superMethod = null;
    Indexed indexedAnno = null;
    Cached cachedAnno = null;
    String cn = getClass().getSimpleName();

    try {
      superMethod = DAO.class.getMethod(m.getName(), m.getParameterTypes());
      indexedAnno = Config.SEARCH_ENABLED ? superMethod.getAnnotation(Indexed.class) : null;
      cachedAnno = Config.CACHE_ENABLED ? superMethod.getAnnotation(Cached.class) : null;
    } catch (Exception e) {
      logger.error(null, e);
    }

//      result = indexingAction(mi, indexedAnno);
    Object[] args = mi.getArguments();
    String appid = AOPUtils.getFirstArgOfString(args);

    if (indexedAnno != null) {
      switch (indexedAnno.action()) {
        case ADD:
          ParaObject addMe = AOPUtils.getArgOfParaObject(args);
          if (Utils.isValidObject(addMe)) {
            result = mi.proceed();
            search.index(appid, addMe);
            logger.debug("{}: Indexed {}->{}", cn, appid, addMe.getId());
          } else {
            logger.debug("{}: Invalid object {}->{}", cn, appid, addMe);
          }
          break;
        case REMOVE:
          result = mi.proceed();
          ParaObject removeMe = AOPUtils.getArgOfParaObject(args);
          search.unindex(appid, removeMe);
          logger.debug("{}: Unindexed {}->{}", cn, appid, removeMe.getId());
          break;
        case ADD_ALL:
          result = mi.proceed();
          List<ParaObject> addUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
          search.indexAll(appid, addUs);
          logger.debug("{}: Indexed all {}->#{}", cn, appid, addUs.size());
          break;
        case REMOVE_ALL:
          result = mi.proceed();
          List<ParaObject> removeUs = AOPUtils.getArgOfListOfType(args, ParaObject.class);
          search.unindexAll(appid, removeUs);
          logger.debug("{}: Unindexed all {}->#{}", cn, appid, removeUs.size());
          break;
        default:
          break;
      }
    }
    if (cachedAnno != null) {
      switch (cachedAnno.action()) {
        case GET:
          String getMeId = (String) args[1];
          if (cache.contains(appid, getMeId)) {
            result = cache.get(appid, getMeId);
            logger.debug("{}: Cache hit: {}->{}", cn, appid, getMeId);
View Full Code Here

TOP

Related Classes of com.erudika.para.annotations.Cached

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.