Package javax.ws.rs.core

Examples of javax.ws.rs.core.CacheControl


      String exp = (String) response.getHeaders().getFirst(HttpHeaders.EXPIRES);
      int expires = -1;

      if (cc != null)
      {
         CacheControl cacheControl = CacheControl.valueOf(cc);
         if (cacheControl.isNoCache()) return response;
         expires = cacheControl.getMaxAge();
      }
      else if (exp != null)
      {
         Date date = DateUtil.parseDate(exp);
         expires = (int) ((date.getTime() - System.currentTimeMillis()) / 1000);
View Full Code Here


      {
         initCacheControl(methodCached);
      }
      else if (noMethodCache != null)
      {
         cacheControl = new CacheControl();
         cacheControl.setNoCache(true);
      }
      else if (cache != null)
      {
         initCacheControl(cache);
      }
      else if (nocache != null)
      {
         cacheControl = new CacheControl();
         cacheControl.setNoCache(true);
         for (String field : nocache.fields()) cacheControl.getNoCacheFields().add(field);
      }

      return cacheControl != null;
View Full Code Here

      return cacheControl != null;
   }

   protected void initCacheControl(Cache methodCached)
   {
      cacheControl = new CacheControl();
      if (methodCached.isPrivate())
      {
         cacheControl.setPrivate(true);
      }
      if (methodCached.maxAge() > -1)
View Full Code Here

      String exp = (String) response.getHeaders().getFirst(HttpHeaders.EXPIRES);
      int expires = -1;

      if (cc != null)
      {
         CacheControl cacheControl = CacheControl.valueOf(cc);
         if (cacheControl.isNoCache())
         {
            return createClientResponse(request, old);
         }
         expires = cacheControl.getMaxAge();
      }
      else if (exp != null)
      {
         Date date = DateUtil.parseDate(exp);
         expires = (int) ((date.getTime() - System.currentTimeMillis()) / 1000);
View Full Code Here

   public void testCacheControl()
   {
      CacheControlDelegate delegate = new CacheControlDelegate();

      {
         CacheControl cc = new CacheControl();
         cc.setNoCache(true);
         cc.setNoTransform(true);
         cc.setPrivate(true);
         cc.setMustRevalidate(true);
         cc.setProxyRevalidate(true);
         System.out.println(delegate.toString(cc));
         CacheControl cc2 = delegate.fromString(delegate.toString(cc));
         assertEqual(cc, cc2);

      }

      {
         CacheControl cc = new CacheControl();
         cc.setNoCache(true);
         cc.getNoCacheFields().add("bill");
         cc.getNoCacheFields().add("marc");
         cc.setPrivate(true);
         cc.getPrivateFields().add("yo");
         cc.getCacheExtension().put("foo", "bar");
         cc.setMaxAge(25);
         cc.setSMaxAge(25);
         System.out.println(delegate.toString(cc));
         CacheControl cc2 = delegate.fromString(delegate.toString(cc));
         assertEqual(cc, cc2);

      }
   }
View Full Code Here

      try
      {
         int status = client.executeMethod(method);
         Assert.assertEquals(status, HttpServletResponse.SC_OK);
         System.out.println("Cache-Control: " + method.getResponseHeader("cache-control").getValue());
         CacheControl cc = CacheControl.valueOf(method.getResponseHeader("cache-control").getValue());
         Assert.assertFalse(cc.isPrivate());
         Assert.assertEquals(3600, cc.getMaxAge());
      }
      catch (IOException e)
      {
         throw new RuntimeException(e);
      }
View Full Code Here

      @Produces("text/plain")
      public Response getEtagged(@Context Request request)
      {
         count++;
         Response.ResponseBuilder builder = request.evaluatePreconditions(new EntityTag("42"));
         CacheControl cc = new CacheControl();
         cc.setMaxAge(2);
         if (builder != null)
         {
            return builder.cacheControl(cc).build();
         }
         return Response.ok("hello" + count).cacheControl(cc).tag("42").build();
View Full Code Here

         Response.ResponseBuilder builder = request.evaluatePreconditions(new EntityTag("42"));
         if (builder != null)
         {
            return Response.serverError().build();
         }
         CacheControl cc = new CacheControl();
         cc.setMaxAge(2);
         return Response.ok("hello" + count).cacheControl(cc).tag("32").build();
      }
View Full Code Here

         }
         else
         {
            // validation if client sent
            Response.ResponseBuilder builder = validation.evaluatePreconditions(new EntityTag(entry.getEtag()));
            CacheControl cc = new CacheControl();
            cc.setMaxAge(entry.getExpirationInSeconds());
            if (builder != null)
            {
               return (ServerResponse) builder.cacheControl(cc).build();
            }
View Full Code Here

      if (occ == null)
      {
         context.proceed();
         return;
      }
      CacheControl cc = null;

      if (occ instanceof CacheControl) cc = (CacheControl) occ;
      else
      {
         cc = CacheControl.valueOf(occ.toString());
      }

      if (cc.isNoCache())
      {
         context.proceed();
         return;
      }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.CacheControl

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.