Tabnine Logo
StreamResource$Builder.cached
Code IndexAdd Tabnine to your IDE (free)

How to use
cached
method
in
org.apache.juneau.http.StreamResource$Builder

Best Java code snippets using org.apache.juneau.http.StreamResource$Builder.cached (Showing top 3 results out of 315)

origin: apache/juneau

/**
 * Returns an instance of a {@link StreamResource} that represents the contents of a resource binary file from the
 * classpath.
 *
 * <h5 class='section'>See Also:</h5>
 * <ul>
 *     <li class='jf'>{@link org.apache.juneau.rest.RestContext#REST_classpathResourceFinder}
 *     <li class='jm'>{@link org.apache.juneau.rest.RestRequest#getClasspathStreamResource(String)}
 * </ul>
 *
 * @param name The name of the resource (i.e. the value normally passed to {@link Class#getResourceAsStream(String)}.
 * @param mediaType The value to set as the <js>"Content-Type"</js> header for this object.
 * @param cached If <jk>true</jk>, the resource will be read into a byte array for fast serialization.
 * @return A new stream resource, or <jk>null</jk> if resource could not be found.
 * @throws IOException
 */
@SuppressWarnings("resource")
public StreamResource getClasspathStreamResource(String name, MediaType mediaType, boolean cached) throws IOException {
  InputStream is = context.getClasspathResource(name, getLocale());
  if (is == null)
    return null;
  StreamResource.Builder b = StreamResource.create().mediaType(mediaType).contents(is);
  if (cached)
    b.cached();
  return b.build();
}
origin: org.apache.juneau/juneau-rest-server

/**
 * Returns an instance of a {@link StreamResource} that represents the contents of a resource binary file from the
 * classpath.
 *
 * <h5 class='section'>See Also:</h5>
 * <ul>
 *     <li class='jf'>{@link org.apache.juneau.rest.RestContext#REST_classpathResourceFinder}
 *     <li class='jm'>{@link org.apache.juneau.rest.RestRequest#getClasspathStreamResource(String)}
 * </ul>
 *
 * @param name The name of the resource (i.e. the value normally passed to {@link Class#getResourceAsStream(String)}.
 * @param mediaType The value to set as the <js>"Content-Type"</js> header for this object.
 * @param cached If <jk>true</jk>, the resource will be read into a byte array for fast serialization.
 * @return A new stream resource, or <jk>null</jk> if resource could not be found.
 * @throws IOException
 */
@SuppressWarnings("resource")
public StreamResource getClasspathStreamResource(String name, MediaType mediaType, boolean cached) throws IOException {
  InputStream is = context.getClasspathResource(name, getLocale());
  if (is == null)
    return null;
  StreamResource.Builder b = StreamResource.create().mediaType(mediaType).contents(is);
  if (cached)
    b.cached();
  return b.build();
}
origin: apache/juneau

/**
 * Returns an instance of a {@link StreamResource} that represents the contents of a resource binary file from the
 * classpath.
 *
 * <h5 class='section'>See Also:</h5>
 * <ul>
 *     <li class='jf'>{@link org.apache.juneau.rest.RestContext#REST_classpathResourceFinder}
 *     <li class='jm'>{@link org.apache.juneau.rest.RestRequest#getClasspathStreamResource(String)}
 * </ul>
 *
 * @param name The name of the resource (i.e. the value normally passed to {@link Class#getResourceAsStream(String)}.
 * @param mediaType The value to set as the <js>"Content-Type"</js> header for this object.
 * @param cached If <jk>true</jk>, the resource will be read into a byte array for fast serialization.
 * @return A new stream resource, or <jk>null</jk> if resource could not be found.
 * @throws IOException
 */
@SuppressWarnings("resource")
public StreamResource getClasspathStreamResource(String name, MediaType mediaType, boolean cached) throws IOException {
  InputStream is = context.getClasspathResource(name, getLocale());
  if (is == null)
    return null;
  StreamResource.Builder b = StreamResource.create().mediaType(mediaType).contents(is);
  if (cached)
    b.cached();
  return b.build();
}
org.apache.juneau.httpStreamResource$Buildercached

Javadoc

Specifies that this resource is intended to be cached.

This will trigger the contents to be loaded into a byte array for fast serializing.

Popular methods of StreamResource$Builder

  • build
    Create a new StreamResource using values in this builder.
  • contents
    Specifies the contents for this resource. This method can be called multiple times to add more conte
  • mediaType
    Specifies the resource media type string.
  • <init>
  • headers
    Specifies HTTP response header values.
  • header
    Specifies an HTTP response header value.

Popular in Java

  • Updating database using SQL prepared statement
  • startActivity (Activity)
  • findViewById (Activity)
  • requestLocationUpdates (LocationManager)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now