Adds cache control and etag to the given result.

@param result        the result
@param etag          the etag
@param configuration the application configuration
495768
public static void addCacheControlAndEtagToResult(Result result, String etag, ApplicationConfiguration configuration) {
        String maxAge = configuration.getWithDefault(HTTP_CACHE_CONTROL_MAX_AGE,
                HTTP_CACHE_CONTROL_DEFAULT);

        if ("0".equals(maxAge)) {
            result.with(HeaderNames.CACHE_CONTROL, "no-cache");
        } else {
            result.with(HeaderNames.CACHE_CONTROL, "max-age=" + maxAge);
        }

        // Use etag on demand:
        boolean useEtag = configuration.getBooleanWithDefault(HTTP_USE_ETAG,
                HTTP_USE_ETAG_DEFAULT);

        if (useEtag) {
            result.with(HeaderNames.ETAG, etag);
        }
    }
535604
public void updateStatus(long result) {
		if(result != - 1) {
			Double time = execTime / 1000;
			String s = String.format("Execution time: %s sec - Number of rows retrieved: %,d ", time, result);
			Runnable time_setter = new ExecTimeSetter(s);
			SwingUtilities.invokeLater(time_setter);
		}
	}
899728
function cacheResults (result) {
    // JSON encode result
    try {
        var cacheValue = JSON.stringify(result)
    }
    catch (err) {
        // ignore errors
    }
    // cache value
    if (defined(cacheValue)) {
        // debug
        debug('view:id:collection:set', this.idCacheKey)
        // cache results
        return this.cache.redis.setAsync(this.idCacheKey, cacheValue)
    }
}
92314
public void setResult(Result result) throws IllegalArgumentException
  {
    if(null == result)
      throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_RESULT_NULL, null)); //"Result should not be null");        
    m_result = result;
  }
195676
void initialize(ScheduledExecutorService executor, String cacheName, Configuration cfg) {
      this.executor = executor;
      this.configuration = cfg;
      this.cacheName = cacheName;
   }
283290
private void executeResult() throws Exception {
		result = createResult();

		String timerKey = "executeResult: " + getResultCode();
		try {
			UtilTimerStack.push(timerKey);
			if (result != null) {
				result.execute(this);
			} else if (resultCode != null && !Action.NONE.equals(resultCode)) {
				throw new ConfigurationException("No result defined for action " + getAction().getClass().getName()
						+ " and result " + getResultCode(), proxy.getConfig());
			} else {
				if (LOG.isDebugEnabled()) {
					LOG.debug("No result returned for action " + getAction().getClass().getName() + " at "
							+ proxy.getConfig().getLocation());
				}
			}
		} finally {
			UtilTimerStack.pop(timerKey);
		}
	}
1184716
public void startImpl(Result<I> result)
  {
    DeployFactory2<I> builder = builder();
    
    if (builder == null) {
      result.ok(null);
      return;
    }
    
    if (! _lifecycle.toStarting()) {
      result.ok(_instance);
      return;
    }
    

    I deployInstance = null;

    boolean isActive = false;
    
    try {
      deployInstance = builder.get();
      
      _instance = deployInstance;

      isActive = true;
      
      result.ok(deployInstance);
    } catch (ConfigException e) {
      log.log(Level.FINEST, e.toString(), e);
      log.log(Level.FINE, e.toString(), e);
      
      result.fail(e);
    } catch (Throwable e) {
      log.log(Level.FINEST, e.toString(), e);
      log.log(Level.FINE, e.toString(), e);
      
      result.fail(e);
    } finally {
      if (isActive) {
        _lifecycle.toActive();
      }
      else {
        _lifecycle.toError();
      }
    }
  }
575239
public void addTo(@Nonnull Map<String, String> attributeMap, @Nonnull Result result) {
		attributeMap.put(name, get(result));
	}
1148631
private void addResult(ValidationResult result) {
		if (result == null || result.count() == 0) {
			return;
		}
		this.results.add(result);
	}
1181799
@Override
	public void cacheResult(CPDAvailabilityEstimate cpdAvailabilityEstimate) {
		entityCache.putResult(CPDAvailabilityEstimateModelImpl.ENTITY_CACHE_ENABLED,
			CPDAvailabilityEstimateImpl.class,
			cpdAvailabilityEstimate.getPrimaryKey(), cpdAvailabilityEstimate);

		finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
			new Object[] {
				cpdAvailabilityEstimate.getUuid(),
				cpdAvailabilityEstimate.getGroupId()
			}, cpdAvailabilityEstimate);

		finderCache.putResult(FINDER_PATH_FETCH_BY_CPRODUCTID,
			new Object[] { cpdAvailabilityEstimate.getCProductId() },
			cpdAvailabilityEstimate);

		cpdAvailabilityEstimate.resetOriginalValues();
	}
1298842
public void addCacheConfiguration(String partition, Configuration<String, byte[]> configuration) {
		cacheConfigurations.put(partition, configuration);
	}
58279
public FluentMatchingR<T, R> orElse(R result) {
    patterns.add(Pattern.of(t -> true, t -> result));
    return this;
  }
1364918
@Api
	public static void configureNoCaching(HttpServletResponse response) {
		// HTTP 1.0 header:
		response.setHeader(HTTP_EXPIRES_HEADER, HTTP_EXPIRES_HEADER_NOCACHE_VALUE);
		response.setHeader(HTTP_CACHE_PRAGMA, HTTP_CACHE_PRAGMA_VALUE);

		// HTTP 1.1 header:
		response.setHeader(HTTP_CACHE_CONTROL_HEADER, HTTP_CACHE_CONTROL_HEADER_NOCACHE_VALUE);
	}
320804
public function add_result($result) {
        if (!is_null($this->plan)) {
            $this->plan->add_result($result);
        } else {
            debugging('Attempting to add a result of a task not binded with a plan', DEBUG_DEVELOPER);
        }
    }
412046
protected function cacheResultIfNeeded(LdapOperationInterface $operation, $result, $usedCache, $cacheKey)
    {
        if (!is_null($cacheKey) && !$usedCache) {
            /** @var CacheableOperationInterface $operation */
            $this->cache->set(new CacheItem($cacheKey, $result, $operation->getExpireCacheAt()));
        }

        return $result;
    }
1013925
public void configure(Object configuration) {

        if (!(configuration instanceof Properties) && !(configuration.toString() instanceof String))
            throw new IllegalArgumentException("Configuration for DAR must be of type Properties or String; "
                    + configuration.getClass().getName() + " was received");

        Properties properties = new Properties();
        if (configuration instanceof String) {
            try {
                properties.load(new StringReader((String) configuration));
            } catch (IOException e) {
                throw new IllegalArgumentException(e);
            }
        } else if (configuration instanceof Properties) {
            properties = (Properties) configuration;
        }
        try {
            defaultSipApplicationRouterInfos = this.defaultApplicationRouterParser.parse(properties);
        } catch (ParseException e1) {
            throw new IllegalArgumentException("Failed to parse the new DAR properties", e1);
        }

        String configFileLocation = defaultApplicationRouterParser.getDarConfigurationFileLocation();

        if (configFileLocation.startsWith("file:/")) {
            int i = 5;
            while (configFileLocation.charAt(i) == '/')
                i++;
            configFileLocation = configFileLocation.substring(i - 1);
        } else {
            log.warn("Can not write persist DAR configuration to "
                    + configFileLocation
                    + ". Make sure you have write permissions and make sure it's a local file. NOTE THAT THE NEW DAR CONFIGURATION IS LOADED AND EFFECTIVE.");
            return;
        }

        if (configFileLocation == null || configFileLocation.length() < 1)
            throw new IllegalStateException("Configuration file name is empty.");

        File configFile = new File(configFileLocation);
        FileOutputStream fis = null;
        try {
            fis = new FileOutputStream(configFile);
            properties.store(fis, "Application Router Configuration");
        } catch (Exception e) {
            throw new IllegalStateException("Failed to store configuration file.", e);
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    log.error("fail to close the following file " + configFile.getAbsolutePath(), e);
                }
            }
        }

        log.info("Stored DAR configuration in " + configFile.getAbsolutePath());
    }
358349
public function setResult(&$result) {
        if (!is_null($result) &&
            !$result instanceof Garp_Db_Table_Row &&
            !$result instanceof Garp_Db_Table_Rowset) {
                throw new InvalidArgumentException(__METHOD__.' expects parameter 1 to be a'.
                    'Garp_Db_Table_Row or Garp_Db_Table_Rowset. '.gettype($result).' given.');
        }
        $this->_result = $result;
    }