Package ch.entwine.weblounge.cache.impl

Examples of ch.entwine.weblounge.cache.impl.CacheConfiguration


  @Path("/")
  public Response getStatistics(@Context HttpServletRequest request) {

    // Get the site's cache
    Site site = getSite(request);
    CacheConfiguration cache = getCache(site);

    StringBuilder stats = new StringBuilder();
    stats.append("<cache id=\"").append(cache.getIdentifier()).append("\">");

    // Status
    stats.append("<enabled>").append(cache.isEnabled()).append("</enabled>");

    stats.append("</cache>");

    Response response = Response.ok(stats.toString()).build();
    return response;
View Full Code Here


  @Path("/")
  public Response startCache(@Context HttpServletRequest request) {

    // Get the site's cache
    Site site = getSite(request);
    CacheConfiguration cache = getCache(site);

    // Is the cache already enabled?
    if (cache.isEnabled()) {
      ResponseBuilder response = Response.notModified();
      return response.build();
    }

    // Enable the cache
View Full Code Here

    Site site = getSite(request);
    if (site == null)
      throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);

    // Get the site's cache
    CacheConfiguration cache = getCache(site);
    if (cache == null)
      throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);

    // Is the cache already disabled?
    if (!cache.isEnabled()) {
      ResponseBuilder response = Response.notModified();
      return response.build();
    }

    // Disable the cache
View Full Code Here

    Site site = getSite(request);
    if (site == null)
      throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);

    // Get the site's cache
    CacheConfiguration cache = getCache(site);
    if (cache == null)
      throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);

    // Clear the cache
    try {
      Dictionary<Object, Object> properties = cache.getProperties();
      properties.put(CacheServiceImpl.OPT_CLEAR, "true");

      // Tell the configuration admin service to update the service
      cache.getConfiguration().update(properties);
      properties.remove(CacheServiceImpl.OPT_CLEAR);
      cache.getConfiguration().update(properties);
    } catch (Throwable t) {
      logger.error("Error updating cache '{}': {}", site.getIdentifier(), t.getMessage());
      throw new WebApplicationException();
    }
View Full Code Here

   * @return the cache configuration
   * @throws WebApplicationException
   *           if the cache is not available
   */
  private CacheConfiguration getCache(Site site) throws WebApplicationException {
    CacheConfiguration config = configFactory.getConfiguration(site.getIdentifier());
    if (config == null)
      throw new WebApplicationException(Status.NOT_FOUND);
    return config;
  }
View Full Code Here

      }
    } else if (args.length > 1) {
      String id = args[0];

      // Look up the cache
      CacheConfiguration config = getCache(id);
      if (config == null) {
        try {
          config = getCache(Integer.parseInt(id));
          if (config == null) {
            System.out.println("Unknown cache: " + id);
View Full Code Here

      format.append("#");
    DecimalFormat formatter = new DecimalFormat(format.toString());

    // Display the cache list
    for (int i = 0; i < configurations.length; i++) {
      CacheConfiguration configuration = configurations[i];

      String id = configuration.getIdentifier();
      String name = configuration.getName();
      boolean enabled = configuration.isEnabled();

      StringBuffer buf = new StringBuffer();
      buf.append("[ ").append(formatter.format(i + 1)).append(" ] ");
      while (buf.length() < 8)
        buf.append(" ");
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.cache.impl.CacheConfiguration

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.