Examples of Cached


Examples of br.com.caelum.vraptor.actioncache.Cached

    this.actionCache = actionCache;
    this.headers = headers;
  }

  public void execute(@Observes @CachedAction CachedMethodExecuted event) {
    final Cached cached = event.getCached();
    final CharArrayWriterResponse charResponse = ProxyTargetInstance.get(response);
    actionCache.fetch(new CacheKey(cached, headers), new Callable<ActionCacheEntry>() {

      @Override
      public ActionCacheEntry call() throws Exception {
        String result = charResponse.getOutput();
        logger.debug("Caching response of controller method with key {}",cached.key());
        return new ActionCacheEntry(result, charResponse.getHeaders());
      }
    });
  }
View Full Code Here

Examples of br.com.caelum.vraptor.actioncache.Cached

    this.requestHeaders = requestHeaders;
  }

  public <ParamterType> void execute(Runnable runnable) {
    CachedMethodExecuted cachedMethodExecuted = new CachedMethodExecuted(controllerMethod);
    Cached cached = cachedMethodExecuted.getCached();
    if (cached == null) {
      runnable.run();
      return;
    }
    ActionCacheEntry body = actionCache.fetch(new CacheKey(cached, requestHeaders));
View Full Code Here

Examples of br.com.caelum.vraptor.actioncache.Cached

    this.requestHeaders = requestHeaders;
  }

  public void execute(@Observes @WriteResponse CachedMethodExecuted executed) {
    try {
      Cached cached = executed.getCached();
      CharArrayWriterResponse charArrayResponse = ProxyTargetInstance.get(response);
      ActionCacheEntry entry = actionCache.fetch(new CacheKey(cached,requestHeaders));
      HttpServletResponse originalResponse = charArrayResponse.delegate();
      entry.copyHeadersTo(originalResponse);
      logger.debug("Using cached response for {}",cached.key());
      originalResponse.getWriter().print(entry.getResult());
    } catch (IOException e) {
      throw new ResultException(e);
    }
  }
View Full Code Here

Examples of br.com.caelum.vraptor.actioncache.Cached

    this.requestHeaders = requestHeaders;
  }

  public void execute(@Observes @WriteResponse CachedMethodExecuted executed) {
    try {
      Cached cached = executed.getCached();
      CharArrayWriterResponse charArrayResponse = ProxyTargetInstance.get(response);
      ActionCacheEntry entry = actionCache.fetch(new CacheKey(cached,requestHeaders));
      HttpServletResponse originalResponse = charArrayResponse.delegate();
      entry.copyHeadersTo(originalResponse);
      logger.debug("Using cached response for {}", cached.key());
      originalResponse.getWriter().write(entry.getResult());
      originalResponse.flushBuffer();
    } catch (IOException e) {
      throw new ResultException(e);
    }
View Full Code Here

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

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.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

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

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);
    }

//      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

Examples of com.google.code.gaeom.annotation.Cached

    return null;
  }

  public void set(Object object, Key key)
  {
    Cached cached = object.getClass().getAnnotation(Cached.class);
    if (cached != null)
    {
      keyToObject.put(key, new Entry(object, cached.value()));
      objectToKey.put(object, key);
    }
  }
View Full Code Here

Examples of javarag.Cached

          } else if (hasAnnotation(decl, Collected.class)) {
            builder.createCollected(name);
            attributeNames.add(name);
            collectionAttributes.add(name);
          }
          Cached cached = decl.getAnnotation(Cached.class);
          if (cached != null && cached.value() == CacheMode.ALWAYS) {
            builder.setCached(name);
          }
          if (hasAnnotation(decl, Circular.class)) {
            builder.setCircular(name);
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.